简体   繁体   English

linux内核模块权限

[英]linux kernel module permissions

I wrote a kernel module and a user that opens it with O_RDWR mode, 我写了一个内核模块和一个用O_RDWR模式打开它的用户,

in the module_permission's func i get int op parameter , 在module_permission的函数中,我得到int op参数,

and would like to know if its value is the same as O_RDWR or maybe the system call open changes it to another known value , and if so where can i find it.. 并想知道其值是否与O_RDWR相同,或者可能是系统调用open将其更改为另一个已知值,如果可以,我在哪里可以找到它。

thanks a lot.. 非常感谢..

You mean your module exports a device node that the user opens as a file with O_RDWR? 您是说模块将用户打开的设备节点导出为O_RDWR文件? In this case if you are using a newer kernel, the mode is in the struct file* parameter passed to your module's open call: 在这种情况下,如果您使用的是较新的内核,则该模式在传递给模块的open调用的struct file *参数中:

int my_open(struct inode* inode, struct file* filep) 
{
    unsigned mode = file->f_mode;
    //... 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM