mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-26 16:18:31 +00:00
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. MFC after: 2 weeks
This commit is contained in:
parent
343044c43b
commit
e6e2445622
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=299872
@ -216,6 +216,28 @@ fuse_filehandle_valid(struct vnode *vp, fufh_type_t fufh_type)
|
||||
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)
|
||||
|
@ -137,6 +137,7 @@ fuse_filehandle_xlate_to_oflags(fufh_type_t type)
|
||||
}
|
||||
|
||||
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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user