svn-testing comments

Bryan Kadzban bryan at kadzban.is-a-geek.net
Wed Jul 14 10:19:02 PDT 2004


On Wed, Jul 14, 2004 at 05:24:42PM +0100, Matthew Burgess wrote:
> On Wed, 14 Jul 2004 00:26:13 -0500
> Bruce Dubbs <bdubbs at swbell.net> wrote:
> 
> > As it stands right now, the book essentially says:
> >    "Do this--and magic occurs".
> 
> Right, this is Bug #853 and is partially solved by
> http://www.linuxfromscratch.org/~matthew/lfs_udev.txt.  I just need
> someone who actually knows what they're talking about to neaten the
> remaining points up. (Those marked by "QUESTION" and "FIXME" remarks).

lfs_udev.txt says:
> --- QUESTION ---
> Is the sysfs registration really done during bootup (implies it's
> bootscript driven) or is it during the kernel loading stage?  I'd
> imagine it's the latter.
> --- QUESTION ---

It depends on the specific driver, but all of them that I've ever looked
at do the registration as part of their init function.  That would be
when the kernel loads, or when the module loads if that specific driver
was built as a module.

> --- QUESTION ---
> We mention 'hotplug events' and 'hotplug event handlers' above - do we
> need to describe what they are?
> --- QUESTION ---

Might not hurt.  But that's more of a policy-type thing (the answer to
the question isn't technical in nature).  If you want to, this is what I
can come up with:

Hotplug events are implemented with a call to a userspace program, with
a defined set of environment variables set to specific values that
depend on the event.  The default program is /sbin/hotplug, but we just
changed it by writing to /proc/sys/kernel/hotplug, so that udev is
called instead.

When udev gets called, it inspects the environment to find out which
device generated the hotplug event.  Then it inspects that device's
sysfs entry (if one exists) to find out which device node type
(character or block) and major/minor pair should be used.  Then it
creates the required device node in its tree.

> --- FIXME ---
> Here we need to mention the S05modules bootscript that will actually
> load the module during bootup.  Now, does the 'modprobe' that the
> S05modules bootscript perform generate a hotplug event that udev will
> detect and act upon?  Or does the user need to use the 'createfiles'
> script to create the device?  We also need to mention the fact that
> there is a possibility that even though the module has been loaded,
> the device node may not be created for up to a few seconds as the
> module loading and udev processes work asynchronously.
> --- FIXME ---

When the module is loaded, its MODULE_INIT() function is called.  That
function generally registers the relevant device entry in sysfs, which I
believe is what generates the udev hotplug event.  (Actually, maybe not
-- if it does happen that way, then it happens in sysfs_create_file().)

> > The definition "udevdir=/dev" is not explained.
> 
> I'd *guess* it tells udev where to create the device nodes.  On
> confirmation of this I'll add it to the book with the rest of #bug 853.

Yes, that's what it is.

According to the udev Makefile, the udevdir variable is used to generate
the UDEV_ROOT preprocessor #define in udev_version.h.  That #define is
copied into udev_root (a global variable) by udev_config.c.  It is then
used by various functions inside udev-add.c and udev-remove.c (and also
a couple of other unimportant-looking files) to build the filename of the
device node to create.




More information about the lfs-dev mailing list