diff options
author | Alasdair Kergon <agk@redhat.com> | 2009-08-03 18:44:54 +0000 |
---|---|---|
committer | Alasdair Kergon <agk@redhat.com> | 2009-08-03 18:44:54 +0000 |
commit | 252239bdac59a4fcfd7b9279a1df2c965e9cf0fa (patch) | |
tree | 8e73ef569cc819e5b35c466766eea7ed3944c653 /udev/10-dm.rules.in | |
parent | f9e17e36aa776503616c916334433389b7d6c80f (diff) | |
download | lvm2-252239bdac59a4fcfd7b9279a1df2c965e9cf0fa.tar.gz |
Add default udev rules.
Update dm-ioctl.h comments.
Diffstat (limited to 'udev/10-dm.rules.in')
-rw-r--r-- | udev/10-dm.rules.in | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/udev/10-dm.rules.in b/udev/10-dm.rules.in new file mode 100644 index 000000000..e0de5d3ee --- /dev/null +++ b/udev/10-dm.rules.in @@ -0,0 +1,44 @@ +# Udev rules for device-mapper devices. +# +# These rules create a DM control node in /dev/(DM_DIR) directory. +# The rules also create nodes named dm-x (x is a number) in /dev +# directory and symlinks to these nodes with names given by +# the actual DM names. Some udev environment variables are set +# for use in later rules: +# DM_NAME - actual DM device's name +# DM_UUID - UUID set for DM device (blank if not specified) +# DM_SUSPENDED - suspended state of DM device (0 or 1) + +KERNEL=="device-mapper", NAME="(DM_DIR)/control" + +SUBSYSTEM!="block", GOTO="dm_end" +KERNEL!="dm-[0-9]*", GOTO="dm_end" +ACTION!="add|change", GOTO="dm_end" + +# Normally, we operate on "change" events only. But when +# coldplugging, there's an "add" event present. We have to +# recognize this and do our actions in this particular +# situation, too. Also, we don't want the nodes to be +# created prematurely on "add" events while not coldplugging. +ACTION=="add", ENV{STARTUP}!="1", NAME="", GOTO="dm_end" + +# "dm" sysfs subdirectory is available in newer versions of DM +# only (kernels >= 2.6.29). We have to check for its existence +# and use dmsetup tool instead to get the DM name, uuid and +# suspended state if the "dm" subdirectory is not present. +# The "suspended" item was added even later (kernels >= ???), +# so we also have to call dmsetup if the kernel version used +# is in between these releases. +TEST=="dm", ENV{DM_NAME}="$attr{dm/name}", ENV{DM_UUID}="$attr{dm/uuid}", ENV{DM_SUSPENDED}="$attr{dm/suspended}" +TEST!="dm", IMPORT{program}="/sbin/dmsetup info -j %M -m %m -c --nameprefixes --noheadings --rows -o name,uuid,suspended" +ENV{DM_SUSPENDED}!="?*", IMPORT{program}="/sbin/dmsetup info -j %M -m %m -c --nameprefixes --noheadings --rows -o suspended" + +# dmsetup tool provides suspended state information in textual +# form with values "Suspended"/"Active". We translate it to +# 0/1 respectively to be consistent with sysfs values. +ENV{DM_SUSPENDED}=="Active", ENV{DM_SUSPENDED}="0" +ENV{DM_SUSPENDED}=="Suspended", ENV{DM_SUSPENDED}="1" + +ENV{DM_NAME}=="?*", NAME="$kernel", SYMLINK+="(DM_DIR)/$env{DM_NAME}" + +LABEL="dm_end" |