23,217
社区成员




#include <linux/init.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
MODULE_LICENSE("Dual BSD/GPL");
static char *whom = "world";
module_param(whom, charp, 0);
static int howmany = 1;
module_param(howmany, int, 0);
static int hello_init(void)
{
int i;
for( i=0; i<howmany; i++)
printk("(%d) Hello, %s!\n",i,whom);
return 0;
}
static void hello_exit(void)
{
printk("Goodbye!\n");
}
module_init(hello_init);
module_exit(hello_exit);
Makefile
obj-m += hello.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean