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 / 55-dm.rules < prev    next >
Encoding:
Text File  |  2010-06-04  |  4.4 KB  |  98 lines

  1. # Udev rules for device-mapper devices.
  2. # See /usr/share/doc/dmsetup/README.udev for further information.
  3.  
  4. KERNEL=="device-mapper", NAME="mapper/control"
  5.  
  6. SUBSYSTEM!="block", GOTO="dm_end"
  7. KERNEL!="dm-[0-9]*", GOTO="dm_end"
  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. # Decode udev control flags and set environment variables appropriately.
  17. # These flags are encoded in DM_COOKIE variable that was introduced in
  18. # kernel version 2.6.31. Therefore, we can use this feature with
  19. # kernels >= 2.6.31 only.
  20. ENV{DM_COOKIE}=="?*", IMPORT{program}="/sbin/dmsetup udevflags $env{DM_COOKIE}"
  21. ENV{DM_COOKIE}=="?*", RUN+="/sbin/dmsetup udevcomplete $env{DM_COOKIE}"
  22.  
  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.  
  28. ACTION!="add|change", GOTO="dm_end"
  29.  
  30. # There is no cookie set nor any flags encoded in events not originating
  31. # in libdevmapper so we need to detect this and try to behave correctly.
  32. # For such spurious events, regenerate all flags from current udev database content
  33. # (this information would normally be inaccessible for spurious ADD and CHANGE events).
  34. ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", GOTO="dm_flags_done"
  35. IMPORT{db}="DM_UDEV_DISABLE_DM_RULES_FLAG"
  36. IMPORT{db}="DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG"
  37. IMPORT{db}="DM_UDEV_DISABLE_DISK_RULES_FLAG"
  38. IMPORT{db}="DM_UDEV_DISABLE_OTHER_RULES_FLAG"
  39. IMPORT{db}="DM_UDEV_LOW_PRIORITY_FLAG"
  40. IMPORT{db}="DM_UDEV_DISABLE_LIBRARY_FALLBACK_FLAG"
  41. IMPORT{db}="DM_UDEV_FLAG7"
  42. IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG0"
  43. IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG1"
  44. IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG2"
  45. IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG3"
  46. IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG4"
  47. IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG5"
  48. IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG6"
  49. IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG7"
  50. LABEL="dm_flags_done"
  51.  
  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. ACTION=="add", ENV{STARTUP}!="1", NAME="", GOTO="dm_end"
  58.  
  59. # "dm" sysfs subdirectory is available in newer versions of DM
  60. # only (kernels >= 2.6.29). We have to check for its existence
  61. # and use dmsetup tool instead to get the DM name, uuid and 
  62. # suspended state if the "dm" subdirectory is not present.
  63. # The "suspended" item was added even later (kernels >= 2.6.31),
  64. # so we also have to call dmsetup if the kernel version used
  65. # is in between these releases.
  66. TEST=="dm", ENV{DM_NAME}="$attr{dm/name}", ENV{DM_UUID}="$attr{dm/uuid}", ENV{DM_SUSPENDED}="$attr{dm/suspended}"
  67. TEST!="dm", IMPORT{program}="/sbin/dmsetup info -j %M -m %m -c --nameprefixes --noheadings --rows -o name,uuid,suspended"
  68. ENV{DM_SUSPENDED}!="?*", IMPORT{program}="/sbin/dmsetup info -j %M -m %m -c --nameprefixes --noheadings --rows -o suspended"
  69.  
  70. # dmsetup tool provides suspended state information in textual
  71. # form with values "Suspended"/"Active". We translate it to
  72. # 0/1 respectively to be consistent with sysfs values.
  73. ENV{DM_SUSPENDED}=="Active", ENV{DM_SUSPENDED}="0"
  74. ENV{DM_SUSPENDED}=="Suspended", ENV{DM_SUSPENDED}="1"
  75.  
  76. ENV{DM_UDEV_RULES}="1"
  77.  
  78. ENV{DM_NAME}=="?*", SYMLINK+="mapper/$env{DM_NAME}"
  79.  
  80. # We have to ignore further rule application for inappropriate events
  81. # and devices. But still send the notification if cookie exists.
  82. ENV{DM_UUID}=="mpath-?*", ENV{DM_ACTION}=="PATH_FAILED", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
  83. ENV{DM_UUID}=="CRYPT-TEMP-?*", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
  84. ENV{DM_UUID}!="?*", ENV{DM_NAME}=="temporary-cryptsetup-?*", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
  85.  
  86. ENV{DM_SUSPENDED}=="1", ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}="1"
  87.  
  88. ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}!="", ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}="1"
  89.  
  90. GOTO="dm_end"
  91.  
  92. LABEL="dm_disable"
  93. ENV{DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG}="1"
  94. ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}="1"
  95. ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
  96.  
  97. LABEL="dm_end"
  98.