diff options
author | Peter Rajnoha <prajnoha@redhat.com> | 2012-06-22 05:50:02 -0400 |
---|---|---|
committer | Peter Rajnoha <prajnoha@redhat.com> | 2012-06-27 12:11:56 +0200 |
commit | e6f8d86409e54300aeda05a82aad9b072d22ed4d (patch) | |
tree | d2cf9af1ae67694c79ce15acd024ec3d93531e3f /udev | |
parent | 9a96f930a762418f1014f6a9da9546cb1f501f04 (diff) | |
download | lvm2-e6f8d86409e54300aeda05a82aad9b072d22ed4d.tar.gz |
udev: udev rules cleanup
Remove executable path detection in udev rules and use sbindir that
is configured, but still provide the original functionality by means
of 'configure --enable-udev-rule-exec-detection'.
Normally, the exec path for the tools called in udev rules should
not differ from the sbindir used, however, there are cases this is
necessary. For example different environments could be assembled
in a way that these path differ for some reason (distribution installer,
initrd ...).
This functionality is kept for compatibility only. Any environment
moving the binaries around and using different paths should be fixed
eventually!
Diffstat (limited to 'udev')
-rw-r--r-- | udev/10-dm.rules.in | 12 | ||||
-rw-r--r-- | udev/11-dm-lvm.rules.in (renamed from udev/11-dm-lvm.rules) | 2 | ||||
-rw-r--r-- | udev/69-dm-lvm-metad.rules.in (renamed from udev/69-dm-lvm-metad.rules) | 8 | ||||
-rw-r--r-- | udev/95-dm-notify.rules.in (renamed from udev/95-dm-notify.rules) | 2 | ||||
-rw-r--r-- | udev/Makefile.in | 33 |
5 files changed, 30 insertions, 27 deletions
diff --git a/udev/10-dm.rules.in b/udev/10-dm.rules.in index 605e08870..29af467bf 100644 --- a/udev/10-dm.rules.in +++ b/udev/10-dm.rules.in @@ -18,11 +18,7 @@ KERNEL=="device-mapper", NAME="(DM_DIR)/control" SUBSYSTEM!="block", GOTO="dm_end" KERNEL!="dm-[0-9]*", GOTO="dm_end" - -# Set proper sbin path, /sbin has higher priority than /usr/sbin. -ENV{DM_SBIN_PATH}="/sbin" -TEST!="$env{DM_SBIN_PATH}/dmsetup", ENV{DM_SBIN_PATH}="/usr/sbin" -TEST!="$env{DM_SBIN_PATH}/dmsetup", GOTO="dm_end" +(DM_EXEC_RULE) # Device created, major and minor number assigned - "add" event generated. # Table loaded - no event generated. @@ -40,7 +36,7 @@ ACTION!="add|change", GOTO="dm_end" # These flags are encoded in DM_COOKIE variable that was introduced in # kernel version 2.6.31. Therefore, we can use this feature with # kernels >= 2.6.31 only. Cookie is not decoded for remove event. -ENV{DM_COOKIE}=="?*", IMPORT{program}="$env{DM_SBIN_PATH}/dmsetup udevflags $env{DM_COOKIE}" +ENV{DM_COOKIE}=="?*", IMPORT{program}="(DM_EXEC)/dmsetup udevflags $env{DM_COOKIE}" # Rule out easy-to-detect inappropriate events first. ENV{DISK_RO}=="1", GOTO="dm_disable" @@ -91,8 +87,8 @@ ACTION=="add", ENV{DM_UDEV_RULES_VSN}!="1", ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}!="1 # 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}="$env{DM_SBIN_PATH}/dmsetup info -j %M -m %m -c --nameprefixes --noheadings --rows -o name,uuid,suspended" -ENV{DM_SUSPENDED}!="?*", IMPORT{program}="$env{DM_SBIN_PATH}/dmsetup info -j %M -m %m -c --nameprefixes --noheadings --rows -o suspended" +TEST!="dm", IMPORT{program}="(DM_EXEC)/dmsetup info -j %M -m %m -c --nameprefixes --noheadings --rows -o name,uuid,suspended" +ENV{DM_SUSPENDED}!="?*", IMPORT{program}="(DM_EXEC)/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 diff --git a/udev/11-dm-lvm.rules b/udev/11-dm-lvm.rules.in index 824446489..58ef21063 100644 --- a/udev/11-dm-lvm.rules +++ b/udev/11-dm-lvm.rules.in @@ -18,7 +18,7 @@ ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="lvm_end" ENV{DM_UUID}!="LVM-?*", GOTO="lvm_end" # Use DM name and split it up into its VG/LV/layer constituents. -IMPORT{program}="$env{DM_SBIN_PATH}/dmsetup splitname --nameprefixes --noheadings --rows $env{DM_NAME}" +IMPORT{program}="(DM_EXEC)/dmsetup splitname --nameprefixes --noheadings --rows $env{DM_NAME}" ENV{DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG}=="1", GOTO="lvm_end" diff --git a/udev/69-dm-lvm-metad.rules b/udev/69-dm-lvm-metad.rules.in index d272e6e22..26309deba 100644 --- a/udev/69-dm-lvm-metad.rules +++ b/udev/69-dm-lvm-metad.rules.in @@ -15,16 +15,12 @@ # used as LVM PVs are processed (ID_FS_TYPE="LVM2_member" or "LVM1_member"). SUBSYSTEM!="block", GOTO="lvm_end" +(LVM_EXEC_RULE) # Device-mapper devices are processed only on change event or on supported synthesized event. KERNEL=="dm-[0-9]*", ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="lvm_end" -# Set proper sbin path, /sbin has higher priority than /usr/sbin. -ENV{LVM_SBIN_PATH}="/sbin" -TEST!="$env{LVM_SBIN_PATH}/lvm", ENV{LVM_SBIN_PATH}="/usr/sbin" -TEST!="$env{LVM_SBIN_PATH}/lvm", GOTO="lvm_end" - # Only process devices already marked as a PV - this requires blkid to be called before. -ENV{ID_FS_TYPE}=="LVM2_member|LVM1_member", RUN+="$env{LVM_SBIN_PATH}/lvm pvscan --cache --major $major --minor $minor" +ENV{ID_FS_TYPE}=="LVM2_member|LVM1_member", RUN+="(LVM_EXEC)/lvm pvscan --cache --major $major --minor $minor" LABEL="lvm_end" diff --git a/udev/95-dm-notify.rules b/udev/95-dm-notify.rules.in index 72cc609d8..80d59d37d 100644 --- a/udev/95-dm-notify.rules +++ b/udev/95-dm-notify.rules.in @@ -9,4 +9,4 @@ # a cookie value sent within "change" and "remove" events (the cookie # value is set before by that process for every action requested). -ENV{DM_COOKIE}=="?*", RUN+="$env{DM_SBIN_PATH}/dmsetup udevcomplete $env{DM_COOKIE}" +ENV{DM_COOKIE}=="?*", RUN+="(DM_EXEC)/dmsetup udevcomplete $env{DM_COOKIE}" diff --git a/udev/Makefile.in b/udev/Makefile.in index 4ace9108e..5c15bdb64 100644 --- a/udev/Makefile.in +++ b/udev/Makefile.in @@ -15,28 +15,39 @@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ +include $(top_builddir)/make.tmpl +vpath %.rules $(srcdir) + DM_RULES=10-dm.rules 13-dm-disk.rules 95-dm-notify.rules LVM_RULES=11-dm-lvm.rules -DM_DIR=$(shell grep "\#define DM_DIR" $(top_srcdir)/libdm/misc/dm-ioctl.h | awk '{print $$3}') - ifeq ("@BUILD_LVMETAD@", "yes") LVM_RULES+=69-dm-lvm-metad.rules endif -ifeq ("@UDEV_HAS_BUILTIN_BLKID@", "yes") - BLKID_RULE=IMPORT{builtin}=\"blkid\" +DM_DIR=$(shell grep "\#define DM_DIR" $(top_srcdir)/libdm/misc/dm-ioctl.h | awk '{print $$3}') + +ifeq ("@UDEV_RULE_EXEC_DETECTION@", "yes") +SBIN=\$$env{DM_SBIN_PATH} +DM_EXEC_RULE=ENV{DM_SBIN_PATH}=\"\/sbin\"\\nTEST!=\"\$$env{DM_SBIN_PATH}\/dmsetup\", ENV{DM_SBIN_PATH}=\"\/usr\/sbin\" +DM_EXEC=\$$env{DM_SBIN_PATH} +LVM_EXEC_RULE=ENV{LVM_SBIN_PATH}=\"\/sbin\"\\nTEST!=\"\$$env{LVM_SBIN_PATH}\/lvm\", ENV{LVM_SBIN_PATH}=\"\/usr\/sbin\" +LVM_EXEC=\$$env{LVM_SBIN_PATH} else - BLKID_RULE=IMPORT{program}=\"\$$env{DM_SBIN_PATH}\/blkid -o udev -p \$$tempnode\" +SBIN="@sbindir@" +DM_EXEC_RULE="" +DM_EXEC=${SBIN} +LVM_EXEC_RULE="" +LVM_EXEC=${SBIN} endif -CLEAN_TARGETS = 10-dm.rules 13-dm-disk.rules - -include $(top_builddir)/make.tmpl - -vpath %.rules $(srcdir) +ifeq ("@UDEV_HAS_BUILTIN_BLKID@", "yes") +BLKID_RULE=IMPORT{builtin}=\"blkid\" +else +BLKID_RULE=IMPORT{program}=\"${SBIN}\/blkid -o udev -p \$$tempnode\" +endif %.rules: %.rules.in - $(SED) -e "s/(DM_DIR)/$(DM_DIR)/" -e "s/(BLKID_RULE)/$(BLKID_RULE)/" $< >$@ + $(SED) -e "s+(DM_DIR)+$(DM_DIR)+;s+(BLKID_RULE)+$(BLKID_RULE)+;s+(DM_EXEC_RULE)+$(DM_EXEC_RULE)+;s+(DM_EXEC)+$(DM_EXEC)+;s+(LVM_EXEC_RULE)+$(LVM_EXEC_RULE)+;s+(LVM_EXEC)+$(LVM_EXEC)+;" $< >$@ %_install: %.rules $(INSTALL_DATA) -D $< $(udevdir)/$(<F) |