From dcf72302e365013dd6a44a4d88452da5fb38d592 Mon Sep 17 00:00:00 2001 From: Benergy Meenan Ravuri Date: Sun, 25 Dec 2022 11:01:44 +0400 Subject: [PATCH] fog: 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: Jabiyeff Signed-off-by: alternoegraha --- gpt-utils/gpt-utils.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gpt-utils/gpt-utils.cpp b/gpt-utils/gpt-utils.cpp index 3cbb775..6cba28f 100644 --- a/gpt-utils/gpt-utils.cpp +++ b/gpt-utils/gpt-utils.cpp @@ -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__, @@ -1517,6 +1517,7 @@ int gpt_disk_commit(struct gpt_disk *disk) __func__); goto error; } + fsync(fd); close(fd); return 0; error: