~ubuntu-branches/ubuntu/quantal/lvm2/quantal

« back to all changes in this revision

Viewing changes to debian/tree/dmsetup/lib/udev/rules.d/55-dm.rules

  • Committer: Steve Langasek
  • Date: 2012-04-14 02:57:53 UTC
  • mfrom: (3.1.22 sid)
  • Revision ID: steve.langasek@canonical.com-20120414025753-ejbdw9c8llik58y9
Merge version 2.02.88-2 from Debian testing

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
SUBSYSTEM!="block", GOTO="dm_end"
7
7
KERNEL!="dm-[0-9]*", GOTO="dm_end"
8
8
 
9
 
# There is a new change event generated in block layer since kernel
10
 
# version 2.6.32. It adds notification for changes in read-only
11
 
# attribute. We don't want to misinterpret the regular meaning of change
12
 
# events for DM devices and we don't want to apply the rules prematurely,
13
 
# therefore we disable them in this situation.
14
 
ENV{DISK_RO}=="1", GOTO="dm_disable"
15
 
 
16
9
# Decode udev control flags and set environment variables appropriately.
17
10
# These flags are encoded in DM_COOKIE variable that was introduced in
18
11
# kernel version 2.6.31. Therefore, we can use this feature with
20
13
ENV{DM_COOKIE}=="?*", IMPORT{program}="/sbin/dmsetup udevflags $env{DM_COOKIE}"
21
14
ENV{DM_COOKIE}=="?*", RUN+="/sbin/dmsetup udevcomplete $env{DM_COOKIE}"
22
15
 
23
 
# Normally, we would test for DM_UDEV_DISABLE_DM_RULES_FLAG here and skip
24
 
# the rules if set. However, we need to set DM_* environment variables
25
 
# for now to properly filter out inappropriate events. This dependency
26
 
# might be removed in the future.
27
 
 
 
16
# Device created, major and minor number assigned - "add" event generated.
 
17
# Table loaded - no event generated.
 
18
# Device resumed (or renamed) - "change" event generated.
 
19
# Device removed - "remove" event generated.
 
20
#
 
21
# The dm-X nodes are always created, even on "add" event, we can't suppress
 
22
# that (the node is created even earlier with devtmpfs). All the symlinks
 
23
# (e.g. /dev/mapper) are created in right time after a device has its table
 
24
# loaded and is properly resumed. For this reason, direct use of dm-X nodes
 
25
# is not recommended.
28
26
ACTION!="add|change", GOTO="dm_end"
29
27
 
 
28
# Rule out easy-to-detect inappropriate events first.
 
29
ENV{DISK_RO}=="1", GOTO="dm_disable"
 
30
 
30
31
# There is no cookie set nor any flags encoded in events not originating
31
32
# in libdevmapper so we need to detect this and try to behave correctly.
32
33
# For such spurious events, regenerate all flags from current udev database content
38
39
IMPORT{db}="DM_UDEV_DISABLE_OTHER_RULES_FLAG"
39
40
IMPORT{db}="DM_UDEV_LOW_PRIORITY_FLAG"
40
41
IMPORT{db}="DM_UDEV_DISABLE_LIBRARY_FALLBACK_FLAG"
 
42
IMPORT{db}="DM_UDEV_PRIMARY_SOURCE_FLAG"
41
43
IMPORT{db}="DM_UDEV_FLAG7"
42
44
IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG0"
43
45
IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG1"
47
49
IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG5"
48
50
IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG6"
49
51
IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG7"
 
52
IMPORT{db}="DM_UDEV_RULES"
50
53
LABEL="dm_flags_done"
51
54
 
52
 
# Normally, we operate on "change" events only. But when
53
 
# coldplugging, there's an "add" event present. We have to
54
 
# recognize this and do our actions in this particular
55
 
# situation, too. Also, we don't want the nodes to be
56
 
# created prematurely on "add" events while not coldplugging.
57
 
 
58
 
# Disabled, as we need to respond to "add" events during boot
59
 
#ACTION=="add", ENV{STARTUP}!="1", NAME="", GOTO="dm_end"
 
55
# Normally, we operate on "change" events. But when coldplugging, there's an
 
56
# "add" event present. We have to recognize this and do our actions in this
 
57
# particular situation, too. Also, we don't want the nodes to be created
 
58
# prematurely on "add" events while not coldplugging. We check
 
59
# DM_UDEV_PRIMARY_SOURCE_FLAG to see if the device was activated correctly
 
60
# before and if not, we ignore the "add" event totally. This way we can support
 
61
# udev triggers generating "add" events (e.g. "udevadm trigger --action=add" or
 
62
# "echo add > /sys/block/<dm_device>/uevent"). The trigger with "add" event is
 
63
# also used at boot to reevaluate udev rules for all existing devices activated
 
64
# before (e.g. in initrd). If udev is used in initrd, we require the udev init
 
65
# script to not remove the existing udev database so we can reuse the information
 
66
# stored at the time of device activation in the initrd.
 
67
ACTION=="add", ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}!="1", GOTO="dm_disable"
60
68
 
61
69
# "dm" sysfs subdirectory is available in newer versions of DM
62
70
# only (kernels >= 2.6.29). We have to check for its existence
77
85
 
78
86
ENV{DM_UDEV_RULES}="1"
79
87
 
80
 
ENV{DM_NAME}=="?*", SYMLINK+="mapper/$env{DM_NAME}"
 
88
ENV{DM_UDEV_DISABLE_DM_RULES_FLAG}!="1", ENV{DM_NAME}=="?*", SYMLINK+="mapper/$env{DM_NAME}"
81
89
 
82
90
# We have to ignore further rule application for inappropriate events
83
91
# and devices. But still send the notification if cookie exists.
84
 
ENV{DM_UUID}=="mpath-?*", ENV{DM_ACTION}=="PATH_FAILED", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
85
 
ENV{DM_UUID}=="CRYPT-TEMP-?*", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
86
 
ENV{DM_UUID}!="?*", ENV{DM_NAME}=="temporary-cryptsetup-?*", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
87
 
 
88
 
ENV{DM_SUSPENDED}=="1", ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}="1"
89
 
 
90
 
ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}!="", ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}="1"
 
92
ENV{DM_UUID}=="mpath-?*", ENV{DM_ACTION}=="PATH_FAILED", GOTO="dm_disable"
 
93
ENV{DM_UUID}=="CRYPT-TEMP-?*", GOTO="dm_disable"
 
94
ENV{DM_UUID}!="?*", ENV{DM_NAME}=="temporary-cryptsetup-?*", GOTO="dm_disable"
 
95
 
 
96
# Avoid processing and scanning a DM device in the other (foreign)
 
97
# rules if it is in suspended state. However, we still keep 'disk'
 
98
# and 'DM subsystem' related rules enabled in this case.
 
99
ENV{DM_SUSPENDED}=="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
91
100
 
92
101
GOTO="dm_end"
93
102
 
95
104
ENV{DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG}="1"
96
105
ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}="1"
97
106
ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
 
107
OPTIONS:="nowatch"
98
108
 
99
109
LABEL="dm_end"