diff options
author | William Hubbs <w.d.hubbs@gmail.com> | 2012-08-17 13:26:21 -0500 |
---|---|---|
committer | William Hubbs <w.d.hubbs@gmail.com> | 2012-08-17 13:26:21 -0500 |
commit | 07e848638cbf0e06c0de1b01644d5d2279d696a7 (patch) | |
tree | 23b20baa9d1028da4f2d2440f5c8d47c7cab3fac /init.d/swapfiles.in | |
parent | c8703354e36d85468e4b336371be424b76a68726 (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
Diffstat (limited to 'init.d/swapfiles.in')
-rw-r--r-- | init.d/swapfiles.in | 18 |
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 |