using sys_mknod, how to create a character device file from module

From: Daniel Schüle (uval_at_rz.uni-karlsruhe.de)
Date: 10/14/05


Date: Fri, 14 Oct 2005 02:37:36 +0200

Hello experts,

I want my module to create some character device files on insmod
and delete them at rmmod, sounds simple but I cannot figure out
how to do it
I did expect that the code below would do it, but it returns
an error code -14 which stands for EFAULT

using a string instead of ->deviceFilename brings same error
no character file is created

I am not sure one can use sys_* from kernel space
maybe sys_mknod expects a pointer from userspace?

Thx for your help

Daniel

static void mknod_device_files(void)
{
        int i;
        for(i=0; i<driver.num_module; i++)
                sys_mknod(driver.module[i]->deviceFilename, S_IFCHR | 0666,
MKDEV(driver.major, driver.module[i]->minor));
                // returns -14
}

static void remove_device_files(void)
{
        int i;
        for(i=0; i<driver.num_module; i++)
                sys_unlink(driver.module[i]->deviceFilename);
}

static int startup(void)
{
        // ..
        mknod_device_files();
        // ...
}

static void cleanup(void)
{
        // ...
        remove_device_files();
}



Relevant Pages