在启动时对 /dev 文件设置权限 0666

在启动时对 /dev 文件设置权限 0666

我必须加载一些附加模块。其中之一生成 /dev/knem 文件。我必须将权限设置为 0666,这样基本chmod 0666 /dev/knem就可以了,但我想在启动时直接分配它。

我应该在哪里编写配置,以便内核在加载模块时直接设置它?

提前致谢

答案1

我可能是错的,但是你不能使用 udev 规则,在挂载 /dev/knem 时分配 0666 权限吗?

http://www.reactivated.net/writing_udev_rules.html#syntax

Controlling permissions and ownership

udev allows you to use additional assignments in rules to control ownership and permission attributes on each device.

The GROUP assignment allows you to define which Unix group should own the device node. Here is an example rule which defines that the video group will own the framebuffer devices:

    KERNEL=="fb[0-9]*", NAME="fb/%n", SYMLINK+="%k", GROUP="video"

The OWNER key, perhaps less useful, allows you to define which Unix user should have ownership permissions on the device node. Assuming the slightly odd situation where you would want john to own your floppy devices, you could use:

    KERNEL=="fd[0-9]*", OWNER="john"

udev defaults to creating nodes with Unix permissions of 0660 (read/write to owner and group). If you need to, you can override these defaults on certain devices using rules including the MODE assignment. As an example, the following rule defines that the inotify node shall be readable and writable to everyone:

    KERNEL=="inotify", NAME="misc/%k", SYMLINK+="%k", MODE="0666"

可以在这篇文章中找到创建 UDEV 规则的分步说明:http://ubuntuforums.org/showthread.php?t=168221

相关内容