chiark / gitweb /
remove example rules and put the dev.d stuff into the run_directory folder
[elogind.git] / extras / run_directory / RFC-dev.d
1  /etc/dev.d/  How it works, and what it is for
2  
3  by Greg Kroah-Hartman <greg@kroah.com> March 2004
4
5 The /etc/dev.d directory works much like the /etc/hotplug.d/ directory
6 in that it is a place to put symlinks or programs that get called when
7 an event happens in the system.  Programs will get called whenever the
8 device naming program in the system has either named a new device and
9 created a /dev node for it, or when a /dev node has been removed from
10 the system due to a device being removed.
11
12 The directory tree under /etc/dev.d/ dictate which program is run first,
13 and when some programs will be run or not.  The device naming program
14 calls the programs in the following order:
15         /etc/dev.d/DEVNAME/*.dev
16         /etc/dev.d/SUBSYSTEM/*.dev
17         /etc/dev.d/default/*.dev
18
19 The .dev extension is needed to allow automatic package managers to
20 deposit backup files in these directories safely.
21
22 The DEVNAME name is the name of the /dev file that has been created, or
23 for network devices, the name of the newly named network device.  This
24 value, including the /dev path, will also be exported to userspace in
25 the DEVNAME environment variable.
26
27 The SUBSYSTEM name is the name of the sysfs subsystem that originally
28 generated the hotplug event that caused the device naming program to
29 create or remove the /dev node originally.  This value is passed to
30 userspace as the first argument to the program.
31
32 The default directory will always be run, to enable programs to catch
33 every device add and remove in a single place.
34
35 All environment variables that were originally passed by the hotplug
36 call that caused this device action will also be passed to the program
37 called in the /etc/dev.d/ directories.  Examples of these variables are
38 ACTION, DEVPATH, and others.  See the hotplug documentation for full
39 description of this
40
41 An equivalent shell script that would do this same kind of action would
42 be:
43         DIR="/etc/dev.d"
44         export DEVNAME="whatever_dev_name_udev_just_gave"
45         for I in "${DIR}/$DEVNAME/"*.dev "${DIR}/$1/"*.dev "${DIR}/default/"*.dev ; do
46                 if [ -f $I ]; then $I $1 ; fi
47         done
48         exit 1;
49
50