1

I have been trying to change root files in my phone through an app I am developing. The phone I have is a Moto G6, fully rooted. I'm using terminal emulators to run commands on my phone. I've tried "Terminal Emulator for Android" and "Shell Terminal Emulator" apps to try to make my files modifiable.

The commands I've tried to run are as follows:

su
mount -o rw,remount /system

In Terminal Emulator for Android this appears to work because it offers no error message but in Shell Terminal Emulator I'm hit with the following:

"...whatever.../system not user mountable in fstab"

So I went to check if it worked anyway and tried to modify a file in the root browser. The file:

/sys/devices/virtual/android_usb/android0/power/control

The file currently has the permissions set as "rw-r--r--" and filled with the text "auto" and after trying to save the file with the contents "0" instead I'm provided with this big ugly error message:

Error when saving file
=====Description=====
java.io.FileNotFoundException: "...file name..." and then (permission denied)

What I want to know is why I don't have permission to edit these files, afterall my phone is fully rooted and I have granted root access to the text editor.

Any solution or step in the right direction is greatly appreciated.

5
  • FileNotFoundException is a Java Exception which indicated that you are trying to write a file from within an app without superuser permissions. All java file access APIs can't be used if you need root permissions. You can only execute command-line executables via su. Therefore if you want to overwerite a system file save it somewehere where you have access and then copy the file with su and a command-line command to it's destination.
    – Robert
    Aug 28, 2019 at 17:13
  • Please note that app development questions are foo-topic here. Use stackoverflow.com instead.
    – Robert
    Aug 28, 2019 at 17:14
  • @Robert This is not necessarily an app development question, I happen to be applying this knowledge in the development of an app but I asked this question in order to understand the android system better. Aug 29, 2019 at 8:27
  • @AdamHigginsn it is best if you strictly ask it from an end-user's perspective than, instead of using code related errors. I have reopened it for now.
    – Firelord
    Aug 29, 2019 at 9:35
  • @Firelord It wasn't an error with code, just access problems while running commands on an android device Aug 29, 2019 at 10:04

1 Answer 1

1

in Shell Terminal Emulator app I'm hit with the following:
"...whatever.../system not user mountable in fstab"

toybox mount returns that error when UID isn't 0 i.e. you aren't root.

tried to modify a file in the root browser. The file:
/sys/devices/virtual/android_usb/android0/power/control

/system and /sys are two different filesystems. Mounting one R/W won't allow you R/W access to the other. /system is the mount point of a partition which contains Android OS. It can't be mounted R/W without getting root access and without disabling dm-verity. sysfs is Linux kernel's pseudo filesystem which provides information related to hardware stuff and exposes some interfaces to userspace for kernel configuration and tweaking.

sysfs is mounted R/W by default but not every file in this filesystem can be modified. Only some specific values can be written to specific files. The file you are trying to write is related to power management of USB Gadget driver of kernel which is to let the device be in some kind of slave role (device mode), not in USB host role. Possible values for control file are auto and on as per documentation.

after trying to save the file with the contents "0" instead I'm provided with this big ugly error message

I'm not sure about that Java related error, you can get better help at stackoverflow. However you can get a root shell and do:

~# echo -n on >/sys/devices/virtual/android_usb/android0/power/control

This must work, I've tried that in GUI text editor too. Probably the value 0 you are trying to write isn't a valid value for kernel, except if you are changing something at driver level.

If the purpose is only to edit files for testing which can't be accessed / modified without root, create / edit / delete a file in /data/local. /data doesn't need remounting.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .