]> code.ossystems Code Review - openembedded-core.git/commitdiff
initscripts: check if swapon/swapoff exists before executing them
authorMing Liu <peter.x.liu@external.atlascopco.com>
Thu, 26 May 2016 21:14:33 +0000 (23:14 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 30 May 2016 08:30:33 +0000 (09:30 +0100)
Not all built images contain swapon/swapoff, for instance, it is
configurable with or without them in busybox. So it'd better to check if
they exist or not before executing them.

Redirecting the potential errors to /dev/null is not good enough, which
might suppress the *real* errors.

Signed-off-by: Ming Liu <peter.x.liu@external.atlascopco.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
meta/recipes-core/initscripts/initscripts-1.0/checkroot.sh
meta/recipes-core/initscripts/initscripts-1.0/mountall.sh
meta/recipes-core/initscripts/initscripts-1.0/umountfs

index dfee2afaad866944af0de0c997eac69565d4d3df..02f0351fcb35798040ab8b8e15ad1b28653c4cb2 100755 (executable)
@@ -69,7 +69,7 @@ fi
 # before fsck, since fsck can be quite memory-hungry.
 #
 test "$VERBOSE" != no && echo "Activating swap"
-swapon -a 2> /dev/null
+[ -x /sbin/swapon ] && swapon -a
 
 #
 # Check the root filesystem.
index 94bae420c0d32d155c999dc841245e52cfce850b..c719be5d9ac021aa15d69f78cb1d33af8f905f18 100755 (executable)
@@ -33,7 +33,7 @@ kill -USR1 1
 # Execute swapon command again, in case we want to swap to
 # a file on a now mounted filesystem.
 #
-swapon -a 2> /dev/null
+[ -x /sbin/swapon ] && swapon -a
 
 : exit 0
 
index 61324c630b71d64fcba6750de9d263e33e403cfe..7fb5c58b3e910734bb363d0dd8e0055ffc011e35 100755 (executable)
@@ -12,7 +12,7 @@
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 
 echo "Deactivating swap..."
-swapoff -a
+[ -x /sbin/swapoff ] && swapoff -a
 
 # We leave /proc mounted.
 echo "Unmounting local filesystems..."