From: Robin H. Johnson Date: Thu, 9 Feb 2012 07:40:51 +0000 (-0800) Subject: linuxrc /usr mounting X-Git-Tag: v3.4.25~9 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1077359d86836accf26f9711f1fde74f8f92b88b;p=genkernel.git linuxrc /usr mounting Dogfooding of the /usr mount code with the matching OpenRC change to make the mounts RW revealed some bugs and gotchas in our prior code, now fixed and verified to work. Signed-off-by: Robin H. Johnson --- diff --git a/ChangeLog b/ChangeLog index 9f52685..f867f22 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,12 @@ # Distributed under the GPL v2 # $Id$ + 09 Feb 2012; Robin H. Johnson defaults/initrd.scripts, + defaults/linuxrc: + Dogfooding of the /usr mount code with the matching OpenRC change to make the + mounts RW revealed some bugs and gotchas in our prior code, now fixed and + verified to work. + 06 Feb 2012; Robin H. Johnson arch/alpha/config.sh, arch/arm/config.sh, arch/ia64/config.sh, arch/mips/config.sh, arch/parisc/config.sh, arch/parisc64/config.sh, arch/ppc/config.sh, diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index 54e7b80..16e1d0d 100755 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -1199,7 +1199,7 @@ get_mounts_list() ' ${NEW_ROOT}/etc/initramfs.mounts } -get_mount_options() +get_mount_fstype() { awk -v fs="$1" ' /^[[:blank:]]*#/ { next } @@ -1207,6 +1207,14 @@ get_mount_options() ' ${NEW_ROOT}/etc/fstab } +get_mount_options() +{ + awk -v fs="$1" ' + /^[[:blank:]]*#/ { next } + $2 == fs { print $4 } + ' ${NEW_ROOT}/etc/fstab +} + get_mount_device() { awk -v fs="$1" ' @@ -1215,3 +1223,12 @@ get_mount_device() ' ${NEW_ROOT}/etc/fstab } +# If the kernel is handed a mount option is does not recognize, it WILL fail to +# mount. util-linux handles auto/noauto, but busybox passes it straight to the kernel +# which then rejects the mount. +# To make like a little easier, busybox mount does not care about leading, +# trailing or duplicate commas. +strip_mount_options() +{ + sed -r 's/(,|^)(no)?auto(,|$)/,/g' +} diff --git a/defaults/linuxrc b/defaults/linuxrc index 0a69a6d..693257f 100755 --- a/defaults/linuxrc +++ b/defaults/linuxrc @@ -531,7 +531,7 @@ do # there is no isofs filesystem to worry about break else - good_msg "Mounting root..." + good_msg "Mounting $REAL_ROOT as root..." if [ "${ROOTFSTYPE}" = 'zfs' ] then @@ -780,9 +780,14 @@ for fs in $fslist; do # In this case, it's probably part of the filesystem # and not a mountpoint [ -z "$dev" ] && continue - opts="ro,$(get_mount_options \"$fs\")" - if ! mount -o ${opts} $dev ${NEW_ROOT}${fs}; then - rescue_shell "Unable to mount $dev on $fs" + fstype=$(get_mount_fstype $fs) + # ro must be trailing, and the options will always contain at least 'defaults' + opts="$(get_mount_options $fs | strip_mount_options),ro" + mnt=${NEW_ROOT}${fs} + cmd="mount -t $fstype -o $opts $dev $mnt" + good_msg "Mounting $dev as ${fs}: $cmd" + if ! $cmd; then + bad_msg "Unable to mount $dev for $fs" fi done