问题
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