summaryrefslogtreecommitdiff
path: root/util/nvmutil
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-16 16:04:41 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-16 16:05:45 +0000
commitbdb43afac6edef21a15f99b8c3beac01be8b86f7 (patch)
tree2b75b68050a6ee6528c3bef35b6d535a7da74a8a /util/nvmutil
parentd34571217265cc3ee3d5bfe9f5e4016fcc42dfd5 (diff)
util/nvmutil: don't use fsync()
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil')
-rw-r--r--util/nvmutil/nvmutil.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 4a5e48df..359fdc70 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -706,6 +706,8 @@ static ino_t tmp_ino;
*/
char *mktemp(char *template);
int fchmod(int fd, mode_t mode);
+void sync(void);
+int syncfs(int fd);
static int tmp_fd = -1;
static char *tname = NULL;
@@ -1106,12 +1108,7 @@ copy_gbe(void)
if (gbe_tmp_size != gbe_file_size)
err(EIO, "%s: %s: not the same size", fname, tname);
- /*
- * fsync tmp gbe file, because we will compare
- * its contents to what was read (for safety)
- */
- if (fsync(tmp_fd) == -1)
- err(errno, "%s: fsync (tmpfile copy)", tname);
+ sync();
r = rw_file_exact(tmp_fd, bufcmp, gbe_file_size,
0, IO_PREAD, NO_LOOP_EAGAIN, LOOP_EINTR,
@@ -1798,13 +1795,7 @@ write_to_gbe_bin(void)
write_gbe_file();
- /*
- * We may otherwise read from
- * cache, so we must sync.
- */
- if (fsync(tmp_fd) == -1)
- err(errno, "%s: fsync (pre-verification)",
- tname);
+ sync();
check_written_part(0);
check_written_part(1);
@@ -2041,8 +2032,7 @@ gbe_mv(void)
if (r < 0)
goto ret_gbe_mv;
- if (fsync(dest_fd) == -1)
- goto ret_gbe_mv;
+ sync();
if (close(dest_fd) == -1)
goto ret_gbe_mv;
@@ -2156,9 +2146,7 @@ fsync_dir(const char *path)
goto err_fsync_dir;
}
- /* sync file on disk */
- if (fsync(dfd) == -1)
- goto err_fsync_dir;
+ sync();
if (close(dfd) == -1)
goto err_fsync_dir;
@@ -3077,7 +3065,7 @@ x_i_rename(const char *src, const char *dst)
return -1;
}
- fsync(dfd);
+ sync();
close(sfd);
close(dfd);