Search code examples
androidlinux-kernelandroid-sourcechmod

Set file permissions in Android source code


In my Android 10 image I have the file (of type character) /dev/i2c-1:

crw ------- 1 root root 89, 1 2021-05-26 11:51 /dev/i2c-1

I have the source code for this Android and I would like this file to have read and write permission for any user, that is, it would be as follows:

crw-rw-rw- 1 root root 89, 1 2021-05-26 11:51 /dev/i2c-1

Otherwise, I have to run the chmod command every time the device is restarted.


Solution

  • You can change the access permissions in two places:

    1. where your create the file
    2. in init rc files. See examples
    on init
       chmod 666 /dev/i2c-1