twrp: use ANDROID_ROOT environment variable
instead of hard-coded /system path
I updated most of the references I found,
but there might be more
For devices that have to mount system at /system_root,
this allows system to be bind mounted to /system
and detected properly by TWRP
Change-Id: I9f142fd8cec392f5b88e95476258dab9c21a9aac
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index 40205c9..2635934 100644
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -407,7 +407,7 @@
void TWFunc::install_htc_dumlock(void) {
int need_libs = 0;
- if (!PartitionManager.Mount_By_Path("/system", true))
+ if (!PartitionManager.Mount_By_Path(PartitionManager.Get_Android_Root_Path(), true))
return;
if (!PartitionManager.Mount_By_Path("/data", true))
@@ -809,19 +809,19 @@
}
string TWFunc::System_Property_Get(string Prop_Name) {
- bool mount_state = PartitionManager.Is_Mounted_By_Path("/system");
+ bool mount_state = PartitionManager.Is_Mounted_By_Path(PartitionManager.Get_Android_Root_Path());
std::vector<string> buildprop;
string propvalue;
- if (!PartitionManager.Mount_By_Path("/system", true))
+ if (!PartitionManager.Mount_By_Path(PartitionManager.Get_Android_Root_Path(), true))
return propvalue;
string prop_file = "/system/build.prop";
if (!TWFunc::Path_Exists(prop_file))
- prop_file = "/system/system/build.prop"; // for devices with system as a root file system (e.g. Pixel)
+ prop_file = PartitionManager.Get_Android_Root_Path() + "/system/build.prop"; // for devices with system as a root file system (e.g. Pixel)
if (TWFunc::read_file(prop_file, buildprop) != 0) {
- LOGINFO("Unable to open /system/build.prop for getting '%s'.\n", Prop_Name.c_str());
+ LOGINFO("Unable to open build.prop for getting '%s'.\n", Prop_Name.c_str());
DataManager::SetValue(TW_BACKUP_NAME, Get_Current_Date());
if (!mount_state)
- PartitionManager.UnMount_By_Path("/system", false);
+ PartitionManager.UnMount_By_Path(PartitionManager.Get_Android_Root_Path(), false);
return propvalue;
}
int line_count = buildprop.size();
@@ -834,12 +834,12 @@
if (propname == Prop_Name) {
propvalue = buildprop.at(index).substr(end_pos + 1, buildprop.at(index).size());
if (!mount_state)
- PartitionManager.UnMount_By_Path("/system", false);
+ PartitionManager.UnMount_By_Path(PartitionManager.Get_Android_Root_Path(), false);
return propvalue;
}
}
if (!mount_state)
- PartitionManager.UnMount_By_Path("/system", false);
+ PartitionManager.UnMount_By_Path(PartitionManager.Get_Android_Root_Path(), false);
return propvalue;
}
@@ -1095,14 +1095,14 @@
}
void TWFunc::Disable_Stock_Recovery_Replace(void) {
- if (PartitionManager.Mount_By_Path("/system", false)) {
+ if (PartitionManager.Mount_By_Path(PartitionManager.Get_Android_Root_Path(), false)) {
// Disable flashing of stock recovery
if (TWFunc::Path_Exists("/system/recovery-from-boot.p")) {
rename("/system/recovery-from-boot.p", "/system/recovery-from-boot.bak");
gui_msg("rename_stock=Renamed stock recovery file in /system to prevent the stock ROM from replacing TWRP.");
sync();
}
- PartitionManager.UnMount_By_Path("/system", false);
+ PartitionManager.UnMount_By_Path(PartitionManager.Get_Android_Root_Path(), false);
}
}