diff options
Diffstat (limited to 'partition.cpp')
-rw-r--r-- | partition.cpp | 74 |
1 files changed, 47 insertions, 27 deletions
diff --git a/partition.cpp b/partition.cpp index 7cf0ab3fb..e02def032 100644 --- a/partition.cpp +++ b/partition.cpp @@ -49,10 +49,15 @@ extern "C" { #ifdef TW_INCLUDE_CRYPTO_SAMSUNG #include "crypto/libcrypt_samsung/include/libcrypt_samsung.h" #endif +#ifdef USE_EXT4 + #include "make_ext4fs.h" +#endif } using namespace std; +extern struct selabel_handle *selinux_handle; + TWPartition::TWPartition(void) { Can_Be_Mounted = false; Can_Be_Wiped = false; @@ -902,7 +907,9 @@ bool TWPartition::Mount(bool Display_Error) { LOGINFO("Successfully mounted ecryptfs for '%s'\n", Mount_Point.c_str()); Is_Decrypted = true; } - } else { + } else if (Mount_Point == EXPAND(TW_EXTERNAL_STORAGE_PATH)) { + if (Is_Decrypted) + LOGINFO("Mounting external storage, '%s' is not encrypted\n", Mount_Point.c_str()); Is_Decrypted = false; } #endif @@ -1055,7 +1062,7 @@ bool TWPartition::Wipe_AndSec(void) { gui_print("Wiping %s\n", Backup_Display_Name.c_str()); TWFunc::removeDir(Mount_Point + "/.android_secure/", true); - return true; + return true; } bool TWPartition::Backup(string backup_folder) { @@ -1255,6 +1262,19 @@ bool TWPartition::Wipe_EXT4() { if (!UnMount(true)) return false; +#ifdef USE_EXT4 + gui_print("Formatting %s using make_ext4fs function.\n", Display_Name.c_str()); +#ifdef HAVE_SELINUX + if (make_ext4fs(Actual_Block_Device.c_str(), Length, Mount_Point.c_str(), selinux_handle) != 0) { +#else + if (make_ext4fs(Actual_Block_Device.c_str(), Length) != 0) { +#endif + LOGERR("Unable to wipe '%s' using function call.\n", Mount_Point.c_str()); + return false; + } else { + return true; + } +#else if (TWFunc::Path_Exists("/sbin/make_ext4fs")) { string Command, result; @@ -1281,7 +1301,7 @@ bool TWPartition::Wipe_EXT4() { } } else return Wipe_EXT23("ext4"); - +#endif return false; } @@ -1341,31 +1361,31 @@ bool TWPartition::Wipe_MTD() { gui_print("MTD Formatting \"%s\"\n", MTD_Name.c_str()); - mtd_scan_partitions(); - const MtdPartition* mtd = mtd_find_partition_by_name(MTD_Name.c_str()); - if (mtd == NULL) { - LOGERR("No mtd partition named '%s'", MTD_Name.c_str()); - return false; - } - - MtdWriteContext* ctx = mtd_write_partition(mtd); - if (ctx == NULL) { - LOGERR("Can't write '%s', failed to format.", MTD_Name.c_str()); - return false; - } - if (mtd_erase_blocks(ctx, -1) == -1) { - mtd_write_close(ctx); - LOGERR("Failed to format '%s'", MTD_Name.c_str()); - return false; - } - if (mtd_write_close(ctx) != 0) { - LOGERR("Failed to close '%s'", MTD_Name.c_str()); - return false; - } + mtd_scan_partitions(); + const MtdPartition* mtd = mtd_find_partition_by_name(MTD_Name.c_str()); + if (mtd == NULL) { + LOGERR("No mtd partition named '%s'", MTD_Name.c_str()); + return false; + } + + MtdWriteContext* ctx = mtd_write_partition(mtd); + if (ctx == NULL) { + LOGERR("Can't write '%s', failed to format.", MTD_Name.c_str()); + return false; + } + if (mtd_erase_blocks(ctx, -1) == -1) { + mtd_write_close(ctx); + LOGERR("Failed to format '%s'", MTD_Name.c_str()); + return false; + } + if (mtd_write_close(ctx) != 0) { + LOGERR("Failed to close '%s'", MTD_Name.c_str()); + return false; + } Current_File_System = "yaffs2"; Recreate_AndSec_Folder(); gui_print("Done.\n"); - return true; + return true; } bool TWPartition::Wipe_RMRF() { @@ -1395,7 +1415,7 @@ bool TWPartition::Wipe_Data_Without_Wiping_Media() { if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0) continue; // 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. + // the media folder for multi-user. if (strcmp(de->d_name, "media") == 0 || strcmp(de->d_name, ".layout_version") == 0) continue; dir = "/data/"; @@ -1540,7 +1560,7 @@ bool TWPartition::Restore_Tar(string restore_folder, string Restore_File_System) } else { gui_print("Wiping %s...\n", Display_Name.c_str()); if (!Wipe(Restore_File_System)) - return false; + return false; } TWFunc::GUI_Operation_Text(TW_RESTORE_TEXT, Backup_Display_Name, "Restoring"); gui_print("Restoring %s...\n", Backup_Display_Name.c_str()); |