linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fuse: allow umask processing in userspace
       [not found]   ` <4A3BC22A.80907@wanadoo.fr>
@ 2009-06-23 10:14     ` Miklos Szeredi
  2009-06-23 10:23       ` [PATCH] libfuse: " Miklos Szeredi
                         ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Miklos Szeredi @ 2009-06-23 10:14 UTC (permalink / raw)
  To: jean-pierre.andre; +Cc: miklos, utcke+fuse, fuse-devel, linux-fsdevel

On Fri, 19 Jun 2009, Jean-Pierre André wrote:
> On the very related issue of having some way of getting
> the original permission flags (with umask not applied),
> in create(), has there been any progress ?

OK, here's a patch that does this, it applies on top of latest git.
Could you please give it a test?

Even if you are not using git, you can get a "snapshot" of the git
tree from www.kernel.org.

I'll follow up with a patch for libfuse (also against latest CVS or
2.8.0-pre3)

Thanks,
Miklos

---
This patch lets filesystems handle masking the file mode on creation.
This is needed if filesystem is using ACLs.

 - The CREATE, MKDIR and MKNOD requests are extended with a "umask"
   parameter.

 - A new FUSE_DONT_MASK flag is added to the INIT request/reply.  With
   this the filesystem may request that the create mode is not masked.

CC: Jean-Pierre André <jean-pierre.andre@wanadoo.fr>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
 fs/fuse/dir.c        |   20 +++++++++++++++++---
 fs/fuse/fuse_i.h     |    3 +++
 fs/fuse/inode.c      |    9 ++++++++-
 include/linux/fuse.h |   20 ++++++++++++++++++--
 4 files changed, 46 insertions(+), 6 deletions(-)

Index: linux-2.6/fs/fuse/dir.c
===================================================================
--- linux-2.6.orig/fs/fuse/dir.c	2009-06-22 20:37:44.000000000 +0200
+++ linux-2.6/fs/fuse/dir.c	2009-06-23 10:06:36.000000000 +0200
@@ -375,7 +375,7 @@ static int fuse_create_open(struct inode
 	struct fuse_conn *fc = get_fuse_conn(dir);
 	struct fuse_req *req;
 	struct fuse_req *forget_req;
-	struct fuse_open_in inarg;
+	struct fuse_create_in inarg;
 	struct fuse_open_out outopen;
 	struct fuse_entry_out outentry;
 	struct fuse_file *ff;
@@ -399,15 +399,20 @@ static int fuse_create_open(struct inode
 	if (!ff)
 		goto out_put_request;
 
+	if (!fc->dont_mask)
+		mode &= ~current_umask();
+
 	flags &= ~O_NOCTTY;
 	memset(&inarg, 0, sizeof(inarg));
 	memset(&outentry, 0, sizeof(outentry));
 	inarg.flags = flags;
 	inarg.mode = mode;
+	inarg.umask = current_umask();
 	req->in.h.opcode = FUSE_CREATE;
 	req->in.h.nodeid = get_node_id(dir);
 	req->in.numargs = 2;
-	req->in.args[0].size = sizeof(inarg);
+	req->in.args[0].size = fc->minor < 12 ? sizeof(struct fuse_open_in) :
+						sizeof(inarg);
 	req->in.args[0].value = &inarg;
 	req->in.args[1].size = entry->d_name.len + 1;
 	req->in.args[1].value = entry->d_name.name;
@@ -546,12 +551,17 @@ static int fuse_mknod(struct inode *dir,
 	if (IS_ERR(req))
 		return PTR_ERR(req);
 
+	if (!fc->dont_mask)
+		mode &= ~current_umask();
+
 	memset(&inarg, 0, sizeof(inarg));
 	inarg.mode = mode;
 	inarg.rdev = new_encode_dev(rdev);
+	inarg.umask = current_umask();
 	req->in.h.opcode = FUSE_MKNOD;
 	req->in.numargs = 2;
-	req->in.args[0].size = sizeof(inarg);
+	req->in.args[0].size = fc->minor < 12 ? FUSE_COMPAT_MKNOD_IN_SIZE :
+						sizeof(inarg);
 	req->in.args[0].value = &inarg;
 	req->in.args[1].size = entry->d_name.len + 1;
 	req->in.args[1].value = entry->d_name.name;
@@ -578,8 +588,12 @@ static int fuse_mkdir(struct inode *dir,
 	if (IS_ERR(req))
 		return PTR_ERR(req);
 
+	if (!fc->dont_mask)
+		mode &= ~current_umask();
+
 	memset(&inarg, 0, sizeof(inarg));
 	inarg.mode = mode;
+	inarg.umask = current_umask();
 	req->in.h.opcode = FUSE_MKDIR;
 	req->in.numargs = 2;
 	req->in.args[0].size = sizeof(inarg);
Index: linux-2.6/fs/fuse/fuse_i.h
===================================================================
--- linux-2.6.orig/fs/fuse/fuse_i.h	2009-06-22 20:37:44.000000000 +0200
+++ linux-2.6/fs/fuse/fuse_i.h	2009-06-22 20:42:59.000000000 +0200
@@ -446,6 +446,9 @@ struct fuse_conn {
 	/** Do multi-page cached writes */
 	unsigned big_writes:1;
 
+	/** Don't apply umask to creation modes */
+	unsigned dont_mask:1;
+
 	/** The number of requests waiting for completion */
 	atomic_t num_waiting;
 
Index: linux-2.6/fs/fuse/inode.c
===================================================================
--- linux-2.6.orig/fs/fuse/inode.c	2009-06-22 20:37:44.000000000 +0200
+++ linux-2.6/fs/fuse/inode.c	2009-06-22 20:51:10.000000000 +0200
@@ -725,6 +725,8 @@ static void process_init_reply(struct fu
 			}
 			if (arg->flags & FUSE_BIG_WRITES)
 				fc->big_writes = 1;
+			if (arg->flags & FUSE_DONT_MASK)
+				fc->dont_mask = 1;
 		} else {
 			ra_pages = fc->max_read / PAGE_CACHE_SIZE;
 			fc->no_lock = 1;
@@ -748,7 +750,7 @@ static void fuse_send_init(struct fuse_c
 	arg->minor = FUSE_KERNEL_MINOR_VERSION;
 	arg->max_readahead = fc->bdi.ra_pages * PAGE_CACHE_SIZE;
 	arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC |
-		FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES;
+		FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES | FUSE_DONT_MASK;
 	req->in.h.opcode = FUSE_INIT;
 	req->in.numargs = 1;
 	req->in.args[0].size = sizeof(*arg);
@@ -864,6 +866,11 @@ static int fuse_fill_super(struct super_
 	if (err)
 		goto err_put_conn;
 
+	/* Handle umasking inside the fuse code */
+	if (sb->s_flags & MS_POSIXACL)
+		fc->dont_mask = 1;
+	sb->s_flags |= MS_POSIXACL;
+
 	fc->release = fuse_free_conn;
 	fc->flags = d.flags;
 	fc->user_id = d.user_id;
Index: linux-2.6/include/linux/fuse.h
===================================================================
--- linux-2.6.orig/include/linux/fuse.h	2009-06-22 20:37:44.000000000 +0200
+++ linux-2.6/include/linux/fuse.h	2009-06-23 10:05:45.000000000 +0200
@@ -25,6 +25,9 @@
  *  - add IOCTL message
  *  - add unsolicited notification support
  *  - add POLL message and NOTIFY_POLL notification
+ *
+ * 7.12
+ *  - add umask flag to input argument of open, mknod and mkdir
  */
 
 #ifndef _LINUX_FUSE_H
@@ -36,7 +39,7 @@
 #define FUSE_KERNEL_VERSION 7
 
 /** Minor version number of this interface */
-#define FUSE_KERNEL_MINOR_VERSION 11
+#define FUSE_KERNEL_MINOR_VERSION 12
 
 /** The node ID of the root inode */
 #define FUSE_ROOT_ID 1
@@ -112,6 +115,7 @@ struct fuse_file_lock {
  * INIT request/reply flags
  *
  * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".."
+ * FUSE_DONT_MASK: don't apply umask to file mode on create operations
  */
 #define FUSE_ASYNC_READ		(1 << 0)
 #define FUSE_POSIX_LOCKS	(1 << 1)
@@ -119,6 +123,7 @@ struct fuse_file_lock {
 #define FUSE_ATOMIC_O_TRUNC	(1 << 3)
 #define FUSE_EXPORT_SUPPORT	(1 << 4)
 #define FUSE_BIG_WRITES		(1 << 5)
+#define FUSE_DONT_MASK		(1 << 6)
 
 /**
  * CUSE INIT request/reply flags
@@ -262,14 +267,18 @@ struct fuse_attr_out {
 	struct fuse_attr attr;
 };
 
+#define FUSE_COMPAT_MKNOD_IN_SIZE 8
+
 struct fuse_mknod_in {
 	__u32	mode;
 	__u32	rdev;
+	__u32	umask;
+	__u32	padding;
 };
 
 struct fuse_mkdir_in {
 	__u32	mode;
-	__u32	padding;
+	__u32	umask;
 };
 
 struct fuse_rename_in {
@@ -301,7 +310,14 @@ struct fuse_setattr_in {
 
 struct fuse_open_in {
 	__u32	flags;
+	__u32	unused;
+};
+
+struct fuse_create_in {
+	__u32	flags;
 	__u32	mode;
+	__u32	umask;
+	__u32	padding;
 };
 
 struct fuse_open_out {
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] libfuse: allow umask processing in userspace
  2009-06-23 10:14     ` [PATCH] fuse: allow umask processing in userspace Miklos Szeredi
@ 2009-06-23 10:23       ` Miklos Szeredi
       [not found]       ` <E1MJ31Q-00076A-2G-8f8m9JG5TPIdUIPVzhDTVZP2KDSNp7ea@public.gmane.org>
                         ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Miklos Szeredi @ 2009-06-23 10:23 UTC (permalink / raw)
  To: jean-pierre.andre; +Cc: miklos, utcke+fuse, fuse-devel, linux-fsdevel

This patch against fuse-2.8.0-pre3 lets filesystems handle masking the
file mode on creation.

fuse_ctx (lowlevel API) and fuse_context (high level API) are extended
with a 'umask' field.  If the kernel doesn't send the umask, it is set
to zero.

Introduce a new feature flag FUSE_CAP_DONT_MASK, if the kernel
supports this feature, then this flag will be set in conn->capable in
the ->init() method.  If the filesystem sets this flag in in
conn->want, then the create modes will not be masked.

Testing is welcome.

Thanks,
Miklos

---
 include/fuse.h          |    3 +++
 include/fuse_common.h   |    2 ++
 include/fuse_kernel.h   |   20 ++++++++++++++++++--
 include/fuse_lowlevel.h |    3 +++
 lib/fuse_lowlevel.c     |   38 +++++++++++++++++++++++++++++++++++---
 lib/fuse_versionscript  |    4 ++--
 6 files changed, 63 insertions(+), 7 deletions(-)

Index: fuse/include/fuse_lowlevel.h
===================================================================
--- fuse.orig/include/fuse_lowlevel.h	2009-06-23 09:57:22.000000000 +0200
+++ fuse/include/fuse_lowlevel.h	2009-06-23 09:58:14.000000000 +0200
@@ -109,6 +109,9 @@ struct fuse_ctx {
 
 	/** Thread ID of the calling process */
 	pid_t pid;
+
+	/** Umask of the calling process (introduced in version 2.8) */
+	mode_t umask;
 };
 
 /* 'to_set' flags in setattr */
Index: fuse/lib/fuse_lowlevel.c
===================================================================
--- fuse.orig/lib/fuse_lowlevel.c	2009-06-23 09:57:22.000000000 +0200
+++ fuse/lib/fuse_lowlevel.c	2009-06-23 10:07:21.000000000 +0200
@@ -606,9 +606,15 @@ static void do_readlink(fuse_req_t req,
 static void do_mknod(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
 {
 	struct fuse_mknod_in *arg = (struct fuse_mknod_in *) inarg;
+	char *name = PARAM(arg);
+
+	if (req->f->conn.proto_minor >= 12)
+		req->ctx.umask = arg->umask;
+	else
+		name = (char *) inarg + FUSE_COMPAT_MKNOD_IN_SIZE;
 
 	if (req->f->op.mknod)
-		req->f->op.mknod(req, nodeid, PARAM(arg), arg->mode, arg->rdev);
+		req->f->op.mknod(req, nodeid, name, arg->mode, arg->rdev);
 	else
 		fuse_reply_err(req, ENOSYS);
 }
@@ -617,6 +623,9 @@ static void do_mkdir(fuse_req_t req, fus
 {
 	struct fuse_mkdir_in *arg = (struct fuse_mkdir_in *) inarg;
 
+	if (req->f->conn.proto_minor >= 12)
+		req->ctx.umask = arg->umask;
+
 	if (req->f->op.mkdir)
 		req->f->op.mkdir(req, nodeid, PARAM(arg), arg->mode);
 	else
@@ -678,15 +687,21 @@ static void do_link(fuse_req_t req, fuse
 
 static void do_create(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
 {
-	struct fuse_open_in *arg = (struct fuse_open_in *) inarg;
+	struct fuse_create_in *arg = (struct fuse_create_in *) inarg;
 
 	if (req->f->op.create) {
 		struct fuse_file_info fi;
+		char *name = PARAM(arg);
 
 		memset(&fi, 0, sizeof(fi));
 		fi.flags = arg->flags;
 
-		req->f->op.create(req, nodeid, PARAM(arg), arg->mode, &fi);
+		if (req->f->conn.proto_minor >= 12)
+			req->ctx.umask = arg->umask;
+		else
+			name = (char *) inarg + sizeof(struct fuse_open_in);
+
+		req->f->op.create(req, nodeid, name, arg->mode, &fi);
 	} else
 		fuse_reply_err(req, ENOSYS);
 }
@@ -1168,6 +1183,8 @@ static void do_init(fuse_req_t req, fuse
 			f->conn.capable |= FUSE_CAP_EXPORT_SUPPORT;
 		if (arg->flags & FUSE_BIG_WRITES)
 			f->conn.capable |= FUSE_CAP_BIG_WRITES;
+		if (arg->flags & FUSE_DONT_MASK)
+			f->conn.capable |= FUSE_CAP_DONT_MASK;
 	} else {
 		f->conn.async_read = 0;
 		f->conn.max_readahead = 0;
@@ -1207,6 +1224,8 @@ static void do_init(fuse_req_t req, fuse
 		outarg.flags |= FUSE_EXPORT_SUPPORT;
 	if (f->conn.want & FUSE_CAP_BIG_WRITES)
 		outarg.flags |= FUSE_BIG_WRITES;
+	if (f->conn.want & FUSE_CAP_DONT_MASK)
+		outarg.flags |= FUSE_DONT_MASK;
 	outarg.max_readahead = f->conn.max_readahead;
 	outarg.max_write = f->conn.max_write;
 
@@ -1280,6 +1299,19 @@ const struct fuse_ctx *fuse_req_ctx(fuse
 	return &req->ctx;
 }
 
+/*
+ * The size of fuse_ctx got extended, so need to be careful about
+ * incompatibility (i.e. a new binary cannot work with an old
+ * library).
+ */
+const struct fuse_ctx *fuse_req_ctx_compat24(fuse_req_t req);
+const struct fuse_ctx *fuse_req_ctx_compat24(fuse_req_t req)
+{
+	return fuse_req_ctx(req);
+}
+FUSE_SYMVER(".symver fuse_req_ctx_compat24,fuse_req_ctx@FUSE_2.4");
+
+
 void fuse_req_interrupt_func(fuse_req_t req, fuse_interrupt_func_t func,
 			     void *data)
 {
Index: fuse/lib/fuse_versionscript
===================================================================
--- fuse.orig/lib/fuse_versionscript	2009-06-23 09:57:22.000000000 +0200
+++ fuse/lib/fuse_versionscript	2009-06-23 09:58:14.000000000 +0200
@@ -3,7 +3,6 @@ FUSE_2.2 {
 		fuse_destroy;
 		fuse_exit;
 		fuse_exited;
-		fuse_get_context;
 		fuse_invalidate;
 		fuse_is_lib_option;
 		fuse_loop;
@@ -43,7 +42,6 @@ FUSE_2.4 {
 		fuse_reply_readlink;
 		fuse_reply_write;
 		fuse_reply_xattr;
-		fuse_req_ctx;
 		fuse_req_userdata;
 		fuse_session_add_chan;
 		fuse_session_destroy;
@@ -176,6 +174,8 @@ FUSE_2.8 {
 		fuse_reply_poll;
 		fuse_req_getgroups;
 		fuse_getgroups;
+		fuse_req_ctx;
+		fuse_get_context;
 
 	local:
 		*;
Index: fuse/include/fuse.h
===================================================================
--- fuse.orig/include/fuse.h	2009-06-23 09:57:22.000000000 +0200
+++ fuse/include/fuse.h	2009-06-23 09:58:14.000000000 +0200
@@ -518,6 +518,9 @@ struct fuse_context {
 
 	/** Private filesystem data */
 	void *private_data;
+
+	/** Umask of the calling process (introduced in version 2.8) */
+	mode_t umask;
 };
 
 /**
Index: fuse/include/fuse_common.h
===================================================================
--- fuse.orig/include/fuse_common.h	2009-06-23 09:57:22.000000000 +0200
+++ fuse/include/fuse_common.h	2009-06-23 09:58:14.000000000 +0200
@@ -88,12 +88,14 @@ struct fuse_file_info {
  * FUSE_CAP_ATOMIC_O_TRUNC: filesystem handles the O_TRUNC open flag
  * FUSE_CAP_EXPORT_SUPPORT: filesystem handles lookups of "." and ".."
  * FUSE_CAP_BIG_WRITES: filesystem can handle write size larger than 4kB
+ * FUSE_CAP_DONT_MASK: don't apply umask to file mode on create operations
  */
 #define FUSE_CAP_ASYNC_READ	(1 << 0)
 #define FUSE_CAP_POSIX_LOCKS	(1 << 1)
 #define FUSE_CAP_ATOMIC_O_TRUNC	(1 << 3)
 #define FUSE_CAP_EXPORT_SUPPORT	(1 << 4)
 #define FUSE_CAP_BIG_WRITES	(1 << 5)
+#define FUSE_CAP_DONT_MASK	(1 << 6)
 
 /**
  * Ioctl flags
Index: fuse/include/fuse_kernel.h
===================================================================
--- fuse.orig/include/fuse_kernel.h	2009-06-23 09:57:22.000000000 +0200
+++ fuse/include/fuse_kernel.h	2009-06-23 10:06:10.000000000 +0200
@@ -51,6 +51,9 @@
  *  - add IOCTL message
  *  - add unsolicited notification support
  *  - add POLL message and NOTIFY_POLL notification
+ *
+ * 7.12
+ *  - add umask flag to input argument of open, mknod and mkdir
  */
 
 #ifndef _LINUX_FUSE_H
@@ -65,7 +68,7 @@
 #define FUSE_KERNEL_VERSION 7
 
 /** Minor version number of this interface */
-#define FUSE_KERNEL_MINOR_VERSION 11
+#define FUSE_KERNEL_MINOR_VERSION 12
 
 /** The node ID of the root inode */
 #define FUSE_ROOT_ID 1
@@ -141,6 +144,7 @@ struct fuse_file_lock {
  * INIT request/reply flags
  *
  * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".."
+ * FUSE_DONT_MASK: don't apply umask to file mode on create operations
  */
 #define FUSE_ASYNC_READ		(1 << 0)
 #define FUSE_POSIX_LOCKS	(1 << 1)
@@ -148,6 +152,7 @@ struct fuse_file_lock {
 #define FUSE_ATOMIC_O_TRUNC	(1 << 3)
 #define FUSE_EXPORT_SUPPORT	(1 << 4)
 #define FUSE_BIG_WRITES		(1 << 5)
+#define FUSE_DONT_MASK		(1 << 6)
 
 /**
  * CUSE INIT request/reply flags
@@ -291,14 +296,18 @@ struct fuse_attr_out {
 	struct fuse_attr attr;
 };
 
+#define FUSE_COMPAT_MKNOD_IN_SIZE 8
+
 struct fuse_mknod_in {
 	__u32	mode;
 	__u32	rdev;
+	__u32	umask;
+	__u32	padding;
 };
 
 struct fuse_mkdir_in {
 	__u32	mode;
-	__u32	padding;
+	__u32	umask;
 };
 
 struct fuse_rename_in {
@@ -330,7 +339,14 @@ struct fuse_setattr_in {
 
 struct fuse_open_in {
 	__u32	flags;
+	__u32	unused;
+};
+
+struct fuse_create_in {
+	__u32	flags;
 	__u32	mode;
+	__u32	umask;
+	__u32	padding;
 };
 
 struct fuse_open_out {

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] fuse: allow umask processing in userspace
       [not found]       ` <E1MJ31Q-00076A-2G-8f8m9JG5TPIdUIPVzhDTVZP2KDSNp7ea@public.gmane.org>
@ 2009-06-24 16:14         ` Jean-Pierre ANDRE
  0 siblings, 0 replies; 9+ messages in thread
From: Jean-Pierre ANDRE @ 2009-06-24 16:14 UTC (permalink / raw)
  To: Miklos Szeredi
  Cc: fuse-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
	miklos-sUDqSbJrdHQHWmgEVkV9KA

Hi Miklos,

Great, I appreciate.

I cannot test it now, I will from July.

I will probably have questions when I start testing, just one
for now : what condition should be checked in the source of a file
system for being compiled with the new interface (probably a
minimal value for fuse version) ? Obviously the file system
will have to be released will ability to be compiled in both
situations.

Thank you again,

Jean-Pierre



> Message du 23/06/09 12:14
> De : "Miklos Szeredi" 
> A : jean-pierre.andre@wanadoo.fr
> Copie à : miklos@szeredi.hu, utcke+fuse@informatik.uni-hamburg.de, fuse-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org
> Objet : [PATCH] fuse: allow umask processing in userspace
> 
> 
> On Fri, 19 Jun 2009, Jean-Pierre André wrote:
> > On the very related issue of having some way of getting
> > the original permission flags (with umask not applied),
> > in create(), has there been any progress ?
> 
> OK, here's a patch that does this, it applies on top of latest git.
> Could you please give it a test?
> 
> Even if you are not using git, you can get a "snapshot" of the git
> tree from www.kernel.org.
> 
> I'll follow up with a patch for libfuse (also against latest CVS or
> 2.8.0-pre3)
> 
> Thanks,
> Miklos
> 
> ---
> This patch lets filesystems handle masking the file mode on creation.
> This is needed if filesystem is using ACLs.
> 
> - The CREATE, MKDIR and MKNOD requests are extended with a "umask"
> parameter.
> 
> - A new FUSE_DONT_MASK flag is added to the INIT request/reply. With
> this the filesystem may request that the create mode is not masked.
> 
> CC: Jean-Pierre André 
> Signed-off-by: Miklos Szeredi
------------------------------------------------------------------------------
_______________________________________________
fuse-devel mailing list
fuse-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fuse-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] fuse: allow umask processing in userspace
  2009-06-23 10:14     ` [PATCH] fuse: allow umask processing in userspace Miklos Szeredi
  2009-06-23 10:23       ` [PATCH] libfuse: " Miklos Szeredi
       [not found]       ` <E1MJ31Q-00076A-2G-8f8m9JG5TPIdUIPVzhDTVZP2KDSNp7ea@public.gmane.org>
@ 2009-07-02 13:20       ` Jean-Pierre André
  2009-07-03  9:23         ` Miklos Szeredi
  2009-07-03  7:50       ` Jean-Pierre André
  2009-07-04 14:51       ` Jean-Pierre André
  4 siblings, 1 reply; 9+ messages in thread
From: Jean-Pierre André @ 2009-07-02 13:20 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: utcke+fuse, fuse-devel, linux-fsdevel, Szabolcs Szakacsits

Hi Miklos,

On my first try, I did not get much far. I could not compile
the kernel module for kernel-2.6.29.5-191 because of
undefined function current_umask(). This function
is nowhere to be found in the kernel source.

Is this a function (or macro) missing from the proposed
patch or part of a kernel upgrade ? In this latter case,
can it be implemented within the patch ? If not, I would
rather avoid installing a specific kernel for this test
and just use a dummy version returning a fixed value.

Anyway, what would be the minimal kernel version ?

Regards

Jean-Pierre


Miklos Szeredi wrote:
> On Fri, 19 Jun 2009, Jean-Pierre André wrote:
>   
>> On the very related issue of having some way of getting
>> the original permission flags (with umask not applied),
>> in create(), has there been any progress ?
>>     
>
> OK, here's a patch that does this, it applies on top of latest git.
> Could you please give it a test?
>
> Even if you are not using git, you can get a "snapshot" of the git
> tree from www.kernel.org.
>
> I'll follow up with a patch for libfuse (also against latest CVS or
> 2.8.0-pre3)
>
> Thanks,
> Miklos
>
> ---
> This patch lets filesystems handle masking the file mode on creation.
> This is needed if filesystem is using ACLs.
>
>  - The CREATE, MKDIR and MKNOD requests are extended with a "umask"
>    parameter.
>
>  - A new FUSE_DONT_MASK flag is added to the INIT request/reply.  With
>    this the filesystem may request that the create mode is not masked.
>
> CC: Jean-Pierre André <jean-pierre.andre@wanadoo.fr>
> Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
> ---
>  fs/fuse/dir.c        |   20 +++++++++++++++++---
>  fs/fuse/fuse_i.h     |    3 +++
>  fs/fuse/inode.c      |    9 ++++++++-
>  include/linux/fuse.h |   20 ++++++++++++++++++--
>  4 files changed, 46 insertions(+), 6 deletions(-)
>
> Index: linux-2.6/fs/fuse/dir.c
> ===================================================================
> --- linux-2.6.orig/fs/fuse/dir.c	2009-06-22 20:37:44.000000000 +0200
> +++ linux-2.6/fs/fuse/dir.c	2009-06-23 10:06:36.000000000 +0200
> @@ -375,7 +375,7 @@ static int fuse_create_open(struct inode
>  	struct fuse_conn *fc = get_fuse_conn(dir);
>  	struct fuse_req *req;
>  	struct fuse_req *forget_req;
> -	struct fuse_open_in inarg;
> +	struct fuse_create_in inarg;
>  	struct fuse_open_out outopen;
>  	struct fuse_entry_out outentry;
>  	struct fuse_file *ff;
> @@ -399,15 +399,20 @@ static int fuse_create_open(struct inode
>  	if (!ff)
>  		goto out_put_request;
>  
> +	if (!fc->dont_mask)
> +		mode &= ~current_umask();
> +
>  	flags &= ~O_NOCTTY;
>  	memset(&inarg, 0, sizeof(inarg));
>  	memset(&outentry, 0, sizeof(outentry));
>  	inarg.flags = flags;
>  	inarg.mode = mode;
> +	inarg.umask = current_umask();
>  	req->in.h.opcode = FUSE_CREATE;
>  	req->in.h.nodeid = get_node_id(dir);
>  	req->in.numargs = 2;
> -	req->in.args[0].size = sizeof(inarg);
> +	req->in.args[0].size = fc->minor < 12 ? sizeof(struct fuse_open_in) :
> +						sizeof(inarg);
>  	req->in.args[0].value = &inarg;
>  	req->in.args[1].size = entry->d_name.len + 1;
>  	req->in.args[1].value = entry->d_name.name;
> @@ -546,12 +551,17 @@ static int fuse_mknod(struct inode *dir,
>  	if (IS_ERR(req))
>  		return PTR_ERR(req);
>  
> +	if (!fc->dont_mask)
> +		mode &= ~current_umask();
> +
>  	memset(&inarg, 0, sizeof(inarg));
>  	inarg.mode = mode;
>  	inarg.rdev = new_encode_dev(rdev);
> +	inarg.umask = current_umask();
>  	req->in.h.opcode = FUSE_MKNOD;
>  	req->in.numargs = 2;
> -	req->in.args[0].size = sizeof(inarg);
> +	req->in.args[0].size = fc->minor < 12 ? FUSE_COMPAT_MKNOD_IN_SIZE :
> +						sizeof(inarg);
>  	req->in.args[0].value = &inarg;
>  	req->in.args[1].size = entry->d_name.len + 1;
>  	req->in.args[1].value = entry->d_name.name;
> @@ -578,8 +588,12 @@ static int fuse_mkdir(struct inode *dir,
>  	if (IS_ERR(req))
>  		return PTR_ERR(req);
>  
> +	if (!fc->dont_mask)
> +		mode &= ~current_umask();
> +
>  	memset(&inarg, 0, sizeof(inarg));
>  	inarg.mode = mode;
> +	inarg.umask = current_umask();
>  	req->in.h.opcode = FUSE_MKDIR;
>  	req->in.numargs = 2;
>  	req->in.args[0].size = sizeof(inarg);
> Index: linux-2.6/fs/fuse/fuse_i.h
> ===================================================================
> --- linux-2.6.orig/fs/fuse/fuse_i.h	2009-06-22 20:37:44.000000000 +0200
> +++ linux-2.6/fs/fuse/fuse_i.h	2009-06-22 20:42:59.000000000 +0200
> @@ -446,6 +446,9 @@ struct fuse_conn {
>  	/** Do multi-page cached writes */
>  	unsigned big_writes:1;
>  
> +	/** Don't apply umask to creation modes */
> +	unsigned dont_mask:1;
> +
>  	/** The number of requests waiting for completion */
>  	atomic_t num_waiting;
>  
> Index: linux-2.6/fs/fuse/inode.c
> ===================================================================
> --- linux-2.6.orig/fs/fuse/inode.c	2009-06-22 20:37:44.000000000 +0200
> +++ linux-2.6/fs/fuse/inode.c	2009-06-22 20:51:10.000000000 +0200
> @@ -725,6 +725,8 @@ static void process_init_reply(struct fu
>  			}
>  			if (arg->flags & FUSE_BIG_WRITES)
>  				fc->big_writes = 1;
> +			if (arg->flags & FUSE_DONT_MASK)
> +				fc->dont_mask = 1;
>  		} else {
>  			ra_pages = fc->max_read / PAGE_CACHE_SIZE;
>  			fc->no_lock = 1;
> @@ -748,7 +750,7 @@ static void fuse_send_init(struct fuse_c
>  	arg->minor = FUSE_KERNEL_MINOR_VERSION;
>  	arg->max_readahead = fc->bdi.ra_pages * PAGE_CACHE_SIZE;
>  	arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC |
> -		FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES;
> +		FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES | FUSE_DONT_MASK;
>  	req->in.h.opcode = FUSE_INIT;
>  	req->in.numargs = 1;
>  	req->in.args[0].size = sizeof(*arg);
> @@ -864,6 +866,11 @@ static int fuse_fill_super(struct super_
>  	if (err)
>  		goto err_put_conn;
>  
> +	/* Handle umasking inside the fuse code */
> +	if (sb->s_flags & MS_POSIXACL)
> +		fc->dont_mask = 1;
> +	sb->s_flags |= MS_POSIXACL;
> +
>  	fc->release = fuse_free_conn;
>  	fc->flags = d.flags;
>  	fc->user_id = d.user_id;
> Index: linux-2.6/include/linux/fuse.h
> ===================================================================
> --- linux-2.6.orig/include/linux/fuse.h	2009-06-22 20:37:44.000000000 +0200
> +++ linux-2.6/include/linux/fuse.h	2009-06-23 10:05:45.000000000 +0200
> @@ -25,6 +25,9 @@
>   *  - add IOCTL message
>   *  - add unsolicited notification support
>   *  - add POLL message and NOTIFY_POLL notification
> + *
> + * 7.12
> + *  - add umask flag to input argument of open, mknod and mkdir
>   */
>  
>  #ifndef _LINUX_FUSE_H
> @@ -36,7 +39,7 @@
>  #define FUSE_KERNEL_VERSION 7
>  
>  /** Minor version number of this interface */
> -#define FUSE_KERNEL_MINOR_VERSION 11
> +#define FUSE_KERNEL_MINOR_VERSION 12
>  
>  /** The node ID of the root inode */
>  #define FUSE_ROOT_ID 1
> @@ -112,6 +115,7 @@ struct fuse_file_lock {
>   * INIT request/reply flags
>   *
>   * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".."
> + * FUSE_DONT_MASK: don't apply umask to file mode on create operations
>   */
>  #define FUSE_ASYNC_READ		(1 << 0)
>  #define FUSE_POSIX_LOCKS	(1 << 1)
> @@ -119,6 +123,7 @@ struct fuse_file_lock {
>  #define FUSE_ATOMIC_O_TRUNC	(1 << 3)
>  #define FUSE_EXPORT_SUPPORT	(1 << 4)
>  #define FUSE_BIG_WRITES		(1 << 5)
> +#define FUSE_DONT_MASK		(1 << 6)
>  
>  /**
>   * CUSE INIT request/reply flags
> @@ -262,14 +267,18 @@ struct fuse_attr_out {
>  	struct fuse_attr attr;
>  };
>  
> +#define FUSE_COMPAT_MKNOD_IN_SIZE 8
> +
>  struct fuse_mknod_in {
>  	__u32	mode;
>  	__u32	rdev;
> +	__u32	umask;
> +	__u32	padding;
>  };
>  
>  struct fuse_mkdir_in {
>  	__u32	mode;
> -	__u32	padding;
> +	__u32	umask;
>  };
>  
>  struct fuse_rename_in {
> @@ -301,7 +310,14 @@ struct fuse_setattr_in {
>  
>  struct fuse_open_in {
>  	__u32	flags;
> +	__u32	unused;
> +};
> +
> +struct fuse_create_in {
> +	__u32	flags;
>  	__u32	mode;
> +	__u32	umask;
> +	__u32	padding;
>  };
>  
>  struct fuse_open_out {
>
>   

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] fuse: allow umask processing in userspace
  2009-06-23 10:14     ` [PATCH] fuse: allow umask processing in userspace Miklos Szeredi
                         ` (2 preceding siblings ...)
  2009-07-02 13:20       ` Jean-Pierre André
@ 2009-07-03  7:50       ` Jean-Pierre André
  2009-07-04 14:51       ` Jean-Pierre André
  4 siblings, 0 replies; 9+ messages in thread
From: Jean-Pierre André @ 2009-07-03  7:50 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: utcke+fuse, fuse-devel, linux-fsdevel, Szabolcs Szakacsits

Hi Miklos,

Good news : use of default ACL is now ok,
Bad news : several tests on mkdir/mknod fail.

This is because umask is not applied anymore, in
any situation, and it was somewhat expected as I
defined current_umask() as zero.

BUT :

I only built a new fuse.ko for kernel 2.6.29.5-191
based on the fuse source released with this kernel
and the below patches applied (manually). No change
whatever elsewhere (I did not recompile the kernel),
and there is nothing in this patch which removes the
old code which was applying the umask (there is only
new code which applies the umask on condition).

Also I did not update the server part (the file system),
which should be ok as the old fields remain at the same
location (and the new behaviour cannot be requested).

So why does this patch prevent the umask being
applied to the "mode" argument ? I mean : how does
it avoid the old code which was applying the umask ?

Is there a hidden hack somewhere ?

Regards

Jean-Pierre





Miklos Szeredi wrote:
> On Fri, 19 Jun 2009, Jean-Pierre André wrote:
>   
>> On the very related issue of having some way of getting
>> the original permission flags (with umask not applied),
>> in create(), has there been any progress ?
>>     
>
> OK, here's a patch that does this, it applies on top of latest git.
> Could you please give it a test?
>
> Even if you are not using git, you can get a "snapshot" of the git
> tree from www.kernel.org.
>
> I'll follow up with a patch for libfuse (also against latest CVS or
> 2.8.0-pre3)
>
> Thanks,
> Miklos
>
> ---
> This patch lets filesystems handle masking the file mode on creation.
> This is needed if filesystem is using ACLs.
>
>  - The CREATE, MKDIR and MKNOD requests are extended with a "umask"
>    parameter.
>
>  - A new FUSE_DONT_MASK flag is added to the INIT request/reply.  With
>    this the filesystem may request that the create mode is not masked.
>
> CC: Jean-Pierre André <jean-pierre.andre@wanadoo.fr>
> Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
> ---
>  fs/fuse/dir.c        |   20 +++++++++++++++++---
>  fs/fuse/fuse_i.h     |    3 +++
>  fs/fuse/inode.c      |    9 ++++++++-
>  include/linux/fuse.h |   20 ++++++++++++++++++--
>  4 files changed, 46 insertions(+), 6 deletions(-)
>
> Index: linux-2.6/fs/fuse/dir.c
> ===================================================================
> --- linux-2.6.orig/fs/fuse/dir.c	2009-06-22 20:37:44.000000000 +0200
> +++ linux-2.6/fs/fuse/dir.c	2009-06-23 10:06:36.000000000 +0200
> @@ -375,7 +375,7 @@ static int fuse_create_open(struct inode
>  	struct fuse_conn *fc = get_fuse_conn(dir);
>  	struct fuse_req *req;
>  	struct fuse_req *forget_req;
> -	struct fuse_open_in inarg;
> +	struct fuse_create_in inarg;
>  	struct fuse_open_out outopen;
>  	struct fuse_entry_out outentry;
>  	struct fuse_file *ff;
> @@ -399,15 +399,20 @@ static int fuse_create_open(struct inode
>  	if (!ff)
>  		goto out_put_request;
>  
> +	if (!fc->dont_mask)
> +		mode &= ~current_umask();
> +
>  	flags &= ~O_NOCTTY;
>  	memset(&inarg, 0, sizeof(inarg));
>  	memset(&outentry, 0, sizeof(outentry));
>  	inarg.flags = flags;
>  	inarg.mode = mode;
> +	inarg.umask = current_umask();
>  	req->in.h.opcode = FUSE_CREATE;
>  	req->in.h.nodeid = get_node_id(dir);
>  	req->in.numargs = 2;
> -	req->in.args[0].size = sizeof(inarg);
> +	req->in.args[0].size = fc->minor < 12 ? sizeof(struct fuse_open_in) :
> +						sizeof(inarg);
>  	req->in.args[0].value = &inarg;
>  	req->in.args[1].size = entry->d_name.len + 1;
>  	req->in.args[1].value = entry->d_name.name;
> @@ -546,12 +551,17 @@ static int fuse_mknod(struct inode *dir,
>  	if (IS_ERR(req))
>  		return PTR_ERR(req);
>  
> +	if (!fc->dont_mask)
> +		mode &= ~current_umask();
> +
>  	memset(&inarg, 0, sizeof(inarg));
>  	inarg.mode = mode;
>  	inarg.rdev = new_encode_dev(rdev);
> +	inarg.umask = current_umask();
>  	req->in.h.opcode = FUSE_MKNOD;
>  	req->in.numargs = 2;
> -	req->in.args[0].size = sizeof(inarg);
> +	req->in.args[0].size = fc->minor < 12 ? FUSE_COMPAT_MKNOD_IN_SIZE :
> +						sizeof(inarg);
>  	req->in.args[0].value = &inarg;
>  	req->in.args[1].size = entry->d_name.len + 1;
>  	req->in.args[1].value = entry->d_name.name;
> @@ -578,8 +588,12 @@ static int fuse_mkdir(struct inode *dir,
>  	if (IS_ERR(req))
>  		return PTR_ERR(req);
>  
> +	if (!fc->dont_mask)
> +		mode &= ~current_umask();
> +
>  	memset(&inarg, 0, sizeof(inarg));
>  	inarg.mode = mode;
> +	inarg.umask = current_umask();
>  	req->in.h.opcode = FUSE_MKDIR;
>  	req->in.numargs = 2;
>  	req->in.args[0].size = sizeof(inarg);
> Index: linux-2.6/fs/fuse/fuse_i.h
> ===================================================================
> --- linux-2.6.orig/fs/fuse/fuse_i.h	2009-06-22 20:37:44.000000000 +0200
> +++ linux-2.6/fs/fuse/fuse_i.h	2009-06-22 20:42:59.000000000 +0200
> @@ -446,6 +446,9 @@ struct fuse_conn {
>  	/** Do multi-page cached writes */
>  	unsigned big_writes:1;
>  
> +	/** Don't apply umask to creation modes */
> +	unsigned dont_mask:1;
> +
>  	/** The number of requests waiting for completion */
>  	atomic_t num_waiting;
>  
> Index: linux-2.6/fs/fuse/inode.c
> ===================================================================
> --- linux-2.6.orig/fs/fuse/inode.c	2009-06-22 20:37:44.000000000 +0200
> +++ linux-2.6/fs/fuse/inode.c	2009-06-22 20:51:10.000000000 +0200
> @@ -725,6 +725,8 @@ static void process_init_reply(struct fu
>  			}
>  			if (arg->flags & FUSE_BIG_WRITES)
>  				fc->big_writes = 1;
> +			if (arg->flags & FUSE_DONT_MASK)
> +				fc->dont_mask = 1;
>  		} else {
>  			ra_pages = fc->max_read / PAGE_CACHE_SIZE;
>  			fc->no_lock = 1;
> @@ -748,7 +750,7 @@ static void fuse_send_init(struct fuse_c
>  	arg->minor = FUSE_KERNEL_MINOR_VERSION;
>  	arg->max_readahead = fc->bdi.ra_pages * PAGE_CACHE_SIZE;
>  	arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC |
> -		FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES;
> +		FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES | FUSE_DONT_MASK;
>  	req->in.h.opcode = FUSE_INIT;
>  	req->in.numargs = 1;
>  	req->in.args[0].size = sizeof(*arg);
> @@ -864,6 +866,11 @@ static int fuse_fill_super(struct super_
>  	if (err)
>  		goto err_put_conn;
>  
> +	/* Handle umasking inside the fuse code */
> +	if (sb->s_flags & MS_POSIXACL)
> +		fc->dont_mask = 1;
> +	sb->s_flags |= MS_POSIXACL;
> +
>  	fc->release = fuse_free_conn;
>  	fc->flags = d.flags;
>  	fc->user_id = d.user_id;
> Index: linux-2.6/include/linux/fuse.h
> ===================================================================
> --- linux-2.6.orig/include/linux/fuse.h	2009-06-22 20:37:44.000000000 +0200
> +++ linux-2.6/include/linux/fuse.h	2009-06-23 10:05:45.000000000 +0200
> @@ -25,6 +25,9 @@
>   *  - add IOCTL message
>   *  - add unsolicited notification support
>   *  - add POLL message and NOTIFY_POLL notification
> + *
> + * 7.12
> + *  - add umask flag to input argument of open, mknod and mkdir
>   */
>  
>  #ifndef _LINUX_FUSE_H
> @@ -36,7 +39,7 @@
>  #define FUSE_KERNEL_VERSION 7
>  
>  /** Minor version number of this interface */
> -#define FUSE_KERNEL_MINOR_VERSION 11
> +#define FUSE_KERNEL_MINOR_VERSION 12
>  
>  /** The node ID of the root inode */
>  #define FUSE_ROOT_ID 1
> @@ -112,6 +115,7 @@ struct fuse_file_lock {
>   * INIT request/reply flags
>   *
>   * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".."
> + * FUSE_DONT_MASK: don't apply umask to file mode on create operations
>   */
>  #define FUSE_ASYNC_READ		(1 << 0)
>  #define FUSE_POSIX_LOCKS	(1 << 1)
> @@ -119,6 +123,7 @@ struct fuse_file_lock {
>  #define FUSE_ATOMIC_O_TRUNC	(1 << 3)
>  #define FUSE_EXPORT_SUPPORT	(1 << 4)
>  #define FUSE_BIG_WRITES		(1 << 5)
> +#define FUSE_DONT_MASK		(1 << 6)
>  
>  /**
>   * CUSE INIT request/reply flags
> @@ -262,14 +267,18 @@ struct fuse_attr_out {
>  	struct fuse_attr attr;
>  };
>  
> +#define FUSE_COMPAT_MKNOD_IN_SIZE 8
> +
>  struct fuse_mknod_in {
>  	__u32	mode;
>  	__u32	rdev;
> +	__u32	umask;
> +	__u32	padding;
>  };
>  
>  struct fuse_mkdir_in {
>  	__u32	mode;
> -	__u32	padding;
> +	__u32	umask;
>  };
>  
>  struct fuse_rename_in {
> @@ -301,7 +310,14 @@ struct fuse_setattr_in {
>  
>  struct fuse_open_in {
>  	__u32	flags;
> +	__u32	unused;
> +};
> +
> +struct fuse_create_in {
> +	__u32	flags;
>  	__u32	mode;
> +	__u32	umask;
> +	__u32	padding;
>  };
>  
>  struct fuse_open_out {
>
>
>   

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] fuse: allow umask processing in userspace
  2009-07-02 13:20       ` Jean-Pierre André
@ 2009-07-03  9:23         ` Miklos Szeredi
  0 siblings, 0 replies; 9+ messages in thread
From: Miklos Szeredi @ 2009-07-03  9:23 UTC (permalink / raw)
  To: jean-pierre.andre; +Cc: miklos, utcke+fuse, fuse-devel, linux-fsdevel, szaka

Hi Jean-Pierre,

On Thu, 02 Jul 2009, Jean-Pierre André wrote:
> On my first try, I did not get much far. I could not compile
> the kernel module for kernel-2.6.29.5-191 because of
> undefined function current_umask(). This function
> is nowhere to be found in the kernel source.
> 
> Is this a function (or macro) missing from the proposed
> patch or part of a kernel upgrade ? In this latter case,
> can it be implemented within the patch ? If not, I would
> rather avoid installing a specific kernel for this test
> and just use a dummy version returning a fixed value.

Thank you for testing this patch.

To compile on 2.6.29 just add this line to fuse_i.h:

#define current_umask() (current->fs->umask)

> Anyway, what would be the minimal kernel version ?

The patch should work on 2.6.30 or later without problems.

Or you can try 2.6.31-rc1-git10 from www.kernel.org, which already has
this patch applied.

Thanks,
Miklos
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] fuse: allow umask processing in userspace
  2009-06-23 10:14     ` [PATCH] fuse: allow umask processing in userspace Miklos Szeredi
                         ` (3 preceding siblings ...)
  2009-07-03  7:50       ` Jean-Pierre André
@ 2009-07-04 14:51       ` Jean-Pierre André
  2009-07-06 11:52         ` Miklos Szeredi
  4 siblings, 1 reply; 9+ messages in thread
From: Jean-Pierre André @ 2009-07-04 14:51 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: utcke+fuse, fuse-devel, linux-fsdevel, Szabolcs Szakacsits

Hi Miklos,

I went through the patches and the tests, and I can
announce that ntfs-3g is the first fuse-based file system
which passes the PJD Posix test fully, including the
Posix ACL parts.

Thank you for having made this possible.

I used kernel 2.6.29 with your proposed patches applied
to the fuse client (fuse.ko), and a simplified version of
the fuse server (fuse-lite), which I upgraded manually
according to your proposed patches.

There were only three modifications needed not mentioned
in your proposal, probably consequences of different
reference versions :
- new fields in attr_out and write_in
- umask not copied from low level context to high level.

I checked the client-server compatibility in the four
possible associations (new client / old server, etc.),
but of course both new client and new server are required
to get the correct permissions on file creation.

For releasing a file system source compatible with both
old and new fuse.h, I check whether FUSE_CAP_DONT_MASK
is defined. From now on, I can release code which will compile
and run with current fuse (server and file system ready)
and will benefit from permission fixes when kernels with
updated fuse client will be released.

There is just a point which worries me : I cannot understand
how your client patch deactivates the old code which was
applying the umask. I would prefer not to discover it the
hard way...

Regards

Jean-Pierre





Miklos Szeredi wrote:
> On Fri, 19 Jun 2009, Jean-Pierre André wrote:
>   
>> On the very related issue of having some way of getting
>> the original permission flags (with umask not applied),
>> in create(), has there been any progress ?
>>     
>
> OK, here's a patch that does this, it applies on top of latest git.
> Could you please give it a test?
>
> Even if you are not using git, you can get a "snapshot" of the git
> tree from www.kernel.org.
>
> I'll follow up with a patch for libfuse (also against latest CVS or
> 2.8.0-pre3)
>
> Thanks,
> Miklos
>
> ---
> This patch lets filesystems handle masking the file mode on creation.
> This is needed if filesystem is using ACLs.
>
>  - The CREATE, MKDIR and MKNOD requests are extended with a "umask"
>    parameter.
>
>  - A new FUSE_DONT_MASK flag is added to the INIT request/reply.  With
>    this the filesystem may request that the create mode is not masked.
>   


--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] fuse: allow umask processing in userspace
  2009-07-04 14:51       ` Jean-Pierre André
@ 2009-07-06 11:52         ` Miklos Szeredi
  2009-07-06 18:52           ` Jean-Pierre André
  0 siblings, 1 reply; 9+ messages in thread
From: Miklos Szeredi @ 2009-07-06 11:52 UTC (permalink / raw)
  To: jean-pierre.andre; +Cc: miklos, utcke+fuse, fuse-devel, linux-fsdevel, szaka

On Sat, 04 Jul 2009, Jean-Pierre André wrote:
> I went through the patches and the tests, and I can
> announce that ntfs-3g is the first fuse-based file system
> which passes the PJD Posix test fully, including the
> Posix ACL parts.

Thanks for testing.

> I used kernel 2.6.29 with your proposed patches applied
> to the fuse client (fuse.ko), and a simplified version of
> the fuse server (fuse-lite), which I upgraded manually
> according to your proposed patches.
> 
> There were only three modifications needed not mentioned
> in your proposal, probably consequences of different
> reference versions :
> - new fields in attr_out and write_in
> - umask not copied from low level context to high level.

This should be fixed in latest CVS.

> I checked the client-server compatibility in the four
> possible associations (new client / old server, etc.),
> but of course both new client and new server are required
> to get the correct permissions on file creation.
> 
> For releasing a file system source compatible with both
> old and new fuse.h, I check whether FUSE_CAP_DONT_MASK
> is defined. From now on, I can release code which will compile
> and run with current fuse (server and file system ready)
> and will benefit from permission fixes when kernels with
> updated fuse client will be released.
> 
> There is just a point which worries me : I cannot understand
> how your client patch deactivates the old code which was
> applying the umask. I would prefer not to discover it the
> hard way...

The

	sb->s_flags |= MS_POSIXACL;

line tells the VFS that it should leave umask applying to the
filesystem.  The flag is misnamed, it really should be "MS_NOMASK" or
something.

Thanks,
Miklos
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] fuse: allow umask processing in userspace
  2009-07-06 11:52         ` Miklos Szeredi
@ 2009-07-06 18:52           ` Jean-Pierre André
  0 siblings, 0 replies; 9+ messages in thread
From: Jean-Pierre André @ 2009-07-06 18:52 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: utcke+fuse, fuse-devel, linux-fsdevel, szaka

Hi Miklos,

Miklos Szeredi wrote:
> On Sat, 04 Jul 2009, Jean-Pierre André wrote:
>   
>> I went through the patches and the tests, and I can
>> announce that ntfs-3g is the first fuse-based file system
>> which passes the PJD Posix test fully, including the
>> Posix ACL parts.
>>     
>
> Thanks for testing.
>
>   
[...]
>> There is just a point which worries me : I cannot understand
>> how your client patch deactivates the old code which was
>> applying the umask. I would prefer not to discover it the
>> hard way...
>>     
>
> The
>
> 	sb->s_flags |= MS_POSIXACL;
>
> line tells the VFS that it should leave umask applying to the
> filesystem.  The flag is misnamed, it really should be "MS_NOMASK" or
> something.
>   

So there it was, relying on a safe condition...

Thanks so much.

Jean-Pierre

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-07-06 18:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20090618093635.GQ17358@hasgksssven.desy.de>
     [not found] ` <E1MHdOR-0008U9-Vb@pomaz-ex.szeredi.hu>
     [not found]   ` <4A3BC22A.80907@wanadoo.fr>
2009-06-23 10:14     ` [PATCH] fuse: allow umask processing in userspace Miklos Szeredi
2009-06-23 10:23       ` [PATCH] libfuse: " Miklos Szeredi
     [not found]       ` <E1MJ31Q-00076A-2G-8f8m9JG5TPIdUIPVzhDTVZP2KDSNp7ea@public.gmane.org>
2009-06-24 16:14         ` [PATCH] fuse: " Jean-Pierre ANDRE
2009-07-02 13:20       ` Jean-Pierre André
2009-07-03  9:23         ` Miklos Szeredi
2009-07-03  7:50       ` Jean-Pierre André
2009-07-04 14:51       ` Jean-Pierre André
2009-07-06 11:52         ` Miklos Szeredi
2009-07-06 18:52           ` Jean-Pierre André

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).