]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
split 95udev-rules/59-persistent-storage.rules to md and dm modules
authorHarald Hoyer <harald@redhat.com>
Thu, 7 Mar 2013 13:49:21 +0000 (14:49 +0100)
committerHarald Hoyer <harald@redhat.com>
Thu, 7 Mar 2013 14:01:47 +0000 (15:01 +0100)
dracut-functions.sh
modules.d/90dm/59-persistent-storage-dm.rules [new file with mode: 0644]
modules.d/90dm/module-setup.sh
modules.d/90mdraid/59-persistent-storage-md.rules [new file with mode: 0644]
modules.d/90mdraid/module-setup.sh
modules.d/95udev-rules/59-persistent-storage.rules
modules.d/95udev-rules/module-setup.sh
modules.d/95udev-rules/udev-rules-prepare.sh [deleted file]

index 53ee9f75becb52ca0b1d1dc13abaa7eeaf542b3d..2a84d175fae2f97a5989f1bc0809b7dc1a12b12f 100755 (executable)
@@ -978,6 +978,33 @@ inst_rules() {
     done
 }
 
+prepare_udev_rules() {
+    [ -z "$UDEVVERSION" ] && export UDEVVERSION=$(udevadm --version)
+
+    for f in "$@"; do
+        f="${initdir}/etc/udev/rules.d/$f"
+        [ -e "$f" ] || continue
+        while read line; do
+            if [ "${line%%IMPORT PATH_ID}" != "$line" ]; then
+                if [ $UDEVVERSION -ge 174 ]; then
+                    printf '%sIMPORT{builtin}="path_id"\n' "${line%%IMPORT PATH_ID}"
+                else
+                    printf '%sIMPORT{program}="path_id %%p"\n' "${line%%IMPORT PATH_ID}"
+                fi
+            elif [ "${line%%IMPORT BLKID}" != "$line" ]; then
+                if [ $UDEVVERSION -ge 176 ]; then
+                    printf '%sIMPORT{builtin}="blkid"\n' "${line%%IMPORT BLKID}"
+                else
+                    printf '%sIMPORT{program}="/sbin/blkid -o udev -p $tempnode"\n' "${line%%IMPORT BLKID}"
+                fi
+            else
+                echo "$line"
+            fi
+        done < "${f}" > "${f}.new"
+        mv "${f}.new" "$f"
+    done
+}
+
 # install function specialized for hooks
 # $1 = type of hook, $2 = hook priority (lower runs first), $3 = hook
 # All hooks should be POSIX/SuS compliant, they will be sourced by init.
diff --git a/modules.d/90dm/59-persistent-storage-dm.rules b/modules.d/90dm/59-persistent-storage-dm.rules
new file mode 100644 (file)
index 0000000..73b0937
--- /dev/null
@@ -0,0 +1,15 @@
+SUBSYSTEM!="block", GOTO="dm_end"
+ACTION!="add|change", GOTO="dm_end"
+# Also don't process disks that are slated to be a multipath device
+ENV{DM_MULTIPATH_DEVICE_PATH}=="?*", GOTO="dm_end"
+
+KERNEL!="dm-[0-9]*", GOTO="dm_end"
+ACTION=="add", GOTO="dm_end"
+IMPORT{program}="/sbin/dmsetup info -c --nameprefixes --unquoted --rows --noheadings -o name,uuid,suspended,readonly,major,minor,open,tables_loaded,names_using_dev -j%M -m%m"
+ENV{DM_NAME}!="?*", GOTO="dm_end"
+ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", GOTO="dm_end"
+ENV{DM_UUID}=="CRYPT-TEMP-?*", GOTO="dm_end"
+ENV{DM_UUID}!="?*", ENV{DM_NAME}=="temporary-cryptsetup-?*", GOTO="dm_end"
+IMPORT BLKID
+
+LABEL="dm_end"
index 6ec9af49463e4af7d157ee08ea0cd8de76f190c6..314c082fa71c31dfe7b3adc53e9566b6edcce6b7 100755 (executable)
@@ -32,6 +32,9 @@ install() {
 
     inst_rules "$moddir/11-dm.rules"
 
+    inst_rules "$moddir/59-persistent-storage-dm.rules"
+    prepare_udev_rules 59-persistent-storage-dm.rules
+
     inst_hook shutdown 30 "$moddir/dm-shutdown.sh"
 }
 
diff --git a/modules.d/90mdraid/59-persistent-storage-md.rules b/modules.d/90mdraid/59-persistent-storage-md.rules
new file mode 100644 (file)
index 0000000..bea9325
--- /dev/null
@@ -0,0 +1,23 @@
+SUBSYSTEM!="block", GOTO="md_end"
+ACTION!="add|change", GOTO="md_end"
+# Also don't process disks that are slated to be a multipath device
+ENV{DM_MULTIPATH_DEVICE_PATH}=="?*", GOTO="md_end"
+
+KERNEL!="md[0-9]*|md_d[0-9]*|md/*", KERNEL!="md*", GOTO="md_end"
+
+# partitions have no md/{array_state,metadata_version}
+ENV{DEVTYPE}=="partition", GOTO="md_ignore_state"
+
+# container devices have a metadata version of e.g. 'external:ddf' and
+# never leave state 'inactive'
+ATTR{md/metadata_version}=="external:[A-Za-z]*", ATTR{md/array_state}=="inactive", GOTO="md_ignore_state"
+TEST!="md/array_state", GOTO="md_end"
+ATTR{md/array_state}=="|clear|inactive", GOTO="md_end"
+
+LABEL="md_ignore_state"
+
+IMPORT{program}="/sbin/mdadm --detail --export $tempnode"
+IMPORT BLKID
+OPTIONS+="link_priority=100"
+OPTIONS+="watch"
+LABEL="md_end"
index 3824f406e1a1690d4ccc8a7b6a1a6582cf61c3d1..a2b9ac2a90fe7b3994f44f0f213a25b6e51fb94d 100755 (executable)
@@ -48,23 +48,18 @@ install() {
     inst $(command -v partx) /sbin/partx
     inst $(command -v mdadm) /sbin/mdadm
 
-     # XXX: mdmon really needs to run as non-root?
-     #      If so, write only the user it needs in the initrd's /etc/passwd (and maybe /etc/group)
-     #      in a similar fashion to modules.d/95nfs.  Do not copy /etc/passwd and /etc/group from
-     #      the system into the initrd.
-     #      dledford has hardware to test this, so he should be able to clean this up.
-     # inst /etc/passwd
-     # inst /etc/group
-
-     inst_rules 64-md-raid.rules
-     # remove incremental assembly from stock rules, so they don't shadow
-     # 65-md-inc*.rules and its fine-grained controls, or cause other problems
-     # when we explicitly don't want certain components to be incrementally
-     # assembled
-     sed -i -r -e '/RUN\+?="[[:alpha:]/]*mdadm[[:blank:]]+(--incremental|-I)[[:blank:]]+(\$env\{DEVNAME\}|\$tempnode)"/d' "${initdir}${udevdir}/rules.d/64-md-raid.rules"
+    inst_rules 64-md-raid.rules
+    # remove incremental assembly from stock rules, so they don't shadow
+    # 65-md-inc*.rules and its fine-grained controls, or cause other problems
+    # when we explicitly don't want certain components to be incrementally
+    # assembled
+    sed -i -r -e '/RUN\+?="[[:alpha:]/]*mdadm[[:blank:]]+(--incremental|-I)[[:blank:]]+(\$env\{DEVNAME\}|\$tempnode)"/d' "${initdir}${udevdir}/rules.d/64-md-raid.rules"
 
     inst_rules "$moddir/65-md-incremental-imsm.rules"
 
+    inst_rules "$moddir/59-persistent-storage-md.rules"
+    prepare_udev_rules 59-persistent-storage-md.rules
+
     # guard against pre-3.0 mdadm versions, that can't handle containers
     if ! mdadm -Q -e imsm /dev/null >/dev/null 2>&1; then
         inst_hook pre-trigger 30 "$moddir/md-noimsm.sh"
index c221cda5db4572c9bfd486f61b5715715a44651e..47ff6edd95001c99f3038663e4b24d628100a9eb 100644 (file)
@@ -6,35 +6,4 @@ ENV{DM_MULTIPATH_DEVICE_PATH}=="?*", GOTO="ps_end"
 KERNEL=="cciss[0-9]*", IMPORT BLKID
 KERNEL=="nbd[0-9]*", IMPORT BLKID
 
-
-KERNEL!="md[0-9]*|md_d[0-9]*|md/*", KERNEL!="md*", GOTO="md_end"
-
-# partitions have no md/{array_state,metadata_version}
-ENV{DEVTYPE}=="partition", GOTO="md_ignore_state"
-
-# container devices have a metadata version of e.g. 'external:ddf' and
-# never leave state 'inactive'
-ATTR{md/metadata_version}=="external:[A-Za-z]*", ATTR{md/array_state}=="inactive", GOTO="md_ignore_state"
-TEST!="md/array_state", GOTO="md_end"
-ATTR{md/array_state}=="|clear|inactive", GOTO="md_end"
-
-LABEL="md_ignore_state"
-
-IMPORT{program}="/sbin/mdadm --detail --export $tempnode"
-IMPORT BLKID
-OPTIONS+="link_priority=100"
-OPTIONS+="watch"
-LABEL="md_end"
-
-
-KERNEL!="dm-[0-9]*", GOTO="ps_end"
-ACTION=="add", GOTO="ps_end"
-IMPORT{program}="/sbin/dmsetup info -c --nameprefixes --unquoted --rows --noheadings -o name,uuid,suspended,readonly,major,minor,open,tables_loaded,names_using_dev -j%M -m%m"
-ENV{DM_NAME}!="?*", GOTO="ps_end"
-ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", GOTO="ps_end"
-ENV{DM_UUID}=="CRYPT-TEMP-?*", GOTO="ps_end"
-ENV{DM_UUID}!="?*", ENV{DM_NAME}=="temporary-cryptsetup-?*", GOTO="ps_end"
-IMPORT BLKID
-
-
 LABEL="ps_end"
index f56f166247d48a6117336b62d6561a03e6fede92..1eb8642c91dca2ad2e1b13840ba3c22ae726c342 100755 (executable)
@@ -34,6 +34,8 @@ install() {
         "$moddir/59-persistent-storage.rules" \
         "$moddir/61-persistent-storage.rules"
 
+    prepare_udev_rules 59-persistent-storage.rules 61-persistent-storage.rules
+
     inst_dir /run/udev
     inst_dir /run/udev/rules.d
 
@@ -41,7 +43,7 @@ install() {
         for i in cdrom tape dialout floppy; do
             if ! egrep -q "^$i:" "$initdir/etc/group" 2>/dev/null; then
                 if ! egrep "^$i:" /etc/group 2>/dev/null; then
-                        case $i in 
+                        case $i in
                             cdrom)   echo "$i:x:11:";;
                             dialout) echo "$i:x:18:";;
                             floppy)  echo "$i:x:19:";;
@@ -75,6 +77,5 @@ install() {
 
     inst_libdir_file "libnss_files*"
 
-    . "$moddir/udev-rules-prepare.sh"
 }
 
diff --git a/modules.d/95udev-rules/udev-rules-prepare.sh b/modules.d/95udev-rules/udev-rules-prepare.sh
deleted file mode 100644 (file)
index 920485d..0000000
+++ /dev/null
@@ -1,27 +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
-
-[ -z "$UDEVVERSION" ] && export UDEVVERSION=$(udevadm --version)
-
-for f in ${initdir}/etc/udev/rules.d/*-persistent-storage.rules; do
-    [ -e "$f" ] || continue
-    while read line; do
-        if [ "${line%%IMPORT PATH_ID}" != "$line" ]; then
-            if [ $UDEVVERSION -ge 174 ]; then
-                printf '%sIMPORT{builtin}="path_id"\n' "${line%%IMPORT PATH_ID}"
-            else
-                printf '%sIMPORT{program}="path_id %%p"\n' "${line%%IMPORT PATH_ID}"
-            fi
-        elif [ "${line%%IMPORT BLKID}" != "$line" ]; then
-            if [ $UDEVVERSION -ge 176 ]; then
-                printf '%sIMPORT{builtin}="blkid"\n' "${line%%IMPORT BLKID}"
-            else
-                printf '%sIMPORT{program}="/sbin/blkid -o udev -p $tempnode"\n' "${line%%IMPORT BLKID}"
-            fi
-        else
-            echo "$line"
-        fi
-    done < "${f}" > "${f}.new"
-    mv "${f}.new" "$f"
-done