Traditional Linux implementations provide their users with an
abstract device path, called
The device files are split in two groups, called
If you take a look at a certain device file, you might find something like this:
# ls -l /dev/hda brw-rw---- 1 root disk 3, 0 Jul 5 2000 /dev/hda
In the previous example we see that
Two examples are
If you do a quick check in such a
When you add new hardware to your system, and this hardware didn't have
a device file previously, you would have to create one. Advanced users know
that this task can be accomplished with
When you have programs interacting with hardware using the device files,
you can't have the root partition mounted read only, while there is no
further need to have it mounted read-write. And you can't have
As you can imagine, the kernel hackers have found quite a number of
solutions to the aforementioned problems. However, many of them had
other flaws as described in
devfs tackles all listed problems. It only provides the user with existing devices, adds new nodes when new devices are found, and makes it possible to mount the root filesystem read only. And it tackles more problems we haven't discussed previously because they are less interesting for users...
For instance, with devfs, you don't have to worry about major/minor pairs. It is still supported (for backwards compatibility), but isn't needed. This makes it possible for Linux to support even more devices, since there are no limits anymore (numbers always have boundaries :)
Yet devfs does come with it's own problems; for the end users these issues
aren't really visible, but for the kernel maintainers the problems are big
enough to mark devfs
For more information as to why devfs is marked obsolete, please read the
One of the first things you might notice is that devfs uses directories to group devices together. This improves readability, as now all related devices are inside a common directory.
For instance, all IDE-related devices are inside the
IDE and SCSI disks are controlled by an adapter (on-board or a seperate
card), called the
So, whereas
To give you an idea on the directories, this is a listing of the directories which I have on my laptop:
cdroms/ cpu/ discs/ floppy/ ide/ input/ loop/ misc/ netlink/ printers/ pts/ pty/ scsi/ sg/ shm/ sound/ sr/ usb/ vc/ vcc/
Using this new scheme sounds fun, but several tools and programs make
use of the previous, old scheme. To make sure no system is broken,
$ ls -l /dev/hda4 lr-xr-xr-x 1 root root 33 Aug 25 12:08 /dev/hda4 -> ide/host0/bus0/target0/lun0/part4
With
When you alter the
SIGHUP will have
SIGUSR1 will do the same, but won't generate REGISTER events.
To send a signal, simply use
# kill -s SIGHUP `pidof devfsd`or # killall -s SIGHUP devfsd
If you want the compatibility symlinks that clutter up
# Comment the following two lines out to remove the symlinks REGISTER .* MKOLDCOMPAT UNREGISTER .* RMOLDCOMPAT
You need to reboot your system for the changes to take affect.
When you load a module, devfs will automatically create the device
files. If you don't want this behaviour, remove the following line from
LOOKUP .* MODLOAD
Although you can set permissions in
PAM uses the
Let's first take a look at the groups part. As an example we view the sound-group:
<sound>=/dev/dsp* /dev/audio* /dev/midi* \
/dev/mixer* /dev/sequencer* \
/dev/sound/* /dev/snd/* /dev/beep \
/dev/admm* \
/dev/adsp* /dev/aload* /dev/amidi* /dev/dmfm* \
/dev/dmmidi* /dev/sndstat
The syntax is quite easy: you start with a group-name, and end with a list of devices that belong to that group.
Now, groups aren't very useful if you can't do anything with them. So the next part describes how permissions are handled.
<console> 0600 <sound> 0600 root.audio
The first field is the terminal check. On most systems, this is the console-group. PAM will check this field for every login. If the login happens on a device contained in the console-group, PAM will check and possibly change the permissions on some device files.
The second field contains the permissions to which a device file is set upon succesfull login. When a person logs into the system, and the device files are owned by a default owner/group, PAM wil change the ownership to the logged on user, and set the permissions to those in this second field. In this case, 0600 is used (user has read/write access, all others don't).
The third field contains the device-group whose permissions will be changed. In this case, the sound-group (all device files related to sound) will be changed.
The fourth field defines the permissions to which the device file is set after returning to the default state. In other words, if the person who owns all the device files logs out, PAM will set the permissions back to a default state, described by this fourth field.
The fifth field defines the ownership (with group if you want) to which the device attributes are set after returning to the default state. In other words, if the person who owns all the device files logs out, PAM will set the ownership back to a default state, described by this fifth field.
If you really want to set permissions using
REGISTER ^cdroms/.* PERMISSIONS root.cdrom 0660
The second field is the device group, starting from
The fourth field is the ownership of the device file. Unlike with PAM
this isn't changed (unless it is mentioned in
The fifth field contains the permissions of the device file.
This is the default behaviour for Gentoo: if you
REGISTER ^pt[sy]/.* IGNORE CHANGE ^pt[sy]/.* IGNORE CREATE ^pt[sy]/.* IGNORE DELETE ^pt[sy] IGNORE REGISTER ^log IGNORE CHANGE ^log IGNORE CREATE ^log IGNORE DELETE ^log IGNORE REGISTER .* COPY /lib/dev-state/$devname $devpath CHANGE .* COPY $devpath /lib/dev-state/$devname CREATE .* COPY $devpath /lib/dev-state/$devname DELETE .* CFUNCTION GLOBAL unlink /lib/dev-state/$devname RESTORE /lib/dev-state
In other words, changed device files are copied over to
Another possibility is to mount
mount --bind /dev /lib/dev-state mount -t devfs none /dev devfsd /dev
For more information on devfs, check out the following resources.
The devfsd.conf manpage explains the syntax of the
The
On
Daniel Robbins has written a set of articles for IBM's DeveloperWorks about Advanced filesystems. Three of them are about devfs: