[PATCH 06/10] check root candidates more carefully

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is from the following thread:

http://thread.gmane.org/gmane.linux.raid/35753/focus=35795

Additional tests + more specific info.

Signed-off-by: Michal Soltys <soltys@xxxxxxxx>
---
 modules.d/99base/dracut-lib.sh |   11 +++++++++++
 modules.d/99base/init          |   12 ++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
index 62c3bf5..cf5aae6 100755
--- a/modules.d/99base/dracut-lib.sh
+++ b/modules.d/99base/dracut-lib.sh
@@ -544,3 +544,14 @@ foreach_uuid_until() (
 
     return 1
 )
+
+usable_root() {
+    local _d
+    [ -d $1 ] || return 1
+    for _d in "$1"/{etc,proc,sys,dev,tmp,usr,var}; do
+        [ -e $_d ] || return 1
+    done
+    [ -e "$1/bin" -o -e "$1/sbin" ] || return 1
+    [ -e "$1/lib" -o -e "$1/lib64" ] || return 1
+    return 0
+}
diff --git a/modules.d/99base/init b/modules.d/99base/init
index 0970a48..bc5d2ba 100755
--- a/modules.d/99base/init
+++ b/modules.d/99base/init
@@ -298,10 +298,18 @@ getarg 'rd.break=mount' 'rdbreak=mount' && emergency_shell -n mount "Break mount
 # be sourced any number of times. As soon as one suceeds, no more are sourced.
 i=0
 while :; do
-    [ -d "$NEWROOT/proc" ] && break;
+    if ismounted "$NEWROOT"; then
+        usable_root "$NEWROOT" && break;
+        umount "$NEWROOT"
+    fi
     for f in $hookdir/mount/*.sh; do
         [ -f "$f" ] && . "$f"
-        [ -d "$NEWROOT/proc" ] && break;
+        if ismounted "$NEWROOT"; then
+            usable_root "$NEWROOT" && break;
+            warn "$NEWROOT has no proper rootfs layout, ignoring and removing offending mount hook"
+            umount "$NEWROOT"
+            rm -f "$f"
+        fi
     done
 
     i=$(($i+1))
-- 
1.7.5.3

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux