Skip to content

Commit

Permalink
Move udev rules from /etc/udev to /lib/udev
Browse files Browse the repository at this point in the history
This change moves the default install location for the zfs udev
rules from /etc/udev/ to /lib/udev/.  The correct convention is
for rules provided by a package to be installed in /lib/udev/.
The /etc/udev/ directory is reserved for custom rules or local
overrides.

Additionally, this patch cleans up some abuse of the bindir install
location by adding a udevdir and udevruledir install directories.
This allows us to revert to the default bin install location.  The
udev install directories can be set with the following new options.

  --with-udevdir=DIR      install udev helpers [EPREFIX/lib/udev]
  --with-udevruledir=DIR  install udev rules [UDEVDIR/rules.d]

Signed-off-by: Brian Behlendorf <[email protected]>
Closes #356
  • Loading branch information
kylef authored and behlendorf committed Aug 8, 2011
1 parent f3ab88d commit 12d06ba
Show file tree
Hide file tree
Showing 18 changed files with 45 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include $(top_srcdir)/config/deb.am
include $(top_srcdir)/config/tgz.am

if CONFIG_USER
USER_DIR = dracut etc man scripts lib cmd
USER_DIR = dracut udev etc man scripts lib cmd
endif
if CONFIG_KERNEL
KERNEL_DIR = module
Expand Down
2 changes: 1 addition & 1 deletion cmd/sas_switch_id/Makefile.am
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dist_bin_SCRIPTS = sas_switch_id
dist_udev_SCRIPTS = sas_switch_id
2 changes: 1 addition & 1 deletion cmd/zpool_id/Makefile.am
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dist_bin_SCRIPTS = zpool_id
dist_udev_SCRIPTS = zpool_id
2 changes: 1 addition & 1 deletion cmd/zvol_id/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ DEFAULT_INCLUDES += \
-I$(top_srcdir)/include \
-I$(top_srcdir)/lib/libspl/include

bin_PROGRAMS = zvol_id
udev_PROGRAMS = zvol_id

zvol_id_SOURCES = \
$(top_srcdir)/cmd/zvol_id/zvol_id_main.c
14 changes: 14 additions & 0 deletions config/user-udev.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
AC_DEFUN([ZFS_AC_CONFIG_USER_UDEV], [
AC_ARG_WITH(udevdir,
AC_HELP_STRING([--with-udevdir=DIR],
[install udev helpers [[EPREFIX/lib/udev]]]),
udevdir=$withval, udevdir='${exec_prefix}/lib/udev')
AC_ARG_WITH(udevruledir,
AC_HELP_STRING([--with-udevruledir=DIR],
[install udev rules [[UDEVDIR/rules.d]]]),
udevruledir=$withval, udevruledir='${udevdir}/rules.d')
AC_SUBST(udevdir)
AC_SUBST(udevruledir)
])
1 change: 1 addition & 0 deletions config/user.m4
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ dnl #
dnl # Default ZFS user configuration
dnl #
AC_DEFUN([ZFS_AC_CONFIG_USER], [
ZFS_AC_CONFIG_USER_UDEV
ZFS_AC_CONFIG_USER_ARCH
ZFS_AC_CONFIG_USER_IOCTL
ZFS_AC_CONFIG_USER_ZLIB
Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ AC_CONFIG_FILES([
Makefile
dracut/Makefile
dracut/90zfs/Makefile
udev/Makefile
udev/rules.d/Makefile
etc/Makefile
etc/udev/Makefile
etc/udev/rules.d/Makefile
etc/init.d/Makefile
etc/init.d/zfs.arch
etc/init.d/zfs.gentoo
Expand Down
4 changes: 2 additions & 2 deletions dracut/90zfs/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ installkernel() {

install() {
inst_rules "$moddir/90-zfs.rules"
inst_rules /etc/udev/rules.d/60-zpool.rules
inst_rules /etc/udev/rules.d/60-zvol.rules
inst_rules /lib/udev/rules.d/60-zpool.rules
inst_rules /lib/udev/rules.d/60-zvol.rules
inst /etc/zfs/zdev.conf
inst /etc/zfs/zpool.cache
inst /etc/hostid
Expand Down
2 changes: 1 addition & 1 deletion etc/Makefile.am
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SUBDIRS = init.d udev zfs
SUBDIRS = init.d zfs
15 changes: 0 additions & 15 deletions etc/udev/rules.d/Makefile.am

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# /etc/udev/rules.d/60-zpool.rules
# /lib/udev/rules.d/60-zpool.rules
#

ENV{DEVTYPE}=="disk", IMPORT{program}="@bindir@/zpool_id -d %p"
ENV{DEVTYPE}=="disk", IMPORT{program}="@udevdir@/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{DEVTYPE}=="partition", ENV{ID_ZPOOL}=="?*", SYMLINK+="$env{ID_ZPOOL_PATH}-part%n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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|change" PROGRAM="@bindir@/zvol_id $tempnode" SYMLINK+="zvol/%c %c"
KERNEL=="zd*" SUBSYSTEM=="block" ACTION=="add|change" PROGRAM="@udevdir@/zvol_id $tempnode" SYMLINK+="zvol/%c %c"
14 changes: 14 additions & 0 deletions udev/rules.d/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
udevrule_DATA = \
60-zpool.rules \
60-zvol.rules

EXTRA_DIST = \
60-zpool.rules.in \
60-zvol.rules.in

$(udevrule_DATA):
-$(SED) -e 's,@udevdir\@,$(udevdir),g' '[email protected]' >'$@'

distclean-local::
-$(RM) $(udevrule_DATA)

File renamed without changes.
7 changes: 4 additions & 3 deletions zfs.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
%define release @ZFS_META_RELEASE@
%define debug_package %{nil}
%define _prefix /
%define _bindir /lib/udev
%define _libexecdir /usr/libexec
%define _datadir /usr/share
%define _udevdir /lib/udev

Summary: ZFS Library and Utils
Group: Utilities/System
Expand Down Expand Up @@ -61,7 +61,7 @@ which are ZFS aware.
%prep
%setup
%build
%configure --with-config=user --without-blkid
%configure --with-config=user --without-blkid --with-udevdir=%{_udevdir}
make

%install
Expand All @@ -80,8 +80,9 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/*
%{_mandir}/man8/*
%{_sysconfdir}/init.d/*
%{_sysconfdir}/udev/rules.d/*
%{_sysconfdir}/zfs/*
%{_udevdir}/*
%{_udevdir}/rules.d/*

%files devel
%defattr(-,root,root)
Expand Down

3 comments on commit 12d06ba

@hobbes1069
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should --with-udevdir default to EPREFIX/lib/udev?

I'm a Fedora packager so EPREFIX may make sense for other distros, but on Fedora the guideline is the packages install to /usr/{bin,lib{,64},share}... etc. But the udev rules do not go into /usr/lib/udev but /lib/udev as you mention.

@behlendorf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this behavior was modeled after what the lvm2 packages do. Now I'm not a packaging guru (for any distro) so I'm not 100% sure if that's right or wrong but that's the history.

@hobbes1069
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was easy enough to override manually, just thought I'd mention it.

Please sign in to comment.