How to rename the name of a kernel module without renaming .ko passed to insmod?

I need to rename the kernel module (the name that is displayed using lsmod) of an existing driver without changing the name of the source file.

eg.

# insmod xxx.ko
<<module loads successfully>>
# lsmod
Module                  Size  Used by    Tainted: P
xxx                   191527  0
#
  • I want to rename xxx to yyy .

  • Now I know that changing the name of the source driver file (when it is associated with one file) changes the name of the module.

  • But I do not want to change the name of the source file.

+4
source share
1 answer

Rename obj-mto Makefile and set the dependency obj-mto the source module.

, hello.c, . , mynewname.

Makefile, :

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.

+3

Source: https://habr.com/ru/post/1546048/


All Articles