Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 May 2016 23:30:37 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r300978 - stable/10/sys/fs/fuse
Message-ID:  <201605292330.u4TNUbIO084103@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Sun May 29 23:30:36 2016
New Revision: 300978
URL: https://svnweb.freebsd.org/changeset/base/300978

Log:
  MFC: r299872
  Fix fuse for "cp" of a mode 0444 file to the file system.
  
  When "cp" of a file with read-only (mode 0444) to a fuse mounted
  file system was attempted it would fail with EACCES. This was because
  fuse would attempt to open the file WRONLY and the open would fail.
  This patch changes the fuse_vnop_open() to test for an extant read-write
  open and use that, if it is available.
  This makes the "cp" of a read-only file to the fuse mounted file system
  work ok.
  There are simpler ways to fix this than adding the fuse_filehandle_validrw()
  function, but this function is useful for future patches related to
  exporting a fuse filesystem via NFS.

Modified:
  stable/10/sys/fs/fuse/fuse_file.c
  stable/10/sys/fs/fuse/fuse_file.h
  stable/10/sys/fs/fuse/fuse_vnops.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/fs/fuse/fuse_file.c
==============================================================================
--- stable/10/sys/fs/fuse/fuse_file.c	Sun May 29 23:05:14 2016	(r300977)
+++ stable/10/sys/fs/fuse/fuse_file.c	Sun May 29 23:30:36 2016	(r300978)
@@ -216,6 +216,28 @@ fuse_filehandle_valid(struct vnode *vp, 
 	return FUFH_IS_VALID(fufh);
 }
 
+/*
+ * Check for a valid file handle, first the type requested, but if that
+ * isn't valid, try for FUFH_RDWR.
+ * Return the FUFH type that is valid or FUFH_INVALID if there are none.
+ * This is a variant of fuse_filehandle_vaild() analogous to
+ * fuse_filehandle_getrw().
+ */
+fufh_type_t
+fuse_filehandle_validrw(struct vnode *vp, fufh_type_t fufh_type)
+{
+	struct fuse_vnode_data *fvdat = VTOFUD(vp);
+	struct fuse_filehandle *fufh;
+
+	fufh = &fvdat->fufh[fufh_type];
+	if (FUFH_IS_VALID(fufh) != 0)
+		return (fufh_type);
+	fufh = &fvdat->fufh[FUFH_RDWR];
+	if (FUFH_IS_VALID(fufh) != 0)
+		return (FUFH_RDWR);
+	return (FUFH_INVALID);
+}
+
 int
 fuse_filehandle_get(struct vnode *vp, fufh_type_t fufh_type,
     struct fuse_filehandle **fufhp)

Modified: stable/10/sys/fs/fuse/fuse_file.h
==============================================================================
--- stable/10/sys/fs/fuse/fuse_file.h	Sun May 29 23:05:14 2016	(r300977)
+++ stable/10/sys/fs/fuse/fuse_file.h	Sun May 29 23:30:36 2016	(r300978)
@@ -137,6 +137,7 @@ fuse_filehandle_xlate_to_oflags(fufh_typ
 }
 
 int fuse_filehandle_valid(struct vnode *vp, fufh_type_t fufh_type);
+fufh_type_t fuse_filehandle_validrw(struct vnode *vp, fufh_type_t fufh_type);
 int fuse_filehandle_get(struct vnode *vp, fufh_type_t fufh_type,
                         struct fuse_filehandle **fufhp);
 int fuse_filehandle_getrw(struct vnode *vp, fufh_type_t fufh_type,

Modified: stable/10/sys/fs/fuse/fuse_vnops.c
==============================================================================
--- stable/10/sys/fs/fuse/fuse_vnops.c	Sun May 29 23:05:14 2016	(r300977)
+++ stable/10/sys/fs/fuse/fuse_vnops.c	Sun May 29 23:30:36 2016	(r300978)
@@ -1153,7 +1153,7 @@ fuse_vnop_open(struct vop_open_args *ap)
 			fuse_open_flags = FOPEN_DIRECT_IO;
 	}
 
-	if (fuse_filehandle_valid(vp, fufh_type)) {
+	if (fuse_filehandle_validrw(vp, fufh_type) != FUFH_INVALID) {
 		fuse_vnode_open(vp, fuse_open_flags, td);
 		return 0;
 	}



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