From d2c332bc21267f5e01cb545d3f01cae1dcacdae3 Mon Sep 17 00:00:00 2001 From: Archaic Date: Thu, 13 Apr 2006 18:45:33 +0000 Subject: Merged the udev_update branch to trunk. git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@7509 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689 --- chapter06/udev.xml | 233 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 168 insertions(+), 65 deletions(-) (limited to 'chapter06/udev.xml') diff --git a/chapter06/udev.xml b/chapter06/udev.xml index 96d2ec579..f78ab1cec 100644 --- a/chapter06/udev.xml +++ b/chapter06/udev.xml @@ -26,7 +26,7 @@ 0.1 SBU - 3.8 MB + 4.8 MB @@ -43,19 +43,31 @@ Installation of Udev + Create some devices and directories that Udev cannot handle due to + them being required very early in the boot process: + +install -dv /lib/{firmware,udev/devices/{pts,shm}} +mknod -m0666 /lib/udev/devices/null c 1 3 +ln -sv /proc/self/fd /lib/udev/devices/fd +ln -sv /proc/self/fd/0 /lib/udev/devices/stdin +ln -sv /proc/self/fd/1 /lib/udev/devices/stdout +ln -sv /proc/self/fd/2 /lib/udev/devices/stderr +ln -sv /proc/kcore /lib/udev/devices/core + Compile the package: -make EXTRAS=extras/run_directory +make EXTRAS="extras/ata_id extras/cdrom_id extras/edd_id \ + extras/firmware extras/floppy extras/scsi_id \ + extras/usb_id extras/volume_id" The meaning of the make option: - EXTRAS=extras/run_directory + EXTRAS=... - This builds the udev_run_devd and - udev_run_hotplugd binaries, which are required - for correct handling of hotpluggable devices. + This builds several helper binaries that can aid in writing custom + Udev rules. @@ -66,7 +78,10 @@ Install the package: -make DESTDIR=/ EXTRAS=extras/run_directory install +make DESTDIR=/ \ + EXTRAS="extras/ata_id extras/cdrom_id extras/edd_id \ + extras/firmware extras/floppy extras/scsi_id \ + extras/usb_id extras/volume_id" install The meaning of the make parameter: @@ -87,16 +102,78 @@ cp -v ../&udev-config-file; /etc/udev/rules.d/25-lfs.rules + Create some rules that work around broken sysfs attribute creation + timing in linux-2.6.15: + +cat >> /etc/udev/rules.d/10-wait_for_sysfs.rules << "EOF" +ACTION=="add", DEVPATH=="/devices/*", ENV{PHYSDEVBUS}=="?*", WAIT_FOR_SYSFS="bus" +ACTION=="add", SUBSYSTEM=="net", WAIT_FOR_SYSFS="address" +EOF + Install the documentation that explains how to create Udev rules: install -m644 -D -v docs/writing_udev_rules/index.html /usr/share/doc/udev-&udev-version;/index.html - - - Run the udevstart program to create our full - complement of device nodes. - -/sbin/udevstart + + + When Udev is started by the LFS-Bootscripts, a replay of all kernel + device events happens. These events tell Udev what devices exist. + Sometimes the Udev bootscript doesn't wait long enough for + udevd to process all of the replayed events and + consequently the devices for those missed events are not created before the + script exits. Since udevd is still running in the + background, the devices will be created a few milliseconds later, but the + next bootscript to run may require a device to exist before it has been + created. To avoid such missed events, and to avoid hardcoding an overly + long wait time, It is recommended that you run the following commands to + aid the LFS development team in debugging these missed events and finding + an acceptable solution more quickly. + + First, create a simple C file: + +cat > bug.c << EOF +/* Simple event recorder */ +#define _GNU_SOURCE +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include <stdlib.h> +#include <argz.h> +int main(int argc, char * argv[]) +{ + char * envz; + size_t len; + int bug; + bug = open("/dev/bug", O_WRONLY | O_APPEND); + if (bug == -1) + return 0; + setenv("_SEPARATOR", "--------------------------------------", 1); + argz_create(environ, &envz, &len); + argz_stringify(envz, len, '\n'); + envz[len-1]='\n'; + write(bug, envz, len); + close(bug); + free(envz); + return 0; +} +EOF + + Now compile it: + +gcc -o /lib/udev/bug bug.c + + The next step adds a simple logging rule to run this program. + +cat > /etc/udev/rules.d/90-bug.rules << "EOF" +ACTION=="add", RUN+="bug" +EOF + + When booting the new LFS system, if any events are missed, a warning + message will appear and a /dev/bugreport file will be + created. The warning message will tell you where to send feedback. + + @@ -108,8 +185,9 @@ Installed directory - udev, udev_run_devd, udev_run_hotplugd, udevcontrol, udevd, - udevinfo, udevmonitor, udevsend, udevstart, and udevtest + ata_id, cdrom_id, create_floppy_devices, edd_id, firmware_helper, + scsi_id, udevcontrol, udevd, udevinfo, udevmonitor, udevtest, usb_id + and vol_id /etc/udev @@ -119,38 +197,66 @@ - - udev + + ata_id + + Provides Udev with a unique string and + additional information (uuid, label) for an ATA drive + + ata_id + + + + + + cdrom_id + + Provides Udev with the capabilities of a + CD-ROM or DVD-ROM drive + + cdrom_id + + + + + + create_floppy_devices - Creates device nodes in /dev - or renames network interfaces (not in LFS) in response to hotplug - events - - udev + Creates all possible floppy devices based on the CMOS type + + create_floppy_devices - - udev_run_devd + + edd_id - Executes programs and scripts in the /etc/dev.d/ directory in response to - hotplug events - - udev_run_devd + Provides Udev with the EDD ID for a BIOS disk drive + + edd_id - - udev_run_hotplugd + + firmware_helper - Executes programs and scripts in the /etc/hotplug.d/ directory in response - to hotplug events - - udev_run_hotplugd + Uploads firmware to devices + + firmware_helper + + + + + + scsi_id + + Provides Udev with a unique SCSI identifier + based on the data returned from sending a SCSI INQUIRY command to + the specified device + + scsi_id @@ -169,8 +275,9 @@ udevd - A daemon that reorders hotplug events before submitting them to - udev, thus avoiding various race conditions + A daemon that listens for uevents on the netlink socket, + creates devices and runs the configured external programs in + response to these uevents udevd @@ -180,7 +287,7 @@ udevinfo - Allows users to query the udev database for + Allows users to query the Udev database for information on any device currently present on the system; it also provides a way to query any device in the sysfs tree to help create udev @@ -194,48 +301,44 @@ udevmonitor - Prints the event received from the kernel and the event which - udev sends out after rule processing + Prints the event received from the kernel and the environment + which Udev sends out after rule processing udevmonitor - - udevsend + + udevtest - Delivers hotplug events to udevd - - udevsend + Simulates a uevent for the given device, and prints out the + name of the node the real udevd would have created, + or the name of the renamed network interface + + udevtest - - udevstart + + usb_id - Creates device nodes in /dev - that correspond to drivers compiled directly into the kernel; it - performs that task by simulating hotplug events presumably dropped by - the kernel before invocation of this program (e.g., because the root - filesystem has not been mounted) and submitting such synthetic hotplug - events to udev - - udevstart + Provides Udev with information about USB + devices + + usb_id - - udevtest + + vol_id - Simulates a udev run for the given device, - and prints out the name of the node the real udev - would have created or (not in LFS) the name of the renamed network - interface - - udevtest + Provides Udev with the label and uuid of a + filesystem + + vol_id @@ -243,7 +346,7 @@ /etc/udev - Contains udev configuation files, + Contains Udev configuation files, device permissions, and rules for device naming /etc/udev -- cgit v1.2.3-54-g00ecf