From owner-freebsd-fs@FreeBSD.ORG Thu Jun 16 22:34:40 2011 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 66393106564A; Thu, 16 Jun 2011 22:34:40 +0000 (UTC) (envelope-from ady@ady.ro) Received: from mail-ey0-f182.google.com (mail-ey0-f182.google.com [209.85.215.182]) by mx1.freebsd.org (Postfix) with ESMTP id 6E64F8FC08; Thu, 16 Jun 2011 22:34:39 +0000 (UTC) Received: by eyg7 with SMTP id 7so1037228eyg.13 for ; Thu, 16 Jun 2011 15:34:38 -0700 (PDT) Received: by 10.14.186.14 with SMTP id v14mr617135eem.7.1308263678216; Thu, 16 Jun 2011 15:34:38 -0700 (PDT) MIME-Version: 1.0 Sender: ady@ady.ro Received: by 10.14.27.205 with HTTP; Thu, 16 Jun 2011 15:34:18 -0700 (PDT) In-Reply-To: References: From: Adrian Penisoara Date: Fri, 17 Jun 2011 00:34:18 +0200 X-Google-Sender-Auth: imWZVtv09jYQjEcccKCy3v0hk34 Message-ID: To: freebsd-fs@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Pawel Jakub Dawidek Subject: Re: ZFS sharenfs mangling NFS options X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jun 2011 22:34:40 -0000 On Thu, Jun 16, 2011 at 11:47 PM, Adrian Penisoara wro= te: > Hi, > > =A0I was nicely surprised to see that the "sharenfs" option for a ZFS > dataset does the expected trick and automatically shares on NFS the > dataset via /etc/zfs/exports. However, I had some not so pleasant > experiences customizing the NFS sharing parameters -- e.g. when the > contents of the "sharenfs" property was automatically translated into > [/etc/zfs/]exports entries: > =A0 * whatever hostname contains a "-" (dash) it gets malformed by > being split over the dash character > =A0 * whatever NFS parameter is prefixed with a "-" (dash) and it's not > the first in the list it gets transformed into a hostname entry > > =A0After some hunting into the CDDL sources I have been able to > pinpoint the exact (library) code doing the translation as function > translate_opts() in src/cddl/compat/opensolaris/misc/fsshare.c : > > =A0 =A0 =A0 =A0while ((o =3D strsep(&s, "-, ")) !=3D NULL) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (o[0] =3D=3D '\0') > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0continue; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0for (i =3D 0; known_opts[i] !=3D NULL; i++= ) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0len =3D strlen(known_opts[= i]); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (strncmp(known_opts[i],= o, len) =3D=3D 0 && > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(o[len] =3D=3D '\0= ' || o[len] =3D=3D '=3D')) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0strlcat(ne= wopts, "-", sizeof(newopts)); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0strlcat(newopts, o, sizeof(newopts)); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0strlcat(newopts, " ", sizeof(newopts)); > =A0 =A0 =A0 =A0} > > =A0If I'm able to read C correctly, then it looks like the code above > fails to take into consideration the case of hostnames containing > dashes and the case of options prefixed with dashes (although it is > advertised as valid format in the comments). To be more clear, here is a sample sharenfs property entry: "-maproot=3D0 -alldirs clienf-nfs1" This gets transformed to something like "-maproot=3D0 alldirs client nfs1" = ... Regards, Adrian Penisoara EntepriseBSD.com