summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-17 16:59:50 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-26 06:59:42 +0000
commit60a6d3861c5c94f8329ea85b8d4663fc6006232e (patch)
treed248023ab4566431cfd30e5ed5f8c99f5319b717
parentc1c49c394571719ed9c27c65af4f26a239af4bd4 (diff)
util/nvmuti: make fsync_dir() generic
yes, this begins the next phase of nvmutil: remove global status in functions that should be generic, and make functions that are not generic, generic. make everything as re-useable in a library as possible. most of the program is error control, as it should be, but much of it is mixed in with functions that really should just be split up for libraries. so that is what i'm now beginning. Signed-off-by: Leah Rowe <leah@libreboot.org>
-rw-r--r--util/nvmutil/nvmutil.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index c6fabf93..002ec715 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -1553,8 +1553,10 @@ gbe_mv(void)
tmp_gbe_bin_exists = 0;
- if (fsync_dir(f->fname) < 0)
+ if (fsync_dir(f->fname) < 0) {
+ f->io_err_gbe_bin = 1;
r = -1;
+ }
goto ret_gbe_mv;
}
@@ -1600,8 +1602,10 @@ gbe_mv(void)
if (rename(dest_tmp, f->fname) == -1)
goto ret_gbe_mv;
- if (fsync_dir(f->fname) < 0)
+ if (fsync_dir(f->fname) < 0) {
+ f->io_err_gbe_bin = 1;
goto ret_gbe_mv;
+ }
free(dest_tmp);
dest_tmp = NULL;
@@ -1611,8 +1615,10 @@ ret_gbe_mv:
if (f->gbe_fd > -1) {
if (x_i_close(f->gbe_fd) < 0)
r = -1;
- if (fsync_dir(f->fname) < 0)
+ if (fsync_dir(f->fname) < 0) {
+ f->io_err_gbe_bin = 1;
r = -1;
+ }
f->gbe_fd = -1;
}
@@ -1656,8 +1662,6 @@ ret_gbe_mv:
int
fsync_dir(const char *path)
{
- struct xfile *f = &nv->f;
-
#if defined(PATH_LEN) && \
(PATH_LEN) >= 256
unsigned long maxlen = PATH_LEN;
@@ -1742,7 +1746,7 @@ err_fsync_dir:
errno = EIO;
if (errno != saved_errno)
- fprintf(stderr, "%s: %s\n", f->fname, strerror(errno));
+ fprintf(stderr, "%s: %s\n", path, strerror(errno));
if (dirbuf != NULL)
free(dirbuf);
@@ -1750,7 +1754,6 @@ err_fsync_dir:
if (dfd > -1)
x_i_close(dfd);
- f->io_err_gbe_bin = 1;
errno = saved_errno;
return -1;