Accessing Root Files (/system, /dev) From A Native Library In Android Application
Solution 1:
In recent android versions, rootfs and system are mounted read-only after init has set up the directories and files.
In order to create a file in the system partition you must remount them with write access. So you will have to call on /system/bin/mount as root user.
The command for mounting system rw is different depending on if /system/bin/mount a toybox or toolbox symlink
If you're failing to get su in with Runtime.getRuntime().exec("su"), are you using the su binary produced by aosp in userdebug builds? If so I believe you would have to be shell user in order to use it. Maybe switch to a more commonly available su binary or update the aosp one.
EDIT: for mounting system rw, you first need to determine if /system/bin/mount is a symlink to toybox or to toolbox, because the command they use for mounting system rw will be different
ls -l, or readlink should be able to easily answer that.
for toolbox,
(running as uid(0))
mount -o remount,rw /system
for toybox,
(running as uid(0))
mount -o rw,remount -t auto /system
In Java the subprocess must request su first as only root user can execute the mount command
Post a Comment for "Accessing Root Files (/system, /dev) From A Native Library In Android Application"