From 7e8fed40e2bd923d0bc42717e85e1d7785e1c463 Mon Sep 17 00:00:00 2001 From: Benergy Meenan Ravuri Date: Mon, 12 Jul 2021 23:27:12 +0530 Subject: [PATCH] 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 --- 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 58fc93a..7c3a9bb 100644 --- a/gpt-utils/gpt-utils.cpp +++ b/gpt-utils/gpt-utils.cpp @@ -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: