diff options
author | Michael Runge <mrunge@google.com> | 2014-10-28 19:49:57 -0700 |
---|---|---|
committer | Michael Runge <mrunge@google.com> | 2014-10-28 19:49:57 -0700 |
commit | 042c3cd04ec3ef416019fa382cd5b1a942bd79e1 (patch) | |
tree | 8b0544483b3827351f406c5e987e2bf2641d9c68 /minzip | |
parent | 5ddf4293df45a051c7900eeb62fb5ec4950b6cb6 (diff) | |
download | bootable_recovery-042c3cd04ec3ef416019fa382cd5b1a942bd79e1.zip bootable_recovery-042c3cd04ec3ef416019fa382cd5b1a942bd79e1.tar.gz bootable_recovery-042c3cd04ec3ef416019fa382cd5b1a942bd79e1.tar.bz2 |
Force sync files written by minzip.
Some files appear to be missing their sync to disk.
Bug: 18145574
Change-Id: Ic858624a4dd65bbfc54d30f3a13c607078270345
Diffstat (limited to 'minzip')
-rw-r--r-- | minzip/Zip.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/minzip/Zip.c b/minzip/Zip.c index 5070104..70aff00 100644 --- a/minzip/Zip.c +++ b/minzip/Zip.c @@ -1067,7 +1067,8 @@ bool mzExtractRecursive(const ZipArchive *pArchive, setfscreatecon(secontext); } - int fd = creat(targetFile, UNZIP_FILEMODE); + int fd = open(targetFile, O_CREAT|O_WRONLY|O_TRUNC|O_SYNC + , UNZIP_FILEMODE); if (secontext) { freecon(secontext); @@ -1082,7 +1083,12 @@ bool mzExtractRecursive(const ZipArchive *pArchive, } bool ok = mzExtractZipEntryToFile(pArchive, pEntry, fd); - close(fd); + if (ok) { + ok = (fsync(fd) == 0); + } + if (close(fd) != 0) { + ok = false; + } if (!ok) { LOGE("Error extracting \"%s\"\n", targetFile); ok = false; |