[CLUE-Tech] module loading question

Keith Hellman kehellman at yahoo.com
Wed Mar 26 20:12:57 MST 2003


On Wed, Mar 26, 2003 at 04:21:06PM -0700, David Anselmi wrote:
> What happens is that the kernel loads modules when it needs them.  So if 
> you mount an ext3 filesystem, the kernel knows to load the ext3 module 
> first.  For many devices the kernel knows what to do and it Just 
> Works(tm).  Iptables is one of those (except for the ftp piece).
> 
> Network drivers are an example where things aren't automatic.  You put a 
> line that says "alias eth0 8139too" in modules.conf and now the kernel 
> knows (modprobe knows?) that when you ifconfig eth0 it needs the 8139 
> driver.  I don't know the details about why filesystem drivers and 
> ethernet drivers are different, but they are.

I believe the difference is that ether devices exist in their own
namespace within the kernel; in part for ease of configuration (maybe this
is the whole reason, I dunno).

When the kernel needs a module to read a filesystem, its not like it has
to say... "Hmmm, this looks like a foofs disk, I wonder what module the
user wants to read it with...".  The answer is pretty obvious, its the
foofs module.  Try the following as an experiment:  in one terminal
  #tail -f /var/log/messages
and in another terminal, 
  #mount -t foofs /dev/ram0 /mnt
Both will probably have to be done as root else you will get perm
errors.  You should see the kernel make an attempt to 'modprobe foofs'
in the message log.  This fails cause there isn't such a thing as a
foofs filesystem.

Now keep those messages scrolling and type (in the other window)
  #ifconfig foodev 0.0.0.0 up
You guessed it.  The kernel tries to 'modprobe foodev' and fails.

The point here is that filesystems have names, and nice, consistent,
agreed upon names within Linux.  Ethernet device hardware names (not
eth0, lo0, ... the real HARDWARE/module names) are wide and varied, each
with a required uniq name.  It is by convention that Linux uses ethX for
ethernet devices; so the kernel tells modprobe 'gimmee the eth3 hardware
module', you tell modprobe that its a 3com (alias eth3 3c509) and
everyone lives happily ever after.

You can't carry this too far however.  I can't, for instance:
- create a minix filesystem on /dev/ram0
- alias foofs to minix in modules.conf
- then mount -t foofs /dev/ram0 /mnt
Nor can I 
- alias foodev to 3c509
- then ifconfig foodev 0.0.0.0 up

This is speculation, but I would think the reason is because the kernel
looks for foofs after it has made the modprobe call.  But minix.o
registers itself (inside the kernel) as, well, "minix".  The kernel
can't find a "foofs" filesystem driver to attempt a superblock read!
Likewise, the 3c509 module registers any devices it finds as an ethX
device, so even though the modprobe SUCCEEDS, you get a 'No such device'
error.

I'm not sure about other distros, but the SuSE modules.conf is repleat
with lots of 'alias block-major-NUMBER ...' and 'alias sound-slot-0 ...'.
When you access a device file for which there is no loaded support in
the kernel, the kernel can't ask for a module by name.  Well perhaps it
could, but devices can be *hard linked*, and the *easiest* way to support
this is by requesting device support via MAJOR/MINOR number.

-- 
Keith Hellman                             #include <disclaimer.h>
kehellman at yahoo.com               from disclaimer import standard

"Experience is a harsh teacher.  She gives the test before you learn the
lesson."

--Unknown



More information about the clue-tech mailing list