aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fuse
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2009-06-30 14:12:23 -0400
committerMiklos Szeredi <mszeredi@suse.cz>2009-06-30 14:12:23 -0400
commite0a43ddcc08c34dbd666d93600fd23914505f4aa (patch)
tree103449845b1ffaf8f32ed98a1a543276227ec087 /fs/fuse
parent201fa69a2849536ef2912e8e971ec0b01c04eff4 (diff)
fuse: allow umask processing in userspace
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>
Diffstat (limited to 'fs/fuse')
-rw-r--r--fs/fuse/dir.c20
-rw-r--r--fs/fuse/fuse_i.h3
-rw-r--r--fs/fuse/inode.c9
3 files changed, 28 insertions, 4 deletions
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index b3089a083d30..6b700734e519 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -375,7 +375,7 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode,
375 struct fuse_conn *fc = get_fuse_conn(dir); 375 struct fuse_conn *fc = get_fuse_conn(dir);
376 struct fuse_req *req; 376 struct fuse_req *req;
377 struct fuse_req *forget_req; 377 struct fuse_req *forget_req;
378 struct fuse_open_in inarg; 378 struct fuse_create_in inarg;
379 struct fuse_open_out outopen; 379 struct fuse_open_out outopen;
380 struct fuse_entry_out outentry; 380 struct fuse_entry_out outentry;
381 struct fuse_file *ff; 381 struct fuse_file *ff;
@@ -399,15 +399,20 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode,
399 if (!ff) 399 if (!ff)
400 goto out_put_request; 400 goto out_put_request;
401 401
402 if (!fc->dont_mask)
403 mode &= ~current_umask();
404
402 flags &= ~O_NOCTTY; 405 flags &= ~O_NOCTTY;
403 memset(&inarg, 0, sizeof(inarg)); 406 memset(&inarg, 0, sizeof(inarg));
404 memset(&outentry, 0, sizeof(outentry)); 407 memset(&outentry, 0, sizeof(outentry));
405 inarg.flags = flags; 408 inarg.flags = flags;
406 inarg.mode = mode; 409 inarg.mode = mode;
410 inarg.umask = current_umask();
407 req->in.h.opcode = FUSE_CREATE; 411 req->in.h.opcode = FUSE_CREATE;
408 req->in.h.nodeid = get_node_id(dir); 412 req->in.h.nodeid = get_node_id(dir);
409 req->in.numargs = 2; 413 req->in.numargs = 2;
410 req->in.args[0].size = sizeof(inarg); 414 req->in.args[0].size = fc->minor < 12 ? sizeof(struct fuse_open_in) :
415 sizeof(inarg);
411 req->in.args[0].value = &inarg; 416 req->in.args[0].value = &inarg;
412 req->in.args[1].size = entry->d_name.len + 1; 417 req->in.args[1].size = entry->d_name.len + 1;
413 req->in.args[1].value = entry->d_name.name; 418 req->in.args[1].value = entry->d_name.name;
@@ -546,12 +551,17 @@ static int fuse_mknod(struct inode *dir, struct dentry *entry, int mode,
546 if (IS_ERR(req)) 551 if (IS_ERR(req))
547 return PTR_ERR(req); 552 return PTR_ERR(req);
548 553
554 if (!fc->dont_mask)
555 mode &= ~current_umask();
556
549 memset(&inarg, 0, sizeof(inarg)); 557 memset(&inarg, 0, sizeof(inarg));
550 inarg.mode = mode; 558 inarg.mode = mode;
551 inarg.rdev = new_encode_dev(rdev); 559 inarg.rdev = new_encode_dev(rdev);
560 inarg.umask = current_umask();
552 req->in.h.opcode = FUSE_MKNOD; 561 req->in.h.opcode = FUSE_MKNOD;
553 req->in.numargs = 2; 562 req->in.numargs = 2;
554 req->in.args[0].size = sizeof(inarg); 563 req->in.args[0].size = fc->minor < 12 ? FUSE_COMPAT_MKNOD_IN_SIZE :
564 sizeof(inarg);
555 req->in.args[0].value = &inarg; 565 req->in.args[0].value = &inarg;
556 req->in.args[1].size = entry->d_name.len + 1; 566 req->in.args[1].size = entry->d_name.len + 1;
557 req->in.args[1].value = entry->d_name.name; 567 req->in.args[1].value = entry->d_name.name;
@@ -578,8 +588,12 @@ static int fuse_mkdir(struct inode *dir, struct dentry *entry, int mode)
578 if (IS_ERR(req)) 588 if (IS_ERR(req))
579 return PTR_ERR(req); 589 return PTR_ERR(req);
580 590
591 if (!fc->dont_mask)
592 mode &= ~current_umask();
593
581 memset(&inarg, 0, sizeof(inarg)); 594 memset(&inarg, 0, sizeof(inarg));
582 inarg.mode = mode; 595 inarg.mode = mode;
596 inarg.umask = current_umask();
583 req->in.h.opcode = FUSE_MKDIR; 597 req->in.h.opcode = FUSE_MKDIR;
584 req->in.numargs = 2; 598 req->in.numargs = 2;
585 req->in.args[0].size = sizeof(inarg); 599 req->in.args[0].size = sizeof(inarg);
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index aaf2f9ff970e..ede4f77b2d6c 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -446,6 +446,9 @@ struct fuse_conn {
446 /** Do multi-page cached writes */ 446 /** Do multi-page cached writes */
447 unsigned big_writes:1; 447 unsigned big_writes:1;
448 448
449 /** Don't apply umask to creation modes */
450 unsigned dont_mask:1;
451
449 /** The number of requests waiting for completion */ 452 /** The number of requests waiting for completion */
450 atomic_t num_waiting; 453 atomic_t num_waiting;
451 454
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index d8673ccf90b7..6cc501bd0187 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -725,6 +725,8 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
725 } 725 }
726 if (arg->flags & FUSE_BIG_WRITES) 726 if (arg->flags & FUSE_BIG_WRITES)
727 fc->big_writes = 1; 727 fc->big_writes = 1;
728 if (arg->flags & FUSE_DONT_MASK)
729 fc->dont_mask = 1;
728 } else { 730 } else {
729 ra_pages = fc->max_read / PAGE_CACHE_SIZE; 731 ra_pages = fc->max_read / PAGE_CACHE_SIZE;
730 fc->no_lock = 1; 732 fc->no_lock = 1;
@@ -748,7 +750,7 @@ static void fuse_send_init(struct fuse_conn *fc, struct fuse_req *req)
748 arg->minor = FUSE_KERNEL_MINOR_VERSION; 750 arg->minor = FUSE_KERNEL_MINOR_VERSION;
749 arg->max_readahead = fc->bdi.ra_pages * PAGE_CACHE_SIZE; 751 arg->max_readahead = fc->bdi.ra_pages * PAGE_CACHE_SIZE;
750 arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC | 752 arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC |
751 FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES; 753 FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES | FUSE_DONT_MASK;
752 req->in.h.opcode = FUSE_INIT; 754 req->in.h.opcode = FUSE_INIT;
753 req->in.numargs = 1; 755 req->in.numargs = 1;
754 req->in.args[0].size = sizeof(*arg); 756 req->in.args[0].size = sizeof(*arg);
@@ -864,6 +866,11 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
864 if (err) 866 if (err)
865 goto err_put_conn; 867 goto err_put_conn;
866 868
869 /* Handle umasking inside the fuse code */
870 if (sb->s_flags & MS_POSIXACL)
871 fc->dont_mask = 1;
872 sb->s_flags |= MS_POSIXACL;
873
867 fc->release = fuse_free_conn; 874 fc->release = fuse_free_conn;
868 fc->flags = d.flags; 875 fc->flags = d.flags;
869 fc->user_id = d.user_id; 876 fc->user_id = d.user_id;