I'm trying to modify /etc/hosts/
file and for that I make a separate file in external storage and then cp
it to the location. I'm getting these error messages:
01-14 18:51:51.069: E/HostsActivity(5356): rm failed for /etc/hosts, Read-only file system
01-14 18:51:51.079: E/HostsActivity(5356): failed on '/mnt/sdcard/hosts' - Cross-device link
What do I do?
I'm using RootTools.
My code:
try {
String fn = write_file("hosts", hostsData);
RootTools.getShell(true).add(new Command(0, "rm /etc/hosts", "mv " + fn + " /etc/hosts")
{
@Override
public void output(int arg0, String arg1) {
// TODO Auto-generated method stub
Log.e("HostsActivity", arg1);
}
}).waitForFinish();
tv_status.setText("Done");
} catch (Exception ioe) {
Log.e("HostsActivity", ioe.toString());
tv_status.setText(ioe.toString());
}
I have asked for root permissions in the beginning of the activity in the onCreate
if (!RootTools.isAccessGiven()) {
TextView tv = new TextView(this);
tv.setText("Root access not given. Please ensure root access.");
setContentView(tv);
}
setContentView(R.layout.activity_hosts);
You need to remount /etc by default it is Read-only file system.
Than you need to check permissions on the /etc/hosts and maybe you need to correct file permissions using chmod command.