I have an Android 10 device whose bootloader is unlocked. I have downloaded its firmware, modified it and get the adb shell rooted in recovery. Following are the steps for it:

  1. Download AIK
  2. Extract recovery.img and modified ramdisk/default.prop as follows:
  1. Replace split_img/recovery.img-zImage with permissive kernel(built from kernel sources)
  2. Repack it and flash it on the device.
  3. Reboot to recovery and run adb shell. It will be rooted.

I want to add simple chmod 666 /dev/diag command and I have mounted system with stock recovery mount system option and then tried to do following:

  1. Write chmod command at the end of init.rc.
  2. Tried creating new rc scripts under /system/etc/init/ folder. New rc script has just chmod command written in it.
  3. Tried appending(e.g. echo "chmod 666 /dev/diag" >> /system/etc/init/cameraserver.rc) chmod command in other rc files in /system/etc/init/ folder.

All were not able to change the required permissions. init.rc changes lost after reboot. Other files/changes persist after reboot but doesn't change the permission of diag port.

OTOH, I was able to make a system app with changes in /system/app/ folder.

Is there anything else that I can try to run the chmod command after phone boots?

  • 1
    echo "chmod 666 /dev/diag" >> /system/etc/init/cameraserver.rc won't work. You need to provide an init trigger (on ...) as well. Simple is to edit the ueventd.rc file (it must be from vendor, not AOSP) which creates /dev/diag device node. Replace the relevant statement inside that file to set whatever permission mode you want. Mar 31 '20 at 8:35
  • 2
    If that's an option for you: tasker can react on the BOOT_COMPLETED event and run e.g. a terminal command as root, like ! chmod 666 /dev/diag (the exclamation mark tells it to run the command as root).
    – Izzy
    Mar 31 '20 at 10:23
  • 1
    @IrfanLatif on property:sys.boot_completed=1 event helps me to change the /dev/diag permissions but it doesn't help me to change /vendor/bin/diag_mdlog permissions.. Any suggestion? I looked into ueventd.rc and there is no diag related changes.. Mar 31 '20 at 12:27
  • 3
    Ah, yes, that is true. But your question uses the root-access tag – which says "for questions spefically requiring root permissions". So that tag basically implies your device is rooted. Maybe you edit your question and clarify? While at tags: what part is about rom-flashing, and which about selinux or systemless-root? Just asking ;)
    – Izzy
    Mar 31 '20 at 21:12
  • 2
    @IrfanLatif I have rooted system with modifying the prop.default file from recovery rooted adb shell and then modified the ueventd.rc of vendor as you suggested. Thanks :) Apr 1 '20 at 10:26

echo "chmod 666 /dev/diag" >> /system/etc/init/cameraserver.rc won't work. You need to provide an init trigger as well. For instance:

~# echo "on boot" >/etc/init/dev_diag_chmod.rc
~# echo "    chmod 666 /dev/diag" >>/etc/init/dev_diag_chmod.rc
~# chown 0.0 /etc/init/dev_diag_chmod.rc
~# chmod 0644 /etc/init/dev_diag_chmod.rc
~# chcon u:object_r:system_file:s0 /etc/init/dev_diag_chmod.rc

But even simple approach is to edit the ueventd.rc file (which is read and executed by Android's device manager) provided by vendor (since /dev/diag is a hardware specific interface) which creates the device node. Replace the relevant statement inside that file to set whatever permission mode, owner and group you want. E.g. you can replace:

/dev/diag    0660    system    system


/dev/diag    0666    system    system

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.