From 1d82906dea5eb698a854d992e445e794fb5a0880 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 24 Mar 2011 11:34:41 -0700 Subject: [PATCH] Set cmd paths in udev rules using --prefix The udev/rules.d scripts must use absolute paths to their support binaries. However, where those binaries get installed depends on what --prefix was set to when the package was configured. This change makes the udev/rules.d helpers to *.in files which are processed by configure. This allows them to be dynamically updated to include the specified --prefix. Additionally, this change updates 60-zvol.rules to handle both the 'add' and 'change' actions. This ensures that that all valid zvol devices are correctly linked. --- configure | 4 +- configure.ac | 2 + etc/udev/rules.d/.gitignore | 2 + .../{60-zpool.rules => 60-zpool.rules.in} | 2 +- .../{60-zvol.rules => 60-zvol.rules.in} | 2 +- etc/udev/rules.d/Makefile.am | 5 ++- etc/udev/rules.d/Makefile.in | 37 ++++++++++++------- 7 files changed, 36 insertions(+), 18 deletions(-) create mode 100644 etc/udev/rules.d/.gitignore rename etc/udev/rules.d/{60-zpool.rules => 60-zpool.rules.in} (77%) rename etc/udev/rules.d/{60-zvol.rules => 60-zvol.rules.in} (53%) diff --git a/configure b/configure index e4619702d9..88155541bf 100755 --- a/configure +++ b/configure @@ -20008,7 +20008,7 @@ fi $as_echo "$enable_debug" >&6; } -ac_config_files="$ac_config_files Makefile dracut/Makefile dracut/90zfs/Makefile etc/Makefile etc/udev/Makefile etc/udev/rules.d/Makefile etc/init.d/Makefile etc/zfs/Makefile man/Makefile man/man8/Makefile lib/Makefile lib/libspl/Makefile lib/libspl/asm-generic/Makefile lib/libspl/asm-i386/Makefile lib/libspl/asm-x86_64/Makefile lib/libspl/include/Makefile lib/libspl/include/ia32/Makefile lib/libspl/include/ia32/sys/Makefile lib/libspl/include/rpc/Makefile lib/libspl/include/sys/Makefile lib/libspl/include/sys/sysevent/Makefile lib/libspl/include/sys/dktp/Makefile lib/libspl/include/util/Makefile lib/libavl/Makefile lib/libefi/Makefile lib/libnvpair/Makefile lib/libunicode/Makefile lib/libuutil/Makefile lib/libzpool/Makefile lib/libzfs/Makefile cmd/Makefile cmd/zdb/Makefile cmd/zfs/Makefile cmd/zinject/Makefile cmd/zpool/Makefile cmd/ztest/Makefile cmd/zpios/Makefile cmd/mount_zfs/Makefile cmd/zpool_layout/Makefile cmd/zvol_id/Makefile cmd/zpool_id/Makefile module/Makefile module/avl/Makefile module/nvpair/Makefile module/unicode/Makefile module/zcommon/Makefile module/zfs/Makefile module/zpios/Makefile include/Makefile include/linux/Makefile include/sys/Makefile include/sys/fs/Makefile include/sys/fm/Makefile include/sys/fm/fs/Makefile scripts/Makefile scripts/zpios-profile/Makefile scripts/zpios-test/Makefile scripts/zpool-config/Makefile scripts/zpool-layout/Makefile scripts/common.sh zfs.spec zfs-modules.spec zfs-script-config.sh" +ac_config_files="$ac_config_files Makefile dracut/Makefile dracut/90zfs/Makefile etc/Makefile etc/udev/Makefile etc/udev/rules.d/Makefile etc/udev/rules.d/60-zpool.rules etc/udev/rules.d/60-zvol.rules etc/init.d/Makefile etc/zfs/Makefile man/Makefile man/man8/Makefile lib/Makefile lib/libspl/Makefile lib/libspl/asm-generic/Makefile lib/libspl/asm-i386/Makefile lib/libspl/asm-x86_64/Makefile lib/libspl/include/Makefile lib/libspl/include/ia32/Makefile lib/libspl/include/ia32/sys/Makefile lib/libspl/include/rpc/Makefile lib/libspl/include/sys/Makefile lib/libspl/include/sys/sysevent/Makefile lib/libspl/include/sys/dktp/Makefile lib/libspl/include/util/Makefile lib/libavl/Makefile lib/libefi/Makefile lib/libnvpair/Makefile lib/libunicode/Makefile lib/libuutil/Makefile lib/libzpool/Makefile lib/libzfs/Makefile cmd/Makefile cmd/zdb/Makefile cmd/zfs/Makefile cmd/zinject/Makefile cmd/zpool/Makefile cmd/ztest/Makefile cmd/zpios/Makefile cmd/mount_zfs/Makefile cmd/zpool_layout/Makefile cmd/zvol_id/Makefile cmd/zpool_id/Makefile module/Makefile module/avl/Makefile module/nvpair/Makefile module/unicode/Makefile module/zcommon/Makefile module/zfs/Makefile module/zpios/Makefile include/Makefile include/linux/Makefile include/sys/Makefile include/sys/fs/Makefile include/sys/fm/Makefile include/sys/fm/fs/Makefile scripts/Makefile scripts/zpios-profile/Makefile scripts/zpios-test/Makefile scripts/zpool-config/Makefile scripts/zpool-layout/Makefile scripts/common.sh zfs.spec zfs-modules.spec zfs-script-config.sh" cat >confcache <<\_ACEOF @@ -20930,6 +20930,8 @@ do "etc/Makefile") CONFIG_FILES="$CONFIG_FILES etc/Makefile" ;; "etc/udev/Makefile") CONFIG_FILES="$CONFIG_FILES etc/udev/Makefile" ;; "etc/udev/rules.d/Makefile") CONFIG_FILES="$CONFIG_FILES etc/udev/rules.d/Makefile" ;; + "etc/udev/rules.d/60-zpool.rules") CONFIG_FILES="$CONFIG_FILES etc/udev/rules.d/60-zpool.rules" ;; + "etc/udev/rules.d/60-zvol.rules") CONFIG_FILES="$CONFIG_FILES etc/udev/rules.d/60-zvol.rules" ;; "etc/init.d/Makefile") CONFIG_FILES="$CONFIG_FILES etc/init.d/Makefile" ;; "etc/zfs/Makefile") CONFIG_FILES="$CONFIG_FILES etc/zfs/Makefile" ;; "man/Makefile") CONFIG_FILES="$CONFIG_FILES man/Makefile" ;; diff --git a/configure.ac b/configure.ac index a188fa7979..b578341b65 100644 --- a/configure.ac +++ b/configure.ac @@ -60,6 +60,8 @@ AC_CONFIG_FILES([ etc/Makefile etc/udev/Makefile etc/udev/rules.d/Makefile + etc/udev/rules.d/60-zpool.rules + etc/udev/rules.d/60-zvol.rules etc/init.d/Makefile etc/zfs/Makefile man/Makefile diff --git a/etc/udev/rules.d/.gitignore b/etc/udev/rules.d/.gitignore new file mode 100644 index 0000000000..e56d65ef8e --- /dev/null +++ b/etc/udev/rules.d/.gitignore @@ -0,0 +1,2 @@ +60-zpool.rules +60-zvol.rules diff --git a/etc/udev/rules.d/60-zpool.rules b/etc/udev/rules.d/60-zpool.rules.in similarity index 77% rename from etc/udev/rules.d/60-zpool.rules rename to etc/udev/rules.d/60-zpool.rules.in index 0f4a356dd6..f06be6a218 100644 --- a/etc/udev/rules.d/60-zpool.rules +++ b/etc/udev/rules.d/60-zpool.rules.in @@ -2,7 +2,7 @@ # /etc/udev/rules.d/99-zpool.rules # -ENV{DEVTYPE}=="disk", IMPORT{program}="/usr/bin/zpool_id -d %p" +ENV{DEVTYPE}=="disk", IMPORT{program}="@prefix@/bin/zpool_id -d %p" KERNEL=="*[!0-9]", ENV{SUBSYSTEM}=="block", ENV{ID_ZPOOL}=="?*", SYMLINK+="$env{ID_ZPOOL_PATH}" KERNEL=="*[0-9]", ENV{SUBSYSTEM}=="block", ENV{ID_ZPOOL}=="?*", SYMLINK+="$env{ID_ZPOOL_PATH}-part%n" diff --git a/etc/udev/rules.d/60-zvol.rules b/etc/udev/rules.d/60-zvol.rules.in similarity index 53% rename from etc/udev/rules.d/60-zvol.rules rename to etc/udev/rules.d/60-zvol.rules.in index 803d4260d2..860e74b218 100644 --- a/etc/udev/rules.d/60-zvol.rules +++ b/etc/udev/rules.d/60-zvol.rules.in @@ -3,4 +3,4 @@ # persistent disk links: /dev/zvol/dataset_name # also creates compatibilty symlink of /dev/dataset_name -KERNEL=="zd*" SUBSYSTEM=="block" ACTION=="add" PROGRAM="/usr/bin/zvol_id $tempnode" SYMLINK+="zvol/%c %c" +KERNEL=="zd*" SUBSYSTEM=="block" ACTION=="add|change" PROGRAM="@prefix@/bin/zvol_id $tempnode" SYMLINK+="zvol/%c %c" diff --git a/etc/udev/rules.d/Makefile.am b/etc/udev/rules.d/Makefile.am index 04536007a5..1a7a1e3924 100644 --- a/etc/udev/rules.d/Makefile.am +++ b/etc/udev/rules.d/Makefile.am @@ -4,4 +4,7 @@ pkgsysconf_DATA = \ 60-zpool.rules \ 60-zvol.rules -EXTRA_DIST = $(pkgsysconf_DATA) +EXTRA_DIST = 60-zpool.rules.in 60-zvol.rules.in + +distclean-local:: + -$(RM) $(pkgsysconf_DATA) diff --git a/etc/udev/rules.d/Makefile.in b/etc/udev/rules.d/Makefile.in index 5cc5b350ac..9937d06a37 100644 --- a/etc/udev/rules.d/Makefile.in +++ b/etc/udev/rules.d/Makefile.in @@ -36,7 +36,8 @@ build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = etc/udev/rules.d -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +DIST_COMMON = $(srcdir)/60-zpool.rules.in $(srcdir)/60-zvol.rules.in \ + $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-bdev-block-device-operations.m4 \ @@ -56,6 +57,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-fmode-t.m4 \ $(top_srcdir)/config/kernel-fsync.m4 \ $(top_srcdir)/config/kernel-get-disk-ro.m4 \ + $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ @@ -77,7 +79,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/zfs_config.h -CONFIG_CLEAN_FILES = +CONFIG_CLEAN_FILES = 60-zpool.rules 60-zvol.rules CONFIG_CLEAN_VPATH_FILES = AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) @@ -282,7 +284,7 @@ pkgsysconf_DATA = \ 60-zpool.rules \ 60-zvol.rules -EXTRA_DIST = $(pkgsysconf_DATA) +EXTRA_DIST = 60-zpool.rules.in 60-zvol.rules.in all: all-am .SUFFIXES: @@ -316,6 +318,10 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): +60-zpool.rules: $(top_builddir)/config.status $(srcdir)/60-zpool.rules.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +60-zvol.rules: $(top_builddir)/config.status $(srcdir)/60-zvol.rules.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ mostlyclean-libtool: -rm -f *.lo @@ -417,7 +423,7 @@ clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -f Makefile -distclean-am: clean-am distclean-generic +distclean-am: clean-am distclean-generic distclean-local dvi: dvi-am @@ -480,18 +486,21 @@ uninstall-am: uninstall-pkgsysconfDATA .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic clean-libtool \ - distclean distclean-generic distclean-libtool distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-pdf \ - install-pdf-am install-pkgsysconfDATA install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - uninstall uninstall-am uninstall-pkgsysconfDATA + distclean distclean-generic distclean-libtool distclean-local \ + distdir dvi dvi-am html html-am info info-am install \ + install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-pkgsysconfDATA install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ + ps ps-am uninstall uninstall-am uninstall-pkgsysconfDATA +distclean-local:: + -$(RM) $(pkgsysconf_DATA) + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: