From owner-freebsd-fs@freebsd.org Mon Aug 3 09:32:59 2015 Return-Path: Delivered-To: freebsd-fs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D53659B1482 for ; Mon, 3 Aug 2015 09:32:59 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id BAE4FF49 for ; Mon, 3 Aug 2015 09:32:59 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: by mailman.ysv.freebsd.org (Postfix) id BA0A39B1481; Mon, 3 Aug 2015 09:32:59 +0000 (UTC) Delivered-To: fs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9EF189B1480 for ; Mon, 3 Aug 2015 09:32:59 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from smtp.digiware.nl (smtp.digiware.nl [31.223.170.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2AFFDF47; Mon, 3 Aug 2015 09:32:58 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from rack1.digiware.nl (unknown [127.0.0.1]) by smtp.digiware.nl (Postfix) with ESMTP id 60B491534C4; Mon, 3 Aug 2015 11:32:54 +0200 (CEST) X-Virus-Scanned: amavisd-new at digiware.nl Received: from smtp.digiware.nl ([127.0.0.1]) by rack1.digiware.nl (rack1.digiware.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dbbDqpUqv1CZ; Mon, 3 Aug 2015 11:32:53 +0200 (CEST) Received: from [IPv6:2001:4cb8:3:1:bd55:9a1f:88:880] (unknown [IPv6:2001:4cb8:3:1:bd55:9a1f:88:880]) by smtp.digiware.nl (Postfix) with ESMTP id 1D4771534C0; Mon, 3 Aug 2015 11:32:53 +0200 (CEST) Message-ID: <55BF3542.2070206@digiware.nl> Date: Mon, 03 Aug 2015 11:32:50 +0200 From: Willem Jan Withagen Organization: Digiware Management b.v. User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Lev Serebryakov CC: fs@freebsd.org Subject: Re: Multiple entries in ZFS "sharenfs" property? References: <130767529.20150801150343@serebryakov.spb.ru> <55BDF5D2.3090306@digiware.nl> <1941826477.20150802210808@serebryakov.spb.ru> <55BE83FA.1060208@digiware.nl> In-Reply-To: <55BE83FA.1060208@digiware.nl> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Aug 2015 09:33:00 -0000 On 2-8-2015 22:56, Willem Jan Withagen wrote: > On 2-8-2015 20:08, Lev Serebryakov wrote: >> Hello Willem, >> >> Sunday, August 2, 2015, 1:49:54 PM, you wrote: >>>> Is it possible to put multiple entries (for multiple networks) into >>>> "sharenfs" property for ZFS filesystem? >> >>> Something like? >>> >>> I think I just did it by putting the text between '' 's: >>> ' >> >>> Which then ends up in /etc/zfs/exports: >>> /home/wjw -alldirs -maproot=0 -network 192.168.10.0 -mask 255.255.252.0 >> I need 4 such lines per FS (with different -network / -mask arguments). One line works. Four lines don't. > > Hi Lev, > > Nope, that doesn't work, as far as I can tell. > You'd have to revert to editting /etc/exports. > > Or hack on 'zfs set sharenfs' to generate multiple lines, in some sort > of format. Like making ';' a line separator, and then prefix each part > with the volume we are modifying. > > Place to give it a go are in: > cddl/compat/opensolaris/misc/fsshare.c:213 > if (share) { > fprintf(newfd, "%s\t%s\n", mountpoint, > translate_opts(shareopts)); > } > And there split the shareopts on the split char (eg. ';') in several > shareopts and then loop over them. Disadvantage is that the max length > op the options is: MAXPATHLEN. So you can easily run out of space if you > have many exports to do. Could not resist... --WjW Perhaps something like: Index: compat/opensolaris/misc/fsshare.c =================================================================== --- compat/opensolaris/misc/fsshare.c (revision 286222) +++ compat/opensolaris/misc/fsshare.c (working copy) @@ -151,6 +151,7 @@ int share) { char tmpfile[PATH_MAX]; + char tmpshareopts[OPTSSIZE], *sharep, *sepp; char *line; FILE *newfd, *oldfd; int fd, error; @@ -211,8 +212,25 @@ goto out; } if (share) { - fprintf(newfd, "%s\t%s\n", mountpoint, - translate_opts(shareopts)); + /* Feed shareopts in piecces to translate_opts */ + if (strlcpy(tmpshareopts, shareopts, sizeof(tmpshareopts)) + >= sizeof(tmpshareopts)) + return (ENAMETOOLONG); + sharep = tmpshareopts; + do { + sepp = strchr(sharep, ';'); + if ( sepp != sharep) { + if (sepp != NULL) + *sepp = '\0'; + fprintf(newfd, "%s\t%s\n", mountpoint, + translate_opts(sharep)); + sharep= sepp+1; + } + /* + * exit if no seperator was found + * then we just did the last iteration + */ + } while (sepp != NULL); } out: