确保模块使用期间不被卸载
来源:互联网 发布:手机百度网盘网络出错 编辑:程序博客网 时间:2024/05/04 10:04
These manipulate the module usage count, to protect against removal (a module also can't be removed if another module uses one of its exported symbols: see below). Before calling into module code, you should call try_module_get() on that module: if it fails, then the module is being removed and you should act as if it wasn't there. Otherwise, you can safely enter the module, and call module_put() when you're finished.
Most registerable structures have an owner field, such as in the file_operations structure. Set this field to the macro THIS_MODULE.
内核源码目录下include/linux/module.h
#ifdef MODULE
#define MODULE_GENERIC_TABLE(gtype,name) \
extern const struct gtype##_id __mod_##gtype##_table \
__attribute__ ((unused, alias(__stringify(name))))
extern struct module __this_module;
#define THIS_MODULE (&__this_module)
#else
#define MODULE_GENERIC_TABLE(gtype,name)
#define THIS_MODULE ((struct module *)0)
#endif
__this_module这个符号是在加载到内核后才产生的。insmod命令执行后,会调用kernel/module.c里的一个系统调用 sys_init_module,它会调用load_module函数,将用户空间传入的整个内核模块文件创建成一个内核模块,并返回一个struct module结构体,从此,内核中便以这个结构体代表这个内核模块。
- 确保模块使用期间不被卸载
- 7招防黑技巧确保Windows系统不被攻击
- 确保你的 float,double 值 不被 改变
- win7系统中ip地址如何确保不被修改
- 卸载模块
- Flex 使用ModuleLoader加载模块及卸载模块的实例
- Flex 使用ModuleLoader加载模块及卸载模块的实例
- kafka使用high api如何确保不丢失消息,不重复发送,消息只读取一次
- 关于如何使用内核模块来卸载文件系统(文件系统正在被使用)的测试和验证
- 确保页面不被嵌入框架和不被弹出的脚本
- 【c++系列】使用标准库规范确保不超出数组边界
- 确保非局部静态对象在使用前被初始化
- 确保 objects(对象)在使用前被初始化
- 确保非局部静态对象在使用前被初始化
- 对象的初始化:确保对象在使用之前被初始化 `
- 确保非局部静态对象在使用前被初始化
- Effective C++,rule 4,确保对象使用前被初始化
- 确保非局部静态对象使用前被初始化
- scp 无需密码
- mmap函数详解
- RGB565格式互转,及彩条程序
- 【手机拍照技巧】提高你的拍照水平!教程详细!
- 僵尸进程(zombie)以及避免方法
- 确保模块使用期间不被卸载
- 使用snprintf函数时的两点注意事项
- Linux的I2C 设备驱动 -- mini2440 上i2c接口触摸屏驱动
- 路要怎么走?关于程序员成长的一点思考
- 专访谷歌CEO:像对待家人一样对待员工
- ubuntu 10.04 建立交叉编译环境 arm-linux-gcc-4.3.2
- 程序员成长之路(转)
- 程序员成长最快的环境
- 程序员成长的10个阶段