Hi,

 The following program hangs the kernel, when the insmod on it, is run. Can any 
one provide ideas why :

#include <linux/module.h>       // for init_module()
#include <linux/proc_fs.h>      // for create_proc_info_entry()
#include <asm/io.h>             // for inb(), outb()

int my_func( char *buf, char **start, off_t off, int count, int *eof, void 
*data )
{
        return 0;
}

char modname[] = "cmos";
static int __init my_init( void )
{

        struct proc_dir_entry *pde, *tmp;
        tmp = kmalloc(sizeof(struct proc_dir_entry), GFP_KERNEL);
        pde= create_proc_entry(modname, S_IFDIR | S_IRUGO | S_IXUGO , tmp);

        pde->nlink = 1;
        pde->read_proc = my_func;
        if(pde)
                printk("proc_create sucessfull name = %s\n", pde->name);
        else
                printk("proc_create not so sucessfull. Exiting........... \n");
        return 0;
}

static void __exit my_exit(void )
{
        remove_proc_entry( modname, NULL );
        printk("Exiting ................\n");
}

module_init( my_init );
module_exit( my_exit );
MODULE_LICENSE("GPL");

Thanks,
Giriprasad



Reply via email to