]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
mount-root: do not pollute init arguments
authorHarald Hoyer <harald@redhat.com>
Wed, 17 Feb 2010 19:18:10 +0000 (20:18 +0100)
committerHarald Hoyer <harald@redhat.com>
Wed, 17 Feb 2010 19:18:10 +0000 (20:18 +0100)
and do not remount if no new rootopts set in /etc/fstab

modules.d/95rootfs-block/mount-root.sh

index 62290abc40ccd357f810a9d5a8ae6c19d27d0ab9..3c18406c1a58876811a85f6805c3790e9e558307 100755 (executable)
@@ -2,9 +2,29 @@
 
 . /lib/dracut-lib.sh
 
+filter_rootopts() {
+    rootopts=$1
+    # strip ro and rw options
+    local OLDIFS=$IFS
+    IFS=,
+    set -- $rootopts
+    IFS=$OLDIFS
+    local v
+    while [ $# -gt 0 ]; do
+        case $1 in
+            rw|ro);;
+            *)
+                v="$v,${1}";;
+        esac
+        shift
+    done
+    rootopts=${v#,}
+    echo $rootopts
+}
+
 if [ -n "$root" -a -z "${root%%block:*}" ]; then
     mount -t ${fstype:-auto} -o "$rflags" "${root#block:}" "$NEWROOT" \
-        && ROOTFS_MOUNTED=yes
+        && ROOTFS_MOUNTED=yes 
 
     if ! getarg rd_NO_FSTAB \
       && ! getarg rootflags \
@@ -23,27 +43,9 @@ if [ -n "$root" -a -z "${root%%block:*}" ]; then
             fi
        done < "$NEWROOT/etc/fstab"
 
+       rootopts=$(filter_rootopts $rootopts)
 
-       # strip ro and rw options
-       {
-           local OLDIFS=$IFS
-           IFS=,       
-           set -- $rootopts
-           IFS=$OLDIFS
-           local v
-           while [ $# -gt 0 ]; do
-               case $1 in 
-                   rw|ro);;
-                   *)
-                       v="$v,${1}";;
-               esac
-               shift
-           done
-           rootopts=${v#,}
-       }
-
-
-       if [ "$rootopts" != "defaults" ]; then
+       if [ -n "$rootopts" -a "$rootopts" != "defaults" ]; then
             umount $NEWROOT
             info "Remounting ${root#block:} with -o $rootopts,$rflags"
             mount -t "$rootfs" -o "$rflags","$rootopts" \