Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 11413cd2 authored by Narayan Kamath's avatar Narayan Kamath Committed by Android Git Automerger
Browse files

am 9916e0b4: am 46745cb2: am 4d0cb5e8: Merge "Reserve space on disk using fallocate"

* commit '9916e0b4':
  Reserve space on disk using fallocate
parents 17649e0f 9916e0b4
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -1131,7 +1131,22 @@ int32_t ExtractEntryToFile(ZipArchiveHandle handle,
    return kIoError;
  }

  int result = TEMP_FAILURE_RETRY(ftruncate(fd, declared_length + current_offset));
  int result = 0;
#if defined(__linux__)
  // Make sure we have enough space on the volume to extract the compressed
  // entry. Note that the call to ftruncate below will change the file size but
  // will not allocate space on disk.
  if (declared_length > 0) {
    result = TEMP_FAILURE_RETRY(fallocate(fd, 0, current_offset, declared_length));
    if (result == -1) {
      ALOGW("Zip: unable to allocate space for file to %" PRId64 ": %s",
            static_cast<int64_t>(declared_length + current_offset), strerror(errno));
      return kIoError;
    }
  }
#endif  // defined(__linux__)

  result = TEMP_FAILURE_RETRY(ftruncate(fd, declared_length + current_offset));
  if (result == -1) {
    ALOGW("Zip: unable to truncate file to %" PRId64 ": %s",
          static_cast<int64_t>(declared_length + current_offset), strerror(errno));