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
This commit is contained in:
William Hubbs 2012-08-17 13:26:21 -05:00
parent c8703354e3
commit 07e848638c

View File

@ -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