aboutsummaryrefslogtreecommitdiff
path: root/gpt-utils
diff options
context:
space:
mode:
authorArian <arian.kulmer@web.de>2022-03-20 18:54:23 -0300
committersinanmohd <pcmsinan@gmail.com>2023-01-05 21:30:23 +0530
commit879002a08cc9faa1a4e8b167f579650d10e79e21 (patch)
tree1d39be0f06d8607d695db2498cba152652010b9f /gpt-utils
parent5aa2b6c12bcb8f03b376d6b7a18e264198d8ef86 (diff)
veux: gpt-utils: Do fsync after writing partition entries
Do fsync after writing partition entries to ensure data is actually written before rebooting device.
Diffstat (limited to 'gpt-utils')
-rw-r--r--gpt-utils/gpt-utils.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/gpt-utils/gpt-utils.cpp b/gpt-utils/gpt-utils.cpp
index 58fc93a..1fe955f 100644
--- a/gpt-utils/gpt-utils.cpp
+++ b/gpt-utils/gpt-utils.cpp
@@ -1374,7 +1374,7 @@ int gpt_disk_get_disk_info(const char *dev, struct gpt_disk *dsk)
dev);
goto error;
}
- fd = open(disk->devpath, O_RDWR);
+ fd = open(disk->devpath, O_RDWR | O_DSYNC);
if (fd < 0) {
ALOGE("%s: Failed to open %s: %s",
__func__,
@@ -1478,7 +1478,7 @@ int gpt_disk_commit(struct gpt_disk *disk)
ALOGE("%s: Invalid args", __func__);
goto error;
}
- fd = open(disk->devpath, O_RDWR);
+ fd = open(disk->devpath, O_RDWR | O_DSYNC);
if (fd < 0) {
ALOGE("%s: Failed to open %s: %s",
__func__,
@@ -1510,6 +1510,7 @@ int gpt_disk_commit(struct gpt_disk *disk)
__func__);
goto error;
}
+ fsync(fd);
close(fd);
return 0;
error: