Merge "updater: Use O_SYNC and fsync() for package_extract_file()."
This commit is contained in:
+13
-6
@@ -555,14 +555,21 @@ Value* PackageExtractFileFn(const char* name, State* state,
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
FILE* f = fopen(dest_path, "wb");
|
int fd = TEMP_FAILURE_RETRY(open(dest_path, O_WRONLY | O_CREAT | O_TRUNC | O_SYNC,
|
||||||
if (f == NULL) {
|
S_IRUSR | S_IWUSR));
|
||||||
printf("%s: can't open %s for write: %s\n",
|
if (fd == -1) {
|
||||||
name, dest_path, strerror(errno));
|
printf("%s: can't open %s for write: %s\n", name, dest_path, strerror(errno));
|
||||||
goto done2;
|
goto done2;
|
||||||
}
|
}
|
||||||
success = mzExtractZipEntryToFile(za, entry, fileno(f));
|
success = mzExtractZipEntryToFile(za, entry, fd);
|
||||||
fclose(f);
|
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:
|
done2:
|
||||||
|
|||||||
Reference in New Issue
Block a user