3
我写了一个内核模块,它读取和写入/proc
文件,它工作正常。现在我想使用它的权限,但是当我为下面显示的权限编写函数时,它给我一个错误。目标是让每个人都能够读取文件,但只有root可以写入。get_current()在这个内核模块中返回什么?
int my_permission(struct inode *inode, int op)
{
if(op == 4||(op == 2 && current->euid = 0)) //euid is not a member of task_struct
return 0;
return -EACCES;
}
const struct inode_operations my_iops = {
.permission = my_permission,
};
我得到的错误是:
/home/karan/practice/procf/testproc1.c: In function ‘my_permission’:
/home/karan/practice/procf/testproc1.c:50:32: error: ‘struct task_struct’ has no member named ‘euid'
我知道current
已经#defined到get_current()
。这是为什么发生?是否有从get_current()
返回的结构成员列表?