Martin,

The patch looks good.  Thanks for updating the documentation too, it is
important (and of course difficult) to keep it in sync with the state of
the code.

Jeff, can you apply this patch.  Check the man page formatting after
application, because I haven't seen the \fB instead of .B foramt, and
just want to make sure it works with our version of nroff.  Also update
the AUTHORS file to reflect Martin and Junjiro's contributions to it.
If everything looks good after that, go ahead and close bug 444.

Charles

On Fri, 2006-01-20 at 20:26 +0100, Martin Kreiner wrote:
> hi,
> 
> here the announced patch to deal whith NFS servers that return -EACCES
> instead of -EROFS on a read-only export introducing the per-branch
> option "nfsro":
> 
> mount -t unionfs dirs=/nfsdiff=rw:/nfsbase=nfsro none /union
> 
> this patch should close bug #444 
> (https://bugzilla.filesystems.org/show_bug.cgi?id=444)
> 
> i completed/polished the man pages unionfs(4) and unionctl(8) as well
> and shamelessly borrowed some lines from Junjiro Okajima for the
> unionctl.c changes
> (http://www.fsl.cs.sunysb.edu/pipermail/unionfs/2005-December/001530.html).
> 
> have fun,
> martin
> 
> --- unionfs-20060117-2031/INSTALL.org 2006-01-19 20:51:57.484981994 +0000
> +++ unionfs-20060117-2031/INSTALL     2006-01-20 17:24:06.732489435 +0000
> @@ -81,10 +81,10 @@
>    Followed, by more parse errors,  then you need to make sure you have
>    e2fsprogs-devel installed (or your distribution's equivalent).
>  
> -* Some NFS servers return -EPERM instead of -EROFS when they are exported
> +* Some NFS servers return -EACCES instead of -EROFS when they are exported
>    read-only.  This means that we can't legitimately determine when a user is
>    not allowed to access a file.  To enable a hack so that NFS appears to work
> -  correctly (but NFS ACLs will break), mount the union with 
> nfsperms=insecure.
> +  correctly (but NFS ACLs will break), mount the nfs-branch with mode nfsro.
>  
>  * If you want to export Unionfs over NFS, then you need to add
>    extra information to /etc/exports.  knfsd will not export Unionfs unless
> --- unionfs-20060117-2031/man/unionfs.4.org   2006-01-19 21:17:05.143666724 
> +0000
> +++ unionfs-20060117-2031/man/unionfs.4       2006-01-20 20:00:37.040991144 
> +0000
> @@ -1,66 +1,146 @@
>  .\" Process with groff -man -Tascii unionfs.1
>  .\"
> -.TH UNIONFS 4 "August 2005" Linux
> +.TH UNIONFS 4 "January 2006" Linux
>  .SH NAME
>  Unionfs \- a unification file system for Linux
>  .SH SYNOPSIS
>  Unionfs is not a command, but rather a file system.  This manual page 
> describes
>  additional mount options that Unionfs supports.
>  
> -mount -t unionfs -o 
> dirs=/branch1[=ro|=rw]:/branch2[=ro|=rw]:...:/branchN[=ro|=rw],imap=forwardmap:reversemap1:reversemap2:...:reversemapN,[copyup=preserve,currentuser,mounter]
>  none /mnt/unionfs
> +\fBmount -t unionfs \-o\fP 
> \fIbranch-option\fP[\fB,\fP\fIunion-options\fP[\fB,\fP...]] \fBunionfs\fP 
> \fIunion-dir\fP
>  
>  .SH DESCRIPTION
> -.B dirs
> +Unionfs is a stackable unification file system, which can appear to merge the
> +contents of several directories (branches), while keeping their physical
> +content separate. Unionfs is useful for unified source tree management, 
> merged
> +contents of split CD-ROM, merged separate software package directories, data
> +grids, and more. Unionfs allows any mix of read-only and read-write branches,
> +as well as insertion and deletion of branches anywhere in the fan-out. To
> +maintain unix semantics, Unionfs handles elimination of duplicates, 
> +partial-error conditions, and more.
> +
> +Unionfs is part of the larger FiST project.
> +
> +.SH OPTIONS
> +The available \fIbranch-option\fP for the mount command is:
> +
> +.TP
> +\fBdirs=\fP\fIbranch\fP[\fB=ro\fP|\fB=nfsro\fP|\fB=rw\fP][\fB:\fP...]\fP
>  specifies a colon separated list of which directories compose the union.
> -Additionally, read-only or read-write permissions of the branch can be
> -specified by appending "=ro" or "=rw" to each directory.  Directories that 
> come
> -earlier in the list have a higher precedence than those which come later.
> -
> -.B debug
> -specifies the FiST debugging level.  1 through 8 specify individual 
> log-levels.
> -If debug is set to 11 through 18, the output will include debug-10 and all
> -lower levels.  If you set this to a non-zero value lots of output will be 
> sent
> -to the kernel ring buffer, some of which may be sensitive. The default value
> -for this option is 0 which will produce no output.
> +Directories that come earlier in the list have a higher precedence than those
> +which come later. Additionally, read-only or read-write permissions of the
> +branch can be specified by appending \fB=ro\fP or \fB=rw\fP (default) to
> +each directory.
> +
> +Is the directory a read-only NFS mount and the NFS server returns -EACCES for
> +read-only exports, instead of -EROFS, append \fB=nfsro\fP to the desired
> +directory if you want to use copy-on-write with NFS. If this flag is set, 
> then
> +Unionfs will apply standard Unix permissions to files on NFS (so NFS ACLs 
> will
> +break).
> +
> +Syntax:
> +dirs=/branch1[=ro|=nfsro|=rw]:/branch2[=ro|=nfsro|=rw]:...:/branchN[=ro|=nfsro|=rw]
> +
> +Example:
> +\fBdirs=/writable_branch=rw:/read-only_branch=ro:/nfs-mounted_branch=nfsro\fP
> +
> +.TP
> +The available \fIunion-options\fP for the mount command are:
> +.TP
> +.B debug=\fIn\fP
> +specifies the FiST debugging level \fIn\fP.  1 through 8 specify individual
> +log-levels. If debug is set to 11 through 18, the output will include 
> debug-10
> +and all lower levels.  If you set this to a non-zero value lots of output 
> will
> +be sent to the kernel ring buffer, some of which may be sensitive. The 
> default
> +value for this option is 0 which will produce no output.
>  
> -.B delete
> +.TP
> +.B delete=\fIvalue\fP
>  controls how Unionfs deletes and renames objects.  Possible values
> -are "all", and "whiteout" with the default behavior being all.
> +are \fBall\fP, and \fBwhiteout\fP with the default behavior being \fBall\fP.
>  
> -.B imap
> -specifies a colon separated list of files that are used as the inode map 
> files.
> +.TP
> +\fBimap=\fP\fIforwardmap\fP\fB:\fP\fIreversemap\fP[\fB:\fP\fIreversemap\fP[\fB:\fP...]]
> +specifies a colon separated list of files that are used as the inode map 
> files
> +(see \fBunionimap(8)\fP for how to create inode map files).
>  You should specify the forward map first, followed by the reverse maps.  The
>  order of the reverse maps does not matter. The default behavior for the imap
>  option if left blank is to not use persistent inode mappings.
>  
> -.B copyup
> +Syntax: imap=forwardmap:reversemap1:reversemap2:...:reversemapN
> +
> +Example: \fBimap=/tmp/foo.forward:/tmp/foo.reverse:/tmp/foo.reverse2\fP
> +
> +.TP
> +\fBcopyup=\fP\fImode\fP
>  specifies which copy-up mode is used to provide copy-on-write semantics in
> -Unionfs.  Possible values are preserve, currentuser, and mounter.  Preserve
> +Unionfs.  Possible \fImode\fP values are \fBpreserve\fP (default),
> +\fBcurrentuser\fP and \fBmounter\fP.
> +.RS
> +.TP
> +.B preserve
>  keeps the permissions in the higher-precedence directory the same as in the
> -lower-precedence directory.  If currentuser is selected, then the copied-up
> -file will be owned by the user whose actions initiated the copy-up operation.
> -Finally, mounter uses an owner and permission specified at mount time. The
> -default behavior for copyup is preserve.
> -
> -.B copyupuid
> -specifies the uid of the copied-up files. This has no default behavior and
> -must be set if copyup is set to the mounter option.
> -
> -.B copyupgid
> -specifies the gid of the copied-up files. This has no default behavior and
> -must be set if copyup is set to the mounter option.
> -
> -.B copyupmode
> -specifies the mode of the copied-up files. This has no default behavior and
> -must be set if copyup is set to the mounter option.
> +lower-precedence directory.
> +.TP
> +.B currentuser
> +the copied-up file will be owned by the user whose actions initiated the 
> copy-up
> +operation.
> +.TP
> +.B mounter
> +use owner and permission specified at mount time via 
> \fBcopyupuid=\fP\fIuid\fP,
> +\fBcopyupgid=\fP\fIgid\fP and \fBcopyupmode=\fP\fImask\fP.
> +.RE
> +
> +.TP
> +\fBcopyupuid=\fP\fIuid\fP
> +specifies the \fIuid\fP of the copied-up files. This has no default behavior 
> and
> +must be set if \fBcopyup=mounter\fP.
> +
> +.TP
> +\fBcopyupgid=\fP\fIgid\fP
> +specifies the \fIgid\fP of the copied-up files. This has no default behavior 
> and
> +must be set if \fBcopyup=mounter\fP.
> +
> +.TP
> +\fBcopyupmode=\fP\fImask\fP
> +sets the file creation mask of the copied-up files to \fImask\fP. This has no
> +default behavior and must be set if \fBcopyup=mounter\fP.
> +
> +.SH EXAMPLES
> +.TP
> +.B mount -t unionfs dirs=/branch_rw=rw:/branch_ro=ro unionfs /union
> +creates a Union in directory `/union' with the branch-directories 
> `/branch_rw'
> +(writable) and `/branch_ro' (read-only).
> +
> +.TP
> +.B mount -t unionfs dirs=/branch_rw=rw:/branch_ro=ro,debug=1,delete=whiteout 
> unionfs /union
> +unifies the directories `/branch_rw', `/branch_ro' in `/union', sets the
> +log-level to `1' and the Unionfs delete and rename behaviour to `whiteout'.
> +
> +.SH BUGS
> +The NFS server returns -EACCES for read-only exports, instead of -EROFS.  
> This
> +means we can't reliably detect a read-only NFS export.  If you want to use
> +copy-on-write with NFS, set the per-branch option `nfsro'.  If this flag
> +is set, then Unionfs will apply standard Unix permissions to files on this
> +nfs-mouted branch.
> +
> +The PPC module loading algorithm has an O(N^2) loop, so it takes a while to
> +load the Unionfs module, because we have lots of symbols.
> +
> +Older versions of Reiser4 don't work with Unionfs, because they can't handle
> +seeking through directories properly.
> +
> +To see a somewhat comprehensive list of Unionfs bugs visit
> +https://bugzilla.filesystems.org
>  
>  .SH AUTHORS
>  Charles Wright <[EMAIL PROTECTED]>,
>  Mohammad Zubair <[EMAIL PROTECTED]>,
>  Erez Zadok <[EMAIL PROTECTED]>
>  .SH "SEE ALSO"
> -.BR unionctl(1),
> -.BR uniondbg(1),
> +.BR unionctl(8),
> +.BR unionimap(8),
> +.BR uniondbg(8),
>  http://www.fsl.cs.sunysb.edu/
>  
>  \"  LocalWords:  groff Tascii unionfs copyup currentuser dirs ro rw imap uid
> --- unionfs-20060117-2031/man/unionctl.8.org  2006-01-20 19:16:50.166543045 
> +0000
> +++ unionfs-20060117-2031/man/unionctl.8      2006-01-20 19:28:00.861018342 
> +0000
> @@ -1,6 +1,6 @@
>  .\" Process with groff -man -Tascii unionfs.1
>  .\"
> -.TH UNIONFS 8 "September 2005" Linux
> +.TH UNIONFS 8 "January 2006" Linux
>  .SH NAME
>  Unionfs \- a unification file system for Linux
>  .SH SYNOPSIS
> @@ -24,7 +24,7 @@
>  .I BRANCH
>  ] [
>  .B --mode
> -(rw|ro) ]
> +(rw|ro|nfsro) ]
>  .I DIRECTORY
>  
>  .B unionctl
> @@ -36,7 +36,7 @@
>  .I UNION
>  .B --mode
>  .I BRANCH
> -(rw|ro)
> +(rw|ro|nfsro)
>  
>  .B unionctl
>  .I UNION
> @@ -68,8 +68,9 @@
>  branch will be added after the specified branch.
>  
>  Finally, --mode will set the permissions on the new branch.  --mode requires
> -one argument, which is either "rw" for a read-write branch or "ro" for a
> -read-only branch.
> +one argument, which is "rw" for a read-write branch, "ro" for a
> +read-only branch and "nfsro" for read-only access on NFS shares (see
> +\fBunionfs(4)\fP for further information).
>  
>  Note: The directory to add must be the last argument.
>  
> @@ -87,7 +88,8 @@
>  .IP "--mode"
>  sets the permissions of a branch.  --mode requires two arguments, the first 
> is
>  the branch to operate on; and the second is what mode to set.  The allowed
> -modes are "ro" for read-only access and "rw" for read-write access.
> +modes are "rw" for read-write access, "ro" for read-only access and "nfsro" 
> for
> +read-only access on NFS shares (see \fBunionfs(4)\fP for further 
> information). 
>  
>  .IP "--list"
>  list branches within the union (and also their permissions).
> --- unionfs-20060117-2031/unionfs.h.org       2006-01-18 17:37:47.868954101 
> +0000
> +++ unionfs-20060117-2031/unionfs.h   2006-01-19 20:05:35.541885069 +0000
> @@ -766,10 +766,7 @@
>  /* 1 = f/s mounter permission, 0 = check for COPYUP_OWNER */
>  #define COPYUP_FS_MOUNTER    16
>  
> -/* 1 = only standard Unix permissions check on nfs if -EACCESS, 0 = no 
> special permission treatment */
> -#define NFS_INSECURE            32
> -
> -#define VALID_MOUNT_FLAGS (DELETE_WHITEOUT | COPYUP_OWNER | 
> COPYUP_FS_MOUNTER | NFS_INSECURE)
> +#define VALID_MOUNT_FLAGS (DELETE_WHITEOUT | COPYUP_OWNER | 
> COPYUP_FS_MOUNTER)
>  
>  /*
>   * MACROS:
> @@ -831,6 +828,9 @@
>  /* We don't support normal remount, but unionctl uses it. */
>  # define UNIONFS_REMOUNT_MAGIC               0x4a5a4380
>  
> +/* should be at least LAST_USED_UNIONFS_PERMISSION<<1 */
> +#define MAY_NFSRO                    16
> +
>  struct unionfs_addbranch_args {
>       unsigned int ab_branch;
>       char *ab_path;
> --- unionfs-20060117-2031/main.c.org  2006-01-18 18:02:46.364023340 +0000
> +++ unionfs-20060117-2031/main.c      2006-01-18 19:17:25.080594506 +0000
> @@ -320,6 +320,9 @@
>               if (!strcmp(name + l - 3, "=ro")) {
>                       perms = MAY_READ;
>                       name[l - 3] = '\0';
> +             } else if (!strcmp(name + l - 6, "=nfsro")) {
> +                     perms = MAY_READ | MAY_NFSRO;
> +                     name[l - 6] = '\0';
>               } else if (!strcmp(name + l - 3, "=rw")) {
>                       perms = MAY_READ | MAY_WRITE;
>                       name[l - 3] = '\0';
> @@ -327,9 +330,10 @@
>                       perms = MAY_READ | MAY_WRITE;
>               }
>  
> -             fist_dprint(4, "unionfs: using directory: %s (%c%c)\n",
> +             fist_dprint(4, "unionfs: using directory: %s (%c%c%c)\n",
>                           name, perms & MAY_READ ? 'r' : '-',
> -                         perms & MAY_WRITE ? 'w' : '-');
> +                         perms & MAY_WRITE ? 'w' : '-',
> +                         perms & MAY_NFSRO ? 'n' : '-');
>  
>               err = path_lookup(name, LOOKUP_FOLLOW, &nd);
>               RECORD_PATH_LOOKUP(&nd);
> @@ -515,20 +519,6 @@
>                       }
>                       continue;
>               }
> -             if (!strcmp("nfsperms", optname)) {
> -                     if (!strcmp("secure", optarg)) {
> -                             /* default */
> -                     } else if (!strcmp("insecure", optarg)) {
> -                             MOUNT_FLAG(sb) |= NFS_INSECURE;
> -                     } else {
> -                             printk(KERN_WARNING
> -                                    "unionfs: invalid nfsperms option 
> '%s'\n",
> -                                    optarg);
> -                             err = -EINVAL;
> -                             goto out_error;
> -                     }
> -                     continue;
> -             }
>  
>               /* All of these options require an integer argument. */
>               intval = simple_strtoul(optarg, &endptr, 0);
> --- unionfs-20060117-2031/branchman.c.org     2006-01-18 18:06:56.687885338 
> +0000
> +++ unionfs-20060117-2031/branchman.c 2006-01-18 18:11:15.356575888 +0000
> @@ -211,7 +211,7 @@
>               goto out;
>  
>       err = -EINVAL;
> -     if (addargs->ab_perms & ~(MAY_READ | MAY_WRITE))
> +     if (addargs->ab_perms & ~(MAY_READ | MAY_WRITE | MAY_NFSRO))
>               goto out;
>       if (!(addargs->ab_perms & MAY_READ))
>               goto out;
> @@ -510,7 +510,7 @@
>       if (rdwrargs->rwb_branch < 0
>           || (rdwrargs->rwb_branch > (sbend(inode->i_sb) + 1)))
>               goto out;
> -     if (rdwrargs->rwb_perms & ~(MAY_READ | MAY_WRITE))
> +     if (rdwrargs->rwb_perms & ~(MAY_READ | MAY_WRITE | MAY_NFSRO))
>               goto out;
>       if (!(rdwrargs->rwb_perms & MAY_READ))
>               goto out;
> --- unionfs-20060117-2031/super.c.org 2006-01-18 18:11:53.868554497 +0000
> +++ unionfs-20060117-2031/super.c     2006-01-18 19:18:54.463335784 +0000
> @@ -452,7 +452,8 @@
>                          PAGE_SIZE);
>               perms = branchperms(sb, bindex);
>               seq_printf(m, "%s=%s", hidden_path,
> -                        perms & MAY_WRITE ? "rw" : "ro");
> +                        perms & MAY_WRITE ? "rw" :
> +                        perms & MAY_NFSRO ? "nfsro" : "ro");
>               if (bindex != bend) {
>                       seq_printf(m, ":");
>               }
> @@ -472,11 +473,6 @@
>       else
>               seq_printf(m, ",copyup=preserve");
>  
> -     if (IS_SET(sb, NFS_INSECURE))
> -             seq_printf(m, ",nfsperms=insecure");
> -     else
> -             seq_printf(m, ",nfsperms=secure");
> -
>        out:
>       if (tmp)
>               free_page(tmp);
> --- unionfs-20060117-2031/inode.c.org 2006-01-18 18:15:11.433145244 +0000
> +++ unionfs-20060117-2031/inode.c     2006-01-18 18:19:27.832426328 +0000
> @@ -838,7 +838,7 @@
>               retval = inode->i_op->permission(inode, submask, nd);
>               if ((retval == -EACCES) && (submask & MAY_WRITE) &&
>                   (!strcmp("nfs", (inode)->i_sb->s_type->name)) &&
> -                 IS_SET(nd->mnt->mnt_sb, NFS_INSECURE)) {
> +                 (branchperms(nd->mnt->mnt_sb, bindex) & MAY_NFSRO)) {
>  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
>                       retval = vfs_permission(inode, submask);
>  #else
> --- unionfs-20060117-2031/unionctl.c.org      2006-01-18 18:24:02.255017478 
> +0000
> +++ unionfs-20060117-2031/unionctl.c  2006-01-19 20:15:42.006074044 +0000
> @@ -59,9 +59,9 @@
>       fprintf(stderr,
>               "ACTION can be --add, --remove, --mode, --list, or 
> --query.\nFurther arguments depend on ACTION.\n");
>       fprintf(stderr,
> -             "\tunionctl UNION --add [ --before BRANCH | --after BRANCH ] [ 
> --mode (rw|ro) ] DIRECTORY\n");
> +             "\tunionctl UNION --add [ --before BRANCH | --after BRANCH ] [ 
> --mode (rw|ro|nfsro) ] DIRECTORY\n");
>       fprintf(stderr, "\tunionctl UNION --remove BRANCH\n");
> -     fprintf(stderr, "\tunionctl UNION --mode BRANCH (rw|ro)\n");
> +     fprintf(stderr, "\tunionctl UNION --mode BRANCH (rw|ro|nfsro)\n");
>       fprintf(stderr, "\tunionctl UNION --list\n");
>       fprintf(stderr, "\tunionctl FILENAME --query\n");
>       fprintf(stderr,
> @@ -69,16 +69,27 @@
>       exit(EXIT_FAILURE);
>  }
>  
> +static inline int parse_rw(char *p)
> +{
> +     if (strcmp(p, "ro") == 0)
> +             return MAY_READ;
> +     else if (strcmp(p, "nfsro") == 0)
> +             return MAY_READ | MAY_NFSRO;
> +     else if (strcmp(p, "rw") == 0)
> +             return MAY_READ | MAY_WRITE;
> +     else
> +             return 0;
> +}
> +
>  static char **parse_options(char *options)
>  {
>       char **ret = NULL;
> -     int n = 0;
> +     int i = 0;
>  
>       char *p;
>       char *q;
>       char *r;
> -     char *s;
> -     int l;
> +     char *s, *t, *u;
>  
>       p = options;
>       do {
> @@ -94,30 +105,32 @@
>                                       *s++ = '\0';
>                               }
>  
> -                             n++;
> -                             ret = realloc(ret, sizeof(char *) * (n + 1));
> +                             i++;
> +                             ret = realloc(ret, sizeof(char *) * (i + 1));
>                               if (!ret) {
>                                       perror("realloc()");
>                                       exit(EXIT_FAILURE);
>                               }
>                               branchperms =
> -                                 realloc(branchperms, sizeof(int) * n);
> +                                 realloc(branchperms, sizeof(int) * i);
>                               if (!branchperms) {
>                                       perror("realloc()");
>                                       exit(EXIT_FAILURE);
>                               }
>  
> -                             l = strlen(r);
> -                             if (((r[l - 1] == 'o') || (r[l - 1] == 'w'))
> -                                 && (r[l - 2] == 'r') && (r[l - 3] == '=')) {
> -                                     r[l - 3] = '\0';
> -                                     branchperms[n - 1] = MAY_READ;
> -                                     if (r[l - 1] == 'w') {
> -                                             branchperms[n - 1] |= MAY_WRITE;
> -                                     }
> +                             t = strchr(r, '=');
> +                             u = t+1;
> +                             if (!t || !u || !*u)
> +                                     goto err;
> +                             *t = 0;
> +                             branchperms[i - 1] = parse_rw(u);
> +                             if (!branchperms[i - 1]) {
> +                             err:
> +                                     fprintf(stderr, "cannot parse '%s'\n", 
> r);
> +                                     exit(EXIT_FAILURE);
>                               }
> -                             ret[n - 1] = strdup(r);
> -                             ret[n] = NULL;
> +                             ret[i - 1] = strdup(r);
> +                             ret[i] = NULL;
>  
>                               r = s;
>                       }
> @@ -159,14 +172,15 @@
>  
>  static void dump_branches(const char *prefix)
>  {
> -     int n = 0;
> +     int i = 0;
>  
> -     while (branches[n]) {
> -             char r, w;
> -             r = (branchperms[n] & MAY_READ) ? 'r' : '-';
> -             w = (branchperms[n] & MAY_WRITE) ? 'w' : '-';
> -             printf("%s%s (%c%c)\n", prefix, branches[n], r, w);
> -             n++;
> +     while (branches[i]) {
> +             char r, w, n;
> +             r = (branchperms[i] & MAY_READ) ? 'r' : '-';
> +             w = (branchperms[i] & MAY_WRITE) ? 'w' : '-';
> +             n = (branchperms[i] & MAY_NFSRO) ? 'n' : '-';
> +             printf("%s%s (%c%c%c)\n", prefix, branches[i], r, w, n);
> +             i++;
>       }
>  }
>  
> @@ -312,14 +326,10 @@
>                                               usage();
>                                       }
>  
> -                                     if (!strcmp(argv[i], "ro")) {
> -                                             addargs.ab_perms = MAY_READ;
> -                                     } else if (!strcmp(argv[i], "rw")) {
> -                                             addargs.ab_perms =
> -                                                 MAY_READ | MAY_WRITE;
> -                                     } else {
> +                                     addargs.ab_perms = parse_rw(argv[i]);
> +                                     if (!addargs.ab_perms) {
>                                               fprintf(stderr,
> -                                                     "Valid modes are ro and 
> rw you specified: \"%s\"\n",
> +                                                     "Valid modes are ro, 
> nfsro and rw you specified: \"%s\"\n",
>                                                       argv[i]);
>                                               usage();
>                                       }
> @@ -382,9 +392,13 @@
>                       usage();
>               }
>  
> +/*
>               if (!strcmp(argv[4], "ro")) {
>                       rdwrargs.rwb_perms = MAY_READ;
>                       branchnum = 3;
> +             } else if (!strcmp(argv[4], "nfsro")) {
> +                     rdwrargs.rwb_perms = MAY_READ | MAY_NFSRO;
> +                     branchnum = 3;
>               } else if (!strcmp(argv[4], "rw")) {
>                       rdwrargs.rwb_perms = MAY_READ | MAY_WRITE;
>                       branchnum = 3;
> @@ -397,6 +411,18 @@
>               } else {
>                       usage();
>               }
> +*/
> +
> +             branchnum = 3;
> +             rdwrargs.rwb_perms = parse_rw(argv[4]);
> +             if (!rdwrargs.rwb_perms) {
> +                     branchnum = 4;
> +                     rdwrargs.rwb_perms = parse_rw(argv[3]);
> +                     if (!rdwrargs.rwb_perms) {
> +                             usage();
> +                             exit(EXIT_FAILURE);
> +                     }
> +             }
>  
>               if (realpath(argv[branchnum], resolv_bp) == NULL) {
>                       perror("realpath()");
> @@ -481,13 +507,14 @@
>               }
>  
>               for (i = 0; i <= ret; i++) {
> -                     char r, w;
> +                     char r, w, n;
>                       r = (branchperms[i] & MAY_READ) ? 'r' : '-';
>                       w = (branchperms[i] & MAY_WRITE) ? 'w' : '-';
> +                     n = (branchperms[i] & MAY_NFSRO) ? 'n' : '-';
>  
>                       if (FD_ISSET(i, &branchlist))
> -                             printf("%s\t%s (%c%c)\n", argv[unionpos],
> -                                    branches[i], r, w);
> +                             printf("%s\t%s (%c%c%c)\n", argv[unionpos],
> +                                             branches[i], r, w, n);
>               }
>               break;
>       }
> --- unionfs-20060117-2031/BUGS.org    2006-01-20 19:54:08.787020617 +0000
> +++ unionfs-20060117-2031/BUGS        2006-01-20 20:01:39.856645574 +0000
> @@ -1,11 +1,12 @@
>  This file has a list of bugs or misfeatures  with other systems that affect
>  Unionfs.  To see a somewhat comprehensive list of Unionfs bugs visit
> -http://bugzilla.fsl.cs.sunysb.edu.
> +https://bugzilla.filesystems.org
>  
>  The NFS server returns -EACCES for read-only exports, instead of -EROFS.  
> This
>  means we can't reliably detect a read-only NFS export.  If you want to use
> -copy-on-write with NFS, mount the unionfs with nfsperms=insecure.  If this 
> flag
> -is set, then Unionfs will apply standard Unix permissions to files on NFS.
> +copy-on-write with NFS, set the per-branch option `nfsro'.  If this flag
> +is set, then Unionfs will apply standard Unix permissions to files on this
> +nfs-mouted branch.
>  
>  The PPC module loading algorithm has an O(N^2) loop, so it takes a while to
>  load the Unionfs module, because we have lots of symbols.
> _______________________________________________
> unionfs mailing list
> [email protected]
> http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs

_______________________________________________
unionfs mailing list
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs

Reply via email to