summaryrefslogtreecommitdiff
path: root/util/nvmutil/nvmutil.c
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-16 19:56:53 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-26 06:59:42 +0000
commita575a47733b1fe3ee127a46b223916764b5638cf (patch)
tree37ad901fb47ace502f4127e276d1a480ed24bcf2 /util/nvmutil/nvmutil.c
parent8e2921f1ced3d27dce017bf1a5f427d3b1bb6db6 (diff)
util/nvmutil: use real rename() syscall
i was being cute earlier, but the rewrite defeats the purpose of atomic file handling in nvmutil, by not actually renaming! it was more like, doing an actual copy, which meant that corruption is likely during power loss i've commented the code because i may use it in a library in the future. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil/nvmutil.c')
-rw-r--r--util/nvmutil/nvmutil.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 2182348a..05ea7b4e 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -472,7 +472,13 @@ const char *getnvmprogname(void);
char *new_tmpfile(int *fd, int local, const char *path);
int x_i_mkstemp(char *template);
char *x_c_strrchr(const char *s, int c);
+/* x_i_rename not suitable
+ * for atomic writes. kept
+ * commentted for use in a
+ * library in the future */
+/*
int x_i_rename(const char *src, const char *dst);
+*/
char *x_c_tmpdir(void);
int x_i_close(int fd);
void *x_v_memcpy(void *dst,
@@ -1999,7 +2005,7 @@ gbe_mv(void)
saved_errno = errno;
- r = x_i_rename(tname, fname);
+ r = rename(tname, fname);
if (r > -1) {
/*
@@ -2052,7 +2058,7 @@ gbe_mv(void)
if (x_i_close(dest_fd) == -1)
goto ret_gbe_mv;
- if (x_i_rename(dest_tmp, fname) == -1)
+ if (rename(dest_tmp, fname) == -1)
goto ret_gbe_mv;
if (fsync_dir(fname) < 0)
@@ -2105,7 +2111,7 @@ ret_gbe_mv:
}
/*
- * Ensure x_i_rename() is durable by syncing the
+ * Ensure rename() is durable by syncing the
* directory containing the target file.
*/
int
@@ -3069,6 +3075,7 @@ x_c_strrchr(const char *s, int c)
return (char *)p;
}
+/*
int
x_i_rename(const char *src, const char *dst)
{
@@ -3111,6 +3118,7 @@ x_i_rename(const char *src, const char *dst)
return 0;
}
+*/
char *
x_c_tmpdir(void)