Skip to content
Browse files

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 <dreisner@archlinux.org>
  • Loading branch information...
1 parent 2ad79d0 commit b6554601442b00ddb67343a693718902ce7cd816 @falconindy falconindy committed Jul 31, 2011
Showing with 16 additions and 26 deletions.
  1. +16 −26 init_functions
View
42 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:

0 comments on commit b655460

Please sign in to comment.
Something went wrong with that request. Please try again.