diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-17 16:59:50 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-17 16:59:50 +0000 |
| commit | 6e63106dae202471d66c5274979b3caf1cd09096 (patch) | |
| tree | 7c13f408e00925c1f746a173ce8a8cd33ddc165e /util/nvmutil | |
| parent | 6b1757da57d02ddb78826be8f3f6c1c2c98643f8 (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>
Diffstat (limited to 'util/nvmutil')
| -rw-r--r-- | util/nvmutil/nvmutil.c | 17 |
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; |
