您的位置:首页 > 运维架构 > Linux

[代码实例][Linux内核][模块]helloworld程序

2016-06-21 01:09 375 查看

源文件

/*
* hello.c
*/
#include <linux/init.h>
#include <linux/module.h>

static int hello_init(void)
{
printk(KERN_ALERT "hello, world\n");
return 0;
}

static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, cruel world\n");
}

module_init(hello_init);
module_exit(hello_exit);

MODULE_LICENSE("Dual BSD/GPL");


Makefile文件

ifneq ($(KERNELRELEASE),)
obj-m := hello.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: