ntfs-3g: Fix cm-13 compatibility

CM-13 tree completely changes the names of the binaries that are created
for ntfs-3g.  If we are using a CM-13 tree (CM SDK 4) make sure the
dependencies and relinking are adjusted accordingly.

Also, adapt partition code so it can make use of whichever set of
binaries are present.

Change-Id: I810caafa818f18281fd29dcf8f31b3053133b5ed
diff --git a/partition.cpp b/partition.cpp
index a17a647..58db706 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -1013,13 +1013,21 @@
 		}
 	}
 
-	if (Current_File_System == "ntfs" && TWFunc::Path_Exists("/sbin/ntfs-3g")) {
+	if (Current_File_System == "ntfs" && (TWFunc::Path_Exists("/sbin/ntfs-3g") || TWFunc::Path_Exists("/sbin/mount.ntfs"))) {
 		string cmd;
+		string Ntfsmount_Binary = "";
+
+		if (TWFunc::Path_Exists("/sbin/ntfs-3g"))
+			Ntfsmount_Binary = "ntfs-3g";
+		else if (TWFunc::Path_Exists("/sbin/mount.ntfs"))
+			Ntfsmount_Binary = "mount.ntfs";
+
 		if (Mount_Read_Only)
-			cmd = "/sbin/ntfs-3g -o ro " + Actual_Block_Device + " " + Mount_Point;
+			cmd = "/sbin/" + Ntfsmount_Binary + " -o ro " + Actual_Block_Device + " " + Mount_Point;
 		else
-			cmd = "/sbin/ntfs-3g " + Actual_Block_Device + " " + Mount_Point;
+			cmd = "/sbin/" + Ntfsmount_Binary + " " + Actual_Block_Device + " " + Mount_Point;
 		LOGINFO("cmd: '%s'\n", cmd.c_str());
+
 		if (TWFunc::Exec_Cmd(cmd) == 0) {
 			return true;
 		} else {
@@ -1250,7 +1258,7 @@
 		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"))
+	else if (Current_File_System == "ntfs" && (TWFunc::Path_Exists("/sbin/ntfsfix") || TWFunc::Path_Exists("/sbin/fsck.ntfs")))
 		return true;
 	return false;
 }
@@ -1335,15 +1343,20 @@
 		}
 	}
 	if (Current_File_System == "ntfs") {
-		if (!TWFunc::Path_Exists("/sbin/ntfsfix")) {
+		string Ntfsfix_Binary;
+		if (TWFunc::Path_Exists("/sbin/ntfsfix"))
+			Ntfsfix_Binary = "ntfsfix";
+		else if (TWFunc::Path_Exists("/sbin/fsck.ntfs"))
+			Ntfsfix_Binary = "fsck.ntfs";
+		else {
 			gui_msg(Msg(msg::kError, "repair_not_exist={1} does not exist! Cannot repair!")("ntfsfix"));
 			return false;
 		}
 		if (!UnMount(true))
 			return false;
-		gui_msg(Msg("reparing=Repairing {1} using {2}...")(Display_Name)("ntfsfix"));
+		gui_msg(Msg("reparing=Repairing {1} using {2}...")(Display_Name)(Ntfsfix_Binary));
 		Find_Actual_Block_Device();
-		command = "/sbin/ntfsfix " + Actual_Block_Device;
+		command = "/sbin/" + Ntfsfix_Binary + " " + Actual_Block_Device;
 		LOGINFO("Repair command: %s\n", command.c_str());
 		if (TWFunc::Exec_Cmd(command) == 0) {
 			gui_msg("done=Done.");
@@ -1877,23 +1890,28 @@
 
 bool TWPartition::Wipe_NTFS() {
 	string command;
+	string Ntfsmake_Binary;
 
-	if (TWFunc::Path_Exists("/sbin/mkntfs")) {
-		if (!UnMount(true))
-			return false;
+	if (TWFunc::Path_Exists("/sbin/mkntfs"))
+		Ntfsmake_Binary = "mkntfs";
+	else if (TWFunc::Path_Exists("/sbin/mkfs.ntfs"))
+		Ntfsmake_Binary = "mkfs.ntfs";
+	else
+		return false;
 
-		gui_msg(Msg("formating_using=Formatting {1} using {2}...")(Display_Name)("mkntfs"));
-		Find_Actual_Block_Device();
-		command = "mkntfs " + Actual_Block_Device;
-		if (TWFunc::Exec_Cmd(command) == 0) {
-			Recreate_AndSec_Folder();
-			gui_msg("done=Done.");
-			return true;
-		} else {
-			gui_msg(Msg(msg::kError, "unable_to_wipe=Unable to wipe {1}.")(Display_Name));
-			return false;
-		}
+	if (!UnMount(true))
+		return false;
+
+	gui_msg(Msg("formating_using=Formatting {1} using {2}...")(Display_Name)(Ntfsmake_Binary));
+	Find_Actual_Block_Device();
+	command = "/sbin/" + Ntfsmake_Binary + " " + Actual_Block_Device;
+	if (TWFunc::Exec_Cmd(command) == 0) {
+		Recreate_AndSec_Folder();
+		gui_msg("done=Done.");
 		return true;
+	} else {
+		gui_msg(Msg(msg::kError, "unable_to_wipe=Unable to wipe {1}.")(Display_Name));
+		return false;
 	}
 	return false;
 }