[oe-commits] [openembedded-core] 49/56: initscripts: check if swapon/swapoff exists before executing them

git at git.openembedded.org git at git.openembedded.org
Mon May 30 08:39:12 UTC 2016


rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit 2cb1142710cc2beb762c4c2b8edd44d3a97dafa0
Author: Ming Liu <peter.x.liu at external.atlascopco.com>
AuthorDate: Thu May 26 23:14:33 2016 +0200

    initscripts: check if swapon/swapoff exists before executing them
    
    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 at external.atlascopco.com>
    Signed-off-by: Ross Burton <ross.burton at intel.com>
---
 meta/recipes-core/initscripts/initscripts-1.0/checkroot.sh | 2 +-
 meta/recipes-core/initscripts/initscripts-1.0/mountall.sh  | 2 +-
 meta/recipes-core/initscripts/initscripts-1.0/umountfs     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/meta/recipes-core/initscripts/initscripts-1.0/checkroot.sh b/meta/recipes-core/initscripts/initscripts-1.0/checkroot.sh
index dfee2af..02f0351 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/checkroot.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/checkroot.sh
@@ -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.
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/mountall.sh b/meta/recipes-core/initscripts/initscripts-1.0/mountall.sh
index 94bae42..c719be5 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/mountall.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/mountall.sh
@@ -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
 
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/umountfs b/meta/recipes-core/initscripts/initscripts-1.0/umountfs
index 61324c6..7fb5c58 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/umountfs
+++ b/meta/recipes-core/initscripts/initscripts-1.0/umountfs
@@ -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..."

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list