Skip to content

Commit

Permalink
Honor all options of "zfs mount -o"
Browse files Browse the repository at this point in the history
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
  • Loading branch information
asomers committed Sep 5, 2017
1 parent 6bbc5fb commit 0556fab
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions cddl/compat/opensolaris/misc/zmount.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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);
}

0 comments on commit 0556fab

Please sign in to comment.