Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Dec 2016 21:26:43 +0000 (UTC)
From:      Brooks Davis <brooks@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r310092 - head/sbin/mount
Message-ID:  <201612142126.uBELQh2J023535@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: brooks
Date: Wed Dec 14 21:26:43 2016
New Revision: 310092
URL: https://svnweb.freebsd.org/changeset/base/310092

Log:
  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
  MFC after:	1 week
  Sponsored by:	DARPA, AFRL
  Differential Revision:	https://reviews.freebsd.org/D8513

Modified:
  head/sbin/mount/getmntopts.c
  head/sbin/mount/mntopts.h

Modified: head/sbin/mount/getmntopts.c
==============================================================================
--- head/sbin/mount/getmntopts.c	Wed Dec 14 21:14:43 2016	(r310091)
+++ head/sbin/mount/getmntopts.c	Wed Dec 14 21:26:43 2016	(r310092)
@@ -181,3 +181,17 @@ build_iovec_argf(struct iovec **iov, int
 	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);
+}

Modified: head/sbin/mount/mntopts.h
==============================================================================
--- head/sbin/mount/mntopts.h	Wed Dec 14 21:14:43 2016	(r310091)
+++ head/sbin/mount/mntopts.h	Wed Dec 14 21:26:43 2016	(r310092)
@@ -99,3 +99,4 @@ int checkpath(const char *, char resolve
 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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201612142126.uBELQh2J023535>