]> sourceware.org Git - lvm2.git/commitdiff
udev: udev rules cleanup
authorPeter Rajnoha <prajnoha@redhat.com>
Fri, 22 Jun 2012 09:50:02 +0000 (05:50 -0400)
committerPeter Rajnoha <prajnoha@redhat.com>
Wed, 27 Jun 2012 10:11:56 +0000 (12:11 +0200)
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!

WHATS_NEW_DM
configure.in
udev/10-dm.rules.in
udev/11-dm-lvm.rules.in [moved from udev/11-dm-lvm.rules with 91% similarity]
udev/69-dm-lvm-metad.rules.in [moved from udev/69-dm-lvm-metad.rules with 75% similarity]
udev/95-dm-notify.rules.in [moved from udev/95-dm-notify.rules with 82% similarity]
udev/Makefile.in

index f6596c12f760f5469d11fd47239a874f4187fed7..711104bb3906d1fa6674d485698bf7ebaeb97305 100644 (file)
@@ -1,5 +1,7 @@
 Version 1.02.76 - 
 ===============================
+  Add configure --enable-udev-rule-exec-detection to detect exec path in rules.
+  Use sbindir in udev rules by default and remove executable path detection.
   Remove hard-coded paths for dmeventd fifos and use default-dm-run-dir.
   Add configure --with-lvmetad-pidfile to remove hard-coded value.
   Add configure --with-default-pid-dir for common directory with pid files.
index 814c0bdb4f496debf45d7309629b51f54a4b4fa3..6c273245fbbdde62213b73657ac685442e651897 100644 (file)
@@ -934,16 +934,22 @@ AC_ARG_ENABLE(udev_rules,
              UDEV_RULES=$enableval, UDEV_RULES=$UDEV_SYNC)
 AC_MSG_RESULT($UDEV_RULES)
 
-if test x$UDEV_RULES = xyes; then
-       AC_MSG_CHECKING(whether udev supports builtin blkid)
-       udev_version=$(udevadm info --version 2>/dev/null)
-       if test -n "$udev_version" && test "$udev_version" -ge 176; then
-               UDEV_HAS_BUILTIN_BLKID=yes
-       else
-               UDEV_HAS_BUILTIN_BLKID=no
-       fi
-       AC_MSG_RESULT($UDEV_HAS_BUILTIN_BLKID)
+AC_MSG_CHECKING(whether to enable executable path detection in udev rules)
+AC_ARG_ENABLE(udev_rule_exec_detection,
+             AC_HELP_STRING([--enable-udev-rule-exec-detection],
+                            [enable executable path detection in udev rules]),
+             UDEV_RULE_EXEC_DETECTION=$enableval, UDEV_RULE_EXEC_DETECTION=no)
+AC_MSG_RESULT($UDEV_RULE_EXEC_DETECTION)
+
+dnl -- Check support for built-in blkid against target udev version
+AC_MSG_CHECKING(whether udev supports built-in blkid)
+test x$PKGCONFIG_INIT != x1 && pkg_config_init
+if $($PKG_CONFIG --atleast-version=176 libudev); then
+       UDEV_HAS_BUILTIN_BLKID=yes
+else
+       UDEV_HAS_BUILTIN_BLKID=no
 fi
+AC_MSG_RESULT($UDEV_HAS_BUILTIN_BLKID)
 
 ################################################################################
 dnl -- Compatibility mode
@@ -1528,6 +1534,7 @@ AC_SUBST(UDEV_LIBS)
 AC_SUBST(UDEV_PC)
 AC_SUBST(UDEV_RULES)
 AC_SUBST(UDEV_SYNC)
+AC_SUBST(UDEV_RULE_EXEC_DETECTION)
 AC_SUBST(UDEV_HAS_BUILTIN_BLKID)
 AC_SUBST(CUNIT_LIBS)
 AC_SUBST(CUNIT_CFLAGS)
index 605e0887052c972ae35a9243204893a2245ea369..29af467bf93df37b54a6b796ca5415f4931ab66d 100644 (file)
@@ -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
similarity index 91%
rename from udev/11-dm-lvm.rules
rename to udev/11-dm-lvm.rules.in
index 82444648915d3719eb730945dd91376da4721f59..58ef210631dc09eb5c704d58ad18ef899d23ac46 100644 (file)
@@ -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"
 
similarity index 75%
rename from udev/69-dm-lvm-metad.rules
rename to udev/69-dm-lvm-metad.rules.in
index d272e6e229f9a66601ae877e98b336aee27ef3ca..26309deba457bd403bdc02baf70ebd42bb6f8030 100644 (file)
 # 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"
similarity index 82%
rename from udev/95-dm-notify.rules
rename to udev/95-dm-notify.rules.in
index 72cc609d866e5bcf112e3958932c689c1f45e471..80d59d37d3f27373efaf385b15664478c3f647fc 100644 (file)
@@ -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}"
index 4ace9108e6acedeb9a05bc27a76ae3d30a911ae0..5c15bdb64812bc39ca666ec8c016f9e5f27c4b7d 100644 (file)
@@ -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)
This page took 0.043272 seconds and 5 git commands to generate.