home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / lib / udev / rules.d / 60-persistent-storage.rules < prev    next >
Encoding:
Text File  |  2010-12-12  |  5.7 KB  |  150 lines

  1. # This file contains the rules needed to create persistent device names.
  2.  
  3. # forward scsi device events to the corresponding block device
  4. ACTION=="change", SUBSYSTEM=="scsi", ENV{DEVTYPE}=="scsi_device", \
  5.     TEST=="block",            ATTR{block/*/uevent}="change"
  6.  
  7. # we are only interested in add and change actions for block devices
  8. ACTION=="remove",            GOTO="persistent_storage_end"
  9. SUBSYSTEM!="block",            GOTO="persistent_storage_end"
  10.  
  11. # and we can safely ignore these kinds of devices
  12. 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]*", \
  13.                     GOTO="persistent_storage_end"
  14.  
  15. # skip removable ide devices, because open(2) on them causes an events loop
  16. KERNEL=="hd*[!0-9]", ATTR{removable}=="1", \
  17.     SUBSYSTEMS=="ide", ATTRS{media}=="disk|floppy", \
  18.                     GOTO="persistent_storage_end"
  19. KERNEL=="hd*[0-9]", ATTRS{removable}=="1", \
  20.                     GOTO="persistent_storage_end"
  21.  
  22. # ignore partitions that span the entire disk
  23. TEST=="whole_disk",            GOTO="persistent_storage_end"
  24.  
  25. # workaround for kernels < 2.6.25-rc1
  26. ENV{DEVTYPE}!="?*", ATTR{range}=="?*",    ENV{DEVTYPE}="disk"
  27. ENV{DEVTYPE}!="?*", ATTR{start}=="?*",    ENV{DEVTYPE}="partition"
  28.  
  29. # partitions do not have hardware identificators
  30. ENV{DEVTYPE}!="disk",            GOTO="persistent_storage_not_a_disk"
  31. # nor do paravirtualized hard disks
  32. KERNEL=="vd*",                GOTO="persistent_storage_not_a_disk"
  33.  
  34. # look for different kinds of unique identificators
  35. KERNEL=="hd*", \
  36.     IMPORT{program}="ata_id --export $tempnode"
  37.  
  38. KERNEL=="mmcblk[0-9]", ATTRS{name}=="?*", ATTRS{serial}=="?*", \
  39.     ENV{ID_BUS}="memstick", ENV{ID_SERIAL}="$attr{name}_$attr{serial}"
  40. KERNEL=="mspblk[0-9]", ATTRS{name}=="?*", ATTRS{serial}=="?*", \
  41.     ENV{ID_BUS}="mmc",    ENV{ID_SERIAL}="$attr{name}_$attr{serial}"
  42.  
  43. KERNEL=="sd*|sr*",            ATTRS{ieee1394_id}=="?*", \
  44.     ENV{ID_BUS}="ieee1394", ENV{ID_SERIAL}="$attr{ieee1394_id}"
  45.  
  46. KERNEL=="vd*",                ATTRS{serial}=="?*", \
  47.     ENV{ID_BUS}="virtio",    ENV{ID_SERIAL}="$attr{serial}"
  48.  
  49. # USB devices use their own serial number
  50. KERNEL=="sd*|sr*",            ENV{ID_SERIAL}!="?*", \
  51.     SUBSYSTEMS=="usb", \
  52.     IMPORT{program}="usb_id --export $devpath"
  53. # ATA devices with their own "ata" kernel subsystem
  54. KERNEL=="sd*|sr*",            ENV{ID_SERIAL}!="?*", \
  55.     SUBSYSTEMS=="ata", \
  56.     IMPORT{program}="ata_id --export $tempnode"
  57. # ATA devices using the "scsi" subsystem
  58. KERNEL=="sd*|sr*",            ENV{ID_SERIAL}!="?*", \
  59.     SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", \
  60.     IMPORT{program}="ata_id --export $tempnode"
  61. # scsi devices
  62. KERNEL=="sd*|sr*",            ENV{ID_SERIAL}!="?*", \
  63.     ENV{ID_BUS}="scsi", \
  64.     IMPORT{program}="scsi_id --export --whitelisted --device=$tempnode"
  65.  
  66. KERNEL=="cciss*",             ENV{ID_SERIAL}!="?*", \
  67.     ENV{ID_BUS}="cciss", \
  68.     IMPORT{program}="scsi_id --export --whitelisted --device=$tempnode"
  69.  
  70. KERNEL=="dasd*", \
  71.     IMPORT{program}="dasd_id --export $tempnode"
  72.  
  73. KERNEL=="sd*|hd*|cciss*", \
  74.     IMPORT{program}="edd_id --export $tempnode"
  75.  
  76. # scsi compat links for ATA devices
  77. KERNEL=="sd*", ENV{ID_BUS}=="ata", \
  78.     PROGRAM="scsi_id --whitelisted --replace-whitespace -p0x80 -d$tempnode", \
  79.     RESULT=="?*", ENV{ID_SCSI_COMPAT}="$result"
  80.  
  81. # find the physical path of the device
  82. ENV{ID_PATH}=="", DEVPATH!="*/virtual/*", \
  83.     IMPORT{program}="path_id $devpath"
  84.  
  85. LABEL="persistent_storage_not_a_disk"
  86.  
  87. # import the variables of partitions from the parent disks
  88. ENV{DEVTYPE}=="partition",        IMPORT{parent}="ID_*"
  89.  
  90. # by-id (hardware serial number)
  91. KERNEL=="hd*[!0-9]",            ENV{ID_SERIAL}=="?*", \
  92.     SYMLINK+="disk/by-id/ata-$env{ID_SERIAL}"
  93. KERNEL=="hd*[0-9]",            ENV{ID_SERIAL}=="?*", \
  94.     SYMLINK+="disk/by-id/ata-$env{ID_SERIAL}-part%n"
  95.  
  96. KERNEL=="sd*[!0-9]",            ENV{ID_SCSI_COMPAT}=="?*", \
  97.     SYMLINK+="disk/by-id/scsi-$env{ID_SCSI_COMPAT}"
  98. KERNEL=="sd*[0-9]",            ENV{ID_SCSI_COMPAT}=="?*", \
  99.     SYMLINK+="disk/by-id/scsi-$env{ID_SCSI_COMPAT}-part%n"
  100.  
  101. ENV{DEVTYPE}=="disk",        ENV{ID_BUS}=="?*", ENV{ID_SERIAL}=="?*", \
  102.     SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}"
  103. ENV{DEVTYPE}=="partition",    ENV{ID_BUS}=="?*", ENV{ID_SERIAL}=="?*", \
  104.     SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}-part%n"
  105.  
  106. ENV{DEVTYPE}=="disk",            ENV{ID_EDD}=="?*", \
  107.     SYMLINK+="disk/by-id/edd-$env{ID_EDD}"
  108. ENV{DEVTYPE}=="partition",        ENV{ID_EDD}=="?*", \
  109.     SYMLINK+="disk/by-id/edd-$env{ID_EDD}-part%n"
  110.  
  111. ENV{DEVTYPE}=="disk",            ENV{ID_WWN}=="?*", \
  112.     SYMLINK+="disk/by-id/wwn-$env{ID_WWN}"
  113. ENV{DEVTYPE}=="partition",        ENV{ID_WWN}=="?*", \
  114.     SYMLINK+="disk/by-id/wwn-$env{ID_WWN}-part%n"
  115.  
  116. # by-path (parent device path)
  117. ENV{DEVTYPE}=="disk",            ENV{ID_PATH}=="?*", \
  118.     SYMLINK+="disk/by-path/$env{ID_PATH}"
  119. ENV{DEVTYPE}=="partition",        ENV{ID_PATH}=="?*", \
  120.     SYMLINK+="disk/by-path/$env{ID_PATH}-part%n"
  121.  
  122. # skip unpartitioned removable media devices from drivers which do not send
  123. # "change" events
  124. ENV{DEVTYPE}=="disk", KERNEL!="sd*|sr*", ATTR{removable}=="1", \
  125.                     GOTO="persistent_storage_end"
  126.  
  127. # probe filesystem metadata of optical drives which have a media inserted
  128. KERNEL=="sr*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DATA}=="?*", \
  129.     ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="?*", \
  130.     IMPORT{program}="/sbin/blkid -o udev -p -u noraid -O $env{ID_CDROM_MEDIA_SESSION_LAST_OFFSET} $tempnode"
  131. # single-session CDs do not have ID_CDROM_MEDIA_SESSION_LAST_OFFSET
  132. KERNEL=="sr*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DATA}=="?*", \
  133.     ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="", \
  134.     IMPORT{program}="/sbin/blkid -o udev -p -u noraid $tempnode"
  135.  
  136. # probe filesystem metadata of disks
  137. KERNEL!="sr*", IMPORT{program}="/sbin/blkid -o udev -p $tempnode"
  138.  
  139. # watch for future changes
  140. KERNEL!="sr*", OPTIONS+="watch"
  141.  
  142. # by-label/by-uuid links (filesystem metadata)
  143. ENV{ID_FS_UUID_ENC}=="?*",    ENV{ID_FS_USAGE}=="filesystem|other|crypto", \
  144.     SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
  145. ENV{ID_FS_LABEL_ENC}=="?*",    ENV{ID_FS_USAGE}=="filesystem|other", \
  146.     SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"
  147.  
  148. LABEL="persistent_storage_end"
  149.  
  150.