THIS_MODULE在Linux内核模块驱动程序中有何意义? [英] What is the significance of THIS_MODULE in Linux kernel module drivers?
本文介绍了THIS_MODULE在Linux内核模块驱动程序中有何意义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Linux设备驱动程序开发中,file_operations
结构使用struct module *owner
.
In Linux device driver development, the file_operations
structure uses struct module *owner
.
- 当我们总是用
THIS_MODULE
初始化它时,该结构有什么用? - 何时可以将该字段设置为
NULL
?
- What is the use of this structure when we always initialize it with
THIS_MODULE
? - When can this field be set to
NULL
?
推荐答案
此字段告诉谁是struct file_operations
的所有者.这样可以防止模块在运行时被卸载.使用THIS_MODULE
初始化时,当前模块将保留其所有权.
This field tells who is owner of struct file_operations
. This prevents module to get unloaded when it is in operation. When initialized with THIS_MODULE
current module holds the ownership on it.
这篇关于THIS_MODULE在Linux内核模块驱动程序中有何意义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文