From owner-svn-src-stable@freebsd.org Wed Dec 21 22:04:46 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4C081C8A3A1; Wed, 21 Dec 2016 22:04:46 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1B2531D8F; Wed, 21 Dec 2016 22:04:46 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBLM4jWD080770; Wed, 21 Dec 2016 22:04:45 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBLM4jnG080768; Wed, 21 Dec 2016 22:04:45 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201612212204.uBLM4jnG080768@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Wed, 21 Dec 2016 22:04:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r310374 - stable/11/sbin/mount X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Dec 2016 22:04:46 -0000 Author: brooks Date: Wed Dec 21 22:04:44 2016 New Revision: 310374 URL: https://svnweb.freebsd.org/changeset/base/310374 Log: 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 Modified: stable/11/sbin/mount/getmntopts.c stable/11/sbin/mount/mntopts.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/mount/getmntopts.c ============================================================================== --- stable/11/sbin/mount/getmntopts.c Wed Dec 21 20:19:12 2016 (r310373) +++ stable/11/sbin/mount/getmntopts.c Wed Dec 21 22:04:44 2016 (r310374) @@ -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: stable/11/sbin/mount/mntopts.h ============================================================================== --- stable/11/sbin/mount/mntopts.h Wed Dec 21 20:19:12 2016 (r310373) +++ stable/11/sbin/mount/mntopts.h Wed Dec 21 22:04:44 2016 (r310374) @@ -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);