Re: tainted module and rmmod

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2003-07-10 at 11:10, Christophe Lucas wrote:
> 
> I am sure it is loaded, because of I can see entry "titux" in /proc.
> 
> As another people asks, I put the code. It is really simple. It make an
> oops(when I do a: cat /proc/titux), but my problem isn't there for the time.
> Yet, I have done the test with an hello world mdoule without
> MODULE_LICENCE and I have had the same result.
> 
> /* proc_test.c */
> #include <linux/module.h>
> #include <linux/proc_fs.h>
> 
> #define MODVERSIONS
> 
> MODULE_LICENSE( "GPL" );
> MODULE_AUTHOR( "titux" );
> 
> static int titux_read_proc( char *buf , char **start, off_t offset,
>         int count, int *eof , void *data )
> {
>         int len = 0 ;
> 
>         buf = kmalloc( 128 , GFP_USER ) ;
>         len += sprintf( buf + len, "current pid: %i\n", current->pid );
>         *eof = 1 ;
>         return len ;
> }
> 
> void init_module()

Should return an int here

> {
>         printk( "proc_test loaded... ok");
>         create_proc_read_entry( "titux", 0, NULL, titux_read_proc , NULL ) ;
> }
> 
> void cleanup_module()
> {
>         printk( "proc_test unloaded... ok" );
>         remove_proc_entry( "titux", NULL );
> }


Here is a fairly minimal module that works that you may wish to copy.

===================================
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#define MODVERSIONS
MODULE_LICENSE( "GPL" );
int __init my_init(void) {
        printk("hello\n");
        return 0;
}
void __exit my_exit(void) {
        printk("by\n");
}
module_init(my_init);
module_exit(my_exit);
================================
# gcc -D__KERNEL__ -DMODULE -I/path/to/kernel/src/include -O -Wall -o
foo.o -c foo.c
# insmod foo.o
hello
# rmmod foo
by


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux