/[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.6 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.6 2004/07/20 17:12:29 vapier 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.1</version> 24<version>0.5</version>
23<date>September 11, 2003</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
126</p> 135</p>
127 136
128</body> 137</body>
129</section> 138</section>
130<section> 139<section>
131<title>devfs as all-round winner</title> 140<title>devfs as all-round winner ?</title>
132<body> 141<body>
133 142
134<p> 143<p>
135devfs tackles all listed problems. It only provides the user with 144devfs tackles all listed problems. It only provides the user with
136existing devices, adds new nodes when new devices are found, and makes 145existing devices, adds new nodes when new devices are found, and makes
142<p> 151<p>
143For instance, with devfs, you don't have to worry about major/minor 152For instance, with devfs, you don't have to worry about major/minor
144pairs. It is still supported (for backwards compatibility), but isn't 153pairs. It is still supported (for backwards compatibility), but isn't
145needed. This makes it possible for Linux to support even more devices, 154needed. This makes it possible for Linux to support even more devices,
146since there are no limits anymore (numbers always have boundaries :) 155since there are no limits anymore (numbers always have boundaries :)
156</p>
157
158<p>
159Yet devfs does come with it's own problems; for the end users these issues
160aren't really visible, but for the kernel maintainers the problems are big
161enough to mark devfs <e>obsolete</e> in favor of <uri
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.
164</p>
165
166<p>
167For more information as to why devfs is marked obsolete, please read the <uri
168link="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev-FAQ">udev
169FAQ</uri> and <uri
170link="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev_vs_devfs">udev
171versus devfs document</uri>.
147</p> 172</p>
148 173
149</body> 174</body>
150</section> 175</section>
151</chapter> 176</chapter>
195<p> 220<p>
196To 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
197directories which I have on my laptop: 222directories which I have on my laptop:
198</p> 223</p>
199 224
200<pre caption = "Directories in /dev"> 225<pre caption="Directories in /dev">
201cdroms/ cpu/ discs/ floppy/ 226cdroms/ cpu/ discs/ floppy/
202ide/ input/ loop/ misc/ 227ide/ input/ loop/ misc/
203netlink/ printers/ pts/ pty/ 228netlink/ printers/ pts/ pty/
204scsi/ sg/ shm/ sound/ 229scsi/ sg/ shm/ sound/
205sr/ usb/ vc/ vcc/ 230sr/ usb/ vc/ vcc/
216use 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,
217<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
218names, pointing to the new device files. 243names, pointing to the new device files.
219</p> 244</p>
220 245
221<pre caption = "Created symlinks"> 246<pre caption="Created symlinks">
222$ <i>ls -l /dev/hda4</i> 247$ <i>ls -l /dev/hda4</i>
223lr-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
224</pre> 249</pre>
225 250
226<p> 251<p>
257 282
258<p> 283<p>
259To 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>:
260</p> 285</p>
261 286
262<pre caption = "Sending the SIGHUP signal to devfsd"> 287<pre caption="Sending the SIGHUP signal to devfsd">
263# <i>kill -s SIGHUP `pidof devfsd`</i> 288# <i>kill -s SIGHUP `pidof devfsd`</i>
264<comment>or</comment> 289<comment>or</comment>
265# <i>killall -s SIGHUP devfsd</i> 290# <i>killall -s SIGHUP devfsd</i>
266</pre> 291</pre>
267 292
279If you want the compatibility symlinks that clutter up <path>/dev</path> 304If you want the compatibility symlinks that clutter up <path>/dev</path>
280removed from your Gentoo system (Gentoo activates it per default), edit 305removed from your Gentoo system (Gentoo activates it per default), edit
281<path>/etc/devfsd.conf</path> and remove the following two lines: 306<path>/etc/devfsd.conf</path> and remove the following two lines:
282</p> 307</p>
283 308
284<pre caption = "/etc/devfsd.conf for backwards compatibility"> 309<pre caption="/etc/devfsd.conf for backwards compatibility">
285<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>
286REGISTER .* MKOLDCOMPAT 311REGISTER .* MKOLDCOMPAT
287UNREGISTER .* RMOLDCOMPAT 312UNREGISTER .* RMOLDCOMPAT
288</pre> 313</pre>
289 314
301When you load a module, devfs will automatically create the device 326When you load a module, devfs will automatically create the device
302files. 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
303<path>/etc/devfsd.conf</path>: 328<path>/etc/devfsd.conf</path>:
304</p> 329</p>
305 330
306<pre caption = "/etc/devfsd.conf, autoload functionality"> 331<pre caption="/etc/devfsd.conf, autoload functionality">
307LOOKUP .* MODLOAD 332LOOKUP .* MODLOAD
308</pre> 333</pre>
309 334
310</body> 335</body>
311</section> 336</section>
312</chapter> 337</chapter>
313 338
314<chapter> 339<chapter>
315<title>Permission Related Items</title> 340<title>Permission Related Items</title>
316<section> 341<section>
317<title>Set/change permissions using PAM</title>
318<body>
319
320<p>
321Although you can set permissions in <path>/etc/devfsd.conf</path>, you
322are advised to use PAM (<e>Pluggable Authentification Modules</e>). This
323is because PAM has the final say on permissions, possibly ignoring the
324changes you make in <path>/etc/devfsd.conf</path>.
325</p>
326
327<p>
328PAM uses the <path>/etc/security/console.perms</path> file for the
329permissions. The file consists of two parts: the first one describes the
330groups, and the second one the permissions.
331</p>
332
333<p>
334Let's first take a look at the groups part. As an example we view the
335sound-group:
336</p>
337
338<pre caption = "Sound group in /etc/security/console.perms">
339&lt;sound&gt;=/dev/dsp* /dev/audio* /dev/midi* \
340 /dev/mixer* /dev/sequencer* \
341 /dev/sound/* /dev/snd/* /dev/beep \
342 /dev/admm* \
343 /dev/adsp* /dev/aload* /dev/amidi* /dev/dmfm* \
344 /dev/dmmidi* /dev/sndstat
345</pre>
346
347<p>
348The syntax is quite easy: you start with a group-name, and end with a
349list of devices that belong to that group.
350</p>
351
352<p>
353Now, groups aren't very useful if you can't do anything with them. So
354the next part describes how permissions are handled.
355</p>
356
357<pre caption = "Permissions for sound group in /etc/security/console.perms">
358&lt;console&gt; 0600 &lt;sound&gt; 0600 root.audio
359</pre>
360
361<p>
362The first field is the terminal check. On most systems, this is the
363console-group. PAM will check this field for every login. If the login
364happens on a device contained in the console-group, PAM will check and
365possibly change the permissions on some device files.
366</p>
367
368<p>
369The second field contains the permissions to which a device file is set
370upon succesfull login. When a person logs into the system, and the device
371files are owned by a default owner/group, PAM wil change the ownership
372to the logged on user, and set the permissions to those in this second
373field. In this case, 0600 is used (user has read/write access,
374all others don't).
375</p>
376
377<p>
378The third field contains the device-group whose permissions will be
379changed. In this case, the sound-group (all device files related to
380sound) will be changed.
381</p>
382
383<p>
384The fourth field defines the permissions to which the device file is set after
385returning to the default state. In other words, if the person who owns
386all the device files logs out, PAM will set the permissions back to a
387default state, described by this fourth field.
388</p>
389
390<p>
391The fifth field defines the ownership (with group if you want) to which
392the device attributes are set after returning to the default state. In
393other words, if the person who owns all the device files logs out, PAM
394will set the ownership back to a default state, described by this fifth
395field.
396</p>
397
398</body>
399</section>
400<section>
401<title>Set/change permissions with devfsd</title> 342<title>Set/change permissions with devfsd</title>
402<body> 343<body>
403 344
404<p> 345<note>
405If you really want to set permissions using 346These instructions are valid as long as pam_console is disabled in
406<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,
407example: 348then PAM has the final word on permissions.
349</note>
350
408</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>
409 355
410<pre caption = "Permissions in /etc/devfsd.conf"> 356<pre caption="Permissions in /etc/devfsd.conf">
411REGISTER ^cdroms/.* PERMISSIONS root.cdrom 0660 357REGISTER ^cdroms/.* PERMISSIONS root.cdrom 0660
412</pre> 358</pre>
413 359
414<p> 360<p>
415The second field is the device group, starting from <path>/dev</path>. 361The second field is the device group, starting from <path>/dev</path>.
416It is a regular expression, meaning you can select several device files 362It is a regular expression, meaning you can select several device files
417in one rule. 363in one rule.
418</p> 364</p>
419 365
420<p> 366<p>
421The 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
422this isn't changed (unless it is mentioned in <path>console.perms</path>
423since PAM always wins).
424</p>
425
426<p>
427The fifth field contains the permissions of the device file. 368field contains the permissions of the device file.
428</p> 369</p>
429 370
430</body> 371</body>
431</section> 372</section>
432<section> 373<section>
434<body> 375<body>
435 376
436<p> 377<p>
437This 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
438OWNer) 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>
439will save the information when you are shutting down the system. This is 380will save the information so that it will persist across reboots. This
440because the <path>/etc/devfsd.conf</path> file contains the following 381is because the <path>/etc/devfsd.conf</path> file contains the
441lines: 382following lines:
442</p> 383</p>
443 384
444<pre caption = "/etc/devfsd.conf for saving permissions"> 385<pre caption="/etc/devfsd.conf for saving permissions">
445REGISTER ^pt[sy]/.* IGNORE 386REGISTER ^pt[sy]/.* IGNORE
446CHANGE ^pt[sy]/.* IGNORE 387CHANGE ^pt[sy]/.* IGNORE
447CREATE ^pt[sy]/.* IGNORE 388CREATE ^pt[sy]/.* IGNORE
448DELETE ^pt[sy] IGNORE 389DELETE ^pt[sy] IGNORE
449REGISTER ^log IGNORE 390REGISTER ^log IGNORE
458RESTORE /lib/dev-state 399RESTORE /lib/dev-state
459</pre> 400</pre>
460 401
461<p> 402<p>
462In other words, changed device files are copied over to 403In other words, changed device files are copied over to
463<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
464copied over to <path>/dev</path> when booting the system. 405copied over to <path>/dev</path> when booting the system.
465</p> 406</p>
466 407
467<p> 408<p>
468Another possibility is to mount <path>/lib/dev-state</path> on 409Another possibility is to mount <path>/lib/dev-state</path> on
470devfs is not mounted automatically (meaning you'll have to recompile 411devfs is not mounted automatically (meaning you'll have to recompile
471your kernel) and that <path>/dev/console</path> exists. Then, somewhere 412your kernel) and that <path>/dev/console</path> exists. Then, somewhere
472at the beginning of the bootscripts of your system, you place: 413at the beginning of the bootscripts of your system, you place:
473</p> 414</p>
474 415
475<pre caption = "Mounting /lib/dev-state on top of /dev"> 416<pre caption="Mounting /lib/dev-state on top of /dev">
476mount --bind /dev /lib/dev-state 417mount --bind /dev /lib/dev-state
477mount -t devfs none /dev 418mount -t devfs none /dev
478devfsd /dev 419devfsd /dev
479</pre> 420</pre>
480 421

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

  ViewVC Help
Powered by ViewVC 1.1.20