From b6554601442b00ddb67343a693718902ce7cd816 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 31 Jul 2011 19:55:47 -0400 Subject: init_functions: tighten up mount option gathering * Directly assign ro or rw to the rwopt rather than using readwrite as an intermediary * Use a default expansion to cut out an if block in determining the root fstype. Signed-off-by: Dave Reisner --- init_functions | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/init_functions b/init_functions index 609aff0..f235456 100644 --- a/init_functions +++ b/init_functions @@ -40,8 +40,7 @@ parse_cmdline() { # The kernel passes those to init on its own [0123456Ss]) ;; single) ;; - rw) readwrite="yes" ;; - ro) readwrite="no" ;; + rw|ro) rwopt="$w" ;; # only export stuff that does work with ash :) *=*) rhs="$(echo "${w}" | cut -d= -f2-)" lhs="$(echo "${w}" | cut -d= -f1 | sed 's|\.|_|g;s|-|_|g;')" @@ -116,31 +115,22 @@ default_mount_handler() { fi fi # We didn't build filesystem support into busybox, - # instead we use util-linux-ng's blkid for best compatibility - if [ -n "${rootfstype}" ]; then - fstype="${rootfstype}" - else - fstype=$(blkid -u filesystem -o value -s TYPE -p "${root}") - if [ -z "${fstype}" ]; then - err "Unable to determine the file system type of ${root}:" - echo "Either it contains no filesystem, an unknown filesystem," - echo "or more than one valid file system signature was found." - echo - echo "Try adding" - echo " rootfstype=your_filesystem_type" - echo "to the kernel command line." - echo - echo "You are now being dropped into an emergency shell." - launch_interactive_shell - msg "Trying to continue (this will most likely fail) ..." - fi - fi - if [ "${readwrite}" = "yes" ]; then - rwopt="rw" - else - rwopt="ro" + # instead we use util-linux's blkid for best compatibility + fstype=${rootfstype:-$(blkid -u filesystem -o value -s TYPE -p "$root")} + if [ -z "$fstype" ]; then + err "Unable to determine the file system type of ${root}:" + echo "Either it contains no filesystem, an unknown filesystem," + echo "or more than one valid file system signature was found." + echo + echo "Try adding" + echo " rootfstype=your_filesystem_type" + echo "to the kernel command line." + echo + echo "You are now being dropped into an emergency shell." + launch_interactive_shell + msg "Trying to continue (this will most likely fail) ..." fi - mount ${fstype:+-t ${fstype}} -o ${rwopt}${rootflags:+,${rootflags}} "${root}" "$1" + mount ${fstype:+-t $fstype} -o ${rwopt:-ro}${rootflags:+,$rootflags} "$root" "$1" } # vim: set ft=sh ts=4 sw=4 et: -- cgit v1.2.3-24-g4f1b