diff options
| author | 2021-11-10 16:33:16 +0000 | |
|---|---|---|
| committer | 2021-11-10 16:33:16 +0000 | |
| commit | 97fe9c7a9c645e0c522d1cf61519e12b623aafbf (patch) | |
| tree | df504aad819f9953db7c3f1b4974ee6022d53def | |
| parent | 39bf2ed7e5c84566f0baf252323147e5b4136b62 (diff) | |
| parent | 61a0a35dd5ef7dc73c49dee549296765c8fcb706 (diff) | |
Merge "Compress .so files for PackageManager to reclaim the space"
| -rw-r--r-- | core/jni/com_android_internal_content_NativeLibraryHelper.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp index be82879c8411..ef6fd7dd6829 100644 --- a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp +++ b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp @@ -36,6 +36,7 @@ #include <inttypes.h> #include <sys/stat.h> #include <sys/types.h> +#include <linux/fs.h> #include <memory> @@ -253,6 +254,16 @@ copyFileIfChanged(JNIEnv *env, void* arg, ZipFileRO* zipFile, ZipEntryRO zipEntr return INSTALL_FAILED_CONTAINER_ERROR; } + // If a filesystem like f2fs supports per-file compression, set the compression bit before data + // writes + unsigned int flags; + if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1) { + ALOGE("Failed to call FS_IOC_GETFLAGS on %s: %s\n", localTmpFileName, strerror(errno)); + } else if ((flags & FS_COMPR_FL) == 0) { + flags |= FS_COMPR_FL; + ioctl(fd, FS_IOC_SETFLAGS, &flags); + } + if (!zipFile->uncompressEntry(zipEntry, fd)) { ALOGE("Failed uncompressing %s to %s\n", fileName, localTmpFileName); close(fd); |