diff options
Diffstat (limited to 'partition.cpp')
-rw-r--r-- | partition.cpp | 78 |
1 files changed, 33 insertions, 45 deletions
diff --git a/partition.cpp b/partition.cpp index 31b1bfdb3..95f6bcac4 100644 --- a/partition.cpp +++ b/partition.cpp @@ -74,10 +74,18 @@ static struct flag_list mount_flags[] = { { "remount", MS_REMOUNT }, { "bind", MS_BIND }, { "rec", MS_REC }, +#ifdef MS_UNBINDABLE { "unbindable", MS_UNBINDABLE }, +#endif +#ifdef MS_PRIVATE { "private", MS_PRIVATE }, +#endif +#ifdef MS_SLAVE { "slave", MS_SLAVE }, +#endif +#ifdef MS_SHARED { "shared", MS_SHARED }, +#endif { "sync", MS_SYNCHRONOUS }, { "defaults", 0 }, { 0, 0 }, @@ -353,10 +361,6 @@ bool TWPartition::Process_Fstab_Line(string Line, bool Display_Error) { Is_Storage = true; Removable = true; Wipe_Available_in_GUI = true; -#ifndef RECOVERY_SDCARD_ON_DATA - Setup_AndSec(); - Mount_Storage_Retry(); -#endif #endif } #ifdef TW_INTERNAL_STORAGE_PATH @@ -365,20 +369,12 @@ bool TWPartition::Process_Fstab_Line(string Line, bool Display_Error) { Is_Settings_Storage = true; Storage_Path = EXPAND(TW_INTERNAL_STORAGE_PATH); Wipe_Available_in_GUI = true; -#ifndef RECOVERY_SDCARD_ON_DATA - Setup_AndSec(); - Mount_Storage_Retry(); -#endif } #else if (Mount_Point == "/emmc" || Mount_Point == "/internal_sd" || Mount_Point == "/internal_sdcard") { Is_Storage = true; Is_Settings_Storage = true; Wipe_Available_in_GUI = true; -#ifndef RECOVERY_SDCARD_ON_DATA - Setup_AndSec(); - Mount_Storage_Retry(); -#endif } #endif } else if (Is_Image(Fstab_File_System)) { @@ -391,7 +387,6 @@ bool TWPartition::Process_Fstab_Line(string Line, bool Display_Error) { } else if (Mount_Point == "/recovery") { Display_Name = "Recovery"; Backup_Display_Name = Display_Name; - Can_Be_Backed_Up = true; } } @@ -458,8 +453,20 @@ bool TWPartition::Process_Flags(string Flags, bool Display_Error) { ptr_len = strlen(ptr); if (strcmp(ptr, "removable") == 0) { Removable = true; - } else if (strcmp(ptr, "storage") == 0) { - Is_Storage = true; + } else if (strncmp(ptr, "storage", 7) == 0) { + if (ptr_len == 7) { + LOGINFO("ptr_len is 7, storage set to true\n"); + Is_Storage = true; + } else if (ptr_len == 9) { + ptr += 9; + if (*ptr == '1' || *ptr == 'y' || *ptr == 'Y') { + LOGINFO("storage set to true\n"); + Is_Storage = true; + } else { + LOGINFO("storage set to false\n"); + Is_Storage = false; + } + } } else if (strcmp(ptr, "settingsstorage") == 0) { Is_Storage = true; } else if (strcmp(ptr, "canbewiped") == 0) { @@ -644,6 +651,7 @@ void TWPartition::Setup_AndSec(void) { Backup_Path = Symlink_Mount_Point; Make_Dir("/and-sec", true); Recreate_AndSec_Folder(); + Mount_Storage_Retry(); } void TWPartition::Find_Real_Block_Device(string& Block, bool Display_Error) { @@ -1519,8 +1527,9 @@ bool TWPartition::Wipe_Data_Without_Wiping_Media() { // The media folder is the "internal sdcard" // The .layout_version file is responsible for determining whether 4.2 decides up upgrade // the media folder for multi-user. + //TODO: convert this to use twrpDU.cpp if (strcmp(de->d_name, "media") == 0 || strcmp(de->d_name, ".layout_version") == 0) continue; - + dir = "/data/"; dir.append(de->d_name); if (de->d_type == DT_DIR) { @@ -1531,6 +1540,7 @@ bool TWPartition::Wipe_Data_Without_Wiping_Media() { } } closedir(d); + gui_print("Done.\n"); return true; } @@ -1575,35 +1585,12 @@ bool TWPartition::Backup_Tar(string backup_folder) { Backup_FileName = back_name; Full_FileName = backup_folder + "/" + Backup_FileName; tar.has_data_media = Has_Data_Media; - if (!use_encryption && Backup_Size > MAX_ARCHIVE_SIZE) { - // This backup needs to be split into multiple archives - gui_print("Breaking backup file into multiple archives...\n"); - sprintf(back_name, "%s", Backup_Path.c_str()); - tar.setdir(back_name); - tar.setfn(Full_FileName); - backup_count = tar.splitArchiveFork(); - if (backup_count == -1) { - LOGERR("Error tarring split files!\n"); - return false; - } - return true; - } else { - Full_FileName = backup_folder + "/" + Backup_FileName; - tar.setdir(Backup_Path); - tar.setfn(Full_FileName); - if (tar.createTarFork() != 0) - return false; - if (use_compression && !use_encryption) { - string gzname = Full_FileName + ".gz"; - rename(gzname.c_str(), Full_FileName.c_str()); - } - if (use_encryption) - Full_FileName += "000"; - if (TWFunc::Get_File_Size(Full_FileName) == 0) { - LOGERR("Backup file size for '%s' is 0 bytes.\n", Full_FileName.c_str()); - return false; - } - } + Full_FileName = backup_folder + "/" + Backup_FileName; + tar.setdir(Backup_Path); + tar.setfn(Full_FileName); + tar.setsize(Backup_Size); + if (tar.createTarFork() != 0) + return false; return true; } @@ -1778,6 +1765,7 @@ bool TWPartition::Update_Size(bool Display_Error) { unsigned long long data_media_used, actual_data; du.add_relative_dir("media"); Used = du.Get_Folder_Size("/data"); + du.clear_relative_dir("media"); Backup_Size = Used; int bak = (int)(Used / 1048576LLU); int fre = (int)(Free / 1048576LLU); |