/[gentoo]/xml/htdocs/doc/en/devfs-guide.xml
Gentoo

Diff of /xml/htdocs/doc/en/devfs-guide.xml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.7 Revision 1.11
1<?xml version='1.0' encoding="UTF-8"?> 1<?xml version='1.0' encoding="UTF-8"?>
2<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/devfs-guide.xml,v 1.7 2004/09/09 11:56:26 swift Exp $ --> 2<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/devfs-guide.xml,v 1.11 2005/07/18 10:03:44 fox2mike Exp $ -->
3 3
4<!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> 4<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
5 5
6<guide link="/doc/en/devfs-guide.xml"> 6<guide link="/doc/en/devfs-guide.xml">
7<title>Device File System Guide</title> 7<title>Device File System Guide</title>
15<abstract> 15<abstract>
16In this document you'll find information on what devfs is really about 16In this document you'll find information on what devfs is really about
17and how to work with it. 17and how to work with it.
18</abstract> 18</abstract>
19 19
20<!-- The content of this document is licensed under the CC-BY-SA license -->
21<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
20<license/> 22<license/>
21 23
22<version>0.2</version> 24<version>0.5</version>
23<date>September 09, 2004</date> 25<date>2005-07-18</date>
24 26
25<chapter> 27<chapter>
26<title>What is devfs?</title> 28<title>What is devfs?</title>
27<section> 29<section>
28<title>The (good?) old days</title> 30<title>The (good?) old days</title>
29<body> 31<body>
32
33<warn>
34devfs is <e>obsolete</e> and will eventually be removed from the stable 2.6
35tree. Users on 2.6 kernels are hereby advised to switch to udev. For further
36information on udev, please refer to the <uri
37link="/doc/en/udev-guide.xml">Gentoo udev Guide</uri>.
38</warn>
30 39
31<p> 40<p>
32Traditional Linux implementations provide their users with an 41Traditional Linux implementations provide their users with an
33abstract device path, called <path>/dev</path>. Inside this path the 42abstract device path, called <path>/dev</path>. Inside this path the
34user finds <e>device nodes</e>, special files that represent devices 43user finds <e>device nodes</e>, special files that represent devices
50<p> 59<p>
51If you take a look at a certain device file, you might find something 60If you take a look at a certain device file, you might find something
52like this: 61like this:
53</p> 62</p>
54 63
55<pre caption = "Checking the information of a device file"> 64<pre caption="Checking the information of a device file">
56# <i>ls -l /dev/hda</i> 65# <i>ls -l /dev/hda</i>
57brw-rw---- 1 root disk 3, 0 Jul 5 2000 /dev/hda 66brw-rw---- 1 root disk 3, 0 Jul 5 2000 /dev/hda
58</pre> 67</pre>
59 68
60<p> 69<p>
61In the previous example we see that <path>/dev/hda</path> is a block 70In the previous example we see that <path>/dev/hda</path> is a block
62device. However, more importantly, it has two special numbers assigned 71device. However, more importantly, it has two special numbers assigned
63to it: <path>3, 0</path>. This pair is called the <e>major-minor</e> 72to it: <b>3, 0</b>. This pair is called the <e>major-minor</e>
64pair. It is used by the kernel to map a device file to a real device. 73pair. It is used by the kernel to map a device file to a real device.
65The major corresponds with a certain device, the minor with a subdevice. 74The major corresponds with a certain device, the minor with a subdevice.
66Seems confusing? It isn't. 75Seems confusing? It isn't.
67</p> 76</p>
68 77
69<p> 78<p>
70Two examples are <path>/dev/hda4</path> and <path>/dev/tty5</path>. The 79Two examples are <path>/dev/hda4</path> and <path>/dev/tty5</path>. The
71first device file corresponds with the fourth partition on the first IDE 80first device file corresponds with the fourth partition on the first IDE
72device. Its major-minor pair is <path>3, 4</path>. In other words, the 81device. Its major-minor pair is <b>3, 4</b>. In other words, the
73minor corresponds with the partition where the major corresponds with 82minor corresponds with the partition where the major corresponds with
74the device. The second example has <path>4, 5</path> as major-minor 83the device. The second example has <b>4, 5</b> as major-minor
75pair. In this case, the major corresponds with the terminal driver, 84pair. In this case, the major corresponds with the terminal driver,
76while the minor corresponds with the terminal number (in this case, the 85while the minor corresponds with the terminal number (in this case, the
77fifth terminal). 86fifth terminal).
78</p> 87</p>
79 88
148 157
149<p> 158<p>
150Yet devfs does come with it's own problems; for the end users these issues 159Yet devfs does come with it's own problems; for the end users these issues
151aren't really visible, but for the kernel maintainers the problems are big 160aren't really visible, but for the kernel maintainers the problems are big
152enough to mark devfs <e>obsolete</e> in favor of <uri 161enough to mark devfs <e>obsolete</e> in favor of <uri
153link="udev-guide.xml">udev</uri> (which Gentoo supports as well :). 162link="udev-guide.xml">udev</uri>, which Gentoo supports and uses by default on
163most architectures since the 2005.0 release when using a 2.6 kernel.
154</p> 164</p>
155 165
156<p> 166<p>
157For more information as to why devfs is marked obsolete, please read the <uri 167For more information as to why devfs is marked obsolete, please read the <uri
158link="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev-FAQ">udev 168link="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev-FAQ">udev
210<p> 220<p>
211To give you an idea on the directories, this is a listing of the 221To give you an idea on the directories, this is a listing of the
212directories which I have on my laptop: 222directories which I have on my laptop:
213</p> 223</p>
214 224
215<pre caption = "Directories in /dev"> 225<pre caption="Directories in /dev">
216cdroms/ cpu/ discs/ floppy/ 226cdroms/ cpu/ discs/ floppy/
217ide/ input/ loop/ misc/ 227ide/ input/ loop/ misc/
218netlink/ printers/ pts/ pty/ 228netlink/ printers/ pts/ pty/
219scsi/ sg/ shm/ sound/ 229scsi/ sg/ shm/ sound/
220sr/ usb/ vc/ vcc/ 230sr/ usb/ vc/ vcc/
231use of the previous, old scheme. To make sure no system is broken, 241use of the previous, old scheme. To make sure no system is broken,
232<c>devfsd</c> is created. This daemon creates symlinks with the old 242<c>devfsd</c> is created. This daemon creates symlinks with the old
233names, pointing to the new device files. 243names, pointing to the new device files.
234</p> 244</p>
235 245
236<pre caption = "Created symlinks"> 246<pre caption="Created symlinks">
237$ <i>ls -l /dev/hda4</i> 247$ <i>ls -l /dev/hda4</i>
238lr-xr-xr-x 1 root root 33 Aug 25 12:08 /dev/hda4 -> ide/host0/bus0/target0/lun0/part4 248lr-xr-xr-x 1 root root 33 Aug 25 12:08 /dev/hda4 -> ide/host0/bus0/target0/lun0/part4
239</pre> 249</pre>
240 250
241<p> 251<p>
272 282
273<p> 283<p>
274To send a signal, simply use <c>kill</c> or <c>killall</c>: 284To send a signal, simply use <c>kill</c> or <c>killall</c>:
275</p> 285</p>
276 286
277<pre caption = "Sending the SIGHUP signal to devfsd"> 287<pre caption="Sending the SIGHUP signal to devfsd">
278# <i>kill -s SIGHUP `pidof devfsd`</i> 288# <i>kill -s SIGHUP `pidof devfsd`</i>
279<comment>or</comment> 289<comment>or</comment>
280# <i>killall -s SIGHUP devfsd</i> 290# <i>killall -s SIGHUP devfsd</i>
281</pre> 291</pre>
282 292
294If you want the compatibility symlinks that clutter up <path>/dev</path> 304If you want the compatibility symlinks that clutter up <path>/dev</path>
295removed from your Gentoo system (Gentoo activates it per default), edit 305removed from your Gentoo system (Gentoo activates it per default), edit
296<path>/etc/devfsd.conf</path> and remove the following two lines: 306<path>/etc/devfsd.conf</path> and remove the following two lines:
297</p> 307</p>
298 308
299<pre caption = "/etc/devfsd.conf for backwards compatibility"> 309<pre caption="/etc/devfsd.conf for backwards compatibility">
300<comment># Comment the following two lines out to remove the symlinks</comment> 310<comment># Comment the following two lines out to remove the symlinks</comment>
301REGISTER .* MKOLDCOMPAT 311REGISTER .* MKOLDCOMPAT
302UNREGISTER .* RMOLDCOMPAT 312UNREGISTER .* RMOLDCOMPAT
303</pre> 313</pre>
304 314
316When you load a module, devfs will automatically create the device 326When you load a module, devfs will automatically create the device
317files. If you don't want this behaviour, remove the following line from 327files. If you don't want this behaviour, remove the following line from
318<path>/etc/devfsd.conf</path>: 328<path>/etc/devfsd.conf</path>:
319</p> 329</p>
320 330
321<pre caption = "/etc/devfsd.conf, autoload functionality"> 331<pre caption="/etc/devfsd.conf, autoload functionality">
322LOOKUP .* MODLOAD 332LOOKUP .* MODLOAD
323</pre> 333</pre>
324 334
325</body> 335</body>
326</section> 336</section>
327</chapter> 337</chapter>
328 338
329<chapter> 339<chapter>
330<title>Permission Related Items</title> 340<title>Permission Related Items</title>
331<section> 341<section>
332<title>Set/change permissions using PAM</title>
333<body>
334
335<p>
336Although you can set permissions in <path>/etc/devfsd.conf</path>, you
337are advised to use PAM (<e>Pluggable Authentification Modules</e>). This
338is because PAM has the final say on permissions, possibly ignoring the
339changes you make in <path>/etc/devfsd.conf</path>.
340</p>
341
342<p>
343PAM uses the <path>/etc/security/console.perms</path> file for the
344permissions. The file consists of two parts: the first one describes the
345groups, and the second one the permissions.
346</p>
347
348<p>
349Let's first take a look at the groups part. As an example we view the
350sound-group:
351</p>
352
353<pre caption = "Sound group in /etc/security/console.perms">
354&lt;sound&gt;=/dev/dsp* /dev/audio* /dev/midi* \
355 /dev/mixer* /dev/sequencer* \
356 /dev/sound/* /dev/snd/* /dev/beep \
357 /dev/admm* \
358 /dev/adsp* /dev/aload* /dev/amidi* /dev/dmfm* \
359 /dev/dmmidi* /dev/sndstat
360</pre>
361
362<p>
363The syntax is quite easy: you start with a group-name, and end with a
364list of devices that belong to that group.
365</p>
366
367<p>
368Now, groups aren't very useful if you can't do anything with them. So
369the next part describes how permissions are handled.
370</p>
371
372<pre caption = "Permissions for sound group in /etc/security/console.perms">
373&lt;console&gt; 0600 &lt;sound&gt; 0600 root.audio
374</pre>
375
376<p>
377The first field is the terminal check. On most systems, this is the
378console-group. PAM will check this field for every login. If the login
379happens on a device contained in the console-group, PAM will check and
380possibly change the permissions on some device files.
381</p>
382
383<p>
384The second field contains the permissions to which a device file is set
385upon succesfull login. When a person logs into the system, and the device
386files are owned by a default owner/group, PAM wil change the ownership
387to the logged on user, and set the permissions to those in this second
388field. In this case, 0600 is used (user has read/write access,
389all others don't).
390</p>
391
392<p>
393The third field contains the device-group whose permissions will be
394changed. In this case, the sound-group (all device files related to
395sound) will be changed.
396</p>
397
398<p>
399The fourth field defines the permissions to which the device file is set after
400returning to the default state. In other words, if the person who owns
401all the device files logs out, PAM will set the permissions back to a
402default state, described by this fourth field.
403</p>
404
405<p>
406The fifth field defines the ownership (with group if you want) to which
407the device attributes are set after returning to the default state. In
408other words, if the person who owns all the device files logs out, PAM
409will set the ownership back to a default state, described by this fifth
410field.
411</p>
412
413</body>
414</section>
415<section>
416<title>Set/change permissions with devfsd</title> 342<title>Set/change permissions with devfsd</title>
417<body> 343<body>
418 344
419<p> 345<note>
420If you really want to set permissions using 346These instructions are valid as long as pam_console is disabled in
421<path>/etc/devfsd.conf</path>, then use the syntax used in the following 347<path>/etc/pam.d/system-auth</path>. If you enabled pam_console there,
422example: 348then PAM has the final word on permissions.
349</note>
350
423</p> 351<p>
352If you want to set permissions using <path>/etc/devfsd.conf</path>,
353then use the syntax used in the following example:
354</p>
424 355
425<pre caption = "Permissions in /etc/devfsd.conf"> 356<pre caption="Permissions in /etc/devfsd.conf">
426REGISTER ^cdroms/.* PERMISSIONS root.cdrom 0660 357REGISTER ^cdroms/.* PERMISSIONS root.cdrom 0660
427</pre> 358</pre>
428 359
429<p> 360<p>
430The second field is the device group, starting from <path>/dev</path>. 361The second field is the device group, starting from <path>/dev</path>.
431It is a regular expression, meaning you can select several device files 362It is a regular expression, meaning you can select several device files
432in one rule. 363in one rule.
433</p> 364</p>
434 365
435<p> 366<p>
436The fourth field is the ownership of the device file. Unlike with PAM 367The fourth field is the ownership of the device file, and the fifth
437this isn't changed (unless it is mentioned in <path>console.perms</path>
438since PAM always wins).
439</p>
440
441<p>
442The fifth field contains the permissions of the device file. 368field contains the permissions of the device file.
443</p> 369</p>
444 370
445</body> 371</body>
446</section> 372</section>
447<section> 373<section>
449<body> 375<body>
450 376
451<p> 377<p>
452This is the default behaviour for Gentoo: if you <c>chown</c> (CHange 378This is the default behaviour for Gentoo: if you <c>chown</c> (CHange
453OWNer) and <c>chmod</c> (CHange MODe) some device files, <c>devfsd</c> 379OWNer) and <c>chmod</c> (CHange MODe) some device files, <c>devfsd</c>
454will save the information when you are shutting down the system. This is 380will save the information so that it will persist across reboots. This
455because the <path>/etc/devfsd.conf</path> file contains the following 381is because the <path>/etc/devfsd.conf</path> file contains the
456lines: 382following lines:
457</p> 383</p>
458 384
459<pre caption = "/etc/devfsd.conf for saving permissions"> 385<pre caption="/etc/devfsd.conf for saving permissions">
460REGISTER ^pt[sy]/.* IGNORE 386REGISTER ^pt[sy]/.* IGNORE
461CHANGE ^pt[sy]/.* IGNORE 387CHANGE ^pt[sy]/.* IGNORE
462CREATE ^pt[sy]/.* IGNORE 388CREATE ^pt[sy]/.* IGNORE
463DELETE ^pt[sy] IGNORE 389DELETE ^pt[sy] IGNORE
464REGISTER ^log IGNORE 390REGISTER ^log IGNORE
473RESTORE /lib/dev-state 399RESTORE /lib/dev-state
474</pre> 400</pre>
475 401
476<p> 402<p>
477In other words, changed device files are copied over to 403In other words, changed device files are copied over to
478<path>/lib/dev-state</path> when shutting down the system, and are 404<path>/lib/dev-state</path> as soon as the change happens, and are
479copied over to <path>/dev</path> when booting the system. 405copied over to <path>/dev</path> when booting the system.
480</p> 406</p>
481 407
482<p> 408<p>
483Another possibility is to mount <path>/lib/dev-state</path> on 409Another possibility is to mount <path>/lib/dev-state</path> on
485devfs is not mounted automatically (meaning you'll have to recompile 411devfs is not mounted automatically (meaning you'll have to recompile
486your kernel) and that <path>/dev/console</path> exists. Then, somewhere 412your kernel) and that <path>/dev/console</path> exists. Then, somewhere
487at the beginning of the bootscripts of your system, you place: 413at the beginning of the bootscripts of your system, you place:
488</p> 414</p>
489 415
490<pre caption = "Mounting /lib/dev-state on top of /dev"> 416<pre caption="Mounting /lib/dev-state on top of /dev">
491mount --bind /dev /lib/dev-state 417mount --bind /dev /lib/dev-state
492mount -t devfs none /dev 418mount -t devfs none /dev
493devfsd /dev 419devfsd /dev
494</pre> 420</pre>
495 421

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.20