Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 03 Aug 2015 11:32:50 +0200
From:      Willem Jan Withagen <wjw@digiware.nl>
To:        Lev Serebryakov <lev@FreeBSD.org>
Cc:        fs@freebsd.org
Subject:   Re: Multiple entries in ZFS "sharenfs" property?
Message-ID:  <55BF3542.2070206@digiware.nl>
In-Reply-To: <55BE83FA.1060208@digiware.nl>
References:  <130767529.20150801150343@serebryakov.spb.ru> <55BDF5D2.3090306@digiware.nl> <1941826477.20150802210808@serebryakov.spb.ru> <55BE83FA.1060208@digiware.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
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:
>>>          ' <volume>
>>
>>> 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:





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?55BF3542.2070206>