summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2016-12-21 22:04:44 +0000
committerbrooks <brooks@FreeBSD.org>2016-12-21 22:04:44 +0000
commit29f6641a17eb9e7fafb70f8d060763101600cd79 (patch)
tree5e038a039af3d766f6e0afc820e7627718d8f303
parent6a16c286f29d59cc449f7cea76b51262b136a62b (diff)
downloadFreeBSD-src-29f6641a17eb9e7fafb70f8d060763101600cd79.zip
FreeBSD-src-29f6641a17eb9e7fafb70f8d060763101600cd79.tar.gz
MFC r310092:
Add a free_iovec() function to reset iovec's. The primary purpose is to call nmount() in a loop with new iovec's so free_iovec takes arguments by reference and resets their values. Reviewed by: cem Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D8513
-rw-r--r--sbin/mount/getmntopts.c14
-rw-r--r--sbin/mount/mntopts.h1
2 files changed, 15 insertions, 0 deletions
diff --git a/sbin/mount/getmntopts.c b/sbin/mount/getmntopts.c
index f8a3453..59a383e 100644
--- a/sbin/mount/getmntopts.c
+++ b/sbin/mount/getmntopts.c
@@ -181,3 +181,17 @@ build_iovec_argf(struct iovec **iov, int *iovlen, const char *name,
va_end(ap);
build_iovec(iov, iovlen, name, strdup(val), (size_t)-1);
}
+
+/*
+ * Free the iovec and reset to NULL with zero length. Useful for calling
+ * nmount in a loop.
+ */
+void
+free_iovec(struct iovec **iov, int *iovlen)
+{
+ int i;
+
+ for (i = 0; i < *iovlen; i++)
+ free((*iov)[i].iov_base);
+ free(*iov);
+}
diff --git a/sbin/mount/mntopts.h b/sbin/mount/mntopts.h
index d273dde..4cb83f1 100644
--- a/sbin/mount/mntopts.h
+++ b/sbin/mount/mntopts.h
@@ -99,3 +99,4 @@ int checkpath(const char *, char resolved_path[]);
extern int getmnt_silent;
void build_iovec(struct iovec **iov, int *iovlen, const char *name, void *val, size_t len);
void build_iovec_argf(struct iovec **iov, int *iovlen, const char *name, const char *fmt, ...);
+void free_iovec(struct iovec **iovec, int *iovlen);
OpenPOWER on IntegriCloud