Blame 0016-rootfs-block-mount-root.sh-warn-if-ro-mount-failed-a.patch

Harald Hoyer c4a5a0
From 5113a3efff522664b85a75d67f674d218035696c Mon Sep 17 00:00:00 2001
Harald Hoyer c4a5a0
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer c4a5a0
Date: Sat, 30 Jun 2012 12:15:42 +0200
Harald Hoyer c4a5a0
Subject: [PATCH] rootfs-block/mount-root.sh: warn if ro mount failed and
Harald Hoyer c4a5a0
 remount
Harald Hoyer c4a5a0
Harald Hoyer c4a5a0
remount the root filesystem, if it was not unmounted
Harald Hoyer c4a5a0
---
Harald Hoyer c4a5a0
 modules.d/95rootfs-block/mount-root.sh |   18 ++++++++++++++----
Harald Hoyer c4a5a0
 1 file changed, 14 insertions(+), 4 deletions(-)
Harald Hoyer c4a5a0
Harald Hoyer c4a5a0
diff --git a/modules.d/95rootfs-block/mount-root.sh b/modules.d/95rootfs-block/mount-root.sh
Harald Hoyer c4a5a0
index 932571a..e61b0e8 100755
Harald Hoyer c4a5a0
--- a/modules.d/95rootfs-block/mount-root.sh
Harald Hoyer c4a5a0
+++ b/modules.d/95rootfs-block/mount-root.sh
Harald Hoyer c4a5a0
@@ -29,7 +29,10 @@ mount_root() {
Harald Hoyer c4a5a0
     local _ret
Harald Hoyer c4a5a0
     # sanity - determine/fix fstype
Harald Hoyer c4a5a0
     rootfs=$(det_fs "${root#block:}" "$fstype")
Harald Hoyer c4a5a0
-    mount -t ${rootfs} -o "$rflags",ro "${root#block:}" "$NEWROOT"
Harald Hoyer c4a5a0
+    while ! mount -t ${rootfs} -o "$rflags",ro "${root#block:}" "$NEWROOT"; do
Harald Hoyer c4a5a0
+        warn "Failed to mount -t ${rootfs} -o $rflags,ro ${root#block:} $NEWROOT"
Harald Hoyer c4a5a0
+        fsck_ask_err
Harald Hoyer c4a5a0
+    done
Harald Hoyer c4a5a0
 
Harald Hoyer c4a5a0
     READONLY=
Harald Hoyer c4a5a0
     fsckoptions=
Harald Hoyer c4a5a0
@@ -106,9 +109,11 @@ mount_root() {
Harald Hoyer c4a5a0
     # printf '%s %s %s %s 1 1 \n' "$esc_root" "$NEWROOT" "$rootfs" "$rflags" >/etc/fstab
Harald Hoyer c4a5a0
 
Harald Hoyer c4a5a0
     ran_fsck=0
Harald Hoyer c4a5a0
-    if [ "$rootfsck" != "0" -a -z "$fastboot" -a "$READONLY" != "yes" ] && \
Harald Hoyer c4a5a0
+    if fsck_able "$rootfs" && \
Harald Hoyer c4a5a0
+        [ "$rootfsck" != "0" -a -z "$fastboot" -a "$READONLY" != "yes" ] && \
Harald Hoyer c4a5a0
             ! strstr "${rflags}" _netdev && \
Harald Hoyer c4a5a0
             ! getargbool 0 rd.skipfsck; then
Harald Hoyer c4a5a0
+        umount "$NEWROOT"
Harald Hoyer c4a5a0
         fsck_single "${root#block:}" "$rootfs" "$rflags" "$fsckoptions"
Harald Hoyer c4a5a0
         _ret=$?
Harald Hoyer c4a5a0
         [ $_ret -ne 255 ] && echo $_ret >/run/initramfs/root-fsck
Harald Hoyer c4a5a0
@@ -117,8 +122,13 @@ mount_root() {
Harald Hoyer c4a5a0
 
Harald Hoyer c4a5a0
     echo "${root#block:} $NEWROOT $rootfs ${rflags:-defaults} 0 $rootfsck" >> /etc/fstab
Harald Hoyer c4a5a0
 
Harald Hoyer c4a5a0
-    info "Remounting ${root#block:} with -o ${rflags}"
Harald Hoyer c4a5a0
-    mount -o remount "$NEWROOT" 2>&1 | vinfo
Harald Hoyer c4a5a0
+    if ! ismounted "$NEWROOT"; then
Harald Hoyer c4a5a0
+        info "Mounting ${root#block:} with -o ${rflags}"
Harald Hoyer c4a5a0
+        mount "$NEWROOT" 2>&1 | vinfo
Harald Hoyer c4a5a0
+    else
Harald Hoyer c4a5a0
+        info "Remounting ${root#block:} with -o ${rflags}"
Harald Hoyer c4a5a0
+        mount -o remount "$NEWROOT" 2>&1 | vinfo
Harald Hoyer c4a5a0
+    fi
Harald Hoyer c4a5a0
 
Harald Hoyer c4a5a0
     [ -f "$NEWROOT"/forcefsck ] && rm -f "$NEWROOT"/forcefsck 2>/dev/null
Harald Hoyer c4a5a0
     [ -f "$NEWROOT"/.autofsck ] && rm -f "$NEWROOT"/.autofsck 2>/dev/null