apply "ro" and "rw" options from cmdline to / mount
rflags is no longer guaranteed to be non empty. / is mounted according to rootflags parameter but forced ro at first. Later it is remounted according to /etc/fstab + rootflags parameter and "ro"/"rw". If parameters are still the same as for first mount, / isn't remounted. Conflicts: modules.d/95rootfs-block/mount-root.sh modules.d/99base/parse-root-opts.shmaster
parent
5767201eaf
commit
79148c2945
|
@ -5,32 +5,13 @@
|
|||
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
|
||||
|
||||
|
@ -96,13 +77,13 @@ mount_root() {
|
|||
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')
|
||||
|
@ -125,7 +106,7 @@ mount_root() {
|
|||
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
|
||||
|
|
|
@ -4,13 +4,10 @@
|
|||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue