Blame 0023-base-init.sh-error-out-early-if-dev-proc-or-sys-cann.patch

Harald Hoyer 2d3fda
From c204501e3eaf31a69ef69aa567f5d3c88f69c66a Mon Sep 17 00:00:00 2001
Harald Hoyer 2d3fda
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer 2d3fda
Date: Tue, 3 Jul 2012 13:14:12 +0200
Harald Hoyer 2d3fda
Subject: [PATCH] base/init.sh: error out early, if /dev, /proc or /sys cannot
Harald Hoyer 2d3fda
 be mounted
Harald Hoyer 2d3fda
Harald Hoyer 2d3fda
---
Harald Hoyer 2d3fda
 modules.d/99base/init.sh |   25 ++++++++++++++++++++-----
Harald Hoyer 2d3fda
 1 file changed, 20 insertions(+), 5 deletions(-)
Harald Hoyer 2d3fda
Harald Hoyer 2d3fda
diff --git a/modules.d/99base/init.sh b/modules.d/99base/init.sh
Harald Hoyer 2d3fda
index d395a99..3eb6424 100755
Harald Hoyer 2d3fda
--- a/modules.d/99base/init.sh
Harald Hoyer 2d3fda
+++ b/modules.d/99base/init.sh
Harald Hoyer 2d3fda
@@ -20,14 +20,22 @@ export PATH
Harald Hoyer 2d3fda
 RD_DEBUG=""
Harald Hoyer 2d3fda
 . /lib/dracut-lib.sh
Harald Hoyer 2d3fda
 
Harald Hoyer 2d3fda
-trap "emergency_shell Signal caught!" 0
Harald Hoyer 2d3fda
-
Harald Hoyer 2d3fda
 # mount some important things
Harald Hoyer 2d3fda
 [ ! -d /proc/self ] && \
Harald Hoyer 2d3fda
-    mount -t proc -o nosuid,noexec,nodev proc /proc >/dev/null 2>&1
Harald Hoyer 2d3fda
+    mount -t proc -o nosuid,noexec,nodev proc /proc >/dev/null
Harald Hoyer 2d3fda
+
Harald Hoyer 2d3fda
+if [ "$?" != "0" ]; then
Harald Hoyer 2d3fda
+    echo "Cannot mount proc on /proc! Compile the kernel with CONFIG_PROC_FS!"
Harald Hoyer 2d3fda
+    exit 1
Harald Hoyer 2d3fda
+fi
Harald Hoyer 2d3fda
 
Harald Hoyer 2d3fda
 [ ! -d /sys/kernel ] && \
Harald Hoyer 2d3fda
-    mount -t sysfs -o nosuid,noexec,nodev sysfs /sys >/dev/null 2>&1
Harald Hoyer 2d3fda
+    mount -t sysfs -o nosuid,noexec,nodev sysfs /sys >/dev/null
Harald Hoyer 2d3fda
+
Harald Hoyer 2d3fda
+if [ "$?" != "0" ]; then
Harald Hoyer 2d3fda
+    echo "Cannot mount sysfs on /sys! Compile the kernel with CONFIG_SYSFS!"
Harald Hoyer 2d3fda
+    exit 1
Harald Hoyer 2d3fda
+fi
Harald Hoyer 2d3fda
 
Harald Hoyer 2d3fda
 if [ -x /lib/systemd/systemd-timestamp ]; then
Harald Hoyer 2d3fda
     RD_TIMESTAMP=$(/lib/systemd/systemd-timestamp)
Harald Hoyer 2d3fda
@@ -39,7 +47,12 @@ fi
Harald Hoyer 2d3fda
 setdebug
Harald Hoyer 2d3fda
 
Harald Hoyer 2d3fda
 if ! ismounted /dev; then
Harald Hoyer 2d3fda
-    mount -t devtmpfs -o mode=0755,nosuid,strictatime devtmpfs /dev >/dev/null 
Harald Hoyer 2d3fda
+    mount -t devtmpfs -o mode=0755,nosuid,strictatime devtmpfs /dev >/dev/null
Harald Hoyer 2d3fda
+fi
Harald Hoyer 2d3fda
+
Harald Hoyer 2d3fda
+if ! ismounted /dev; then
Harald Hoyer 2d3fda
+    echo "Cannot mount devtmpfs on /dev! Compile the kernel with CONFIG_DEVTMPFS!"
Harald Hoyer 2d3fda
+    exit 1
Harald Hoyer 2d3fda
 fi
Harald Hoyer 2d3fda
 
Harald Hoyer 2d3fda
 # prepare the /dev directory
Harald Hoyer 2d3fda
@@ -66,6 +79,8 @@ if ! ismounted /run; then
Harald Hoyer 2d3fda
     rm -fr /newrun
Harald Hoyer 2d3fda
 fi
Harald Hoyer 2d3fda
 
Harald Hoyer 2d3fda
+trap "emergency_shell Signal caught!" 0
Harald Hoyer 2d3fda
+
Harald Hoyer 2d3fda
 [ -d /run/initramfs ] || mkdir -p -m 0755 /run/initramfs
Harald Hoyer 2d3fda
 
Harald Hoyer 2d3fda
 UDEVVERSION=$(udevadm --version)