From owner-svn-src-head@freebsd.org Tue Sep 5 19:28:37 2017 Return-Path: Delivered-To: svn-src-head@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 519CBE1AFF6; Tue, 5 Sep 2017 19:28:37 +0000 (UTC) (envelope-from asomers@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 CC048730C3; Tue, 5 Sep 2017 19:28:36 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v85JSZpG022380; Tue, 5 Sep 2017 19:28:35 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v85JSZ9X022379; Tue, 5 Sep 2017 19:28:35 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201709051928.v85JSZ9X022379@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Tue, 5 Sep 2017 19:28:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r323193 - head/cddl/compat/opensolaris/misc X-SVN-Group: head X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: head/cddl/compat/opensolaris/misc X-SVN-Commit-Revision: 323193 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Sep 2017 19:28:37 -0000 Author: asomers Date: Tue Sep 5 19:28:35 2017 New Revision: 323193 URL: https://svnweb.freebsd.org/changeset/base/323193 Log: Honor all options of "zfs mount -o" The existing code in zmount incorrectly parses the comma-delimited option string. The result is that nmount only honors the last option. AFAICT the parsing has been broken ever since ZFS's initial import in change 168404. PR: 222078 Reviewed by: avg MFC after: 3 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D12232 Modified: head/cddl/compat/opensolaris/misc/zmount.c Modified: head/cddl/compat/opensolaris/misc/zmount.c ============================================================================== --- head/cddl/compat/opensolaris/misc/zmount.c Tue Sep 5 19:04:07 2017 (r323192) +++ head/cddl/compat/opensolaris/misc/zmount.c Tue Sep 5 19:28:35 2017 (r323193) @@ -74,7 +74,7 @@ zmount(const char *spec, const char *dir, int mflag, c char *dataptr, int datalen, char *optptr, int optlen) { struct iovec *iov; - char *optstr, *os, *p; + char *optstr, *os, *p, *tofree; int iovlen, rv; assert(spec != NULL); @@ -87,7 +87,7 @@ zmount(const char *spec, const char *dir, int mflag, c assert(optptr != NULL); assert(optlen > 0); - optstr = strdup(optptr); + tofree = optstr = strdup(optptr); assert(optstr != NULL); iov = NULL; @@ -98,11 +98,9 @@ zmount(const char *spec, const char *dir, int mflag, c build_iovec(&iov, &iovlen, "fspath", __DECONST(char *, dir), (size_t)-1); build_iovec(&iov, &iovlen, "from", __DECONST(char *, spec), (size_t)-1); - for (p = optstr; p != NULL; strsep(&p, ",/ ")) { - if (*p != '\0') - build_iovec(&iov, &iovlen, p, NULL, (size_t)-1); - } + while ((p = strsep(&optstr, ",/")) != NULL) + build_iovec(&iov, &iovlen, p, NULL, (size_t)-1); rv = nmount(iov, iovlen, 0); - free(optstr); + free(tofree); return (rv); }