hiphi: gpt-utils: Do fsync after writing partition entries

Do fsync after writing partition entries to ensure data
is actually written before rebooting device.

Signed-off-by: 7Soldier <reg.fm4@gmail.com>
This commit is contained in:
Benergy Meenan Ravuri 2021-07-12 23:27:12 +05:30 committed by 7Soldier
parent d668daaf63
commit 7e8fed40e2

View file

@ -1478,7 +1478,7 @@ int gpt_disk_commit(struct gpt_disk *disk)
ALOGE("%s: Invalid args", __func__); ALOGE("%s: Invalid args", __func__);
goto error; goto error;
} }
fd = open(disk->devpath, O_RDWR); fd = open(disk->devpath, O_RDWR | O_DSYNC);
if (fd < 0) { if (fd < 0) {
ALOGE("%s: Failed to open %s: %s", ALOGE("%s: Failed to open %s: %s",
__func__, __func__,
@ -1510,6 +1510,7 @@ int gpt_disk_commit(struct gpt_disk *disk)
__func__); __func__);
goto error; goto error;
} }
fsync(fd);
close(fd); close(fd);
return 0; return 0;
error: error: