Changeset 69993f4 for chapter07/udev.xml
- Timestamp:
- 08/29/2004 06:36:34 PM (20 years ago)
- Branches:
- 6.0
- Children:
- 8b320e7
- Parents:
- ec0a37e6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
chapter07/udev.xml
rec0a37e6 r69993f4 5 5 ]> 6 6 <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> 8 8 <?dbhtml filename="udev.html"?> 9 9 … … 12 12 <secondary>usage</secondary></indexterm> 13 13 14 <para>In <xref linkend="chapter-building-system"/> we installed the udev15 package. Before we go into the details regarding how this does its16 job,a brief history of previous methods of handling devices is in14 <para>In <xref linkend="chapter-building-system"/>, we installed the udev 15 package. Before we go into the details regarding how this works, 16 a brief history of previous methods of handling devices is in 17 17 order.</para> 18 18 … … 22 22 thousands of nodes), regardless of whether the corresponding hardware 23 23 devices actually exist. This is typically done via a 24 <command>MAKEDEV</command> script, which simplycontains a number of24 <command>MAKEDEV</command> script, which contains a number of 25 25 calls to the 'mknod' program with the relevant major and minor device 26 26 numbers for every possible device that might exist in the world. Using 27 27 the udev method, only those devices which are detected by the kernel 28 get device nodes created for them. Asthese device nodes will be28 get device nodes created for them. Because these device nodes will be 29 29 created each time the system boots, they will be stored on a 30 30 <systemitem class="filesystem">ramfs</systemitem> (a file system that … … 36 36 <title>History</title> 37 37 38 <para>In Febraury of2000, a new filesystem called <systemitem38 <para>In Febraury 2000, a new filesystem called <systemitem 39 39 class="filesystem">devfs</systemitem> was merged into the 2.3.46 40 kernel and was made generallyavailable during the 2.4 series of40 kernel and was made available during the 2.4 series of 41 41 stable kernels. Although it was present in the kernel source itself, 42 42 this method of creating devices dynamically never received … … 44 44 45 45 <para>The main problem with the approach adopted by <systemitem 46 class="filesystem">devfs</systemitem> was the way thatit handled46 class="filesystem">devfs</systemitem> was the way it handled 47 47 device detection, creation, and naming. The latter issue, that of 48 48 device node naming, was perhaps the most critical. It is generally 49 accepted that if you are to allow device names to be configurablethen49 accepted that if device names are allowed to be configurable, then 50 50 the device naming policy should be up to a system administrator, not 51 imposed upon them by any particular developer(s).<systemitem52 class="filesystem">devfs</systemitem> also suffers from race53 conditions that are inherent in its design ,and cannot be fixed51 imposed on them by any particular developer(s). The <systemitem 52 class="filesystem">devfs</systemitem> file system also suffers from race 53 conditions that are inherent in its design and cannot be fixed 54 54 without a substantial revision to the kernel. It has also been marked 55 55 as deprecated due to a lack of recent maintenance.</para> 56 56 57 57 <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 virtual59 filesystem called <systemitem class="filesystem">sysfs</systemitem>.58 released as the 2.6 series of stable kernels, a new virtual filesystem 59 called <systemitem class="filesystem">sysfs</systemitem> came to be. 60 60 The job of <systemitem class="filesystem">sysfs</systemitem> is to 61 61 export a view of the system's structure to userspace processes. With … … 72 72 was mentioned briefly above. One may wonder how <systemitem 73 73 class="filesystem">sysfs</systemitem> knows about the devices present 74 on a system ,and what device numbers should be used. Drivers that74 on a system and what device numbers should be used. Drivers that 75 75 have been compiled into the kernel directly register their objects 76 76 with <systemitem class="filesystem">sysfs</systemitem> as they are … … 80 80 <filename class="directory">/sys</filename>), the data which the 81 81 built-in drivers registered with <systemitem 82 class="filesystem">sysfs</systemitem> isavailable to userspace82 class="filesystem">sysfs</systemitem> are available to userspace 83 83 processes and to <command>udev</command> for device node creation.</para> 84 84 … … 93 93 match the descriptions. For example, 94 94 <filename>/sys/class/tty/vcs/dev</filename> contains the string 95 <quote>7:0</quote> . <command>udevstart</command> uses this to create96 <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 <filename95 <quote>7:0</quote> This string is used by <command>udevstart</command> 96 to create <filename>/dev/vcs</filename> with major number 97 <emphasis>7</emphasis> and minor <emphasis>0</emphasis>. The 98 permissions of each and every device that <command>udevstart</command> 99 creates are set using files from the <filename 100 100 class="directory">/etc/udev.d/permissions.d/</filename> directory. 101 101 These are numbered in a similar fashion to the LFS bootscripts. If … … 110 110 111 111 <para>Once the above stage is complete, all devices that were already 112 present and have compiled-in drivers will be available for use. How112 present and have compiled-in drivers will be available for use. What 113 113 about those devices that have modular drivers?</para> 114 114 115 <para> We mentioned earlierthe concept of a <quote>hotplug event116 handler </quote>.When a new device connection is detected by the115 <para>Earlier, we mentioned the concept of a <quote>hotplug event 116 handler.</quote> When a new device connection is detected by the 117 117 kernel, the kernel will generate a hotplug event and look at the file 118 118 <filename>/proc/sys/kernel/hotplug</filename> to find out the 119 userspace program t o handle thatdevice's connection. The119 userspace program that handles the device's connection. The 120 120 <command>udev</command> initscript registered <command>udev</command> 121 121 as this handler. When these hotplug events are generated, the kernel 122 122 will tell <command>udev</command> to check the <filename 123 123 class="directory">/sys</filename> filesystem for the information 124 pertaining to this new device ,and create the <filename124 pertaining to this new device and create the <filename 125 125 class="directory">/dev</filename> entry for it.</para> 126 126 … … 135 135 the module is loaded. To solve this, the 136 136 <command>S05modules</command> bootscript was added to the 137 lfs-bootscripts package along with the137 lfs-bootscripts package, along with the 138 138 <filename>/etc/sysconfig/modules</filename> file. By adding module 139 139 names to the <filename>modules</filename> file, these modules will be … … 142 142 appropriate device nodes.</para> 143 143 144 <para>Note that on slower machines ,or for drivers that create a lot144 <para>Note that on slower machines or for drivers that create a lot 145 145 of device nodes, the process of creating devices may take a few 146 146 seconds to complete. This means that some device nodes may not be … … 149 149 150 150 <sect2> 151 <title>Handling hotpluggable/dynamic devices</title>152 153 <para>When you plug in a device, e.g. a USBMP3 player, the kernel151 <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 154 154 recognizes that the device is now connected and generates a hotplug 155 155 event. If the driver is already loaded (either because it was compiled 156 into the kernel , orit was loaded via the157 <command>S05modules</command> bootscript) <command>udev</command> will156 into the kernel or because it was loaded via the 157 <command>S05modules</command> bootscript), <command>udev</command> will 158 158 be called upon to create the relevant device node(s) according to the 159 159 <systemitem class="filesystem">sysfs</systemitem> data available in … … 166 166 yet.</para> 167 167 168 <para>If you are building a system that has a lot of drivers compiled169 as modules rather than directly built into the kernel andusing the170 <command>S05modules</command> is not practical then the Hotplug168 <para>If building a system that has a lot of drivers compiled as 169 modules rather than directly built into the kernel, using the 170 <command>S05modules</command> may not be practical. The Hotplug 171 171 package (see <ulink url="http://linux-hotplug.sourceforge.net/"/>) can 172 be beneficial . When the Hotplug package is installed it will respond173 to the aforementioned kernel's bus driver hotplug events. The Hotplug174 package will load the appropriate module and make this device175 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 creating172 be beneficial in these cases. When the Hotplug package is installed, 173 it will respond to the aforementioned kernel's bus driver hotplug 174 events. The Hotplug package will load the appropriate module and make 175 this 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 182 182 devices nodes:</para> 183 183 184 184 <para>1) A kernel driver may not export its data to sysfs</para> 185 185 186 <para>This is most common with 3rd party drivers from outside the186 <para>This is most common with third party drivers from outside the 187 187 kernel tree. These drivers will not end up having their device nodes 188 created. You can use the188 created. Use the 189 189 <filename>/etc/sysconfig/createfiles</filename> configuration file to 190 190 manually create the devices. Consult the 191 <filename>devices.txt</filename> file inside yourkernel documentation191 <filename>devices.txt</filename> file inside the kernel documentation 192 192 or the documentation for that driver to find the proper major/minor 193 193 numbers.</para> 194 194 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 196 the Advanced Linux Sound Architecture (ALSA) project's Open Sound 197 System (OSS) compatibility module. These types of devices can be 198 handled in one of two ways:</para> 198 199 199 200 <itemizedlist> … … 201 202 <listitem><para>Adding the module names to 202 203 <filename>/etc/sysconfig/modules</filename></para></listitem> 203 <listitem><para>Us e ofan204 <listitem><para>Using an 204 205 <quote>install</quote> line in 205 <filename>/etc/modprobe.conf</filename>. Basically, this tells the206 <filename>/etc/modprobe.conf</filename>. This tells the 206 207 modprobe command <quote>when loading this module, also load this other 207 208 module, at the same time.</quote> For example:</para> … … 217 218 218 219 <sect2> 219 <title>Useful reading</title>220 221 <para> Some additional documentation that will be useful to222 read:</para>220 <title>Useful Reading</title> 221 222 <para>Additional helpful documentation is available at the following 223 sites:</para> 223 224 224 225 <itemizedlist>
Note:
See TracChangeset
for help on using the changeset viewer.