fuse: allow umask processing in userspace
Subsystems (4)
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Miklos Szeredi
maintainerPATCH 1/1 fuse: allow umask processing in userspace
Quoted 3 lines · Jean-Pierre André
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.
--- 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(-)
fs/fuse/dir.c +17 -3
@@ -375,7 +375,7 @@ static int fuse_create_open(struct inodestruct 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 inodeif (!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);
fs/fuse/fuse_i.h +3 -0
@@ -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;
fs/fuse/inode.c +8 -1
@@ -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;
include/linux/fuse.h +18 -2
@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Miklos Szeredi
maintainerPATCH 1/1 libfuse: allow umask processing in userspace
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(-)
include/fuse_lowlevel.h +3 -0
@@ -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 */
lib/fuse_lowlevel.c +35 -3
@@ -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, fusestatic 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(fusereturn &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) {
lib/fuse_versionscript +2 -2
@@ -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: *;
include/fuse.h +3 -0
@@ -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; };/**
include/fuse_common.h +2 -0
@@ -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
include/fuse_kernel.h +18 -2
@@ -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 {
A message that is not in the archive (sent off-list or not yet received): E1MJ31Q-00076A-2G-8f8m9JG5TPIdUIPVzhDTVZP2KDSNp7ea@public.gmane.org
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
Quoted 28 lines
Message du 23/06/09 12:14
De : "Miklos Szeredi"
A : [email protected]
Copie à : [email protected], [email protected], [email protected], [email protected] Objet : [PATCH] fuse: allow umask processing in userspaceQuoted 3 lines · Jean-Pierre André
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.
Quoted 8 lines
- The CREATE, MKDIR and MKNOD requests are extended with a "umask" parameter.
- A new
FUSE_DONT_MASKflag 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/fuse-devel
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
Quoted 219 lines · Miklos Szeredi
Quoted 4 lines · Jean-Pierre André
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_MASKflag is added to the INIT request/reply. With this the filesystem may request that the create mode is not masked.CC Jean-Pierre André <[email protected]>Signed-off-by Miklos Szeredi <[email protected]>--- 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
===================================================================fs/fuse/dir.c +17
-3@@ -375,7 +375,7 @@ static int fuse_create_open(struct inodestruct 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 inodeif (!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
===================================================================fs/fuse/fuse_i.h +3
-0@@ -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
===================================================================fs/fuse/inode.c +8
-1@@ -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
===================================================================include/linux/fuse.h +12
-2@@ -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;
include/linux/fuse.h struct fuse_setattr_in { · line 323
Quoted 10 lines
include/linux/fuse.h +6
-0+}; + +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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Miklos Szeredi
maintainerHi Jean-Pierre,
Quoted 10 lines · Jean-Pierre André
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)
Quoted 1 line
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
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
Quoted 220 lines · Miklos Szeredi
Quoted 4 lines · Jean-Pierre André
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_MASKflag is added to the INIT request/reply. With this the filesystem may request that the create mode is not masked.CC Jean-Pierre André <[email protected]>Signed-off-by Miklos Szeredi <[email protected]>--- 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
===================================================================fs/fuse/dir.c +17
-3@@ -375,7 +375,7 @@ static int fuse_create_open(struct inodestruct 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 inodeif (!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
===================================================================fs/fuse/fuse_i.h +3
-0@@ -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
===================================================================fs/fuse/inode.c +8
-1@@ -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
===================================================================include/linux/fuse.h +12
-2@@ -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;
include/linux/fuse.h struct fuse_setattr_in { · line 323
Quoted 10 lines
include/linux/fuse.h +6
-0+}; + +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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
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
Quoted 23 lines · Miklos Szeredi
Quoted 4 lines · Jean-Pierre André
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.
Quoted 6 lines
- The CREATE, MKDIR and MKNOD requests are extended with a "umask" parameter.
- A new
FUSE_DONT_MASKflag 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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Miklos Szeredi
maintainerQuoted 4 lines · Jean-Pierre André
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.
Quoted 10 lines
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 inattr_outandwrite_in
- umask not copied from low level context to high level.
This should be fixed in latest CVS.
Quoted 12 lines
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 whetherFUSE_CAP_DONT_MASKis 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.
Quoted 4 lines
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Miklos,
Quoted 11 lines · Miklos Szeredi
Quoted 5 lines · Jean-Pierre André
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.
[...]
Quoted 6 lines
Quoted 5 lines
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...
Quoted 8 lines
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html