summaryrefslogtreecommitdiffstats
path: root/cddl/compat
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2007-04-21 13:17:23 +0000
committerpjd <pjd@FreeBSD.org>2007-04-21 13:17:23 +0000
commit2cd524ebede2b227bc0180dda7bd0d3ec7b21972 (patch)
tree1939509ebc59fa7a6f7a7b1dbc8f72b597cc116f /cddl/compat
parent4c79721dd46a0fb6dfc1ef9c221f4618d32f13c3 (diff)
downloadFreeBSD-src-2cd524ebede2b227bc0180dda7bd0d3ec7b21972.zip
FreeBSD-src-2cd524ebede2b227bc0180dda7bd0d3ec7b21972.tar.gz
Improve sharenfs option handling, so it is possible to give hosts list.
Before the change the command above: # zfs set sharenfs=freefall.freebsd.org,69.147.83.54 tank/foo was translated to: /tank/foo -freefall.freebsd.org -69.147.83.54 instead of: /tank/foo freefall.freebsd.org 69.147.83.54 This commit corrects this.
Diffstat (limited to 'cddl/compat')
-rw-r--r--cddl/compat/opensolaris/misc/fsshare.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/cddl/compat/opensolaris/misc/fsshare.c b/cddl/compat/opensolaris/misc/fsshare.c
index 802d120..ca82710 100644
--- a/cddl/compat/opensolaris/misc/fsshare.c
+++ b/cddl/compat/opensolaris/misc/fsshare.c
@@ -99,21 +99,30 @@ getline(FILE *fd, const char *skip)
/*
* Function translate options to a format acceptable by exports(5), eg.
*
- * -ro -network=192.168.0.0 -mask=255.255.255.0 -maproot=0
+ * -ro -network=192.168.0.0 -mask=255.255.255.0 -maproot=0 freefall.freebsd.org 69.147.83.54
*
* Accepted input formats:
*
- * ro,network=192.168.0.0,mask=255.255.255.0,maproot=0
- * ro network=192.168.0.0 mask=255.255.255.0 maproot=0
- * -ro,-network=192.168.0.0,-mask=255.255.255.0,-maproot=0
- * -ro -network=192.168.0.0 -mask=255.255.255.0 -maproot=0
+ * ro,network=192.168.0.0,mask=255.255.255.0,maproot=0,freefall.freebsd.org
+ * ro network=192.168.0.0 mask=255.255.255.0 maproot=0 freefall.freebsd.org
+ * -ro,-network=192.168.0.0,-mask=255.255.255.0,-maproot=0,freefall.freebsd.org
+ * -ro -network=192.168.0.0 -mask=255.255.255.0 -maproot=0 freefall.freebsd.org
+ *
+ * Recognized keywords:
+ *
+ * ro, maproot, mapall, mask, network, alldirs, public, webnfs, index, quiet
+ *
*/
+static const char *known_opts[] = { "ro", "maproot", "mapall", "mask",
+ "network", "alldirs", "public", "webnfs", "index", "quiet", NULL };
static char *
translate_opts(const char *shareopts)
{
static char newopts[OPTSSIZE];
- char oldopts[OPTSSIZE], opt[64];
+ char oldopts[OPTSSIZE];
char *o, *s = NULL;
+ unsigned int i;
+ size_t len;
strlcpy(oldopts, shareopts, sizeof(oldopts));
newopts[0] = '\0';
@@ -121,8 +130,16 @@ translate_opts(const char *shareopts)
while ((o = strsep(&s, "-, ")) != NULL) {
if (o[0] == '\0')
continue;
- snprintf(opt, sizeof(opt), "-%s ", o);
- strlcat(newopts, opt, sizeof(newopts));
+ for (i = 0; known_opts[i] != NULL; i++) {
+ len = strlen(known_opts[i]);
+ if (strncmp(known_opts[i], o, len) == 0 &&
+ (o[len] == '\0' || o[len] == '=')) {
+ strlcat(newopts, "-", sizeof(newopts));
+ break;
+ }
+ }
+ strlcat(newopts, o, sizeof(newopts));
+ strlcat(newopts, " ", sizeof(newopts));
}
return (newopts);
}
OpenPOWER on IntegriCloud