wait host devs in base module
authordyoung@redhat.com <dyoung@redhat.com>
Thu, 23 Aug 2012 03:02:22 +0000 (11:02 +0800)
committerHarald Hoyer <harald@redhat.com>
Thu, 23 Aug 2012 08:15:09 +0000 (10:15 +0200)
each dev in host_devs[] should be waited in initqueue to make sure they
are oneline before initqueue finish.

Add a new wait_host_devs.sh in base module to make this a generic thing.
Because all the devs in fstab lines are also added to host_devs, so no need
do same wait in fstab-sys module anymore.

[v2->v3]: do not add slave devices to host_devs
          wait for persistent dev name in initramfs

Signed-off-by: Dave Young <dyoung@redhat.com>
dracut.sh
modules.d/95fstab-sys/module-setup.sh
modules.d/95fstab-sys/wait-mount-dev.sh [deleted file]
modules.d/99base/module-setup.sh
modules.d/99base/wait-host-devs.sh [new file with mode: 0644]

index dc2c300..2b0b085 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -903,6 +903,22 @@ done
 
 dinfo "*** Including modules done ***"
 
+get_persistent_dev() {
+    local i _tmp
+    local _dev=${1##*/}
+
+    for i in /dev/disk/by-id/*; do
+        _tmp=$(readlink $i)
+        [ "${_tmp##*/}" = "$_dev" ] && echo $i && return
+    done
+}
+
+## save host_devs which we need bring up
+for _dev in ${host_devs[@]}; do
+    _pdev=$(get_persistent_dev $_dev)
+    [ -n "$_pdev" ] && echo $_pdev >> $initdir/etc/host_devs
+done
+
 ## final stuff that has to happen
 if [[ $no_kernel != yes ]]; then
 
index 8468448..ca66005 100755 (executable)
@@ -13,5 +13,4 @@ depends() {
 install() {
     [ -f /etc/fstab.sys ] && inst_simple /etc/fstab.sys
     inst_hook pre-pivot 00 "$moddir/mount-sys.sh"
-    inst_hook cmdline 00 "$moddir/wait-mount-dev.sh"
 }
diff --git a/modules.d/95fstab-sys/wait-mount-dev.sh b/modules.d/95fstab-sys/wait-mount-dev.sh
deleted file mode 100644 (file)
index 99fc16c..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
-# ex: ts=8 sw=4 sts=4 et filetype=sh
-
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
-type det_fs >/dev/null 2>&1 || . /lib/fs-lib.sh
-
-fstab_wait_dev() {
-    local _dev _mp _fs _opts _dump _pass _rest
-    test -e "$1" || return 1
-    while read _dev _mp _fs _opts _dump _pass _rest; do
-        [ -z "${_dev%%#*}" ] && continue # Skip comment lines
-        case "$_dev" in
-        /dev/?*)
-            wait_for_dev $_dev;;
-        *) ;;
-        esac
-    done < $1
-    return 0
-}
-
-[ -f /etc/fstab ] && fstab_wait_dev /etc/fstab
index 22ab277..196f6cf 100755 (executable)
@@ -41,6 +41,7 @@ install() {
     dracut_install switch_root || dfatal "Failed to install switch_root"
 
     inst_simple "$moddir/dracut-lib.sh" "/lib/dracut-lib.sh"
+    inst_hook cmdline 00 "$moddir/wait-host-devs.sh"
     inst_hook cmdline 10 "$moddir/parse-root-opts.sh"
     mkdir -p "${initdir}/var"
     [ -x /lib/systemd/systemd-timestamp ] && inst /lib/systemd/systemd-timestamp
diff --git a/modules.d/99base/wait-host-devs.sh b/modules.d/99base/wait-host-devs.sh
new file mode 100644 (file)
index 0000000..ce84922
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+
+type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+
+wait_host_devs() {
+    local _dev
+
+    while read _dev; do
+        case "$_dev" in
+        /dev/?*)
+            wait_for_dev $_dev
+            ;;
+        *) ;;
+        esac
+    done < $1
+}
+
+[ -f /etc/host_devs ] && wait_host_devs /etc/host_devs