diff options
-rw-r--r-- | Android.mk | 6 | ||||
-rw-r--r-- | partition.cpp | 60 | ||||
-rw-r--r-- | partitions.hpp | 1 | ||||
-rw-r--r-- | prebuilt/Android.mk | 5 |
4 files changed, 72 insertions, 0 deletions
diff --git a/Android.mk b/Android.mk index 664c487e8..c1365e70a 100644 --- a/Android.mk +++ b/Android.mk @@ -382,6 +382,12 @@ ifneq ($(TARGET_RECOVERY_DEVICE_MODULES),) endif LOCAL_CFLAGS += -DTWRES=\"$(TWRES_PATH)\" LOCAL_CFLAGS += -DTWHTCD_PATH=\"$(TWHTCD_PATH)\" +ifeq ($(TW_INCLUDE_NTFS_3G),true) + LOCAL_ADDITIONAL_DEPENDENCIES += \ + ntfs-3g \ + ntfsfix \ + mkntfs +endif include $(BUILD_EXECUTABLE) diff --git a/partition.cpp b/partition.cpp index 6c5cf532e..e612be34f 100644 --- a/partition.cpp +++ b/partition.cpp @@ -974,6 +974,20 @@ bool TWPartition::Mount(bool Display_Error) { } } + if (Current_File_System == "ntfs" && TWFunc::Path_Exists("/sbin/ntfs-3g")) { + string cmd; + if (Mount_Read_Only) + cmd = "/sbin/ntfs-3g -o ro " + Actual_Block_Device + " " + Mount_Point; + else + cmd = "/sbin/ntfs-3g " + Actual_Block_Device + " " + Mount_Point; + LOGINFO("cmd: '%s'\n", cmd.c_str()); + if (TWFunc::Exec_Cmd(cmd) == 0) { + return true; + } else { + LOGINFO("ntfs-3g failed to mount, trying regular mount method.\n"); + } + } + if (Mount_Read_Only) flags |= MS_RDONLY; @@ -1126,6 +1140,8 @@ bool TWPartition::Wipe(string New_File_System) { wiped = Wipe_MTD(); else if (New_File_System == "f2fs") wiped = Wipe_F2FS(); + else if (New_File_System == "ntfs") + wiped = Wipe_NTFS(); else { LOGERR("Unable to wipe '%s' -- unknown file system '%s'\n", Mount_Point.c_str(), New_File_System.c_str()); unlink("/.layout_version"); @@ -1195,6 +1211,8 @@ bool TWPartition::Can_Repair() { return true; else if (Current_File_System == "f2fs" && TWFunc::Path_Exists("/sbin/fsck.f2fs")) return true; + else if (Current_File_System == "ntfs" && TWFunc::Path_Exists("/sbin/ntfsfix")) + return true; return false; } @@ -1277,6 +1295,25 @@ bool TWPartition::Repair() { return false; } } + if (Current_File_System == "ntfs") { + if (!TWFunc::Path_Exists("/sbin/ntfsfix")) { + gui_print("ntfsfix does not exist! Cannot repair!\n"); + return false; + } + if (!UnMount(true)) + return false; + gui_print("Repairing %s using ntfsfix...\n", Display_Name.c_str()); + Find_Actual_Block_Device(); + command = "/sbin/ntfsfix " + Actual_Block_Device; + LOGINFO("Repair command: %s\n", command.c_str()); + if (TWFunc::Exec_Cmd(command) == 0) { + gui_print("Done.\n"); + return true; + } else { + LOGERR("Unable to repair '%s'.\n", Mount_Point.c_str()); + return false; + } + } return false; } @@ -1768,6 +1805,29 @@ bool TWPartition::Wipe_F2FS() { return false; } +bool TWPartition::Wipe_NTFS() { + string command; + + if (TWFunc::Path_Exists("/sbin/mkntfs")) { + if (!UnMount(true)) + return false; + + gui_print("Formatting %s using mkntfs...\n", Display_Name.c_str()); + Find_Actual_Block_Device(); + command = "mkntfs " + Actual_Block_Device; + if (TWFunc::Exec_Cmd(command) == 0) { + Recreate_AndSec_Folder(); + gui_print("Done.\n"); + return true; + } else { + LOGERR("Unable to wipe '%s'.\n", Mount_Point.c_str()); + return false; + } + return true; + } + return false; +} + bool TWPartition::Wipe_Data_Without_Wiping_Media() { #ifdef TW_OEM_BUILD // In an OEM Build we want to do a full format diff --git a/partitions.hpp b/partitions.hpp index 63c01af8d..afcd47431 100644 --- a/partitions.hpp +++ b/partitions.hpp @@ -108,6 +108,7 @@ private: bool Wipe_MTD(); // Formats as yaffs2 for MTD memory types bool Wipe_RMRF(); // Uses rm -rf to wipe bool Wipe_F2FS(); // Uses mkfs.f2fs to wipe + bool Wipe_NTFS(); // Uses mkntfs to wipe bool Wipe_Data_Without_Wiping_Media(); // Uses rm -rf to wipe but does not wipe /data/media bool Backup_Tar(string backup_folder, const unsigned long long *overall_size, const unsigned long long *other_backups_size, pid_t &tar_fork_pid); // Backs up using tar for file systems bool Backup_DD(string backup_folder); // Backs up using dd for emmc memory types diff --git a/prebuilt/Android.mk b/prebuilt/Android.mk index efa1b95e9..a3cbd7a0e 100644 --- a/prebuilt/Android.mk +++ b/prebuilt/Android.mk @@ -166,6 +166,11 @@ endif ifneq ($(wildcard external/pcre/Android.mk),) RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libpcre.so endif +ifeq ($(TW_INCLUDE_NTFS_3G),true) + RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/ntfs-3g + RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/ntfsfix + RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/mkntfs +endif TWRP_AUTOGEN := $(intermediates)/teamwin |