Merge "use libblkid to get filesystem type we can now use libblkid to detect exfat" into twrp2.4
diff --git a/libtar/extract.c b/libtar/extract.c
index 5544287..620513c 100644
--- a/libtar/extract.c
+++ b/libtar/extract.c
@@ -89,13 +89,13 @@
 
 /* switchboard */
 int
-tar_extract_file(TAR *t, char *realname)
+tar_extract_file(TAR *t, char *realname, char *prefix)
 {
 	int i;
 	char *lnp;
 	int pathname_len;
 	int realname_len;
-	
+
 	if (t->options & TAR_NOOVERWRITE)
 	{
 		struct stat s;
@@ -115,7 +115,7 @@
 	}
 	else if (TH_ISLNK(t)) {
 		printf("link\n");
-		i = tar_extract_hardlink(t, realname);
+		i = tar_extract_hardlink(t, realname, prefix);
 	}
 	else if (TH_ISSYM(t)) {
 		printf("sym\n");
@@ -139,13 +139,13 @@
 	}
 
 	if (i != 0) {
-		printf("here i: %d\n", i);
+		printf("FAILED RESTORE OF FILE i: %s\n", realname);
 		return i;
 	}
 
 	i = tar_set_file_perms(t, realname);
 	if (i != 0) {
-		printf("i: %d\n", i);
+		printf("FAILED SETTING PERMS: %d\n", i);
 		return i;
 	}
 /*
@@ -300,7 +300,7 @@
 
 /* hardlink */
 int
-tar_extract_hardlink(TAR * t, char *realname)
+tar_extract_hardlink(TAR * t, char *realname, char *prefix)
 {
 	char *filename;
 	char *linktgt = NULL;
@@ -325,7 +325,8 @@
 	}
 	else
 		linktgt = th_get_linkname(t);
-
+	char *newtgt = strdup(linktgt);
+	sprintf(linktgt, "%s/%s", prefix, newtgt);
 #ifdef DEBUG
 	printf("  ==> extracting: %s (link to %s)\n", filename, linktgt);
 #endif
@@ -346,7 +347,7 @@
 tar_extract_symlink(TAR *t, char *realname)
 {
 	char *filename;
-	
+
 	if (!TH_ISSYM(t))
 	{
 		printf("not a sym\n");
@@ -412,9 +413,9 @@
 		  compat_makedev(devmaj, devmin)) == -1)
 	{
 #ifdef DEBUG
-		perror("mknod()");
+		printf("mknod() failed, returning good anyway");
 #endif
-		return -1;
+		return 0;
 	}
 
 	return 0;
@@ -451,9 +452,9 @@
 		  compat_makedev(devmaj, devmin)) == -1)
 	{
 #ifdef DEBUG
-		perror("mknod()");
+		printf("mknod() failed but returning anyway");
 #endif
-		return -1;
+		return 0;
 	}
 
 	return 0;
diff --git a/libtar/libtar.h b/libtar/libtar.h
index 7a8f332..f2f423b 100644
--- a/libtar/libtar.h
+++ b/libtar/libtar.h
@@ -218,11 +218,11 @@
 /***** extract.c ***********************************************************/
 
 /* sequentially extract next file from t */
-int tar_extract_file(TAR *t, char *realname);
+int tar_extract_file(TAR *t, char *realname, char *prefix);
 
 /* extract different file types */
 int tar_extract_dir(TAR *t, char *realname);
-int tar_extract_hardlink(TAR *t, char *realname);
+int tar_extract_hardlink(TAR *t, char *realname, char *prefix);
 int tar_extract_symlink(TAR *t, char *realname);
 int tar_extract_chardev(TAR *t, char *realname);
 int tar_extract_blockdev(TAR *t, char *realname);
diff --git a/libtar/wrapper.c b/libtar/wrapper.c
index 7cd8ed1..4d82162 100644
--- a/libtar/wrapper.c
+++ b/libtar/wrapper.c
@@ -44,7 +44,7 @@
 			snprintf(buf, sizeof(buf), "%s/%s", prefix, filename);
 		else
 			strlcpy(buf, filename, sizeof(buf));
-		if (tar_extract_file(t, filename) != 0)
+		if (tar_extract_file(t, filename, prefix) != 0)
 			return -1;
 	}
 
@@ -86,7 +86,7 @@
 			continue;
 		}
 		*/
-		if (tar_extract_file(t, buf) != 0)  
+		if (tar_extract_file(t, buf, prefix) != 0)
 			return -1;
 	}
 	return (i == 1 ? 0 : -1);
diff --git a/twrpTar.cpp b/twrpTar.cpp
index c4600aa..159c1d1 100644
--- a/twrpTar.cpp
+++ b/twrpTar.cpp
@@ -122,7 +122,7 @@
 	int status;
 	pid_t pid;
 	if ((pid = fork()) == -1) {
-		LOGI("create tar failed to fork.\n");
+		LOGI("extract tar failed to fork.\n");
 		return -1;
 	}
 	if (pid == 0) {
@@ -133,7 +133,7 @@
 	}
 	else {
 		if ((pid = wait(&status)) == -1) {
-			LOGI("Tar creation failed\n");
+			LOGI("Tar extraction failed\n");
 			return -1;
 		}
 		else {
@@ -142,9 +142,9 @@
 				return -1;
 			}
 			else if (WIFEXITED(status) != 0)
-				LOGI("Tar creation successful\n");
+				LOGI("Tar extraction successful\n");
 			else {
-				LOGI("Tar creation failed\n");
+				LOGI("Tar extraction failed\n");
 				return -1;
 			}
 		}
@@ -210,6 +210,8 @@
 		FileName += de->d_name;
 		if (has_data_media == 1 && FileName.size() >= 11 && strncmp(FileName.c_str(), "/data/media", 11) == 0)
 			continue; // Skip /data/media
+		if (de->d_type == DT_BLK || de->d_type == DT_CHR)
+			continue;
 		if (de->d_type == DT_DIR && strcmp(de->d_name, ".") != 0 && strcmp(de->d_name, "..") != 0)
 		{
 			unsigned long long folder_size = TWFunc::Get_Folder_Size(FileName, false);
@@ -344,6 +346,8 @@
 			LOGI("adding %s\n", de->d_name);
 #ifdef RECOVERY_SDCARD_ON_DATA
 			if ((tardir == "/data" || tardir == "/data/") && strcmp(de->d_name, "media") == 0) continue;
+			if (de->d_type == DT_BLK || de->d_type == DT_CHR)
+				continue;
 #endif
 			if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0)   continue;
 
diff --git a/variables.h b/variables.h
index 826eb6b..6a87f2c 100644
--- a/variables.h
+++ b/variables.h
@@ -17,7 +17,7 @@
 #ifndef _VARIABLES_HEADER_
 #define _VARIABLES_HEADER_
 
-#define TW_VERSION_STR              "2.4.1.0"
+#define TW_VERSION_STR              "2.4.2.0"
 
 #define TW_USE_COMPRESSION_VAR      "tw_use_compression"
 #define TW_FILENAME                 "tw_filename"
@@ -164,7 +164,7 @@
 //   tw_sp2_is_mountable
 //   tw_sp3_is_mountable
 
-// Max archive size for tar backups before we split (1.5GB)

+// Max archive size for tar backups before we split (1.5GB)
 #define MAX_ARCHIVE_SIZE 1610612736LLU
 
 #ifndef CUSTOM_LUN_FILE