summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Pierre André <jpandre@users.sourceforge.net>2013-05-12 09:55:57 +0200
committerJean-Pierre André <jpandre@users.sourceforge.net>2013-05-12 09:55:57 +0200
commit4c8fece06529e0bc7a5a86ee0cafa66e6c902a8f (patch)
treea96a4cf66b8d15430fb32fa9d9aa632fc1d7251c
parent8ef3114dfcee95cd53d8a4d8a8d08b99fd76f126 (diff)
downloadillumos-fusefs-4c8fece06529e0bc7a5a86ee0cafa66e6c902a8f.tar.gz
Allow ftruncate() on files open for write irrespective of permissions
-rw-r--r--kernel/fuse_vnops.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/kernel/fuse_vnops.c b/kernel/fuse_vnops.c
index cc410d6..63e3d11 100644
--- a/kernel/fuse_vnops.c
+++ b/kernel/fuse_vnops.c
@@ -1762,10 +1762,11 @@ fuse_setattr(
* its file handle.
* We cannot tell whether truncate() or ftruncate()
* was used, we can only check whether the calling
- * process has a create handle on the file.
+ * process has a write or create handle on the file to
+ * allow truncation irrespective of current permissions.
*/
fh_param.credp = credp;
- fh_param.rw_mode = FCREAT;
+ fh_param.rw_mode = FWRITE | FAPPEND | FCREAT;
fh_param.fufh = NULL;
if (vp->v_wrcnt
&& (iterate_filehandle(vp, fuse_std_filecheck, &fh_param,
@@ -1956,17 +1957,18 @@ fuse_access_i(void *vvp, int mode, struct cred *credp)
fai->mask |= X_OK;
/*
* Do not request a check from the file system if the
- * file is being created by the current process.
+ * file is being created or written by the current process,
* This is a workaround needed to allow ftruncate()
* for the process having a write descriptor to the file
- * it is currently creating as read-only.
+ * when it is creating as read-only or permissions
+ * changed since the file was opened.
*/
if ((mode & VWRITE) && vp->v_wrcnt) {
struct fuse_fh_param fh_param;
struct fuse_file_handle *fhp;
fh_param.credp = credp;
- fh_param.rw_mode = FCREAT;
+ fh_param.rw_mode = FWRITE | FAPPEND | FCREAT;
fh_param.fufh = NULL;
if (vp->v_wrcnt
&& (iterate_filehandle(vp, fuse_std_filecheck,