如何在不重命名传递给insmod的.ko的情况下重命名内核模块名称? [英] How to rename a kernel module name without renaming the .ko passed to insmod?
问题描述
我需要重命名已经存在的驱动程序的内核模块(使用lsmod显示的名称),而无需更改源文件的名称.
I need to rename a kernel module (the name that get displayed with lsmod) of an already existing driver without changing the name of the source file.
例如
# insmod xxx.ko
<<module loads successfully>>
# lsmod
Module Size Used by Tainted: P
xxx 191527 0
#
-
我想将 xxx 重命名为 yyy .
I want to rename xxx to yyy.
现在,我知道更改驱动程序源文件的名称(当它涉及单个文件时)会更改模块的名称.
Now I know that changing the name of the driver source file (when it involves a single file) changes the name of the module.
但是我不想更改源文件的名称.
But I don't want to change the name of a source file.
推荐答案
在Makefile中重命名
obj-m
并将obj-m
的依赖项设置为原始模块.Rename your
obj-m
in Makefile and set dependency ofobj-m
to original module.例如,我有一个包含所有源代码的文件
hello.c
.但我希望模块为mynewname
.For example, I have file
hello.c
that contain all of my source code. But I want module to bemynewname
.这是执行此操作的整个Makefile:
Here is whole Makefile that does this:
obj-m := mynewname.o mynewname-objs := hello.o KERNELDIR ?= /lib/modules/$(shell uname -r)/build PWD := $(shell pwd) default: $(MAKE) -C $(KERNELDIR) M=$(PWD) modules clean: $(MAKE) -C $(KERNELDIR) M=$(PWD) clean
我将
obj-m
设置为mynewname.o
,并使mynewname.o
依赖于hello.o
.调用make后,您将获得mynewname.ko
.I set
obj-m
tomynewname.o
and makemynewname.o
dependant onhello.o
. After invoking make you'll getmynewname.ko
.这篇关于如何在不重命名传递给insmod的.ko的情况下重命名内核模块名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!