From 75bf041a8ad75f8fc9bba69e937e12b129338a4c Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Fri, 21 Nov 2014 13:54:27 -0600 Subject: Make the android-5.0 branch compile in 4.4 to 4.1 Migrate previous minzip to minzipold replacing the existing minzipold. This will break compatibility with trees that do not support selinux (ICS and older). Migrate former verifier files to verifierold. Add fuse.h to recovery source because older trees do not have it. Add LOCAL_MODULE_TAGS where needed for 4.1 tree. Change-Id: Iade57cb2b0115af7fce9f56aa98636b1744a1ef4 --- minzipold/Android.mk | 10 +++------- minzipold/DirUtil.c | 5 ----- minzipold/DirUtil.h | 4 ---- minzipold/SysUtil.c | 8 ++++---- minzipold/Zip.c | 10 +++++----- minzipold/Zip.h | 4 ---- 6 files changed, 12 insertions(+), 29 deletions(-) (limited to 'minzipold') diff --git a/minzipold/Android.mk b/minzipold/Android.mk index 0435c6afb..68485abe1 100644 --- a/minzipold/Android.mk +++ b/minzipold/Android.mk @@ -8,15 +8,11 @@ LOCAL_SRC_FILES := \ Inlines.c \ Zip.c -LOCAL_C_INCLUDES += \ +LOCAL_C_INCLUDES := \ external/zlib \ external/safe-iop/include -ifeq ($(HAVE_SELINUX),true) -LOCAL_C_INCLUDES += external/libselinux/include -LOCAL_STATIC_LIBRARIES += libselinux -LOCAL_CFLAGS += -DHAVE_SELINUX -endif +LOCAL_STATIC_LIBRARIES := libselinux LOCAL_MODULE := libminzip @@ -39,7 +35,7 @@ LOCAL_C_INCLUDES += \ external/zlib \ external/safe-iop/include -ifeq ($(HAVE_SELINUX),true) +ifeq ($(TWHAVE_SELINUX),true) LOCAL_C_INCLUDES += external/libselinux/include LOCAL_STATIC_LIBRARIES += libselinux LOCAL_CFLAGS += -DHAVE_SELINUX diff --git a/minzipold/DirUtil.c b/minzipold/DirUtil.c index 0d49b5780..8dd5da1da 100644 --- a/minzipold/DirUtil.c +++ b/minzipold/DirUtil.c @@ -145,24 +145,19 @@ dirCreateHierarchy(const char *path, int mode, } else if (ds == DMISSING) { int err; -#ifdef HAVE_SELINUX char *secontext = NULL; if (sehnd) { selabel_lookup(sehnd, &secontext, cpath, mode); setfscreatecon(secontext); } -#endif err = mkdir(cpath, mode); -#ifdef HAVE_SELINUX - if (secontext) { freecon(secontext); setfscreatecon(NULL); } -#endif if (err != 0) { free(cpath); diff --git a/minzipold/DirUtil.h b/minzipold/DirUtil.h index f8be64026..a5cfa761b 100644 --- a/minzipold/DirUtil.h +++ b/minzipold/DirUtil.h @@ -24,12 +24,8 @@ extern "C" { #endif -#ifdef HAVE_SELINUX #include #include -#else -struct selabel_handle; -#endif /* Like "mkdir -p", try to guarantee that all directories * specified in path are present, creating as many directories diff --git a/minzipold/SysUtil.c b/minzipold/SysUtil.c index 49a2522d6..31c76d6d4 100644 --- a/minzipold/SysUtil.c +++ b/minzipold/SysUtil.c @@ -95,16 +95,16 @@ int sysLoadFileInShmem(int fd, MemMapping* pMap) if (memPtr == NULL) return -1; - actual = read(fd, memPtr, length); + pMap->baseAddr = pMap->addr = memPtr; + pMap->baseLength = pMap->length = length; + + actual = TEMP_FAILURE_RETRY(read(fd, memPtr, length)); if (actual != length) { LOGE("only read %d of %d bytes\n", (int) actual, (int) length); sysReleaseShmem(pMap); return -1; } - pMap->baseAddr = pMap->addr = memPtr; - pMap->baseLength = pMap->length = length; - return 0; } diff --git a/minzipold/Zip.c b/minzipold/Zip.c index 54d5d55a3..439e5d9cd 100644 --- a/minzipold/Zip.c +++ b/minzipold/Zip.c @@ -985,6 +985,7 @@ bool mzExtractRecursive(const ZipArchive *pArchive, unsigned int i; bool seenMatch = false; int ok = true; + int extractCount = 0; for (i = 0; i < pArchive->numEntries; i++) { ZipEntry *pEntry = pArchive->pEntries + i; if (pEntry->fileNameLen < zipDirLen) { @@ -1115,23 +1116,19 @@ bool mzExtractRecursive(const ZipArchive *pArchive, * Open the target for writing. */ -#ifdef HAVE_SELINUX char *secontext = NULL; if (sehnd) { selabel_lookup(sehnd, &secontext, targetFile, UNZIP_FILEMODE); setfscreatecon(secontext); } -#endif int fd = creat(targetFile, UNZIP_FILEMODE); -#ifdef HAVE_SELINUX if (secontext) { freecon(secontext); setfscreatecon(NULL); } -#endif if (fd < 0) { LOGE("Can't create target file \"%s\": %s\n", @@ -1154,13 +1151,16 @@ bool mzExtractRecursive(const ZipArchive *pArchive, break; } - LOGD("Extracted file \"%s\"\n", targetFile); + LOGV("Extracted file \"%s\"\n", targetFile); + ++extractCount; } } if (callback != NULL) callback(targetFile, cookie); } + LOGD("Extracted %d file(s)\n", extractCount); + free(helper.buf); free(zpath); diff --git a/minzipold/Zip.h b/minzipold/Zip.h index 4bb9ef6a4..c94282827 100644 --- a/minzipold/Zip.h +++ b/minzipold/Zip.h @@ -18,12 +18,8 @@ extern "C" { #endif -#ifdef HAVE_SELINUX #include #include -#else -struct selabel_handle; -#endif /* * One entry in the Zip archive. Treat this as opaque -- use accessors below. -- cgit v1.2.3