Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Sep 2017 15:06:46 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r324061 - stable/11/cddl/compat/opensolaris/misc
Message-ID:  <201709271506.v8RF6kuB001479@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Wed Sep 27 15:06:46 2017
New Revision: 324061
URL: https://svnweb.freebsd.org/changeset/base/324061

Log:
  MFC r323193:
  
  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
  Sponsored by:	Spectra Logic Corp
  Differential Revision:	https://reviews.freebsd.org/D12232

Modified:
  stable/11/cddl/compat/opensolaris/misc/zmount.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/compat/opensolaris/misc/zmount.c
==============================================================================
--- stable/11/cddl/compat/opensolaris/misc/zmount.c	Wed Sep 27 15:05:49 2017	(r324060)
+++ stable/11/cddl/compat/opensolaris/misc/zmount.c	Wed Sep 27 15:06:46 2017	(r324061)
@@ -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);
 }



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