type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
type det_fs >/dev/null 2>&1 || . /lib/fs-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
- defaults);;
- *)
- v="$v,${1}";;
- esac
- shift
- done
- rootopts=${v#,}
- echo $rootopts
-}
-
mount_root() {
local _ret
+ local _rflags_ro="$rflags,ro"
# sanity - determine/fix fstype
rootfs=$(det_fs "${root#block:}" "$fstype")
- while ! mount -t ${rootfs} -o "$rflags",ro "${root#block:}" "$NEWROOT"; do
- warn "Failed to mount -t ${rootfs} -o $rflags,ro ${root#block:} $NEWROOT"
+ while ! mount -t ${rootfs} -o "$_rflags_ro" "${root#block:}" "$NEWROOT"; do
+ warn "Failed to mount -t ${rootfs} -o $_rflags_ro ${root#block:} $NEWROOT"
fsck_ask_err
done
break
fi
done < "$NEWROOT/etc/fstab"
-
- rootopts=$(filter_rootopts $rootopts)
fi
# we want rootflags (rflags) to take precedence so prepend rootopts to
- # them; rflags is guaranteed to not be empty
- rflags="${rootopts:+${rootopts},}${rflags}"
+ # them
+ rflags="${rootopts},${rflags}"
+ rflags="${rflags#,}"
+ rflags="${rflags%,}"
# backslashes are treated as escape character in fstab
# esc_root=$(echo ${root#block:} | sed 's,\\,\\\\,g')
if ! ismounted "$NEWROOT"; then
info "Mounting ${root#block:} with -o ${rflags}"
mount "$NEWROOT" 2>&1 | vinfo
- else
+ elif ! are_lists_eq , "$rflags" "$_rflags_ro" defaults; then
info "Remounting ${root#block:} with -o ${rflags}"
mount -o remount "$NEWROOT" 2>&1 | vinfo
fi
root=$(getarg root=)
-if rflags="$(getarg rootflags=)"; then
- getarg rw && rflags="${rflags},rw"
- getarg ro && rflags="${rflags},ro"
-else
- getarg rw && rflags=rw
- getarg ro && rflags=ro
-fi
+rflags="$(getarg rootflags=)"
+getargbool 0 rw && rflags="${rflags},rw"
+getargbool 0 ro && rflags="${rflags},ro"
+rflags="${rflags#,}"
fstype="$(getarg rootfstype=)"
if [ -z "$fstype" ]; then