]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
cmdline: cleanup handling and block: handler
authorDavid Dillow <dave@thedillows.org>
Mon, 1 Jun 2009 04:21:53 +0000 (00:21 -0400)
committerDavid Dillow <dave@thedillows.org>
Mon, 1 Jun 2009 04:21:53 +0000 (00:21 -0400)
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.

modules.d/95rootfs-block/block-genrules.sh
modules.d/95rootfs-block/install
modules.d/95rootfs-block/parse-block.sh [new file with mode: 0755]
modules.d/95rootfs-block/parse-root-opts.sh
modules.d/99base/init

index 47083dfc585532042bb588b329e571a440ab7c9f..5c3f957606fe0b76bfb4fb4df78057c994a680bb 100755 (executable)
@@ -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
index 722e47b801f787a4d4a4ee53b13a4badfcfd60f0..b977f9b4886ef4500f8836bcebcfa1db3b6d04a7 100755 (executable)
@@ -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"
diff --git a/modules.d/95rootfs-block/parse-block.sh b/modules.d/95rootfs-block/parse-block.sh
new file mode 100755 (executable)
index 0000000..4b6ecfa
--- /dev/null
@@ -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
index 3a8b1a6f8d22513696e85ba09ac388b0a98cca62..dc0ae6d57f8c80cf9525b108ccf099ca7e9bdeb1 100755 (executable)
@@ -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
     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
index 9ea4747ab406d619884ec1563709635981fe9a01..ebbc6ada9861858400e8b82ae9132d3c845d45d5 100755 (executable)
@@ -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