[PATCH] 64-md-raid.rules fixes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Few small things:

1) introduced in commit b822542608326092e177fd1707ca7fb53b2846c4

md/array_state in case of partition doesn't exists, so all uevents
for partitions didn't execute any further SYMLINK rules

2) mdadm exports MD_NAME, not MD_DEVNAME - replaced

3) 0.9x superblocks don't support name at all, but it can be easily
emulated from kernel name. It simply cuts md and _ in front, and
p[0-9]* at the end of the kernel name. Following SYMLINK rules need
no alteration (tests for MD_NAME are superfluous then though). If
it's really necessary is another thing (and it depends on sh after
all)

Signed-off-by: Michal Soltys <soltys@xxxxxxxx>
---
 rules/packages/64-md-raid.rules |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/rules/packages/64-md-raid.rules b/rules/packages/64-md-raid.rules
index abb029c..5906ab0 100644
--- a/rules/packages/64-md-raid.rules
+++ b/rules/packages/64-md-raid.rules
@@ -8,21 +8,29 @@ ACTION!="add|change", GOTO="md_end"
 # import data from a raid set
 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"
+
+# emulate MD_NAME for 0.9x superblocks
+ENV{MD_NAME}!="?*", PROGRAM="/bin/sh -c 'K=%k ; K=$${K#md}; K=$${K#_}; echo $${K%%p*}'", ENV{MD_NAME}="%c"
+
 ENV{DEVTYPE}=="disk", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}", OPTIONS+="string_escape=replace"
 ENV{DEVTYPE}=="disk", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}"
-ENV{DEVTYPE}=="disk", ENV{MD_DEVNAME}=="?*", SYMLINK+="md/$env{MD_DEVNAME}"
+ENV{DEVTYPE}=="disk", ENV{MD_NAME}=="?*", SYMLINK+="md/$env{MD_NAME}"
 ENV{DEVTYPE}=="partition", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}-part%n", OPTIONS+="string_escape=replace"
 ENV{DEVTYPE}=="partition", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}-part%n"
-ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[^0-9]", SYMLINK+="md/$env{MD_DEVNAME}%n"
-ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[0-9]", SYMLINK+="md/$env{MD_DEVNAME}p%n"
+ENV{DEVTYPE}=="partition", ENV{MD_NAME}=="*[^0-9]", SYMLINK+="md/$env{MD_NAME}%n"
+ENV{DEVTYPE}=="partition", ENV{MD_NAME}=="*[0-9]", SYMLINK+="md/$env{MD_NAME}p%n"
 
 IMPORT{program}="vol_id --export $tempnode"
 OPTIONS+="link_priority=100"
-- 
1.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-hotplug" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel]     [Linux DVB]     [Asterisk Internet PBX]     [DCCP]     [Netdev]     [X.org]     [Util Linux NG]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux