summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorasomers <asomers@FreeBSD.org>2017-09-27 15:06:46 +0000
committerasomers <asomers@FreeBSD.org>2017-09-27 15:06:46 +0000
commitadbcaf69fa842a1ec8102b12d92b1aaece8f2cab (patch)
treea4303420d00eeef02d803d6d6f26052479d3cd6a
parenta71d5bfd873d44535aa1b42b95e3acc465b3d183 (diff)
downloadFreeBSD-src-adbcaf69fa842a1ec8102b12d92b1aaece8f2cab.zip
FreeBSD-src-adbcaf69fa842a1ec8102b12d92b1aaece8f2cab.tar.gz
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
-rw-r--r--cddl/compat/opensolaris/misc/zmount.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/cddl/compat/opensolaris/misc/zmount.c b/cddl/compat/opensolaris/misc/zmount.c
index d46b378..3c965b0 100644
--- a/cddl/compat/opensolaris/misc/zmount.c
+++ b/cddl/compat/opensolaris/misc/zmount.c
@@ -74,7 +74,7 @@ zmount(const char *spec, const char *dir, int mflag, char *fstype,
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, char *fstype,
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, char *fstype,
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);
}
OpenPOWER on IntegriCloud