I'm working on rewriting part of Section 7.4 - Device and Module 
Handling on an LFS System.  This is what I have right now, but would 
like comments.

   -- Bruce

7.4.1. History (unchanged)

7.4.2. Udev Implementation

7.4.2.1. Sysfs

The sysfs filesystem was mentioned briefly above. One may wonder how
sysfs knows about the devices present on a system and what device
numbers should be used for them. Drivers that have been compiled into
the kernel directly register their objects with a sysfs (devtmpfs 
internally) as they are detected by the kernel. For drivers compiled as 
modules, this registration will happen when the module is loaded. Once 
the sysfs filesystem is mounted (on /sys), data which the drivers
register with sysfs are available to userspace processes and to udevd
for processing (including modifications to device nodes).

7.4.2.2. Device Node Creation

In recent version of udev, udevd no longer creates device files.
Instead, this is handled in the kernel by the devtmpfs filesystem. Any
driver that wishes to register a device node will go through devtmpfs
(via the driver core) to do it. When a devtmpfs instance is mounted on
/dev, the device node will initially be created with a fixed name,
permissions, and owner.

A short time later, the kernel will send a uevent to udevd. Based on the
rules specified in the files within the /etc/udev/rules.d,
/lib/udev/rules.d, and /run/udev/rules.d directories, udevd will create
additional symlinks to the device node, change its permissions,
owner, or group, or modify the /sys filesystem entry (name) for that
object.

The rules in these three directories are numbered in a similar fashion
to the LFS-Bootscripts package, and all three directories are merged
together. If udevd can't find a rule for the device it is creating, it
will leave the permissions and ownership at whatever devtmpfs used
initially.

7.4.2.3. Udev Bootscripts

The first LFS bootscript, /etc/init.d/mountvirtfs will copy any devices
located in /lib/udev/devices to /dev. This is necessary because some 
devices, directories, and symlinks are needed before the dynamic  device 
handling processes are available during the early stages of
booting a system, or are required by udevd itself. Creating static 
device nodes in /lib/udev/devices also provides an easy workaround for 
any devices that may not be supported by the dynamic device handling 
infrastructure.

The /etc/rc.d/init.d/udev initscript starts udevd, triggers any 
"coldplug" devices that have already been created by the kernel and 
waits for any rules to complete. The script also unsets the uevent 
handler from the default of /sbin/hotplug.  This is done because the 
kernel no longer needs to call out to an external binary.  Instead udevd 
will listen on a netlink socket for uevents that the kernel raises.

The /etc/rc.d/init.d/udev_retry initscript takes care of re-triggering 
events for subsystems whose rules may rely on filesystems that are not 
mounted until the mountfs script is run (in particular, /usr and /var 
may cause this).  This script runs after the mountfs script, so those 
rules (if re-triggered) should succeed the second time around.  It is 
configured from the /etc/sysconfig/udev_retry file; any words in this 
file other than comments are considered subsystem names to trigger at 
retry time.  To find the subsystem of a device, use 'udevadm info 
--attribute-walk <device>' where <device> is a an absolure path in /dev 
or /sys such as /dev/sr0 or /sys/class/rtc.

7.4.2.4. Module Loading (unchanged)
...
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to