linux内核模块编译-通过Makefile重命名.ko文件名和模块名

这篇博客介绍了如何通过修改Makefile来重命名Linux内核模块的.ko文件和模块名称。在默认情况下,hello.c源文件会被编译为hello.ko模块。通过在Makefile中将obj-m改为xmodule.o并设定其依赖为hello.o,可以将生成的模块文件命名为xmodule.ko,并在系统中显示为xmodule。
摘要由CSDN通过智能技术生成

模块的源文件为hello.c,源码如下:

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/delay.h>

#define HELLO_MAJOR 231
#define DEVICE_NAME "HelloModule"

static int hello_open(struct inode *inode, struct file *file)
{
   
	printk(KERN_EMERG "hello open.\n");
	return 0;
}

static ssize_t hello_write(struct file *file
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值