File: 60-persistent-storage.rules

package info (click to toggle)
udev 164-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 4,336 kB
  • ctags: 1,738
  • sloc: ansic: 18,516; sh: 11,378; perl: 1,725; xml: 1,286; makefile: 692; python: 34
file content (149 lines) | stat: -rw-r--r-- 5,798 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# This file contains the rules needed to create persistent device names.

# forward scsi device events to the corresponding block device
ACTION=="change", SUBSYSTEM=="scsi", ENV{DEVTYPE}=="scsi_device", \
	TEST=="block",			ATTR{block/*/uevent}="change"

# we are only interested in add and change actions for block devices
ACTION=="remove",			GOTO="persistent_storage_end"
SUBSYSTEM!="block",			GOTO="persistent_storage_end"

# and we can safely ignore these kinds of devices
KERNEL=="fd[0-9]*|mtd[0-9]*|mtdblock[0-9]*|nbd[0-9]*|gnbd[0-9]*|dm-[0-9]*|md[0-9]*|btibm[0-9]*", \
					GOTO="persistent_storage_end"

# skip removable ide devices, because open(2) on them causes an events loop
KERNEL=="hd*[!0-9]", ATTR{removable}=="1", \
	SUBSYSTEMS=="ide", ATTRS{media}=="disk|floppy", \
					GOTO="persistent_storage_end"
KERNEL=="hd*[0-9]", ATTRS{removable}=="1", \
					GOTO="persistent_storage_end"

# ignore partitions that span the entire disk
TEST=="whole_disk",			GOTO="persistent_storage_end"

# workaround for kernels < 2.6.25-rc1
ENV{DEVTYPE}!="?*", ATTR{range}=="?*",	ENV{DEVTYPE}="disk"
ENV{DEVTYPE}!="?*", ATTR{start}=="?*",	ENV{DEVTYPE}="partition"

# partitions do not have hardware identificators
ENV{DEVTYPE}!="disk",			GOTO="persistent_storage_not_a_disk"
# nor do paravirtualized hard disks
KERNEL=="vd*",				GOTO="persistent_storage_not_a_disk"

# look for different kinds of unique identificators
KERNEL=="hd*", \
	IMPORT{program}="ata_id --export $tempnode"

KERNEL=="mmcblk[0-9]", ATTRS{name}=="?*", ATTRS{serial}=="?*", \
	ENV{ID_BUS}="memstick", ENV{ID_SERIAL}="$attr{name}_$attr{serial}"
KERNEL=="mspblk[0-9]", ATTRS{name}=="?*", ATTRS{serial}=="?*", \
	ENV{ID_BUS}="mmc",	ENV{ID_SERIAL}="$attr{name}_$attr{serial}"

KERNEL=="sd*|sr*",			ATTRS{ieee1394_id}=="?*", \
	ENV{ID_BUS}="ieee1394", ENV{ID_SERIAL}="$attr{ieee1394_id}"

KERNEL=="vd*",				ATTRS{serial}=="?*", \
	ENV{ID_BUS}="virtio",	ENV{ID_SERIAL}="$attr{serial}"

# USB devices use their own serial number
KERNEL=="sd*|sr*",			ENV{ID_SERIAL}!="?*", \
	SUBSYSTEMS=="usb", \
	IMPORT{program}="usb_id --export $devpath"
# ATA devices with their own "ata" kernel subsystem
KERNEL=="sd*|sr*",			ENV{ID_SERIAL}!="?*", \
	SUBSYSTEMS=="ata", \
	IMPORT{program}="ata_id --export $tempnode"
# ATA devices using the "scsi" subsystem
KERNEL=="sd*|sr*",			ENV{ID_SERIAL}!="?*", \
	SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", \
	IMPORT{program}="ata_id --export $tempnode"
# scsi devices
KERNEL=="sd*|sr*",			ENV{ID_SERIAL}!="?*", \
	ENV{ID_BUS}="scsi", \
	IMPORT{program}="scsi_id --export --whitelisted --device=$tempnode"

KERNEL=="cciss*", 			ENV{ID_SERIAL}!="?*", \
	ENV{ID_BUS}="cciss", \
	IMPORT{program}="scsi_id --export --whitelisted --device=$tempnode"

KERNEL=="dasd*", \
	IMPORT{program}="dasd_id --export $tempnode"

KERNEL=="sd*|hd*|cciss*", \
	IMPORT{program}="edd_id --export $tempnode"

# scsi compat links for ATA devices
KERNEL=="sd*", ENV{ID_BUS}=="ata", \
    PROGRAM="scsi_id --whitelisted --replace-whitespace -p0x80 -d$tempnode", \
	RESULT=="?*", ENV{ID_SCSI_COMPAT}="$result"

# find the physical path of the device
ENV{ID_PATH}=="", DEVPATH!="*/virtual/*", \
	IMPORT{program}="path_id $devpath"

LABEL="persistent_storage_not_a_disk"

# import the variables of partitions from the parent disks
ENV{DEVTYPE}=="partition",		IMPORT{parent}="ID_*"

# by-id (hardware serial number)
KERNEL=="hd*[!0-9]",			ENV{ID_SERIAL}=="?*", \
	SYMLINK+="disk/by-id/ata-$env{ID_SERIAL}"
KERNEL=="hd*[0-9]",			ENV{ID_SERIAL}=="?*", \
	SYMLINK+="disk/by-id/ata-$env{ID_SERIAL}-part%n"

KERNEL=="sd*[!0-9]",			ENV{ID_SCSI_COMPAT}=="?*", \
	SYMLINK+="disk/by-id/scsi-$env{ID_SCSI_COMPAT}"
KERNEL=="sd*[0-9]",			ENV{ID_SCSI_COMPAT}=="?*", \
	SYMLINK+="disk/by-id/scsi-$env{ID_SCSI_COMPAT}-part%n"

ENV{DEVTYPE}=="disk",		ENV{ID_BUS}=="?*", ENV{ID_SERIAL}=="?*", \
	SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}"
ENV{DEVTYPE}=="partition",	ENV{ID_BUS}=="?*", ENV{ID_SERIAL}=="?*", \
	SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}-part%n"

ENV{DEVTYPE}=="disk",			ENV{ID_EDD}=="?*", \
	SYMLINK+="disk/by-id/edd-$env{ID_EDD}"
ENV{DEVTYPE}=="partition",		ENV{ID_EDD}=="?*", \
	SYMLINK+="disk/by-id/edd-$env{ID_EDD}-part%n"

ENV{DEVTYPE}=="disk",			ENV{ID_WWN}=="?*", \
	SYMLINK+="disk/by-id/wwn-$env{ID_WWN}"
ENV{DEVTYPE}=="partition",		ENV{ID_WWN}=="?*", \
	SYMLINK+="disk/by-id/wwn-$env{ID_WWN}-part%n"

# by-path (parent device path)
ENV{DEVTYPE}=="disk",			ENV{ID_PATH}=="?*", \
	SYMLINK+="disk/by-path/$env{ID_PATH}"
ENV{DEVTYPE}=="partition",		ENV{ID_PATH}=="?*", \
	SYMLINK+="disk/by-path/$env{ID_PATH}-part%n"

# skip unpartitioned removable media devices from drivers which do not send
# "change" events
ENV{DEVTYPE}=="disk", KERNEL!="sd*|sr*", ATTR{removable}=="1", \
					GOTO="persistent_storage_end"

# probe filesystem metadata of optical drives which have a media inserted
KERNEL=="sr*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DATA}=="?*", \
	ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="?*", \
	IMPORT{program}="/sbin/blkid -o udev -p -u noraid -O $env{ID_CDROM_MEDIA_SESSION_LAST_OFFSET} $tempnode"
# single-session CDs do not have ID_CDROM_MEDIA_SESSION_LAST_OFFSET
KERNEL=="sr*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DATA}=="?*", \
	ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="", \
	IMPORT{program}="/sbin/blkid -o udev -p -u noraid $tempnode"

# probe filesystem metadata of disks
KERNEL!="sr*", IMPORT{program}="/sbin/blkid -o udev -p $tempnode"

# watch for future changes
KERNEL!="sr*", OPTIONS+="watch"

# by-label/by-uuid links (filesystem metadata)
ENV{ID_FS_UUID_ENC}=="?*",	ENV{ID_FS_USAGE}=="filesystem|other|crypto", \
	SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
ENV{ID_FS_LABEL_ENC}=="?*",	ENV{ID_FS_USAGE}=="filesystem|other", \
	SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"

LABEL="persistent_storage_end"