Changeset b568bbaf for chapter07/udev.xml
- Timestamp:
- 07/02/2005 05:16:45 PM (19 years ago)
- Branches:
- 6.1, 6.1.1
- Children:
- b8a3fb2
- Parents:
- 464fa64f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
chapter07/udev.xml
r464fa64f rb568bbaf 13 13 14 14 <para>In <xref linkend="chapter-building-system"/>, we installed the Udev 15 package. 15 package. Before we go into the details regarding how this works, 16 16 a brief history of previous methods of handling devices is in 17 17 order.</para> 18 18 19 <para>Linux systems in general traditionally use a static device 20 creation method, whereby a great many device nodes are created under 21 <filename class="directory">/dev</filename> (sometimes literally 22 thousands of nodes), regardless of whether the corresponding hardware 23 devices actually exist. This is typically done via a 24 <command>MAKEDEV</command> script, which contains a number of 25 calls to the <command>mknod</command> program with the relevant major and minor device 26 numbers for every possible device that might exist in the world. Using 27 the udev method, only those devices which are detected by the kernel 28 get device nodes created for them. Because these device nodes will be 29 created each time the system boots, they will be stored on a 30 <systemitem class="filesystem">tmpfs</systemitem> (a file system that 31 resides entirely in memory and does not take up any disk space). 32 Device nodes do not require much disk space, so the memory that is 33 used is negligible.</para> 19 <para>Linux systems in general traditionally use a static device creation 20 method, whereby a great many device nodes are created under <filename 21 class="directory">/dev</filename> (sometimes literally thousands of nodes), 22 regardless of whether the corresponding hardware devices actually exist. This is 23 typically done via a <command>MAKEDEV</command> script, which contains a number 24 of calls to the <command>mknod</command> program with the relevant major and 25 minor device numbers for every possible device that might exist in the world. 26 Using the Udev method, only those devices which are detected by the kernel get 27 device nodes created for them. Because these device nodes will be created each 28 time the system boots, they will be stored on a <systemitem 29 class="filesystem">tmpfs</systemitem> file system (a virtual file system that 30 resides entirely in system memory). Device nodes do not require much space, so 31 the memory that is used is negligible.</para> 34 32 35 33 <sect2> … … 55 53 as deprecated due to a lack of recent maintenance.</para> 56 54 57 <para>With the development of the unstable 2.5 kernel tree, later 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 The job of <systemitem class="filesystem">sysfs</systemitem> is to 61 export a view of the system's structure to userspace processes. With 62 this userspace visible representation, the possibility of seeing a 63 userspace replacement for <systemitem 64 class="filesystem">devfs</systemitem> became much more 55 <para>With the development of the unstable 2.5 kernel tree, later released as 56 the 2.6 series of stable kernels, a new virtual filesystem called <systemitem 57 class="filesystem">sysfs</systemitem> came to be. The job of <systemitem 58 class="filesystem">sysfs</systemitem> is to export a view of the system's 59 hardrware configuration to userspace processes. With this userspace-visible 60 representation, the possibility of seeing a userspace replacement for 61 <systemitem class="filesystem">devfs</systemitem> became much more 65 62 realistic.</para> 63 66 64 </sect2> 67 65 … … 69 67 <title>Udev Implementation</title> 70 68 71 <para>The <systemitem class="filesystem">sysfs</systemitem> filesystem 72 was mentioned briefly above. One may wonder how <systemitem 73 class="filesystem">sysfs</systemitem> knows about the devices present 74 on a system and what device numbers should be used. Drivers that 75 have been compiled into the kernel directly register their objects 76 with <systemitem class="filesystem">sysfs</systemitem> as they are 77 detected by the kernel. For drivers compiled as modules, this will 78 happen when the module is loaded. Once the <systemitem 79 class="filesystem">sysfs</systemitem> filesystem is mounted (on 80 <filename class="directory">/sys</filename>), data which the 69 <para>The <systemitem class="filesystem">sysfs</systemitem> filesystem was 70 mentioned briefly above. One may wonder how <systemitem 71 class="filesystem">sysfs</systemitem> knows about the devices present on a 72 system and what device numbers should be used for them. Drivers that have been 73 compiled into the kernel directly register their objects with <systemitem 74 class="filesystem">sysfs</systemitem> as they are detected by the kernel. For 75 drivers compiled as modules, this registration will happen when the module is 76 loaded. Once the <systemitem class="filesystem">sysfs</systemitem> filesystem is 77 mounted (on <filename class="directory">/sys</filename>), data which the 81 78 built-in drivers registered with <systemitem 82 class="filesystem">sysfs</systemitem> are available to userspace 83 processes andto <command>udev</command> for device node creation.</para>79 class="filesystem">sysfs</systemitem> are available to userspace processes and 80 to <command>udev</command> for device node creation.</para> 84 81 85 82 <para>The <command>S10udev</command> initscript takes care of creating these 86 device nodes when Linux is booted. This script starts withregistering87 <command>/sbin/udevsend</command> as a hotplug event handler. 88 (discussed below) should not begenerated during this stage, but89 <command>udev</command> is registered just in case they do occur. 83 device nodes when Linux is booted. This script starts by registering 84 <command>/sbin/udevsend</command> as a hotplug event handler. Hotplug events 85 (discussed below) are not usually generated during this stage, but 86 <command>udev</command> is registered just in case they do occur. The 90 87 <command>udevstart</command> program then walks through the <systemitem 91 88 class="filesystem">/sys</systemitem> filesystem and creates devices under 92 <filename class="directory">/dev</filename> that match the descriptions. 89 <filename class="directory">/dev</filename> that match the descriptions. For 93 90 example, <filename>/sys/class/tty/vcs/dev</filename> contains the string 94 91 <quote>7:0</quote> This string is used by <command>udevstart</command> to create 95 92 <filename>/dev/vcs</filename> with major number <emphasis>7</emphasis> and minor 96 <emphasis>0</emphasis>. 93 <emphasis>0</emphasis>. The names and permissions of the nodes created under 97 94 the <filename class="directory">/dev</filename> directory are configured 98 95 according to the rules specified in the files within the <filename … … 102 99 <emphasis>660</emphasis> and ownership to <emphasis>root:root</emphasis>.</para> 103 100 104 <para>Once the above stage is complete, all devices that were already 105 present and have compiled-in drivers will be available for use. What 106 about those devices that have modular drivers?</para>101 <para>Once the above stage is complete, all devices that were already present 102 and have compiled-in drivers will be available for use. This leads us to the 103 devices that have modular drivers.</para> 107 104 108 105 <para>Earlier, we mentioned the concept of a <quote>hotplug event 109 handler.</quote> When a new device connection is detected by the 110 kernel, the kernel will generate a hotplug event and look at the file 111 <filename>/proc/sys/kernel/hotplug</filename> to find out the 112 userspace program that handles the device's connection. The 113 <command>udev</command> initscript registered <command>udevsend</command> 114 as this handler. When these hotplug events are generated, the kernel 115 will tell <command>udev</command> to check the <filename 116 class="directory">/sys</filename> filesystem for the information 106 handler.</quote> When a new device connection is detected by the kernel, the 107 kernel will generate a hotplug event and look at the file 108 <filename>/proc/sys/kernel/hotplug</filename> to determine the userspace program 109 that handles the device's connection. The <command>udev</command> bootscript 110 registered <command>udevsend</command> as this handler. When these hotplug 111 events are generated, the kernel will tell <command>udev</command> to check the 112 <filename class="directory">/sys</filename> filesystem for the information 117 113 pertaining to this new device and create the <filename 118 114 class="directory">/dev</filename> entry for it.</para> 119 115 120 <para>This brings us to one problem that exists with 121 <command>udev</command>, and likewise with <systemitem 122 class="filesystem">devfs</systemitem> before it. It is commonly 123 referred to as the <quote>chicken and egg</quote> problem. Most Linux 124 distributions handle loading modules via entries in 125 <filename>/etc/modules.conf</filename>. Access to a device node causes 126 the appropriate kernel module to load. With <command>udev</command>, 127 this method will not work because the device node does not exist until 128 the module is loaded. To solve this, the 129 <command>S05modules</command> bootscript was added to the 116 <para>This brings us to one problem that exists with <command>udev</command>, 117 and likewise with <systemitem class="filesystem">devfs</systemitem> before it. 118 It is commonly referred to as the <quote>chicken and egg</quote> problem. Most 119 Linux distributions handle loading modules via entries in 120 <filename>/etc/modules.conf</filename>. Access to a device node causes the 121 appropriate kernel module to load. With <command>udev</command>, this method 122 will not work because the device node does not exist until the module is loaded. 123 To solve this, the <command>S05modules</command> bootscript was added to the 130 124 LFS-Bootscripts package, along with the 131 <filename>/etc/sysconfig/modules</filename> file. By 132 adding module 133 names to the <filename>modules</filename> file, these modules will be 134 loaded when the computer is starting up. This allows 135 <command>udev</command> to detect the devices and create the 136 appropriate device nodes.</para> 125 <filename>/etc/sysconfig/modules</filename> file. By adding module names to the 126 <filename>modules</filename> file, these modules will be loaded when the 127 computer is starts up. This allows <command>udev</command> to detect the devices 128 and create the appropriate device nodes.</para> 137 129 138 130 <para>Note that on slower machines or for drivers that create a lot … … 168 160 class="filesystem">sysfs</systemitem>.</para> 169 161 170 <para>This is most common with third party drivers from outside the 171 kernel tree. These drivers will not end up having their device nodes 172 created. Use the 173 <filename>/etc/sysconfig/createfiles</filename> configuration file to 174 manually create the devices. Consult the 175 <filename>devices.txt</filename> file inside the kernel documentation 176 or the documentation for that driver to find the proper major/minor 177 numbers.</para> 162 <para>This is most common with third party drivers from outside the kernel tree. 163 Udev will be unable to automatically create device nodes for such drivers. Use 164 the <filename>/etc/sysconfig/createfiles</filename> configuration file to 165 manually create the devices. Consult the <filename>devices.txt</filename> file 166 inside the kernel documentation or the documentation for that driver to find the 167 proper major/minor numbers.</para> 178 168 179 169 <para>2) A non-hardware device is required. This is most common with
Note:
See TracChangeset
for help on using the changeset viewer.