Browse Source

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.sh
master
Amadeusz Żołnowski 13 years ago committed by Harald Hoyer
parent
commit
79148c2945
  1. 35
      modules.d/95rootfs-block/mount-root.sh
  2. 11
      modules.d/99base/parse-root-opts.sh

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

@ -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

11
modules.d/99base/parse-root-opts.sh

@ -4,13 +4,10 @@


root=$(getarg root=) root=$(getarg root=)


if rflags="$(getarg rootflags=)"; then rflags="$(getarg rootflags=)"
getarg rw && rflags="${rflags},rw" getargbool 0 rw && rflags="${rflags},rw"
getarg ro && rflags="${rflags},ro" getargbool 0 ro && rflags="${rflags},ro"
else rflags="${rflags#,}"
getarg rw && rflags=rw
getarg ro && rflags=ro
fi


fstype="$(getarg rootfstype=)" fstype="$(getarg rootfstype=)"
if [ -z "$fstype" ]; then if [ -z "$fstype" ]; then

Loading…
Cancel
Save