分类: LINUX
2010-03-18 13:14:50
#include #include MODULE_LICENSE("GPL"); static int __init hello_init (void) { printk("Hello module init\n"); return 0; } static void __exit hello_exit (void) { printk("Hello module exit\n"); } module_init(hello_init); module_exit(hello_exit); |
gcc -D__KERNEL__ -DMODULE -DLINUX -I /usr/local/src/linux2.4/include -c -o hello.o hello.c |
insmod ./hello.o |
rmmod hello |
void *kmalloc(unsigned int len, int priority); void kfree(void *__ptr); |
unsigned long copy_from_user(void *to, const void *from, unsigned long n); unsigned long copy_to_user (void * to, void * from, unsigned long len); |