c device-driver files_ops结构域

时间:2011-06-10 18:09:03

标签: c device-driver

struct file_operations hello_fops = {
owner: THIS_MODULE,
read: hello_read,
write: hello_write,
ioctl: hello_ioctl,
open: hello_open,
release: hello_release,
};

这里是什么意思:在struct field之后,即owner: 在某个地方,我也看到过像.owner:=

另外,如何查看“所有者”的其他可用选项。我想授权所有人发出ioctl调用。

是什么意思。这里 任何人都可以解释这个

1 个答案:

答案 0 :(得分:3)

{.field=value}

是C99风格的初始化程序。

{field: value}

是一个GCC风格的初始化程序。

owner与权限无关。权限是正常的文件权限,您可能希望使用udev规则来设置适当的权限。 ioctl调用通常需要额外的权限,具体取决于其含义,例如:CAP_NET_ADMIN用于某些网络重定位的ioctl。