/[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.1 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.11 2005/07/18 10:03:44 fox2mike Exp $ -->
2 3
3<!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> 4<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
4 5
5<guide link="/doc/en/devfs-guide.xml"> 6<guide link="/doc/en/devfs-guide.xml">
6<title>Device File System Guide</title> 7<title>Device File System Guide</title>
7<author title="Author"> 8<author title="Author">
8 <mail link="swift@gentoo.org">Sven Vermeulen</mail> 9 <mail link="swift@gentoo.org">Sven Vermeulen</mail>
9</author> 10</author>
10<author title="Reviewer"> 11<author title="Reviewer">
11 <mail link="seemant@gentoo.org">Seemant Kulleen</mail> 12 <mail link="seemant@gentoo.org">Seemant Kulleen</mail>
12</author> 13</author>
13 14
14<abstract> 15<abstract>
15In 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
16and how to work with it. 17and how to work with it.
17</abstract> 18</abstract>
18<version>0.1</version> 19
19<date>August 29, 2003</date> 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/>
23
24<version>0.5</version>
25<date>2005-07-18</date>
26
21<chapter> 27<chapter>
22<title>What is devfs?</title> 28<title>What is devfs?</title>
23
24<section> 29<section>
25<title>The (good?) old days</title> 30<title>The (good?) old days</title>
26<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>
27 39
28<p> 40<p>
29Traditional Linux implementations provide their users with an 41Traditional Linux implementations provide their users with an
30abstract device path, called <path>/dev</path>. Inside this path the 42abstract device path, called <path>/dev</path>. Inside this path the
31user finds <e>device nodes</e>, special files that represent devices 43user finds <e>device nodes</e>, special files that represent devices
47<p> 59<p>
48If 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
49like this: 61like this:
50</p> 62</p>
51 63
52<pre caption = "Checking the information of a device file"> 64<pre caption="Checking the information of a device file">
53# <i>ls -l /dev/hda</i> 65# <i>ls -l /dev/hda</i>
54brw-rw---- 1 root disk 3, 0 Jul 5 2000 /dev/hda 66brw-rw---- 1 root disk 3, 0 Jul 5 2000 /dev/hda
55</pre> 67</pre>
56 68
57<p> 69<p>
58In 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
59device. However, more importantly, it has two special numbers assigned 71device. However, more importantly, it has two special numbers assigned
60to 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>
61pair. 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.
62The major corresponds with a certain device, the minor with a subdevice. 74The major corresponds with a certain device, the minor with a subdevice.
63Seems confusing? It isn't. 75Seems confusing? It isn't.
64</p> 76</p>
65 77
66<p> 78<p>
67Two 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
68first device file corresponds with the fourth partition on the first IDE 80first device file corresponds with the fourth partition on the first IDE
69device. 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
70minor corresponds with the partition where the major corresponds with 82minor corresponds with the partition where the major corresponds with
71the 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
72pair. In this case, the major corresponds with the terminal driver, 84pair. In this case, the major corresponds with the terminal driver,
73while the minor corresponds with the terminal number (in this case, the 85while the minor corresponds with the terminal number (in this case, the
74fifth terminal). 86fifth terminal).
75</p> 87</p>
76 88
77</body> 89</body>
78</section> 90</section>
79
80<section> 91<section>
81<title>The problems</title> 92<title>The problems</title>
82<body> 93<body>
83 94
84<p> 95<p>
124</p> 135</p>
125 136
126</body> 137</body>
127</section> 138</section>
128<section> 139<section>
129<title>devfs as all-round winner</title> 140<title>devfs as all-round winner ?</title>
130<body> 141<body>
131 142
132<p> 143<p>
133devfs tackles all listed problems. It only provides the user with 144devfs tackles all listed problems. It only provides the user with
134existing devices, adds new nodes when new devices are found, and makes 145existing devices, adds new nodes when new devices are found, and makes
142pairs. It is still supported (for backwards compatibility), but isn't 153pairs. It is still supported (for backwards compatibility), but isn't
143needed. This makes it possible for Linux to support even more devices, 154needed. This makes it possible for Linux to support even more devices,
144since there are no limits anymore (numbers always have boundaries :) 155since there are no limits anymore (numbers always have boundaries :)
145</p> 156</p>
146 157
147</body> 158<p>
148</section> 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>
149 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>.
172</p>
173
174</body>
175</section>
150</chapter> 176</chapter>
177
151<chapter> 178<chapter>
152<title>Navigating through the device tree</title> 179<title>Navigating through the device tree</title>
153
154<section> 180<section>
155<title>Directories</title> 181<title>Directories</title>
156<body> 182<body>
157 183
158<p> 184<p>
194<p> 220<p>
195To 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
196directories which I have on my laptop: 222directories which I have on my laptop:
197</p> 223</p>
198 224
199<pre caption = "Directories in /dev"> 225<pre caption="Directories in /dev">
200cdroms/ cpu/ discs/ floppy/ 226cdroms/ cpu/ discs/ floppy/
201ide/ input/ loop/ misc/ 227ide/ input/ loop/ misc/
202netlink/ printers/ pts/ pty/ 228netlink/ printers/ pts/ pty/
203scsi/ sg/ shm/ sound/ 229scsi/ sg/ shm/ sound/
204sr/ usb/ vc/ vcc/ 230sr/ usb/ vc/ vcc/
215use 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,
216<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
217names, pointing to the new device files. 243names, pointing to the new device files.
218</p> 244</p>
219 245
220<pre caption = "Created symlinks"> 246<pre caption="Created symlinks">
221$ <i>ls -l /dev/hda4</i> 247$ <i>ls -l /dev/hda4</i>
222lr-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
223</pre> 249</pre>
224 250
225<p> 251<p>
228</p> 254</p>
229 255
230</body> 256</body>
231</section> 257</section>
232</chapter> 258</chapter>
259
233<chapter> 260<chapter>
234<title>Administrating the device tree</title> 261<title>Administrating the device tree</title>
235
236<section> 262<section>
237<title>Restarting devfsd</title> 263<title>Restarting devfsd</title>
238<body> 264<body>
239 265
240<p> 266<p>
256 282
257<p> 283<p>
258To 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>:
259</p> 285</p>
260 286
261<pre caption = "Sending the SIGHUP signal to devfsd"> 287<pre caption="Sending the SIGHUP signal to devfsd">
262# <i>kill -s SIGHUP `pidof devfsd`</i> 288# <i>kill -s SIGHUP `pidof devfsd`</i>
263<comment>or</comment> 289<comment>or</comment>
264# <i>killall -s SIGHUP devfsd</i> 290# <i>killall -s SIGHUP devfsd</i>
265</pre> 291</pre>
266 292
267</body> 293</body>
268</section> 294</section>
269
270<section> 295<section>
271<title>Removing compatibility symlinks</title> 296<title>Removing compatibility symlinks</title>
272<body> 297<body>
273 298
274<warn> 299<warn>
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
291You need to reboot your system for the changes to take affect. 316You need to reboot your system for the changes to take affect.
292</p> 317</p>
293 318
294</body> 319</body>
295</section> 320</section>
296
297<section> 321<section>
298<title>Removing autoload functionality</title> 322<title>Removing autoload functionality</title>
299<body> 323<body>
300 324
301<p> 325<p>
302When you load a module, devfs will automatically create the device 326When you load a module, devfs will automatically create the device
303files. 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
304<path>/etc/devfsd.conf</path>: 328<path>/etc/devfsd.conf</path>:
305</p> 329</p>
306 330
307<pre caption = "/etc/devfsd.conf, autoload functionality"> 331<pre caption="/etc/devfsd.conf, autoload functionality">
308LOOKUP .* MODLOAD 332LOOKUP .* MODLOAD
309</pre> 333</pre>
310 334
311</body> 335</body>
312</section> 336</section>
313
314</chapter> 337</chapter>
338
315<chapter> 339<chapter>
316<title>Permission Related Items</title> 340<title>Permission Related Items</title>
317<section> 341<section>
318<title>Set/change permissions using PAM</title>
319<body>
320
321<p>
322Although you can set permissions in <path>/etc/devfsd.conf</path>, you
323are advised to use PAM (<e>Pluggable Authentification Modules</e>). This
324is because PAM has the final say on permissions, possibly ignoring the
325changes you make in <path>/etc/devfsd.conf</path>.
326</p>
327
328<p>
329PAM uses the <path>/etc/security/console.perms</path> file for the
330permissions. The file consists of two parts: the first one describes the
331groups, and the second one the permissions.
332</p>
333
334<p>
335Let's first take a look at the groups part. As an example we view the
336sound-group:
337</p>
338
339<pre caption = "Sound group in /etc/security/console.perms">
340&lt;sound&gt;=/dev/dsp* /dev/audio* /dev/midi* \
341 /dev/mixer* /dev/sequencer* \
342 /dev/sound/* /dev/snd/* /dev/beep \
343 /dev/admm* \
344 /dev/adsp* /dev/aload* /dev/amidi* /dev/dmfm* \
345 /dev/dmmidi* /dev/sndstat
346</pre>
347
348<p>
349The syntax is quite easy: you start with a group-name, and end with a
350list of devices that belong to that group.
351</p>
352
353<p>
354Now, groups aren't very usefull if you can't do anything with them. So
355the next part describes how permissions are handled.
356</p>
357
358<pre caption = "Permissions for sound group in /etc/security/console.perms">
359&lt;console&gt; 0600 &lt;sound&gt; 0600 root.audio
360</pre>
361
362<p>
363The first field is the terminal check. On most systems, this is the
364console-group. PAM will check this field for every login. If the login
365happens on a device contained in the console-group, PAM will check and
366possibly change the permissions on some device files.
367</p>
368
369<p>
370The second field contains the permissions to which a device file is
371upon succesfull login. When a person logs into the system, and the device
372files are owned by a default owner/group, PAM wil change the ownership
373to the logged on user, and set the permissions to those in this second
374field. In this case, 0600 is used (user has read/write access,
375all others don't).
376</p>
377
378<p>
379The third field contains the device-group whose permissions will be
380changed. In this case, the sound-group (all device files related to
381sound) will be changed.
382</p>
383
384<p>
385The fourth field defines the permissions to which it is set after
386returning to the default state. In other words, if the person who owns
387all the device files logs out, PAM will set the permissions back to a
388default state, described by this fourth field.
389</p>
390
391<p>
392The fifth field defines the ownership (with group if you want) to which
393the device attributes are set after returning to the default state. In
394other words, if the person who owns all the device files logs out, PAM
395will set the ownership back to a default state, described by this fifth
396field.
397</p>
398
399</body>
400</section>
401
402<section>
403<title>Set/change permissions with devfsd</title> 342<title>Set/change permissions with devfsd</title>
404<body> 343<body>
405 344
406<p> 345<note>
407If you really want to set permissions using 346These instructions are valid as long as pam_console is disabled in
408<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,
409example: 348then PAM has the final word on permissions.
349</note>
350
410</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>
411 355
412<pre caption = "Permissions in /etc/devfsd.conf"> 356<pre caption="Permissions in /etc/devfsd.conf">
413REGISTER ^cdroms/.* PERMISSIONS root.cdrom 0660 357REGISTER ^cdroms/.* PERMISSIONS root.cdrom 0660
414</pre> 358</pre>
415 359
416<p> 360<p>
417The second field is the device group, starting from <path>/dev</path>. 361The second field is the device group, starting from <path>/dev</path>.
418It is a regular expression, meaning you can select several device files 362It is a regular expression, meaning you can select several device files
419in one rule. 363in one rule.
420</p> 364</p>
421 365
422<p> 366<p>
423The 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
424this isn't changed (unless it is mentioned in <path>console.perms</path>
425since PAM always wins).
426</p>
427
428<p>
429The fifth field contains the permissions of the device file. 368field contains the permissions of the device file.
430</p> 369</p>
431 370
432</body> 371</body>
433</section> 372</section>
434
435<section> 373<section>
436<title>Manually set permissions and have devfsd save it</title> 374<title>Manually set permissions and have devfsd save it</title>
437<body> 375<body>
438 376
439<p> 377<p>
440This 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
441OWNer) 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>
442will save the information when you are shutting down the system. This is 380will save the information so that it will persist across reboots. This
443because the <path>/etc/devfsd.conf</path> file contains the following 381is because the <path>/etc/devfsd.conf</path> file contains the
444lines: 382following lines:
445</p> 383</p>
446 384
447<pre caption = "/etc/devfsd.conf for saving permissions"> 385<pre caption="/etc/devfsd.conf for saving permissions">
448REGISTER ^pt[sy]/.* IGNORE 386REGISTER ^pt[sy]/.* IGNORE
449CHANGE ^pt[sy]/.* IGNORE 387CHANGE ^pt[sy]/.* IGNORE
450CREATE ^pt[sy]/.* IGNORE 388CREATE ^pt[sy]/.* IGNORE
451DELETE ^pt[sy] IGNORE 389DELETE ^pt[sy] IGNORE
452REGISTER ^log IGNORE 390REGISTER ^log IGNORE
461RESTORE /lib/dev-state 399RESTORE /lib/dev-state
462</pre> 400</pre>
463 401
464<p> 402<p>
465In other words, changed device files are copied over to 403In other words, changed device files are copied over to
466<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
467copied over to <path>/dev</path> when booting the system. 405copied over to <path>/dev</path> when booting the system.
468</p> 406</p>
469 407
470<p> 408<p>
471Another possibility is to mount <path>/lib/dev-state</path> on 409Another possibility is to mount <path>/lib/dev-state</path> on
473devfs is not mounted automatically (meaning you'll have to recompile 411devfs is not mounted automatically (meaning you'll have to recompile
474your kernel) and that <path>/dev/console</path> exists. Then, somewhere 412your kernel) and that <path>/dev/console</path> exists. Then, somewhere
475at the beginning of the bootscripts of your system, you place: 413at the beginning of the bootscripts of your system, you place:
476</p> 414</p>
477 415
478<pre caption = "Mounting /lib/dev-state on top of /dev"> 416<pre caption="Mounting /lib/dev-state on top of /dev">
479mount --bind /dev /lib/dev-state 417mount --bind /dev /lib/dev-state
480mount -t devfs none /dev 418mount -t devfs none /dev
481devfsd /dev 419devfsd /dev
482</pre> 420</pre>
483 421
493<p> 431<p>
494For more information on devfs, check out the following resources. 432For more information on devfs, check out the following resources.
495</p> 433</p>
496 434
497<p> 435<p>
498The devfd.conf manpage explains the syntax of the 436The devfsd.conf manpage explains the syntax of the
499<path>/etc/devfsd.conf</path> file. To view it, type <c>man 437<path>/etc/devfsd.conf</path> file. To view it, type <c>man
500devfsd.conf</c>. 438devfsd.conf</c>.
501</p> 439</p>
502 440
503<p> 441<p>
518Daniel Robbins has written a set of articles for IBM's DeveloperWorks 456Daniel Robbins has written a set of articles for IBM's DeveloperWorks
519about Advanced filesystems. Three of them are about devfs: 457about Advanced filesystems. Three of them are about devfs:
520</p> 458</p>
521 459
522<ul> 460<ul>
523<li><uri 461 <li>
524link="http://www-106.ibm.com/developerworks/linux/library/l-fs4/">Introduction 462 <uri link="http://www-106.ibm.com/developerworks/linux/library/l-fs4/">
525to devfs</uri></li> 463 Introduction to devfs</uri>
526<li><uri 464 </li>
465 <li>
527link="http://www-106.ibm.com/developerworks/linux/library/l-fs5/">Setting 466 <uri link="http://www-106.ibm.com/developerworks/linux/library/l-fs5/">
528up devfs</uri></li> 467 Setting up devfs</uri>
529<li><uri 468 </li>
469 <li>
530link="http://www-106.ibm.com/developerworks/linux/library/l-fs6/">Implementing 470 <uri link="http://www-106.ibm.com/developerworks/linux/library/l-fs6/">
531devfs</uri></li> 471 Implementing devfs</uri>
472 </li>
532</ul> 473</ul>
533 474
534</body> 475</body>
535</section> 476</section>
536</chapter> 477</chapter>

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

  ViewVC Help
Powered by ViewVC 1.1.20