本人的另外一个博客地址: https://www.joeys.top,欢迎大家光临,哈哈哈
问题描述:
module在4.18的kernel上面无法在rmmod的时候会如下报错
[root@node-1 zjp]# insmod hello7.ko
[root@node-1 zjp]# rmmod hello7.ko
rmmod: ERROR: could not remove 'hello7': Device or resource busy
rmmod: ERROR: could not remove module hello7.ko: Device or resource busy
在rmmod卸载module的时候会调用delete_module,在return
EBUSY
The module is not "live" (i.e., it is still being initialized or is already marked for removal); or, the module has an init function but has no exit function, and O_TRUNC was not specified in flags.
调查过程
查看已经安装的module信息
[root@node-1 zjp]# cat /proc/modules | grep hello7
hello7 262144 0 [permanent], Live 0xffff4f26408b0000 (OE)
这个打印的代码
1005 if (mod->init != NULL && mod->exit == NULL) {
1006 printed_something = 1;
1007 seq_printf(m, "[permanent],");
1008 }
1009
卸载的时候
948 /* If it has an init func, it must have an exit func to unload */
949 if (mod->init && !mod->exit) {
950 forced = try_force_unload(flags);
951 if (!forced) {
952 /* This module can't be removed */
953 ret = -EBU