From 0e695aa0c7c4854a8db59e7243535752e97ef049 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 7 Mar 2022 14:01:25 +0100 Subject: [PATCH] Only run swapon/swapoff if they exist To silence warnings at startup/shutdown, check for existance of swapon and swapoff before calling them. Signed-off-by: Joachim Wiberg --- src/finit.c | 3 ++- src/sig.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/finit.c b/src/finit.c index ffa9dd99..11bd1a42 100644 --- a/src/finit.c +++ b/src/finit.c @@ -333,7 +333,8 @@ static void fs_mount_all(void) _d("Calling extra mount hook, after mount -a ..."); plugin_run_hooks(HOOK_MOUNT_POST); - run("swapon -ea", "swapon"); + if (whichp("swapon")) + run("swapon -ea", "swapon"); _d("Finalize, ensure common file systems are available ..."); fs_finalize(); diff --git a/src/sig.c b/src/sig.c index a12393e7..9d44f07d 100644 --- a/src/sig.c +++ b/src/sig.c @@ -321,7 +321,8 @@ void do_shutdown(shutop_t op) /* Unmount any tmpfs before unmounting swap ... */ unmount_tmpfs(); - run("swapoff -e -a", "swapoff"); + if (whichp("swapoff")) + run("swapoff -e -a", "swapoff"); /* ... unmount remaining regular file systems. */ unmount_regular();