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@ziu.info>
[harald@redhat.com: usable_root(): relaxed check for root]
return 1
)
+
+usable_root() {
+ local _d
+ [ -d $1 ] || return 1
+ for _d in proc sys dev; do
+ [ -e "$1"/$_d ] || return 1
+ done
+ return 0
+}
# 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))