summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/nvmutil/lib/file.c25
-rw-r--r--util/nvmutil/nvmutil.c10
2 files changed, 35 insertions, 0 deletions
diff --git a/util/nvmutil/lib/file.c b/util/nvmutil/lib/file.c
index 30694623..a0313405 100644
--- a/util/nvmutil/lib/file.c
+++ b/util/nvmutil/lib/file.c
@@ -2032,9 +2032,34 @@ fs_resolve_at(int dirfd, const char *path, int flags)
if (nextfd < 0)
goto err;
+/*
+don't close fd.
+it's used next by a few functions.
+this results in a fd leak, but
+makes the code work:
+in practise, your program
+will free all descriptors
+on exit
+
+what we need to do is figure out a proper
+system of storing descriptors,
+and freeing them when it's safe;
+see how this function is called
+and whatt calls those and you see what i mean
+
+who owns what is currently not consistent.
+needs rework.
+
+this will be fixed at a later date.
+justt leaving thtis in here for future me.
+
+with this uncommented, i always just get
+"Bad file descriptor" error:
+
saved_close_errno = errno;
(void) close_on_eintr(dirfd);
errno = saved_close_errno;
+*/
dirfd = nextfd;
nextfd = -1;
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index cb08ec43..b4715e5b 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -35,6 +35,16 @@ main(int argc, char *argv[])
size_t c;
+ int rval;
+ char *test = NULL;
+ int fd = -1;
+ rval = new_tmpfile(&fd, &test);
+ if (rval < 0)
+ err_no_cleanup(errno, "TESTERR: ");
+
+ printf("TEST: %s", test);
+ exit(1);
+
/* https://man.openbsd.org/pledge.2
https://man.openbsd.org/unveil.2 */
#if defined(__OpenBSD__) && defined(OpenBSD)