From 6e63106dae202471d66c5274979b3caf1cd09096 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Tue, 17 Mar 2026 16:59:50 +0000 Subject: 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 --- util/nvmutil/nvmutil.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'util/nvmutil') 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; -- cgit v1.2.1