summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2015-12-15 19:32:33 +0100
committerandroid-build-merger <android-build-merger@google.com>2015-12-15 19:32:33 +0100
commitafd85ecad20ddf257c9d61a4fa8f889410b85739 (patch)
treea8c0eea16926f52eab8d221e504d41cc3d3fe590
parentMerge "update_verifier: Track the API change for isSlotBootable()." am: e062645efa (diff)
parentMerge "updater: Use O_SYNC and fsync() for package_extract_file()." (diff)
downloadandroid_bootable_recovery-afd85ecad20ddf257c9d61a4fa8f889410b85739.tar
android_bootable_recovery-afd85ecad20ddf257c9d61a4fa8f889410b85739.tar.gz
android_bootable_recovery-afd85ecad20ddf257c9d61a4fa8f889410b85739.tar.bz2
android_bootable_recovery-afd85ecad20ddf257c9d61a4fa8f889410b85739.tar.lz
android_bootable_recovery-afd85ecad20ddf257c9d61a4fa8f889410b85739.tar.xz
android_bootable_recovery-afd85ecad20ddf257c9d61a4fa8f889410b85739.tar.zst
android_bootable_recovery-afd85ecad20ddf257c9d61a4fa8f889410b85739.zip
-rw-r--r--updater/install.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/updater/install.cpp b/updater/install.cpp
index e2b3db7ce..b09086964 100644
--- a/updater/install.cpp
+++ b/updater/install.cpp
@@ -555,14 +555,21 @@ Value* PackageExtractFileFn(const char* name, State* state,
}
{
- FILE* f = fopen(dest_path, "wb");
- if (f == NULL) {
- printf("%s: can't open %s for write: %s\n",
- name, dest_path, strerror(errno));
+ int fd = TEMP_FAILURE_RETRY(open(dest_path, O_WRONLY | O_CREAT | O_TRUNC | O_SYNC,
+ S_IRUSR | S_IWUSR));
+ if (fd == -1) {
+ printf("%s: can't open %s for write: %s\n", name, dest_path, strerror(errno));
goto done2;
}
- success = mzExtractZipEntryToFile(za, entry, fileno(f));
- fclose(f);
+ success = mzExtractZipEntryToFile(za, entry, fd);
+ if (fsync(fd) == -1) {
+ printf("fsync of \"%s\" failed: %s\n", dest_path, strerror(errno));
+ success = false;
+ }
+ if (close(fd) == -1) {
+ printf("close of \"%s\" failed: %s\n", dest_path, strerror(errno));
+ success = false;
+ }
}
done2: