Device node access permissions in Linux

那年仲夏 提交于 2019-12-11 10:34:44

问题


I'm writing a char device driver for embedded android. The device module, register itself as a char device, and a corresponding device node is created under /dev . The problem is that the access permissions for this device is for root, and I can't read it from android applications (JNI). I have to manually "chmod +r" the device before running the application. How can I decide the access permission of a dynamically created device node ?


回答1:


If your device registers itself using udev, which is the most likely case, then you can create a custom udev rule to manage the permissions on this device.

For example, this rule assigns rw-rw-rw- permissions to a device belonging to the USB vendor 0bb4:
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"



来源:https://stackoverflow.com/questions/7219684/device-node-access-permissions-in-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!