devfs
[Top] [All Lists]

autoloading modules

To: <devfs@xxxxxxxxxxx>
Subject: autoloading modules
From: Sergei Ivanov <svivanov@xxxxxxxxxxx>
Date: Sun, 8 Jul 2001 01:38:00 +0400 (MSD)
Organization: Steklov Institute of Mathematics at St.Petersburg
Sender: owner-devfs@xxxxxxxxxxx
Hello

I just tried devfs for the first time.  After fixing a number of
configuration issues, I found one that looks like a design problem
in devfs (of course, given my poor knowledge of it).

I am using kernel 2.4.6, glibc-2.2.3 and devfsd-1.3.11.
The machine has a disc and a CD-ROM, used to be /dev/hda and /dev/hdb.
The disc driver is in the kernel, and CD-ROM support is in modules.

Without devfs, I have /dev/hda and /dev/hdb.  When /dev/hdb is accessed,
ide-cd module gets loaded.  I don't know how this happens, probably the
kernel uses the results of IDE probe to find out which module to load.

With devfs, there is no /dev/hdb.  This is ok, devfsd is supposed to
manage it.  (And it does so with some other devices - e.g. /dev/ttyS1
works though the serial driver is modular.)  But not so with ide-cd.
It is not autoloaded when /dev/hdb is referenced.

Well, /dev/hdb is an old name, maybe I should use the new name,
/dev/ide/host0/bus0/target1/lun0/cd.  No, it does not work.  Why?
Let's look into /etc/modules.devfs.  What a hell, there is a line
        `probeall /dev/ide ... ide-cd ...' ,
why doesn't it do what I want?  Hmm, right, it cannot.  Because /dev/ide
already exists.  It was created by the in-kernel IDE driver!

If *all* IDE drivers were modules, then indeed, lookup to /dev/ide
would load them all.  But once some of them are in the kernel
(or loaded by other means), there is no such effect.  Right?

I can load ide-cd using /dev/cdroms (it does not exist upon boot).
But this works just because I have only one CD-ROM.  If I had two,
and one of the drivers was already loaded, then the second one would
be not (auto)loadable at all. Or it seems so.

And this method probes for all cdroms, thus loading a lot of modules
(including SCSI), and I definitely don't want this.

What can be done: adding a line
        `alias  /dev/ide/*/cd    ide-cd'
in /etc/modules.conf makes the system load the module when
the "canonical" device name is referenced.

This is the Right Thing, and this is what devfs is for.
I think such alias(es) should be in modules.devfs, or built into modprobe.
Or maybe the right place for this is the kernel itself?
Can devfs load modules without devfsd?

But I still don't have my /dev/hdb!  Well, it appears there as soon
as ide-cd is loaded, but I don't know how to make it work "by lookup".
Yes I can do `alias /dev/hdb ide-cd', but this assumes that /dev/hdb
is always a CD-ROM.  The problem is that there is no magical device
like the old /dev/hdb, referring to "whatever sitting at the primary
slave IDE".

Maybe there should be nodes /dev/ide/.../lun0/disc for all IDE
devices, not only hard discs?  These could belong to the base
IDE driver (ide-probe-mod?) and work like the old /dev/hdX.

Then `/dev/ide/.../cd' could be a symlink to `disc'.
And there might be a symlink `/dev/ide/.../hd' if the device
is a hard disc.  So one could refer to a device "of unknown type",
or of a specific type (hd/cd/whatever) if desired.

Okay, if you are still reading, here is the summary.

0) Devfs is a good thing.  Really.

1) The "probeall" lines in modules.devfsd are bad - because the effect
is inpredictable.  More generally, loading modules by lookup should not
load anything beyond the module providing the referenced node.

2) The default configuration (maybe any configuration) should have aliases
for the kernel names (like /dev/ide/*/cd -> ide-cd).

3) If a driver can load modules itself, devfs should cooperate.
Not everything can be done via devfsd.

With best regards,
Sergei

P.S. It would be nice to mention in the FAQ that non-devfs modules
do not work with devfs kernels.


<Prev in Thread] Current Thread [Next in Thread>