[uClinux-dev] kernel 2.6.12 loadable modules

Matt Waddel Matt.Waddel at freescale.com
Thu Oct 6 18:56:07 EDT 2005


Simple question first, more details below.

Has anybody tried loadable modules in the 20050906
2.6.x release?


Lengthy explanation:

I'm testing loadable module support in the 2.6.x kernel
for a new platform - M5208EVB.  Using a simple
"hello world" module I get the following error when I
try to insmod the program:

# insmod ./hello.ko
insmod: cannot mmap `./hello.ko': No such device

So I look at where the busybox insmod is doing an mmap
and it's in (modutils/insmod.c):

extern int insmod_ng_main( int argc, char **argv)
     map = mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0);
     if (map == MAP_FAILED) {
          bb_perror_msg_and_die("cannot mmap `%s'", filename);

First I thought mmap is not implemented properly, so I
found some test code for mmap in uClibc and ran it.  It
passes as long as the flag variable is or'ed with

Not setting MAP_ANONYMOUS causes the kernel to follow a
path where it looks for file->f_op->mmap, this is where
it fails (mm/nommu.c):

    /* files must support mmap */
    if (!file->f_op || !file->f_op->mmap)
        return -ENODEV;

When using insmod where should these file operations be

The code that checks the flag and creates the "file" is
in (arch/m68knommu/kernel/sys_m68k.c):

static inline long do_mmap2()
    if (!(flags & MAP_ANONYMOUS)) {         <<<<<<<<<
          file = fget(fd);                  <<<<<<<<<
            if (!file)
               goto out;

Any hints would be appreciated.

More information about the uClinux-dev mailing list