The objective of fallocate call seems to be to
make sure that we have enough enough space left
in the disk to house the uncompressed file.
But, fallocate is only supported in the following
file systems:
btrfs, ext4, ocfs2, and xfs
Return error only when fallocate fails due to
lack of space. The immediate ftruncate call is
going to take of the majority of other errors.
Bug: http://b/21558406
Bug: 21561449
Change-Id: I7083f3c7e5d745bd6e8a190ac9020297d638d9d4
(cherry picked from commit a68d0d1fe4)
We're already linking against libbase but we'll have to add
a libbase dependency to every target that includes libziparchive
as a STATIC_LIBRARY dependency, given that there's no way to
express that what we want (except by adding a LOCAL_WHOLE_STATIC_LIBRARY
dependency on libbase to libziparchive but that seems bad too)
Bug: http://b/21558406
Change-Id: I294ad389a9c61a1134a7bc323da25b0004a8f1e0
(cherry picked from commit e97e66ea7c)
It's unnecessary, and causes issues when the uncompressed
output is large.
Bug: http://b/21558406
Change-Id: I99cfb3933b094c2826c7e6c6de9aab03478fcc53
(cherry picked from commit f899bd534b)
There were crashes when android failed to extract
zip archives due to out of free space on disk, with stacks like:
#00 pc 00000000000156b0 /system/lib64/libc.so (memcpy+176)
#01 pc 000000000002e5b8 /system/lib64/libandroidfw.so
#02 pc 000000000002f488 /system/lib64/libandroidfw.so (ExtractToMemory+328)
#03 pc 000000000002f5c8 /system/lib64/libandroidfw.so (ExtractEntryToFile+268)
#04 pc 00000000000287d8 /system/lib64/libandroidfw.so (android::ZipFileRO::\
uncompressEntry(void*, int) const+12)
Space for the file is now allocated using fallocate rather than
ftruncate, since ftruncate dont actually reserve space on disk. When writes
to the mmaped pointer fails to be realized due to out of space SIGBUS
is the result. With this change we make sure that there is space available
before mmaping the pointer.
Change-Id: Ic5e8c33dbe729edb57919dacff73811b34cc2dc2
libziparchive fails to iterate some bootanimation archives
reporting invalid offset error. This is caused by failure
to process a directory with one file
(when name_offset + file_name_length == cd_offset).
Change-Id: I2733e7f782c14a6fadd5491bb94318ac968df206
Nobody ever called acquire() so release() was always
equivalent to delete. Just use delete instead so that
people can use unique_ptr directly (or shared_ptr if
they really want refcounts).
Change-Id: I9e3ad5e0f6a4fcc4e02e5a2ff7ef9514fe234415
Removed LOCAL_C_INCLUDES which are no longer necessary as zlib
now uses the LOCAL_EXPORT_C_INCLUDE_DIRS mechanism.
Removed a couple of redundant LOCAL_MODULE entries
Tested compiling some of the projects that make use of libziparchive
and libziparchive-host using a clean out dir with aosp_flounder-userdebug
aosp_arm-eng targets
make -j3 libziparchive libandroidfw libartd libart libjavacore libjavacoretests aapt
Change-Id: I2988f1b3a62d1df2b5eada4ad39a9246ac1184fb
With mingw 4.8, the new default packed behavior is broken and makes
zip archive fails due to unexpected misalignment in
CentralDirectoryRecord.
This patch uses -mno-ms-bitfields to revert to the old packed
behavior.
Change-Id: Ic977c841e330e19451db1d31ddb22e570a525062
There should never be a need of an entry name with \0 character.
Bug: 16162465
(cherry picked from commit 78271ba97b)
Change-Id: I68c72fb45e8ec70eb125cfc887488bc18ba5447d
It's important because entry names can be encoded in UTF-8 and can have \0
character in the middle.
Use vector instead of char* for prefix in IterationHandle.
Bug: 16162465
Change-Id: Ie34c8d7c6231cc258530c22bdde5542895213649
Add new public method to allow checkisc if an archive has entry names encoded in
UTF-8. If not then they will be encoded in IBM PC character encoding.
Bug: 16162465
Change-Id: I4468d76accca8a9b0b31cae8d43399ffc22cad42
in StartIteration. This method should always be called when the
iteration is over to make sure that we don't leak memory.
Change-Id: I5205c754dfafbab9bb5f06003c3663d2ec4e8a35
Given that all current & future android ABIs are
little endian, we can get rid of the explicit conversions
from memory regions to little endian data members.
Also cleans up a few C style casts that snuck in during
several -Werror efforts and fixes temporary file generation
on target.
bug: 15448202
Change-Id: I4fcbb3c1124cb82c82139d328344e54fc7895353