文件(include/linux/syscalls.h)中,有: #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__) 从而形成sys_init_module函数。 SYSCALL_DEFINE3 对应的内核实现 // kernel/module.c SYSCALL_DEFINE3(init_module, void __user *, umod, unsigned long, len, const char __...
而init_module 定义如下: //此 init_module 不同于驱动代码编译出来的 init_module,此处是 busybox 内的宏。 //modutils/modutils.c#defineinit_module(mod, len, opts) syscall(__NR_init_module, mod, len, opts) //上面的宏逻辑上相当于 #defineinit_module(mod, len, opts)sys_init_module(mod, le...
一个用于卸载模块. linux代码中使用SYSCALL_DEFINEx这个宏定义一个系统调用的入口, 其中x代表系统调用的参数个数, 看一下内核代码就可以找到和模块的加载以及卸载相关的syscall函数, 使用正则表达式或者其他工具能很快在内核代码中找到这三个系统调用的定义.
而init_module 定义如下:(文件 busybox/modutils/modutils.c) #define init_module(mod, len, opts) syscall(__NR_init_module, mod, len, opts) 因此,该系统调用对应内核层的 sys_init_module 函数 关于系统调用,文件(include/linux/syscalls.h)中,有 #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINE...
#define init_module(mod, len, opts) syscall(__NR_init_module, mod, len, opts) 1. 因此,该系统调用对应内核层的sys_init_module函数。 回到Linux内核源代码(kernel/module.c),代码梳理: SYSCALL_DEFINE3(init_module, ...) | -->load_module ...
/// kernel/module/main.cSYSCALL_DEFINE3(init_module,void__user*,umod,unsignedlong,len,constchar__user*,uargs){/// ... ...returnload_module(&info,uargs,0);}SYSCALL_DEFINE3(finit_module,int,fd,constchar__user*,uargs,int,flags){/// ... ...returnload_module(&info,uargs,flags)...
ret_void_star(syscall!(__NR_brk, addr)) }#[cfg(any(target_os = "linux", target_os = "android"))] #[inline] pub(crate) unsafe fn init_module( image: *const c::c_void, len: c::c_uint, param_values: &CStr, ) -> io::Errno { ...
@@ -4501,7 +4591,7 @@ SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags) return -EINVAL;/** * * hdr 是 vmalloc 分配的内存空间,并且保存了整个 ko 文件 */ err = kernel_read_file_from_fd(fd, 0, &hdr, INT_MAX, NULL, READING_MODULE); ...
写过linux驱动的程序猿都知道module_init() 这个函数。那么我们来了解一下module_init这个函数的具体功能和执行过程 在kernel源码目录中找到include\linux\init.h文件 /** * module_init() - driver initialization entry point * @x: function to be run at kernel boot time or...
syscall(__NR_init_module, mod, len, opts) 该系统调用相应内核层的sys_init_module函数。 路径:kernel/module.c SYSCALL_DEFINE3(init_module,…) //载入模块的ko文件,并解释各个section,重定位 mod = load_module(umod, len, uargs); //查找section(".gnu.linkonce.this_module") ...