From 07e848638cbf0e06c0de1b01644d5d2279d696a7 Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Fri, 17 Aug 2012 13:26:21 -0500 Subject: [PATCH] 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: X-Gentoo-Bug: 430378 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=430378 --- init.d/swapfiles.in | 18 ++++++++++-------- 1 file 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