super processing: use logical flag to denote super status
To support all partitions that are on the super partition we now parse for the logical flag in fstab to denote super status. - Remove guards for the first character being '/'. - Skip commented lines in fstab - Build Backup_Display_Name from partitions in super. The first four lines that are in fstab will be displayed. Change-Id: I3f8980187bd4a136257dd6eeaeddd7ea71706cd3 Change-Id: I1ee7c02f91aafb646beaf401a43bcb22fa8c8c7a
This commit is contained in:
@@ -165,10 +165,6 @@ ifeq ($(TW_USES_VENDOR_LIBS),true)
|
||||
LOCAL_CFLAGS += -DUSE_VENDOR_LIBS=1
|
||||
endif
|
||||
|
||||
ifneq ($(BOARD_SUPER_PARTITION_PARTITION_LIST),)
|
||||
LOCAL_CFLAGS += "-DBOARD_SUPER_PARTITION_PARTITION_LIST=\"$(shell echo $(BOARD_SUPER_PARTITION_PARTITION_LIST) | sed -r 's/\b(.)/\u\1/g' | sed -e 's/ \+/, /g')\""
|
||||
endif
|
||||
|
||||
ifeq ($(TW_NO_BIND_SYSTEM),true)
|
||||
LOCAL_CFLAGS += -DTW_NO_BIND_SYSTEM
|
||||
endif
|
||||
|
||||
+13
-21
@@ -162,6 +162,7 @@ enum TW_FSTAB_FLAGS {
|
||||
TWFLAG_WRAPPEDKEY,
|
||||
TWFLAG_ADOPTED_MOUNT_DELAY,
|
||||
TWFLAG_DM_USE_ORIGINAL_PATH,
|
||||
TWFLAG_LOGICAL,
|
||||
};
|
||||
|
||||
/* Flags without a trailing '=' are considered dual format flags and can be
|
||||
@@ -208,6 +209,7 @@ const struct flag_list tw_flags[] = {
|
||||
{ "wrappedkey", TWFLAG_WRAPPEDKEY },
|
||||
{ "adopted_mount_delay=", TWFLAG_ADOPTED_MOUNT_DELAY },
|
||||
{ "dm_use_original_path", TWFLAG_DM_USE_ORIGINAL_PATH },
|
||||
{ "logical", TWFLAG_LOGICAL },
|
||||
{ 0, 0 },
|
||||
};
|
||||
|
||||
@@ -301,6 +303,9 @@ bool TWPartition::Process_Fstab_Line(const char *fstab_line, bool Display_Error,
|
||||
}
|
||||
if (line_len < 10)
|
||||
return false; // There can't possibly be a valid fstab line that is less than 10 chars
|
||||
if (fstab_line[0] == '#')
|
||||
return false; // skip comments
|
||||
|
||||
if (strncmp(fstab_line, "/dev/", strlen("/dev/")) == 0 || strncmp(fstab_line, "/devices/", strlen("/devices/")) == 0) {
|
||||
fstab_version = 2;
|
||||
block_device_index = 0;
|
||||
@@ -308,8 +313,7 @@ bool TWPartition::Process_Fstab_Line(const char *fstab_line, bool Display_Error,
|
||||
fs_index = 2;
|
||||
}
|
||||
|
||||
Is_Super = PartitionManager.Is_Super_Partition(fstab_line);
|
||||
if (Is_Super) {
|
||||
if (fstab_line[0] != '/') {
|
||||
block_device_index = 0;
|
||||
fstab_version = 2;
|
||||
mount_point_index = 1;
|
||||
@@ -356,17 +360,10 @@ bool TWPartition::Process_Fstab_Line(const char *fstab_line, bool Display_Error,
|
||||
Primary_Block_Device = ptr;
|
||||
if (*ptr != '/')
|
||||
LOGERR("Until we get better BML support, you will have to find and provide the full block device path to the BML devices e.g. /dev/block/bml9 instead of the partition name\n");
|
||||
} else if (*ptr != '/') {
|
||||
if (!Is_Super) {
|
||||
if (Display_Error)
|
||||
LOGERR("Invalid block device '%s' in fstab line '%s'", ptr, fstab_line);
|
||||
else
|
||||
LOGINFO("Invalid block device '%s' in fstab line '%s'", ptr, fstab_line);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
Primary_Block_Device = ptr;
|
||||
Find_Real_Block_Device(Primary_Block_Device, Display_Error);
|
||||
if (*ptr == '/')
|
||||
Find_Real_Block_Device(Primary_Block_Device, Display_Error);
|
||||
}
|
||||
item_index++;
|
||||
} else if (item_index > 2) {
|
||||
@@ -1026,6 +1023,9 @@ void TWPartition::Apply_TW_Flag(const unsigned flag, const char* str, const bool
|
||||
case TWFLAG_DM_USE_ORIGINAL_PATH:
|
||||
Use_Original_Path = true;
|
||||
break;
|
||||
case TWFLAG_LOGICAL:
|
||||
Is_Super = true;
|
||||
break;
|
||||
default:
|
||||
// Should not get here
|
||||
LOGINFO("Flag identified for processing, but later unmatched: %i\n", flag);
|
||||
@@ -1248,16 +1248,8 @@ void TWPartition::Find_Real_Block_Device(string& Block, bool Display_Error) {
|
||||
memset(realDevice, 0, sizeof(realDevice));
|
||||
}
|
||||
|
||||
if (device[0] != '/') {
|
||||
if (Display_Error)
|
||||
LOGERR("Invalid symlink path '%s' found on block device '%s'\n", device, Block.c_str());
|
||||
else
|
||||
LOGINFO("Invalid symlink path '%s' found on block device '%s'\n", device, Block.c_str());
|
||||
return;
|
||||
} else {
|
||||
Block = device;
|
||||
return;
|
||||
}
|
||||
Block = device;
|
||||
return;
|
||||
}
|
||||
|
||||
bool TWPartition::Mount_Storage_Retry(bool Display_Error) {
|
||||
|
||||
+23
-30
@@ -159,9 +159,6 @@ int TWPartitionManager::Process_Fstab(string Fstab_Filename, bool Display_Error)
|
||||
if (fstabFile != NULL) {
|
||||
LOGINFO("Reading /etc/twrp.flags\n");
|
||||
while (fgets(fstab_line, sizeof(fstab_line), fstabFile) != NULL) {
|
||||
if (fstab_line[0] != '/')
|
||||
continue;
|
||||
|
||||
size_t line_size = strlen(fstab_line);
|
||||
if (fstab_line[line_size - 1] != '\n')
|
||||
fstab_line[line_size] = '\n';
|
||||
@@ -223,14 +220,12 @@ int TWPartitionManager::Process_Fstab(string Fstab_Filename, bool Display_Error)
|
||||
LOGINFO("Reading %s\n", Fstab_Filename.c_str());
|
||||
|
||||
while (fgets(fstab_line, sizeof(fstab_line), fstabFile) != NULL) {
|
||||
bool isSuper = Is_Super_Partition(fstab_line);
|
||||
|
||||
if (!isSuper && fstab_line[0] != '/')
|
||||
continue;
|
||||
|
||||
if (strstr(fstab_line, "swap"))
|
||||
continue; // Skip swap in recovery
|
||||
|
||||
if (fstab_line[0] == '#')
|
||||
continue;
|
||||
|
||||
size_t line_size = strlen(fstab_line);
|
||||
if (fstab_line[line_size - 1] != '\n')
|
||||
fstab_line[line_size] = '\n';
|
||||
@@ -285,9 +280,8 @@ int TWPartitionManager::Process_Fstab(string Fstab_Filename, bool Display_Error)
|
||||
else
|
||||
(*iter)->Has_Android_Secure = false;
|
||||
|
||||
if (Is_Super_Partition(TWFunc::Remove_Beginning_Slash((*iter)->Get_Mount_Point()).c_str())) {
|
||||
if ((*iter)->Is_Super)
|
||||
Prepare_Super_Volume((*iter));
|
||||
}
|
||||
}
|
||||
|
||||
//Setup Apex before decryption
|
||||
@@ -3341,6 +3335,7 @@ bool TWPartitionManager::Prepare_Super_Volume(TWPartition* twrpPart) {
|
||||
Fstab fstab;
|
||||
std::string bare_partition_name = Get_Bare_Partition_Name(twrpPart->Get_Mount_Point());
|
||||
|
||||
Super_Partition_List.push_back(bare_partition_name);
|
||||
LOGINFO("Trying to prepare %s from super partition\n", bare_partition_name.c_str());
|
||||
|
||||
std::string blk_device_partition;
|
||||
@@ -3394,23 +3389,9 @@ bool TWPartitionManager::Prepare_All_Super_Volumes() {
|
||||
return status;
|
||||
}
|
||||
|
||||
bool TWPartitionManager::Is_Super_Partition(const char* fstab_line) {
|
||||
if (!Get_Super_Status())
|
||||
return false;
|
||||
std::vector<std::string> super_partition_list = {"system", "vendor", "odm", "product", "system_ext"};
|
||||
|
||||
for (auto&& fstab_partition_check: super_partition_list) {
|
||||
if (strncmp(fstab_line, fstab_partition_check.c_str(), fstab_partition_check.size()) == 0) {
|
||||
DataManager::SetValue(TW_IS_SUPER, "1");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string TWPartitionManager::Get_Super_Partition() {
|
||||
int slot_number = Get_Active_Slot_Display() == "A" ? 0 : 1;
|
||||
std::string super_device = fs_mgr_get_super_partition_name(slot_number);
|
||||
std::string super_device = fs_mgr_get_super_partition_name(slot_number);
|
||||
return "/dev/block/by-name/" + super_device;
|
||||
}
|
||||
|
||||
@@ -3427,11 +3408,23 @@ void TWPartitionManager::Setup_Super_Partition() {
|
||||
superPartition->Mount_Point = "/super";
|
||||
superPartition->Actual_Block_Device = superPart;
|
||||
superPartition->Alternate_Block_Device = superPart;
|
||||
#ifdef BOARD_SUPER_PARTITION_PARTITION_LIST
|
||||
superPartition->Backup_Display_Name = "Super (" BOARD_SUPER_PARTITION_PARTITION_LIST ")";
|
||||
#else
|
||||
superPartition->Backup_Display_Name = "Super";
|
||||
#endif
|
||||
superPartition->Backup_Display_Name = "Super (";
|
||||
// Add first 4 items to fstab as logical that you would like to display in Backup_Display_Name
|
||||
// for the Super partition
|
||||
int list_size = Super_Partition_List.size();
|
||||
int orig_list_size = list_size;
|
||||
int max_display_size = 3; // total of 4 items since we start at 0
|
||||
|
||||
for (auto partition: Super_Partition_List) {
|
||||
superPartition->Backup_Display_Name = superPartition->Backup_Display_Name + partition;
|
||||
if ((orig_list_size - list_size) == max_display_size) {
|
||||
break;
|
||||
}
|
||||
if (list_size != 1)
|
||||
superPartition->Backup_Display_Name = superPartition->Backup_Display_Name + " ";
|
||||
list_size--;
|
||||
}
|
||||
superPartition->Backup_Display_Name += ")";
|
||||
superPartition->Can_Flash_Img = true;
|
||||
superPartition->Current_File_System = "emmc";
|
||||
superPartition->Can_Be_Backed_Up = true;
|
||||
|
||||
+1
-1
@@ -375,7 +375,6 @@ public:
|
||||
bool Decrypt_Adopted(); // Attempt to identy and decrypt any adopted storage partitions
|
||||
void Remove_Partition_By_Path(string Path); // Removes / erases a partition entry from the partition list
|
||||
bool Prepare_All_Super_Volumes(); // Prepare all known super volumes from super partition
|
||||
bool Is_Super_Partition(const char* fstab_line); // Checks if partition entry is a super partition
|
||||
bool Flash_Image(string& path, string& filename); // Flashes an image to a selected partition from the partition list
|
||||
bool Restore_Partition(struct PartitionSettings *part_settings); // Restore the partitions based on type
|
||||
TWAtomicInt stop_backup;
|
||||
@@ -432,6 +431,7 @@ private:
|
||||
std::vector<TWPartition*> Partitions; // Vector list of all partitions
|
||||
string Active_Slot_Display; // Current Active Slot (A or B) for display purposes
|
||||
std::vector<users_struct> Users_List; // List of FBE users
|
||||
std::vector<std::string> Super_Partition_List; // Display value for super partitions
|
||||
};
|
||||
|
||||
extern TWPartitionManager PartitionManager;
|
||||
|
||||
Reference in New Issue
Block a user