Originally Posted By: mlord
So I looked at the module loader program (/sbin/modprobe) ...

Speaking of which, here's another code tidbit that I haven't backed up here before:
Mark's simple kernel module loader, useful for when size matters:
Code:
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <syscall.h>

int main (int argc, char *argv[])
{
        int fd;
        struct stat st;
        void *contents;

        fd = open(argv[1], O_RDONLY);
        if (fd != -1 && fstat(fd, &st) != -1) {
                contents = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
                if (contents != MAP_FAILED)
                        if (syscall(SYS_init_module, contents, st.st_size, "") == 0)
                                return 0;
        }
        perror(argv[1]);
        return 1;
}