Helloworld
时间:2009-07-31 来源:gmting
//Hello.c
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk(KERN_ALERT "Hello world!\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye!\n");
}
module_init(hello_init);
module_exit(hello_exit); //Makefile ifneq ($(KERNEL|RELEASE),)
obj-m:=hello.o
else
obj-m:=hello.o
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD:=$(shell pwd) default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules .PHONY:clean
clean:
rm deit $(objects)
endif ///// insmod hello.ko lsmod | grep hello rmmod hello
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk(KERN_ALERT "Hello world!\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye!\n");
}
module_init(hello_init);
module_exit(hello_exit); //Makefile ifneq ($(KERNEL|RELEASE),)
obj-m:=hello.o
else
obj-m:=hello.o
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD:=$(shell pwd) default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules .PHONY:clean
clean:
rm deit $(objects)
endif ///// insmod hello.ko lsmod | grep hello rmmod hello
相关阅读 更多 +