diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2008-07-18 15:56:03 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2008-07-18 15:56:03 +0200 |
commit | 282988c4f8a85c28468e6442e86efe51dc71cc93 (patch) | |
tree | fda0a6ba62adffd8f7c4762b9694ab77e4ea563f | |
parent | 41dd741442ab496901c38f6cd38404bd954f1857 (diff) |
move default rules from /etc/udev/rules.d/ to /lib/udev/rules.d/
None of these rules is supposed to be changed by users, so move
them out of /etc. Custom rules, and automatically generated rules
stay in /etc. All rules are still processed in lexical order,
regardless which directory they live in.
-rw-r--r-- | Makefile | 11 | ||||
-rw-r--r-- | extras/cdrom_id/Makefile | 6 | ||||
-rw-r--r-- | extras/edd_id/Makefile | 6 | ||||
-rw-r--r-- | extras/fstab_import/Makefile | 4 | ||||
-rw-r--r-- | extras/rule_generator/Makefile | 6 | ||||
-rw-r--r-- | rules/debian/50-udev.rules (renamed from etc/udev/debian/50-udev.rules) | 0 | ||||
-rw-r--r-- | rules/debian/60-persistent-input.rules (renamed from etc/udev/debian/60-persistent-input.rules) | 0 | ||||
-rw-r--r-- | rules/debian/60-persistent-storage-tape.rules (renamed from etc/udev/debian/60-persistent-storage-tape.rules) | 0 | ||||
-rw-r--r-- | rules/debian/60-persistent-storage.rules (renamed from etc/udev/debian/60-persistent-storage.rules) | 0 | ||||
-rw-r--r-- | rules/debian/60-persistent-v4l.rules (renamed from etc/udev/debian/60-persistent-v4l.rules) | 0 | ||||
-rw-r--r-- | rules/debian/75-cd-aliases-generator.rules (renamed from etc/udev/debian/75-cd-aliases-generator.rules) | 0 | ||||
-rw-r--r-- | rules/debian/75-persistent-net-generator.rules (renamed from etc/udev/debian/75-persistent-net-generator.rules) | 0 | ||||
-rw-r--r-- | rules/debian/80-drivers.rules (renamed from etc/udev/debian/80-drivers.rules) | 0 | ||||
-rw-r--r-- | rules/debian/91-permissions.rules (renamed from etc/udev/debian/91-permissions.rules) | 0 | ||||
-rw-r--r-- | rules/debian/95-late.rules (renamed from etc/udev/debian/95-late.rules) | 0 | ||||
-rw-r--r-- | rules/frugalware/50-udev-default.rules (renamed from etc/udev/frugalware/50-udev-default.rules) | 0 | ||||
-rw-r--r-- | rules/frugalware/64-device-mapper.rules (renamed from etc/udev/frugalware/64-device-mapper.rules) | 0 | ||||
-rw-r--r-- | rules/gentoo/30-kernel-compat.rules (renamed from etc/udev/gentoo/30-kernel-compat.rules) | 0 | ||||
-rw-r--r-- | rules/gentoo/40-gentoo.rules (renamed from etc/udev/gentoo/40-gentoo.rules) | 0 | ||||
-rw-r--r-- | rules/gentoo/40-video.rules (renamed from etc/udev/gentoo/40-video.rules) | 0 | ||||
-rw-r--r-- | rules/gentoo/65-permissions.rules (renamed from etc/udev/gentoo/65-permissions.rules) | 0 | ||||
-rw-r--r-- | rules/gentoo/90-network.rules (renamed from etc/udev/gentoo/90-network.rules) | 0 | ||||
-rw-r--r-- | rules/packages/40-alsa.rules (renamed from etc/udev/packages/40-alsa.rules) | 0 | ||||
-rw-r--r-- | rules/packages/40-ia64.rules (renamed from etc/udev/packages/40-ia64.rules) | 0 | ||||
-rw-r--r-- | rules/packages/40-pilot-links.rules (renamed from etc/udev/packages/40-pilot-links.rules) | 0 | ||||
-rw-r--r-- | rules/packages/40-ppc.rules (renamed from etc/udev/packages/40-ppc.rules) | 0 | ||||
-rw-r--r-- | rules/packages/40-s390.rules (renamed from etc/udev/packages/40-s390.rules) | 0 | ||||
-rw-r--r-- | rules/packages/40-zaptel.rules (renamed from etc/udev/packages/40-zaptel.rules) | 0 | ||||
-rw-r--r-- | rules/packages/64-device-mapper.rules (renamed from etc/udev/packages/64-device-mapper.rules) | 0 | ||||
-rw-r--r-- | rules/packages/64-md-raid.rules (renamed from etc/udev/packages/64-md-raid.rules) | 0 | ||||
-rw-r--r-- | rules/redhat/40-redhat.rules (renamed from etc/udev/redhat/40-redhat.rules) | 0 | ||||
-rw-r--r-- | rules/redhat/95-pam-console.rules (renamed from etc/udev/redhat/95-pam-console.rules) | 0 | ||||
-rw-r--r-- | rules/rules.d/50-udev-default.rules (renamed from etc/udev/rules.d/50-udev-default.rules) | 0 | ||||
-rw-r--r-- | rules/rules.d/60-persistent-input.rules (renamed from etc/udev/rules.d/60-persistent-input.rules) | 0 | ||||
-rw-r--r-- | rules/rules.d/60-persistent-storage-tape.rules (renamed from etc/udev/rules.d/60-persistent-storage-tape.rules) | 0 | ||||
-rw-r--r-- | rules/rules.d/60-persistent-storage.rules (renamed from etc/udev/rules.d/60-persistent-storage.rules) | 0 | ||||
-rw-r--r-- | rules/rules.d/60-persistent-v4l.rules (renamed from etc/udev/rules.d/60-persistent-v4l.rules) | 0 | ||||
-rw-r--r-- | rules/rules.d/80-drivers.rules (renamed from etc/udev/rules.d/80-drivers.rules) | 0 | ||||
-rw-r--r-- | rules/rules.d/95-udev-late.rules (renamed from etc/udev/rules.d/95-udev-late.rules) | 0 | ||||
-rw-r--r-- | rules/slackware/udev.rules (renamed from etc/udev/slackware/udev.rules) | 0 | ||||
-rw-r--r-- | rules/suse/40-suse.rules (renamed from etc/udev/suse/40-suse.rules) | 0 | ||||
-rw-r--r-- | rules/suse/64-device-mapper.rules (renamed from etc/udev/suse/64-device-mapper.rules) | 0 | ||||
-rwxr-xr-x | test/udev-test.pl | 6 | ||||
-rw-r--r-- | udev.7 | 21 | ||||
-rw-r--r-- | udev.conf (renamed from etc/udev/udev.conf) | 3 | ||||
-rw-r--r-- | udev.h | 3 | ||||
-rw-r--r-- | udev.xml | 23 | ||||
-rw-r--r-- | udev_config.c | 6 | ||||
-rw-r--r-- | udev_rules_parse.c | 68 | ||||
-rw-r--r-- | udevd.c | 25 |
50 files changed, 91 insertions, 97 deletions
@@ -190,9 +190,7 @@ udev_version.h: $(E) " GENHDR " $@ $(Q) echo "/* Generated by make. */" > $@ $(Q) echo \#define UDEV_VERSION \"$(VERSION)\" >> $@ - $(Q) echo \#define UDEV_ROOT \"$(udevdir)\" >> $@ $(Q) echo \#define UDEV_CONFIG_FILE \"$(configdir)/udev.conf\" >> $@ - $(Q) echo \#define UDEV_RULES_DIR \"$(configdir)/rules.d\" >> $@ # man pages %.8 %.7: %.xml @@ -220,15 +218,12 @@ clean: .PHONY: clean install-config: + $(INSTALL) -d $(DESTDIR)$(libudevdir)/rules.d $(INSTALL) -d $(DESTDIR)$(configdir)/rules.d @ if [ ! -r $(DESTDIR)$(configdir)/udev.conf ]; then \ - $(INSTALL_DATA) etc/udev/udev.conf $(DESTDIR)$(configdir); \ + $(INSTALL_DATA) udev.conf $(DESTDIR)$(configdir); \ fi - @ for i in etc/udev/rules.d/*.rules; do \ - if [ ! -r $(DESTDIR)$(configdir)/rules.d/$$(basename $$i) ]; then \ - $(INSTALL_DATA) $$i $(DESTDIR)$(configdir)/rules.d; \ - fi \ - done + cp rules/rules.d/* $(DESTDIR)$(libudevdir)/rules.d @ extras="$(EXTRAS)"; for target in $$extras; do \ $(MAKE) -C $$target $@ || exit 1; \ done; diff --git a/extras/cdrom_id/Makefile b/extras/cdrom_id/Makefile index caab2beaf5..ec03d1fce2 100644 --- a/extras/cdrom_id/Makefile +++ b/extras/cdrom_id/Makefile @@ -51,13 +51,13 @@ clean: install-bin: all $(INSTALL) -d $(DESTDIR)$(libudevdir) $(INSTALL_PROGRAM) $(PROG) $(DESTDIR)$(libudevdir)/$(PROG) - $(INSTALL) -d $(DESTDIR)$(configdir)/rules.d - $(INSTALL_DATA) 60-cdrom_id.rules $(DESTDIR)$(configdir)/rules.d/60-cdrom_id.rules + $(INSTALL) -d $(DESTDIR)$(libudevdir)/rules.d + $(INSTALL_DATA) 60-cdrom_id.rules $(DESTDIR)$(libudevdir)/rules.d/60-cdrom_id.rules .PHONY: install-bin uninstall-bin: - rm $(DESTDIR)$(libudevdir)/$(PROG) - - rm $(DESTDIR)$(configdir)/rules.d/60-cdrom_id.rules + - rm $(DESTDIR)$(libudevdir)/rules.d/60-cdrom_id.rules .PHONY: uninstall-bin install-man: diff --git a/extras/edd_id/Makefile b/extras/edd_id/Makefile index f17a5b8c65..0126b859ee 100644 --- a/extras/edd_id/Makefile +++ b/extras/edd_id/Makefile @@ -51,13 +51,13 @@ clean: install-bin: all $(INSTALL) -d $(DESTDIR)$(libudevdir) $(INSTALL_PROGRAM) $(PROG) $(DESTDIR)$(libudevdir)/$(PROG) - $(INSTALL) -d $(DESTDIR)$(configdir)/rules.d/ - $(INSTALL_DATA) 61-persistent-storage-edd.rules $(DESTDIR)$(configdir)/rules.d/61-persistent-storage-edd.rules + $(INSTALL) -d $(DESTDIR)$(libudevdir)/rules.d/ + $(INSTALL_DATA) 61-persistent-storage-edd.rules $(DESTDIR)$(libudevdir)/rules.d/61-persistent-storage-edd.rules .PHONY: install-bin uninstall-bin: - rm $(DESTDIR)$(libudevdir)/$(PROG) - - rm $(DESTDIR)$(configdir)/rules.d/61-persistent-storage-edd.rules + - rm $(DESTDIR)$(libudevdir)/rules.d/61-persistent-storage-edd.rules .PHONY: uninstall-bin install-man: diff --git a/extras/fstab_import/Makefile b/extras/fstab_import/Makefile index 23448f3217..3f65aa3f64 100644 --- a/extras/fstab_import/Makefile +++ b/extras/fstab_import/Makefile @@ -50,12 +50,12 @@ clean: install-bin: all $(INSTALL_PROGRAM) -D $(PROG) $(DESTDIR)$(libudevdir)/$(PROG) - $(INSTALL_DATA) 79-fstab_import.rules $(DESTDIR)$(configdir)/rules.d/79-fstab_import.rules + $(INSTALL_DATA) 79-fstab_import.rules $(DESTDIR)$(libudevdir)/rules.d/79-fstab_import.rules .PHONY: install-bin uninstall-bin: - rm $(DESTDIR)$(libudevdir)/$(PROG) - - rm $(DESTDIR)$(configdir)/rules.d/79-fstab_import.rules + - rm $(DESTDIR)$(libudevdir)/rules.d/79-fstab_import.rules .PHONY: uninstall-bin install-man: diff --git a/extras/rule_generator/Makefile b/extras/rule_generator/Makefile index d6f1265eb9..e236ca77f0 100644 --- a/extras/rule_generator/Makefile +++ b/extras/rule_generator/Makefile @@ -41,11 +41,11 @@ install-bin: all $(INSTALL_DATA) rule_generator.functions $(DESTDIR)$(libudevdir)/rule_generator.functions $(INSTALL_SCRIPT) write_cd_rules $(DESTDIR)$(libudevdir)/write_cd_rules $(INSTALL_SCRIPT) write_net_rules $(DESTDIR)$(libudevdir)/write_net_rules - $(INSTALL) -d $(DESTDIR)$(configdir)/rules.d + $(INSTALL) -d $(DESTDIR)$(libudevdir)/rules.d $(INSTALL_DATA) 75-cd-aliases-generator.rules \ - $(DESTDIR)$(configdir)/rules.d/75-cd-aliases-generator.rules + $(DESTDIR)$(libudevdir)/rules.d/75-cd-aliases-generator.rules $(INSTALL_DATA) 75-persistent-net-generator.rules \ - $(DESTDIR)$(configdir)/rules.d/75-persistent-net-generator.rules + $(DESTDIR)$(libudevdir)/rules.d/75-persistent-net-generator.rules .PHONY: install-bin uninstall-bin: diff --git a/etc/udev/debian/50-udev.rules b/rules/debian/50-udev.rules index e3a10701cf..e3a10701cf 100644 --- a/etc/udev/debian/50-udev.rules +++ b/rules/debian/50-udev.rules diff --git a/etc/udev/debian/60-persistent-input.rules b/rules/debian/60-persistent-input.rules index 8f49d250b1..8f49d250b1 100644 --- a/etc/udev/debian/60-persistent-input.rules +++ b/rules/debian/60-persistent-input.rules diff --git a/etc/udev/debian/60-persistent-storage-tape.rules b/rules/debian/60-persistent-storage-tape.rules index 94a0b816d4..94a0b816d4 100644 --- a/etc/udev/debian/60-persistent-storage-tape.rules +++ b/rules/debian/60-persistent-storage-tape.rules diff --git a/etc/udev/debian/60-persistent-storage.rules b/rules/debian/60-persistent-storage.rules index 65e7204531..65e7204531 100644 --- a/etc/udev/debian/60-persistent-storage.rules +++ b/rules/debian/60-persistent-storage.rules diff --git a/etc/udev/debian/60-persistent-v4l.rules b/rules/debian/60-persistent-v4l.rules index 5a317b6c18..5a317b6c18 100644 --- a/etc/udev/debian/60-persistent-v4l.rules +++ b/rules/debian/60-persistent-v4l.rules diff --git a/etc/udev/debian/75-cd-aliases-generator.rules b/rules/debian/75-cd-aliases-generator.rules index 6b178a0ae7..6b178a0ae7 100644 --- a/etc/udev/debian/75-cd-aliases-generator.rules +++ b/rules/debian/75-cd-aliases-generator.rules diff --git a/etc/udev/debian/75-persistent-net-generator.rules b/rules/debian/75-persistent-net-generator.rules index e8d3b888e0..e8d3b888e0 100644 --- a/etc/udev/debian/75-persistent-net-generator.rules +++ b/rules/debian/75-persistent-net-generator.rules diff --git a/etc/udev/debian/80-drivers.rules b/rules/debian/80-drivers.rules index edfcfa5394..edfcfa5394 100644 --- a/etc/udev/debian/80-drivers.rules +++ b/rules/debian/80-drivers.rules diff --git a/etc/udev/debian/91-permissions.rules b/rules/debian/91-permissions.rules index 5182a4bd28..5182a4bd28 100644 --- a/etc/udev/debian/91-permissions.rules +++ b/rules/debian/91-permissions.rules diff --git a/etc/udev/debian/95-late.rules b/rules/debian/95-late.rules index 622e019ef3..622e019ef3 100644 --- a/etc/udev/debian/95-late.rules +++ b/rules/debian/95-late.rules diff --git a/etc/udev/frugalware/50-udev-default.rules b/rules/frugalware/50-udev-default.rules index 89ffd7b442..89ffd7b442 100644 --- a/etc/udev/frugalware/50-udev-default.rules +++ b/rules/frugalware/50-udev-default.rules diff --git a/etc/udev/frugalware/64-device-mapper.rules b/rules/frugalware/64-device-mapper.rules index 3837d3f2c7..3837d3f2c7 100644 --- a/etc/udev/frugalware/64-device-mapper.rules +++ b/rules/frugalware/64-device-mapper.rules diff --git a/etc/udev/gentoo/30-kernel-compat.rules b/rules/gentoo/30-kernel-compat.rules index 1f767df8d8..1f767df8d8 100644 --- a/etc/udev/gentoo/30-kernel-compat.rules +++ b/rules/gentoo/30-kernel-compat.rules diff --git a/etc/udev/gentoo/40-gentoo.rules b/rules/gentoo/40-gentoo.rules index 99a1c66c69..99a1c66c69 100644 --- a/etc/udev/gentoo/40-gentoo.rules +++ b/rules/gentoo/40-gentoo.rules diff --git a/etc/udev/gentoo/40-video.rules b/rules/gentoo/40-video.rules index 2d5e53411c..2d5e53411c 100644 --- a/etc/udev/gentoo/40-video.rules +++ b/rules/gentoo/40-video.rules diff --git a/etc/udev/gentoo/65-permissions.rules b/rules/gentoo/65-permissions.rules index 494f19e63f..494f19e63f 100644 --- a/etc/udev/gentoo/65-permissions.rules +++ b/rules/gentoo/65-permissions.rules diff --git a/etc/udev/gentoo/90-network.rules b/rules/gentoo/90-network.rules index 50903af157..50903af157 100644 --- a/etc/udev/gentoo/90-network.rules +++ b/rules/gentoo/90-network.rules diff --git a/etc/udev/packages/40-alsa.rules b/rules/packages/40-alsa.rules index d30a1da8fc..d30a1da8fc 100644 --- a/etc/udev/packages/40-alsa.rules +++ b/rules/packages/40-alsa.rules diff --git a/etc/udev/packages/40-ia64.rules b/rules/packages/40-ia64.rules index 5846f88b1b..5846f88b1b 100644 --- a/etc/udev/packages/40-ia64.rules +++ b/rules/packages/40-ia64.rules diff --git a/etc/udev/packages/40-pilot-links.rules b/rules/packages/40-pilot-links.rules index 1242fff102..1242fff102 100644 --- a/etc/udev/packages/40-pilot-links.rules +++ b/rules/packages/40-pilot-links.rules diff --git a/etc/udev/packages/40-ppc.rules b/rules/packages/40-ppc.rules index 8b62d79e0c..8b62d79e0c 100644 --- a/etc/udev/packages/40-ppc.rules +++ b/rules/packages/40-ppc.rules diff --git a/etc/udev/packages/40-s390.rules b/rules/packages/40-s390.rules index 43035dbe60..43035dbe60 100644 --- a/etc/udev/packages/40-s390.rules +++ b/rules/packages/40-s390.rules diff --git a/etc/udev/packages/40-zaptel.rules b/rules/packages/40-zaptel.rules index 4313a9172e..4313a9172e 100644 --- a/etc/udev/packages/40-zaptel.rules +++ b/rules/packages/40-zaptel.rules diff --git a/etc/udev/packages/64-device-mapper.rules b/rules/packages/64-device-mapper.rules index 8154ef3702..8154ef3702 100644 --- a/etc/udev/packages/64-device-mapper.rules +++ b/rules/packages/64-device-mapper.rules diff --git a/etc/udev/packages/64-md-raid.rules b/rules/packages/64-md-raid.rules index d0510b3095..d0510b3095 100644 --- a/etc/udev/packages/64-md-raid.rules +++ b/rules/packages/64-md-raid.rules diff --git a/etc/udev/redhat/40-redhat.rules b/rules/redhat/40-redhat.rules index 446cc6d1d5..446cc6d1d5 100644 --- a/etc/udev/redhat/40-redhat.rules +++ b/rules/redhat/40-redhat.rules diff --git a/etc/udev/redhat/95-pam-console.rules b/rules/redhat/95-pam-console.rules index cbb2d4aaf9..cbb2d4aaf9 100644 --- a/etc/udev/redhat/95-pam-console.rules +++ b/rules/redhat/95-pam-console.rules diff --git a/etc/udev/rules.d/50-udev-default.rules b/rules/rules.d/50-udev-default.rules index 718d1899f5..718d1899f5 100644 --- a/etc/udev/rules.d/50-udev-default.rules +++ b/rules/rules.d/50-udev-default.rules diff --git a/etc/udev/rules.d/60-persistent-input.rules b/rules/rules.d/60-persistent-input.rules index 34d5ef1557..34d5ef1557 100644 --- a/etc/udev/rules.d/60-persistent-input.rules +++ b/rules/rules.d/60-persistent-input.rules diff --git a/etc/udev/rules.d/60-persistent-storage-tape.rules b/rules/rules.d/60-persistent-storage-tape.rules index d3226f1320..d3226f1320 100644 --- a/etc/udev/rules.d/60-persistent-storage-tape.rules +++ b/rules/rules.d/60-persistent-storage-tape.rules diff --git a/etc/udev/rules.d/60-persistent-storage.rules b/rules/rules.d/60-persistent-storage.rules index 5ae0c7fec9..5ae0c7fec9 100644 --- a/etc/udev/rules.d/60-persistent-storage.rules +++ b/rules/rules.d/60-persistent-storage.rules diff --git a/etc/udev/rules.d/60-persistent-v4l.rules b/rules/rules.d/60-persistent-v4l.rules index 0d673ab396..0d673ab396 100644 --- a/etc/udev/rules.d/60-persistent-v4l.rules +++ b/rules/rules.d/60-persistent-v4l.rules diff --git a/etc/udev/rules.d/80-drivers.rules b/rules/rules.d/80-drivers.rules index 881d7581bf..881d7581bf 100644 --- a/etc/udev/rules.d/80-drivers.rules +++ b/rules/rules.d/80-drivers.rules diff --git a/etc/udev/rules.d/95-udev-late.rules b/rules/rules.d/95-udev-late.rules index 7207081d46..7207081d46 100644 --- a/etc/udev/rules.d/95-udev-late.rules +++ b/rules/rules.d/95-udev-late.rules diff --git a/etc/udev/slackware/udev.rules b/rules/slackware/udev.rules index 12dac4d84d..12dac4d84d 100644 --- a/etc/udev/slackware/udev.rules +++ b/rules/slackware/udev.rules diff --git a/etc/udev/suse/40-suse.rules b/rules/suse/40-suse.rules index d07a72eced..d07a72eced 100644 --- a/etc/udev/suse/40-suse.rules +++ b/rules/suse/40-suse.rules diff --git a/etc/udev/suse/64-device-mapper.rules b/rules/suse/64-device-mapper.rules index b065aec554..b065aec554 100644 --- a/etc/udev/suse/64-device-mapper.rules +++ b/rules/suse/64-device-mapper.rules diff --git a/test/udev-test.pl b/test/udev-test.pl index 72b4aef6bc..f7f68a1416 100755 --- a/test/udev-test.pl +++ b/test/udev-test.pl @@ -23,7 +23,7 @@ use strict; my $PWD = $ENV{PWD}; my $sysfs = "sys/"; my $udev_bin = "../test-udev"; -my $udev_root = "udev-root/"; # !!! directory will be removed !!! +my $udev_root = "udev-root/"; my $udev_conf = "udev-test.conf"; my $udev_rules = "udev-test.rules"; @@ -1847,12 +1847,12 @@ if (!($<==0)) { } # prepare -make_udev_root (); +make_udev_root(); # create config file open CONF, ">$udev_conf" || die "unable to create config file: $udev_conf"; print CONF "udev_root=\"$udev_root\"\n"; -print CONF "udev_rules=\"$udev_rules\"\n"; +print CONF "udev_rules=\"$PWD\"\n"; print CONF "udev_log=\"info\"\n"; close CONF; @@ -25,8 +25,10 @@ and receives uevents directly from the kernel if a device is added or removed fr If udev receives a device event, it matches its configured rules against the available device attributes provided in sysfs to identify the device\. Rules that match may provide additional device information or specify a device node name and multiple symlink names and instruct udev to run additional programs as part of the device event handling\. .SH "CONFIGURATION" .PP -All udev configuration files are placed in -\fI/etc/udev/*\fR\. Every file consists of a set of lines of text\. All empty lines or lines beginning with \'#\' will be ignored\. +udev configuration files are placed in +\fI/etc/udev/\fR +and +\fI/lib/udev/\fR\. All empty lines, or lines beginning with \'#\' will be ignored\. .SS "Configuration file" .PP udev expects its main configuration file at @@ -38,13 +40,6 @@ Specifies where to place the device nodes in the filesystem\. The default value \fI/dev\fR\. .RE .PP -\fBudev_rules\fR -.RS 4 -The name of the udev rules file or directory to look for files with the suffix -\fI\.rules\fR\. Multiple rule files are read in lexical order\. The default value is -\fI/etc/udev/rules\.d\fR\. -.RE -.PP \fBudev_log\fR .RS 4 The logging priority\. Valid values are the numerical syslog priorities or their textual representations: @@ -55,9 +50,11 @@ and .RE .SS "Rules files" .PP -The udev rules are read from the files located in the -\fI/etc/udev/rules\.d\fR -directory or at the location specified value in the configuration file\. Every line in the rules file contains at least one key value pair\. There are two kind of keys, match and assignment keys\. If all match keys are matching against its value, the rule gets applied and the assign keys get the specified value assigned\. +The udev rules are read from the files located in the default rules directory +\fI/lib/udev/rules\.d/\fR, the custom rules directory +\fI/etc/udev/rules\.d/\fR +and the temporary rules directory +\fI/dev/\.udev/rules\.d/\fR\. All rule files are sorted and processed in lexical order, regardless in which of these directories they live\. Every line in the rules file contains at least one key value pair\. There are two kind of keys, match and assignment keys\. If all match keys are matching against its value, the rule gets applied and the assign keys get the specified value assigned\. .PP A matching rule may specify the name of the device node, add a symlink pointing to the node, or run a specified program as part of the event handling\. If no matching rule is found, the default device node name is used\. .PP diff --git a/etc/udev/udev.conf b/udev.conf index e6ef0814bf..998b4a7d18 100644 --- a/etc/udev/udev.conf +++ b/udev.conf @@ -1,7 +1,4 @@ -# udev.conf - # The initial syslog(3) priority: "err", "info", "debug" or its # numerical equivalent. For runtime debugging, the daemons internal # state can be changed with: "udevadm control --log_priority=<value>". udev_log="err" - @@ -47,9 +47,12 @@ #define READ_END 0 #define WRITE_END 1 +#define UDEV_ROOT "/dev" #define DB_DIR ".udev/db" #define DB_NAME_INDEX_DIR ".udev/names" +#define RULES_LIB_DIR "/lib/udev/rules.d" #define RULES_DYN_DIR ".udev/rules.d" +#define RULES_ETC_DIR "/etc/udev/rules.d" struct udev_rules; @@ -40,9 +40,9 @@ </refsect1> <refsect1><title>CONFIGURATION</title> - <para>All udev configuration files are placed in <filename>/etc/udev/*</filename>. - Every file consists of a set of lines of text. All empty lines or lines beginning - with '#' will be ignored.</para> + <para>udev configuration files are placed in <filename>/etc/udev/</filename> + and <filename>/lib/udev/</filename>. All empty lines, or lines beginning with + '#' will be ignored.</para> <refsect2><title>Configuration file</title> <para>udev expects its main configuration file at <filename>/etc/udev/udev.conf</filename>. @@ -58,16 +58,6 @@ </varlistentry> <varlistentry> - <term><option>udev_rules</option></term> - <listitem> - <para>The name of the udev rules file or directory to look for files - with the suffix <filename>.rules</filename>. Multiple rule files are - read in lexical order. The default value is - <filename>/etc/udev/rules.d</filename>.</para> - </listitem> - </varlistentry> - - <varlistentry> <term><option>udev_log</option></term> <listitem> <para>The logging priority. Valid values are the numerical syslog priorities @@ -80,8 +70,11 @@ <refsect2><title>Rules files</title> <para>The udev rules are read from the files located in the - <filename>/etc/udev/rules.d</filename> directory or at the location specified - value in the configuration file. Every line in the rules file contains at least + default rules directory <filename>/lib/udev/rules.d/</filename>, + the custom rules directory <filename>/etc/udev/rules.d/</filename> + and the temporary rules directory <filename>/dev/.udev/rules.d/</filename>. + All rule files are sorted and processed in lexical order, regardless + in which of these directories they live. Every line in the rules file contains at least one key value pair. There are two kind of keys, match and assignment keys. If all match keys are matching against its value, the rule gets applied and the assign keys get the specified value assigned.</para> diff --git a/udev_config.c b/udev_config.c index 42190945fc..55f0361dd2 100644 --- a/udev_config.c +++ b/udev_config.c @@ -164,9 +164,9 @@ void udev_config_init(void) { const char *env; - strcpy(udev_root, UDEV_ROOT); strcpy(udev_config_filename, UDEV_CONFIG_FILE); - strcpy(udev_rules_dir, UDEV_RULES_DIR); + strcpy(udev_root, UDEV_ROOT); + udev_rules_dir[0] = '\0'; udev_log_priority = LOG_ERR; udev_run = 1; @@ -195,6 +195,6 @@ void udev_config_init(void) dbg("UDEV_CONFIG_FILE='%s'\n", udev_config_filename); dbg("udev_root='%s'\n", udev_root); - dbg("udev_rules='%s'\n", udev_rules_dir); + dbg("udev_rules_dir='%s'\n", udev_rules_dir); dbg("udev_log=%d\n", udev_log_priority); } diff --git a/udev_rules_parse.c b/udev_rules_parse.c index bdaf55bd48..999af3b85e 100644 --- a/udev_rules_parse.c +++ b/udev_rules_parse.c @@ -727,53 +727,53 @@ int udev_rules_init(struct udev_rules *rules, int resolve_names) struct stat statbuf; char filename[PATH_MAX]; LIST_HEAD(name_list); - LIST_HEAD(dyn_list); + LIST_HEAD(sort_list); struct name_entry *name_loop, *name_tmp; - struct name_entry *dyn_loop, *dyn_tmp; + struct name_entry *sort_loop, *sort_tmp; int retval = 0; memset(rules, 0x00, sizeof(struct udev_rules)); rules->resolve_names = resolve_names; - /* read main config from single file or all files in a directory */ - if (stat(udev_rules_dir, &statbuf) != 0) - return -1; - if ((statbuf.st_mode & S_IFMT) != S_IFDIR) { - dbg("parse single rules file '%s'\n", udev_rules_dir); - name_list_add(&name_list, udev_rules_dir, 1); + if (udev_rules_dir[0] != '\0') { + /* custom rules location for testing */ + add_matching_files(&name_list, udev_rules_dir, RULESFILE_SUFFIX); } else { - dbg("parse rules directory '%s'\n", udev_rules_dir); - retval = add_matching_files(&name_list, udev_rules_dir, RULESFILE_SUFFIX); - } - - /* read dynamic rules directory */ - strlcpy(filename, udev_root, sizeof(filename)); - strlcat(filename, "/"RULES_DYN_DIR, sizeof(filename)); - if (stat(filename, &statbuf) != 0) { - create_path(filename); - selinux_setfscreatecon(filename, NULL, S_IFDIR|0755); - mkdir(filename, 0755); - selinux_resetfscreatecon(); - } - add_matching_files(&dyn_list, filename, RULESFILE_SUFFIX); + /* read default rules */ + add_matching_files(&name_list, RULES_LIB_DIR, RULESFILE_SUFFIX); + + /* read user/custom rules */ + add_matching_files(&sort_list, RULES_ETC_DIR, RULESFILE_SUFFIX); + + /* read dynamic/temporary rules */ + strlcpy(filename, udev_root, sizeof(filename)); + strlcat(filename, "/"RULES_DYN_DIR, sizeof(filename)); + if (stat(filename, &statbuf) != 0) { + create_path(filename); + selinux_setfscreatecon(filename, NULL, S_IFDIR|0755); + mkdir(filename, 0755); + selinux_resetfscreatecon(); + } + add_matching_files(&sort_list, filename, RULESFILE_SUFFIX); - /* sort dynamic rules files by basename into list of files */ - list_for_each_entry_safe(dyn_loop, dyn_tmp, &dyn_list, node) { - const char *dyn_base = strrchr(dyn_loop->name, '/'); + /* sort all rules files by basename into list of files */ + list_for_each_entry_safe(sort_loop, sort_tmp, &sort_list, node) { + const char *sort_base = strrchr(sort_loop->name, '/'); - if (dyn_base == NULL) - continue; + if (sort_base == NULL) + continue; - list_for_each_entry_safe(name_loop, name_tmp, &name_list, node) { - const char *name_base = strrchr(name_loop->name, '/'); + list_for_each_entry_safe(name_loop, name_tmp, &name_list, node) { + const char *name_base = strrchr(name_loop->name, '/'); - if (name_base == NULL) - continue; + if (name_base == NULL) + continue; - if (strcmp(name_base, dyn_base) > 0) - break; + if (strcmp(name_base, sort_base) > 0) + break; + } + list_move_tail(&sort_loop->node, &name_loop->node); } - list_move_tail(&dyn_loop->node, &name_loop->node); } /* parse list of files */ @@ -1142,14 +1142,23 @@ int main(int argc, char *argv[], char *envp[]) /* watch rules directory */ inotify_fd = inotify_init(); if (inotify_fd >= 0) { - char filename[PATH_MAX]; - - inotify_add_watch(inotify_fd, udev_rules_dir, IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE); - - /* watch dynamic rules directory */ - strlcpy(filename, udev_root, sizeof(filename)); - strlcat(filename, "/"RULES_DYN_DIR, sizeof(filename)); - inotify_add_watch(inotify_fd, filename, IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE); + if (udev_rules_dir[0] != '\0') { + inotify_add_watch(inotify_fd, udev_rules_dir, + IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE); + } else { + char filename[PATH_MAX]; + + inotify_add_watch(inotify_fd, RULES_LIB_DIR, + IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE); + inotify_add_watch(inotify_fd, RULES_ETC_DIR, + IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE); + + /* watch dynamic rules directory */ + strlcpy(filename, udev_root, sizeof(filename)); + strlcat(filename, "/"RULES_DYN_DIR, sizeof(filename)); + inotify_add_watch(inotify_fd, filename, + IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE); + } } else if (errno == ENOSYS) err("the kernel does not support inotify, udevd can't monitor rules file changes\n"); else |