summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBadhri Jagan Sridharan2015-06-02 16:47:57 -0500
committerElliott Hughes2015-06-04 15:26:29 -0500
commit71aebefe49d8126f522287bd35d17c432a4e6383 (patch)
tree62d17ad6061b67794b02c0e32a0c76798d8f2b56 /libziparchive/zip_archive.cc
parent67ab5d95058d6fe1bab71b3f69e1934728902995 (diff)
downloadplatform-system-core-71aebefe49d8126f522287bd35d17c432a4e6383.tar.gz
platform-system-core-71aebefe49d8126f522287bd35d17c432a4e6383.tar.xz
platform-system-core-71aebefe49d8126f522287bd35d17c432a4e6383.zip
libziparchive: fix fallocate failures
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 a68d0d1fe48afc7a7a7fd0ee42df1607f21fa996)
Diffstat (limited to 'libziparchive/zip_archive.cc')
-rw-r--r--libziparchive/zip_archive.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/libziparchive/zip_archive.cc b/libziparchive/zip_archive.cc
index 79c4c53c7..b2a9f88c5 100644
--- a/libziparchive/zip_archive.cc
+++ b/libziparchive/zip_archive.cc
@@ -1008,8 +1008,13 @@ class FileWriter : public Writer {
1008 // entry. Note that the call to ftruncate below will change the file size but 1008 // entry. Note that the call to ftruncate below will change the file size but
1009 // will not allocate space on disk and this call to fallocate will not 1009 // will not allocate space on disk and this call to fallocate will not
1010 // change the file size. 1010 // change the file size.
1011 // Note: fallocate is only supported by the following filesystems -
1012 // btrfs, ext4, ocfs2, and xfs. Therefore fallocate might fail with
1013 // EOPNOTSUPP error when issued in other filesystems.
1014 // Hence, check for the return error code before concluding that the
1015 // disk does not have enough space.
1011 result = TEMP_FAILURE_RETRY(fallocate(fd, 0, current_offset, declared_length)); 1016 result = TEMP_FAILURE_RETRY(fallocate(fd, 0, current_offset, declared_length));
1012 if (result == -1) { 1017 if (result == -1 && errno == ENOSPC) {
1013 ALOGW("Zip: unable to allocate space for file to %" PRId64 ": %s", 1018 ALOGW("Zip: unable to allocate space for file to %" PRId64 ": %s",
1014 static_cast<int64_t>(declared_length + current_offset), strerror(errno)); 1019 static_cast<int64_t>(declared_length + current_offset), strerror(errno));
1015 return std::unique_ptr<FileWriter>(nullptr); 1020 return std::unique_ptr<FileWriter>(nullptr);