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