Skip to content

Commit

Permalink
fog: gpt-utils: Do fsync after writing partition entries
Browse files Browse the repository at this point in the history
Do fsync after writing partition entries to ensure data
is actually written before rebooting device.

Signed-off-by: Jabiyeff <[email protected]>
Signed-off-by: alternoegraha <[email protected]>
  • Loading branch information
Benergy Meenan Ravuri authored and alternoegraha committed Dec 1, 2023
1 parent 7d88fa6 commit dcf7230
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gpt-utils/gpt-utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1485,7 +1485,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__,
Expand Down Expand Up @@ -1517,6 +1517,7 @@ int gpt_disk_commit(struct gpt_disk *disk)
__func__);
goto error;
}
fsync(fd);
close(fd);
return 0;
error:
Expand Down

0 comments on commit dcf7230

Please sign in to comment.