Merge "Remove libjpegtwrp and use CM provided libjpeg" into twrp2.5
diff --git a/exfat/exfat-fuse/Android.mk b/exfat/exfat-fuse/Android.mk
index 9627835..f6ec20a 100644
--- a/exfat/exfat-fuse/Android.mk
+++ b/exfat/exfat-fuse/Android.mk
@@ -12,7 +12,7 @@
 					bootable/recovery/exfat/libexfat \
 					bootable/recovery/fuse/include
 LOCAL_SHARED_LIBRARIES += libz libc libexfat libdl 
-LOCAL_STATIC_LIBRARIES += libfuse
+LOCAL_STATIC_LIBRARIES += libfusetwrp
 
 include $(BUILD_EXECUTABLE)
 
diff --git a/exfat/mkfs/Android.mk b/exfat/mkfs/Android.mk
index bccd7c9..8c48c77 100644
--- a/exfat/mkfs/Android.mk
+++ b/exfat/mkfs/Android.mk
@@ -11,7 +11,7 @@
 					bootable/recovery/exfat/libexfat \
 					bootable/recovery/fuse/include
 LOCAL_SHARED_LIBRARIES += libz libc libexfat libdl 
-LOCAL_STATIC_LIBRARIES += libfuse
+LOCAL_STATIC_LIBRARIES += libfusetwrp
 
 include $(BUILD_EXECUTABLE)
 
diff --git a/fixPermissions.cpp b/fixPermissions.cpp
index 5d4b0d2..2fa1b66 100644
--- a/fixPermissions.cpp
+++ b/fixPermissions.cpp
@@ -59,7 +59,7 @@
 		return -1;
 	}
 
-	gui_print("Fixing /data/app permisions...\n");
+	gui_print("Fixing /data/app permissions...\n");
 	if ((fixDataApps()) != 0) {
 		return -1;
 	}
@@ -111,7 +111,7 @@
 			closedir(d);
 		}
 	} else {
-		gui_print("Fixing /data/data permisions...\n");
+		gui_print("Fixing /data/data permissions...\n");
 		if ((fixDataData("/data/data/")) != 0) {
 			return -1;
 		}
diff --git a/fuse/Android.mk b/fuse/Android.mk
index 59cd9b3..3bd1616 100644
--- a/fuse/Android.mk
+++ b/fuse/Android.mk
@@ -42,7 +42,7 @@
 	-D_FILE_OFFSET_BITS=64 \
 	-DFUSE_USE_VERSION=26
 
-LOCAL_MODULE := libfuse
+LOCAL_MODULE := libfusetwrp
 LOCAL_MODULE_TAGS := optional
 
 include $(BUILD_STATIC_LIBRARY)
@@ -61,6 +61,6 @@
 LOCAL_MODULE := fusexmp
 LOCAL_MODULE_TAGS := optional
 
-LOCAL_STATIC_LIBRARIES := libfuse
+LOCAL_STATIC_LIBRARIES := libfusetwrp
 
 include $(BUILD_EXECUTABLE)
diff --git a/twrpTar.cpp b/twrpTar.cpp
index a27374a..8bfbecd 100644
--- a/twrpTar.cpp
+++ b/twrpTar.cpp
@@ -840,10 +840,10 @@
 int twrpTar::addFilesToExistingTar(vector <string> files, string fn) {
 	char* charTarFile = (char*) fn.c_str();
 
-	if (tar_open(&t, charTarFile, NULL, O_RDONLY | O_LARGEFILE, 0644, TAR_GNU) == -1)
+	if (tar_open(&t, charTarFile, NULL, O_RDONLY | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TAR_GNU) == -1)
 		return -1;
 	removeEOT(charTarFile);
-	if (tar_open(&t, charTarFile, NULL, O_WRONLY | O_APPEND | O_LARGEFILE, 0644, TAR_GNU) == -1)
+	if (tar_open(&t, charTarFile, NULL, O_WRONLY | O_APPEND | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TAR_GNU) == -1)
 		return -1;
 	for (unsigned int i = 0; i < files.size(); ++i) {
 		char* file = (char*) files.at(i).c_str();
@@ -910,7 +910,7 @@
 				return -1;
 			} else if (oaes_pid == 0) {
 				// openaes Child
-				int output_fd = open(tarfn.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+				int output_fd = open(tarfn.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
 				if (output_fd < 0) {
 					LOGERR("Failed to open '%s'\n", tarfn.c_str());
 					for (i = 0; i < 4; i++)
@@ -936,7 +936,7 @@
 				close(pipes[2]);
 				close(pipes[3]);
 				fd = pipes[1];
-				if(tar_fdopen(&t, fd, charRootDir, NULL, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, 0644, TAR_GNU) != 0) {
+				if(tar_fdopen(&t, fd, charRootDir, NULL, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TAR_GNU) != 0) {
 					close(fd);
 					LOGERR("tar_fdopen failed\n");
 					return -1;
@@ -964,7 +964,7 @@
 		} else if (pigz_pid == 0) {
 			// Child
 			close(pigzfd[1]);   // close unused output pipe
-			int output_fd = open(tarfn.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+			int output_fd = open(tarfn.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
 			if (output_fd < 0) {
 				LOGERR("Failed to open '%s'\n", tarfn.c_str());
 				close(pigzfd[0]);
@@ -982,7 +982,7 @@
 			// Parent
 			close(pigzfd[0]); // close parent input
 			fd = pigzfd[1];   // copy parent output
-			if(tar_fdopen(&t, fd, charRootDir, NULL, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, 0644, TAR_GNU) != 0) {
+			if(tar_fdopen(&t, fd, charRootDir, NULL, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TAR_GNU) != 0) {
 				close(fd);
 				LOGERR("tar_fdopen failed\n");
 				return -1;
@@ -1005,7 +1005,7 @@
 		} else if (oaes_pid == 0) {
 			// Child
 			close(oaesfd[1]);   // close unused
-			int output_fd = open(tarfn.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+			int output_fd = open(tarfn.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
 			if (output_fd < 0) {
 				LOGERR("Failed to open '%s'\n", tarfn.c_str());
 				_exit(-1);
@@ -1022,7 +1022,7 @@
 			// Parent
 			close(oaesfd[0]); // close parent input
 			fd = oaesfd[1];   // copy parent output
-			if(tar_fdopen(&t, fd, charRootDir, NULL, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, 0644, TAR_GNU) != 0) {
+			if(tar_fdopen(&t, fd, charRootDir, NULL, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TAR_GNU) != 0) {
 				close(fd);
 				LOGERR("tar_fdopen failed\n");
 				return -1;
@@ -1032,7 +1032,7 @@
 	} else {
 		// Not compressed or encrypted
 		init_libtar_buffer(0);
-		if (tar_open(&t, charTarFile, &type, O_WRONLY | O_CREAT | O_LARGEFILE, 0644, TAR_GNU) == -1) {
+		if (tar_open(&t, charTarFile, &type, O_WRONLY | O_CREAT | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TAR_GNU) == -1) {
 			LOGERR("tar_open error opening '%s'\n", tarfn.c_str());
 			return -1;
 		}
@@ -1115,7 +1115,7 @@
 				close(pipes[1]);
 				close(pipes[3]);
 				fd = pipes[2];
-				if(tar_fdopen(&t, fd, charRootDir, NULL, O_RDONLY | O_LARGEFILE, 0644, TAR_GNU) != 0) {
+				if(tar_fdopen(&t, fd, charRootDir, NULL, O_RDONLY | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TAR_GNU) != 0) {
 					close(fd);
 					LOGERR("tar_fdopen failed\n");
 					return -1;
@@ -1156,7 +1156,7 @@
 			// Parent
 			close(oaesfd[1]); // close parent output
 			fd = oaesfd[0];   // copy parent input
-			if(tar_fdopen(&t, fd, charRootDir, NULL, O_RDONLY | O_LARGEFILE, 0644, TAR_GNU) != 0) {
+			if(tar_fdopen(&t, fd, charRootDir, NULL, O_RDONLY | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TAR_GNU) != 0) {
 				close(fd);
 				LOGERR("tar_fdopen failed\n");
 				return -1;
@@ -1193,13 +1193,13 @@
 			// Parent
 			close(pigzfd[1]); // close parent output
 			fd = pigzfd[0];   // copy parent input
-			if(tar_fdopen(&t, fd, charRootDir, NULL, O_RDONLY | O_LARGEFILE, 0644, TAR_GNU) != 0) {
+			if(tar_fdopen(&t, fd, charRootDir, NULL, O_RDONLY | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TAR_GNU) != 0) {
 				close(fd);
 				LOGERR("tar_fdopen failed\n");
 				return -1;
 			}
 		}
-	} else if (tar_open(&t, charTarFile, NULL, O_RDONLY | O_LARGEFILE, 0644, TAR_GNU) != 0) {
+	} else if (tar_open(&t, charTarFile, NULL, O_RDONLY | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TAR_GNU) != 0) {
 		LOGERR("Unable to open tar archive '%s'\n", charTarFile);
 		return -1;
 	}
@@ -1260,7 +1260,6 @@
 			return -1;
 	}
 	free_libtar_buffer();
-	TWFunc::tw_chmod(tarfn, "644");
 	return 0;
 }