Changeset 69993f4 for chapter07/udev.xml


Ignore:
Timestamp:
08/29/2004 06:36:34 PM (20 years ago)
Author:
Gerard Beekmans <gerard@…>
Branches:
6.0
Children:
8b320e7
Parents:
ec0a37e6
Message:

Second round of edits for final release

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/testing/BOOK@4066 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chapter07/udev.xml

    rec0a37e6 r69993f4  
    55]>
    66<sect1 id="ch-scripts-udev">
    7 <title>Device and Module handling on an LFS system</title>
     7<title>Device and Module Handling on an LFS System</title>
    88<?dbhtml filename="udev.html"?>
    99
     
    1212<secondary>usage</secondary></indexterm>
    1313
    14 <para>In <xref linkend="chapter-building-system"/> we installed the udev
    15 package.  Before we go into the details regarding how this does its
    16 job, a brief history of previous methods of handling devices is in
     14<para>In <xref linkend="chapter-building-system"/>, we installed the udev
     15package.  Before we go into the details regarding how this works,
     16a brief history of previous methods of handling devices is in
    1717order.</para>
    1818
     
    2222thousands of nodes), regardless of whether the corresponding hardware
    2323devices actually exist. This is typically done via a
    24 <command>MAKEDEV</command> script, which simply contains a number of
     24<command>MAKEDEV</command> script, which contains a number of
    2525calls to the 'mknod' program with the relevant major and minor device
    2626numbers for every possible device that might exist in the world. Using
    2727the udev method, only those devices which are detected by the kernel
    28 get device nodes created for them. As these device nodes will be
     28get device nodes created for them. Because these device nodes will be
    2929created each time the system boots, they will be stored on a
    3030<systemitem class="filesystem">ramfs</systemitem> (a file system that
     
    3636<title>History</title>
    3737
    38 <para>In Febraury of 2000, a new filesystem called <systemitem
     38<para>In Febraury 2000, a new filesystem called <systemitem
    3939class="filesystem">devfs</systemitem> was merged into the 2.3.46
    40 kernel and was made generally available during the 2.4 series of
     40kernel and was made available during the 2.4 series of
    4141stable kernels.  Although it was present in the kernel source itself,
    4242this method of creating devices dynamically never received
     
    4444
    4545<para>The main problem with the approach adopted by <systemitem
    46 class="filesystem">devfs</systemitem> was the way that it handled
     46class="filesystem">devfs</systemitem> was the way it handled
    4747device detection, creation, and naming. The latter issue, that of
    4848device node naming, was perhaps the most critical. It is generally
    49 accepted that if you are to allow device names to be configurable then
     49accepted that if device names are allowed to be configurable, then
    5050the device naming policy should be up to a system administrator, not
    51 imposed upon them by any particular developer(s). <systemitem
    52 class="filesystem">devfs</systemitem> also suffers from race
    53 conditions that are inherent in its design, and cannot be fixed
     51imposed on them by any particular developer(s). The <systemitem
     52class="filesystem">devfs</systemitem> file system also suffers from race
     53conditions that are inherent in its design and cannot be fixed
    5454without a substantial revision to the kernel. It has also been marked
    5555as deprecated due to a lack of recent maintenance.</para>
    5656
    5757<para>With the development of the unstable 2.5 kernel tree, later
    58 released as the 2.6 series of stable kernels, came a new virtual
    59 filesystem called <systemitem class="filesystem">sysfs</systemitem>.
     58released as the 2.6 series of stable kernels, a new virtual filesystem
     59called <systemitem class="filesystem">sysfs</systemitem> came to be.
    6060The job of <systemitem class="filesystem">sysfs</systemitem> is to
    6161export a view of the system's structure to userspace processes.  With
     
    7272was mentioned briefly above.  One may wonder how <systemitem
    7373class="filesystem">sysfs</systemitem> knows about the devices present
    74 on a system, and what device numbers should be used.  Drivers that
     74on a system and what device numbers should be used.  Drivers that
    7575have been compiled into the kernel directly register their objects
    7676with <systemitem class="filesystem">sysfs</systemitem> as they are
     
    8080<filename class="directory">/sys</filename>), the data which the
    8181built-in drivers registered with <systemitem
    82 class="filesystem">sysfs</systemitem> is available to userspace
     82class="filesystem">sysfs</systemitem> are available to userspace
    8383processes and to <command>udev</command> for device node creation.</para>
    8484
     
    9393match the descriptions.  For example,
    9494<filename>/sys/class/tty/vcs/dev</filename> contains the string
    95 <quote>7:0</quote>.  <command>udevstart</command> uses this to create
    96 <filename>/dev/vcs</filename> with major number <emphasis>7</emphasis>
    97 and minor <emphasis>0</emphasis>.  The permissions of each and every
    98 device that <command>udevstart</command> creates are set using files
    99 from the <filename
     95<quote>7:0</quote> This string is used by <command>udevstart</command>
     96to create <filename>/dev/vcs</filename> with major number
     97<emphasis>7</emphasis> and minor <emphasis>0</emphasis>.  The
     98permissions of each and every device that <command>udevstart</command>
     99creates are set using files from the <filename
    100100class="directory">/etc/udev.d/permissions.d/</filename> directory.
    101101These are numbered in a similar fashion to the LFS bootscripts.  If
     
    110110
    111111<para>Once the above stage is complete, all devices that were already
    112 present and have compiled-in drivers will be available for use. How
     112present and have compiled-in drivers will be available for use. What
    113113about those devices that have modular drivers?</para>
    114114
    115 <para>We mentioned earlier the concept of a <quote>hotplug event
    116 handler</quote>. When a new device connection is detected by the
     115<para>Earlier, we mentioned the concept of a <quote>hotplug event
     116handler.</quote> When a new device connection is detected by the
    117117kernel, the kernel will generate a hotplug event and look at the file
    118118<filename>/proc/sys/kernel/hotplug</filename> to find out the
    119 userspace program to handle that device's connection.  The
     119userspace program that handles the device's connection.  The
    120120<command>udev</command> initscript registered <command>udev</command>
    121121as this handler. When these hotplug events are generated, the kernel
    122122will tell <command>udev</command> to check the <filename
    123123class="directory">/sys</filename> filesystem for the information
    124 pertaining to this new device, and create the <filename
     124pertaining to this new device and create the <filename
    125125class="directory">/dev</filename> entry for it.</para>
    126126
     
    135135the module is loaded.  To solve this, the
    136136<command>S05modules</command> bootscript was added to the
    137 lfs-bootscripts package along with the
     137lfs-bootscripts package, along with the
    138138<filename>/etc/sysconfig/modules</filename> file.  By adding module
    139139names to the <filename>modules</filename> file, these modules will be
     
    142142appropriate device nodes.</para>
    143143
    144 <para>Note that on slower machines, or for drivers that create a lot
     144<para>Note that on slower machines or for drivers that create a lot
    145145of device nodes, the process of creating devices may take a few
    146146seconds to complete. This means that some device nodes may not be
     
    149149
    150150<sect2>
    151 <title>Handling hotpluggable/dynamic devices</title>
    152 
    153 <para>When you plug in a device, e.g. a USB MP3 player, the kernel
     151<title>Handling Hotpluggable/Dynamic Devices</title>
     152
     153<para>When you plug in a device, such a Universal Serial Bus (USB) MP3 player, the kernel
    154154recognizes that the device is now connected and generates a hotplug
    155155event. If the driver is already loaded (either because it was compiled
    156 into the kernel, or it was loaded via the
    157 <command>S05modules</command> bootscript) <command>udev</command> will
     156into the kernel or because it was loaded via the
     157<command>S05modules</command> bootscript), <command>udev</command> will
    158158be called upon to create the relevant device node(s) according to the
    159159<systemitem class="filesystem">sysfs</systemitem> data available in
     
    166166yet.</para>
    167167
    168 <para>If you are building a system that has a lot of drivers compiled
    169 as modules rather than directly built into the kernel and using the
    170 <command>S05modules</command> is not practical then the Hotplug
     168<para>If building a system that has a lot of drivers compiled as
     169modules rather than directly built into the kernel, using the
     170<command>S05modules</command> may not be practical. The Hotplug
    171171package (see <ulink url="http://linux-hotplug.sourceforge.net/"/>) can
    172 be beneficial. When the Hotplug package is installed it will respond
    173 to the aforementioned kernel's bus driver hotplug events. The Hotplug
    174 package will load the appropriate module and make this device
    175 available by creating the device node(s) for it.</para>
    176 </sect2>
    177 
    178 <sect2>
    179 <title>Problems with creating devices</title>
    180 
    181 <para>There are a few problems when it comes to automatically creating
     172be beneficial in these cases. When the Hotplug package is installed,
     173it will respond to the aforementioned kernel's bus driver hotplug
     174events. The Hotplug package will load the appropriate module and make
     175this device available by creating the device node(s) for it.</para>
     176</sect2>
     177
     178<sect2>
     179<title>Problems with Creating Devices</title>
     180
     181<para>There are a few known problems when it comes to automatically creating
    182182devices nodes:</para>
    183183
    184184<para>1) A kernel driver may not export its data to sysfs</para>
    185185   
    186 <para>This is most common with 3rd party drivers from outside the
     186<para>This is most common with third party drivers from outside the
    187187kernel tree.  These drivers will not end up having their device nodes
    188 created.  You can use the
     188created.  Use the
    189189<filename>/etc/sysconfig/createfiles</filename> configuration file to
    190190manually create the devices. Consult the
    191 <filename>devices.txt</filename> file inside your kernel documentation
     191<filename>devices.txt</filename> file inside the kernel documentation
    192192or the documentation for that driver to find the proper major/minor
    193193numbers.</para>
    194194
    195 <para>2) A non-hardware device is required.  This is most common with the
    196 ALSA project's OSS compatibility module.  These types of devices can
    197 be handled in one of two ways:</para>
     195<para>2) A non-hardware device is required.  This is most common with
     196the Advanced Linux Sound Architecture (ALSA) project's Open Sound
     197System (OSS) compatibility module.  These types of devices can be
     198handled in one of two ways:</para>
    198199
    199200<itemizedlist>
     
    201202<listitem><para>Adding the module names to
    202203<filename>/etc/sysconfig/modules</filename></para></listitem>
    203 <listitem><para>Use of an
     204<listitem><para>Using an
    204205<quote>install</quote> line in
    205 <filename>/etc/modprobe.conf</filename>. Basically, this tells the
     206<filename>/etc/modprobe.conf</filename>. This tells the
    206207modprobe command <quote>when loading this module, also load this other
    207208module, at the same time.</quote>  For example:</para>
     
    217218
    218219<sect2>
    219 <title>Useful reading</title>
    220 
    221 <para>Some additional documentation that will be useful to
    222 read:</para>
     220<title>Useful Reading</title>
     221
     222<para>Additional helpful documentation is available at the following
     223sites:</para>
    223224
    224225<itemizedlist>
Note: See TracChangeset for help on using the changeset viewer.