[arch-projects] [mkinitcpio][PATCH 0/4] For inclusion in 0.7.5
Hi all, This is mostly just 2 patches that have been hanging out on my working branch since the end of July, along with a patch that fixes an edge case I found while testing them. Finally, a minor nitpick to move /new_root creation to the base install hook rather than creating it every time we boot. I'd like to push these and tag a new release this weekend, so please, if you have time, give them a spin. d Dave Reisner (4): install/base: include new_root as part of build process init_functions: tighten up mount option gathering init_functions: replace grep/sed with PEs init_functions: avoid setting var without LHS init | 1 - init_functions | 68 ++++++++++++++++++++++++------------------------------- install/base | 2 +- 3 files changed, 31 insertions(+), 40 deletions(-) -- 1.7.7
We always need this in early userspace, so add it as part of the build process instead of forking at runtime. Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- init | 1 - install/base | 2 +- 2 files changed, 1 insertions(+), 2 deletions(-) diff --git a/init b/init index c772590..c185375 100644 --- a/init +++ b/init @@ -6,7 +6,6 @@ PATH=/usr/sbin:/usr/bin:/sbin:/bin . /init_functions -mkdir -p /new_root mount -t proc proc /proc -o nosuid,noexec,nodev mount -t sysfs sys /sys -o nosuid,noexec,nodev if grep -q devtmpfs /proc/filesystems; then diff --git a/install/base b/install/base index 25b297f..1f2b3b8 100644 --- a/install/base +++ b/install/base @@ -1,7 +1,7 @@ #!/bin/bash build() { - for dir in proc sys dev run usr/{bin,sbin}; do + for dir in new_root proc sys dev run usr/{bin,sbin}; do add_dir "/$dir" done -- 1.7.7
* 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> --- init_functions | 42 ++++++++++++++++-------------------------- 1 files 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: -- 1.7.7
Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- init_functions | 25 +++++++++++++------------ 1 files changed, 13 insertions(+), 12 deletions(-) diff --git a/init_functions b/init_functions index f235456..a2b9d2a 100644 --- a/init_functions +++ b/init_functions @@ -42,10 +42,11 @@ parse_cmdline() { single) ;; 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;')" - if [ "\"" = "${rhs:0:1}" ]; then - if [ "\"" = "${rhs:$((${#rhs}-1))}" ]; then + *=*) rhs=${w#*=} + lhs=${w%%=*} + lhs=${lhs//[-.]/_} + if [ '"' = "${rhs:0:1}" ]; then + if [ "${rhs:$((${#rhs}-1))}" = '"' ]; then rhs="${rhs:1:$((${#rhs}-2))}" else rhs="${rhs:1}" @@ -53,17 +54,17 @@ parse_cmdline() { continue fi fi - (echo "${lhs}" | grep -qe '^[0-9]' -e '[^a-zA-Z0-9_]') || eval ${lhs}=\${rhs} + [ "$lhs" = "${lhs//[^0-9a-zA-Z]}" ] && [ "$lhs" = "${lhs#[0-9]}" ] && eval ${lhs}=\${rhs} ;; - *) lhs="$(echo "${w}" | sed 's|\.|_|g;s|-|_|g;')" - (echo "${lhs}" | grep -qe '^[0-9]' -e '[^a-zA-Z0-9_]') || eval ${lhs}=y + *) lhs=${w//[-.]/_} + [ "$lhs" = "${lhs//[^0-9a-zA-Z]}" ] && [ "$lhs" = "${lhs#[0-9]}" ] && eval ${lhs}=y ;; esac else - if [ "\"" = "${w:$((${#w}-1))}" ]; then - rhs="${rhs} ${w:0:$((${#w}-1))}" + if [ '"' = "${w:$((${#w}-1))}" ]; then + rhs="${rhs} ${w%\"}" in_quotes=0 - (echo "${lhs}" | grep -qe '^[0-9]' -e '[^a-zA-Z0-9_]') || eval ${lhs}=\${rhs} + [ "$lhs" = "${lhs//[^0-9a-zA-Z]}" ] && [ "$lhs" = "${lhs#[0-9]}" ] && eval ${lhs}=\${rhs} else rhs="${rhs} ${w}" fi @@ -92,12 +93,12 @@ default_mount_handler() { break fi # It might be a major/minor pair (8:1) - elif echo ${root} | grep -q :; then + elif [ "$root" != "${root/:}" ]; then major="$(echo ${root} | cut -d: -f1)" minor="$(echo ${root} | cut -d: -f2)" root="/dev/root" # It might be major/minor encoded as a single hex-number (lilo-style) (801) - elif [ ${#root} -le 4 -a ${#root} -gt 2 ] && echo "${root}" | grep -qe '^[A-Fa-f0-9]*$'; then + elif [ ${#root} -le 4 -a ${#root} -gt 2 -a -z "${root//[0-9a-fA-F]}" ]; then str_offset=$((${#root}-2)) major=$((0x${root:0:${str_offset}})) minor=$((0x${root:${str_offset}})) -- 1.7.7
Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- init_functions | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/init_functions b/init_functions index a2b9d2a..e026929 100644 --- a/init_functions +++ b/init_functions @@ -42,6 +42,7 @@ parse_cmdline() { single) ;; rw|ro) rwopt="$w" ;; # only export stuff that does work with ash :) + =*) ;; *=*) rhs=${w#*=} lhs=${w%%=*} lhs=${lhs//[-.]/_} -- 1.7.7
participants (1)
-
Dave Reisner