aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2012-08-17 13:26:21 -0500
committerWilliam Hubbs <w.d.hubbs@gmail.com>2012-08-17 13:26:21 -0500
commit07e848638cbf0e06c0de1b01644d5d2279d696a7 (patch)
tree23b20baa9d1028da4f2d2440f5c8d47c7cab3fac
parentc8703354e36d85468e4b336371be424b76a68726 (diff)
swapfiles: make sure /proc/swaps exists
If CONFIG_SWAP is turned off in the kernel, this file may not exist. In that case, we should not try to read from it. reported-by: <walter@pratyeka.org> X-Gentoo-Bug: 430378 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=430378
-rw-r--r--init.d/swapfiles.in18
1 files changed, 10 insertions, 8 deletions
diff --git a/init.d/swapfiles.in b/init.d/swapfiles.in
index f46f3c86..baf75913 100644
--- a/init.d/swapfiles.in
+++ b/init.d/swapfiles.in
@@ -31,14 +31,16 @@ stop()
case "$RC_UNAME" in
Linux)
- while read filename type rest; do
- case "$type" in
- file) swapoff $filename >/dev/null;;
- esac
- case "$filename" in
- /dev/loop*) swapoff $filename >/dev/null;;
- esac
- done < /proc/swaps
+ if [ -e /proc/swaps ]; then
+ while read filename type rest; do
+ case "$type" in
+ file) swapoff $filename >/dev/null;;
+ esac
+ case "$filename" in
+ /dev/loop*) swapoff $filename >/dev/null;;
+ esac
+ done < /proc/swaps
+ fi
;;
esac
eend 0