Browse Source

cmdline: cleanup handling and block: handler

Now init checks that we understood the root= option, and can
act upon it, presenting and error if not. Also, clean up the
generation of udev rules such that we don't require /bin/echo.
master
David Dillow 16 years ago
parent
commit
d15c7a1ab7
  1. 10
      modules.d/95rootfs-block/block-genrules.sh
  2. 4
      modules.d/95rootfs-block/install
  3. 16
      modules.d/95rootfs-block/parse-block.sh
  4. 15
      modules.d/95rootfs-block/parse-root-opts.sh
  5. 12
      modules.d/99base/init

10
modules.d/95rootfs-block/block-genrules.sh

@ -1,6 +1,10 @@ @@ -1,6 +1,10 @@
if [ "${root#/dev/}" != "$root" ]; then
#!/bin/bash # for highlighting

if [ "${root%%:*}" = "block" ]; then
(
echo 'KERNEL=="'${root#/dev/}'", RUN+="/bin/mount '$fstype' -o '$rflags' '$root' '$NEWROOT'" '
echo 'SYMLINK=="'${root#/dev/}'", RUN+="/bin/mount '$fstype' -o '$rflags' '$root' '$NEWROOT'" '
printf 'KERNEL=="%s", RUN+="/bin/mount -t %s -o %s %s %s"\n' \
${root#block:/dev/} "$fstype" "$rflags" "${root#block:}" "$NEWROOT"
printf 'SYMLINK=="%s", RUN+="/bin/mount -t %s -o %s %s %s"\n' \
${root#block:/dev/} "$fstype" "$rflags" "${root#block:}" "$NEWROOT"
) >> /etc/udev/rules.d/99-mount.rules
fi

4
modules.d/95rootfs-block/install

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/bin/sh
dracut_install echo
inst_hook cmdline 20 "$moddir/parse-root-opts.sh"
inst_hook cmdline 10 "$moddir/parse-root-opts.sh"
inst_hook cmdline 95 "$moddir/parse-block.sh"
inst_hook pre-udev 30 "$moddir/block-genrules.sh"
inst_hook mount 99 "$moddir/mount-root.sh"

16
modules.d/95rootfs-block/parse-block.sh

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
#!/bin/bash # for highlighting

case "$root" in
block:LABEL=*|LABEL=*)
root="${root#block:}"
root="$(echo $root | sed 's,/,\\x2f,g')"
root="block:/dev/disk/by-label/${root#LABEL=}"
rootok=1 ;;
block:UUID=*|UUID=*)
root="${root#block:}"
root="block:/dev/disk/by-uuid/${root#UUID=}"
rootok=1 ;;
/dev/*)
root="block:${root}"
rootok=1 ;;
esac

15
modules.d/95rootfs-block/parse-root-opts.sh

@ -1,14 +1,6 @@ @@ -1,14 +1,6 @@
#!/bin/sh
#!/bin/bash # for highlighting

root=$(getarg root=)
case $root in
LABEL=*) root=${root#LABEL=}
root="$(echo $root |sed 's,/,\\x2f,g')"
root="/dev/disk/by-label/${root}" ;;
UUID=*) root="/dev/disk/by-uuid/${root#UUID=}" ;;
'') echo "Warning: no root specified"
root="/dev/sda1" ;;
esac

if rflags="$(getarg rootflags=)"; then
getarg rw && rflags="${rflags},rw" || rflags="${rflags},ro"
@ -16,6 +8,9 @@ else @@ -16,6 +8,9 @@ else
getarg rw && rflags=rw || rflags=ro
fi

fstype="$(getarg rootfstype=)" && fstype="-t ${fstype}"
fstype="$(getarg rootfstype=)"
if [ -z "$fstype" ]; then
fstype="auto"
fi

export fstype rflags root

12
modules.d/99base/init

@ -47,6 +47,18 @@ mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts >/dev/null 2>&1 @@ -47,6 +47,18 @@ mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts >/dev/null 2>&1
getarg 'rdbreak=cmdline' && emergency_shell
source_all cmdline

if [ -z "$rootok" -a -n "${root%%error:*}" ]; then
root="error: No handler for root=${root}"
fi

if [ -z "${root%%error:*}" ]; then
case "${root%%:*}" in
'') echo "FATAL: no root= option specified" ;;
error) echo "FATAL: ${root#error:}" ;;
esac
emergency_shell
fi

# pre-udev scripts run before udev starts, and are run only once.
getarg 'rdbreak=pre-udev' && emergency_shell
source_all pre-udev

Loading…
Cancel
Save