aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@redhat.com>2016-10-01 01:32:32 -0400
committerMiklos Szeredi <mszeredi@redhat.com>2016-10-01 01:32:32 -0400
commit29433a2991fa636c1fcd5bf5893cf92c37e0b26c (patch)
treed70fc6a8b489570936c1e34cd33a594025e267df
parentbcb6f6d2b9c299db32b20f4357c36a101e7f0293 (diff)
fuse: get rid of fc->flags
Only two flags: "default_permissions" and "allow_other". All other flags are handled via bitfields. So convert these two as well. They don't change during the lifetime of the filesystem, so this is quite safe. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
-rw-r--r--fs/fuse/dir.c8
-rw-r--r--fs/fuse/fuse_i.h18
-rw-r--r--fs/fuse/inode.c18
3 files changed, 20 insertions, 24 deletions
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 30d9dc976e61..f7c84ab835ca 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1028,7 +1028,7 @@ int fuse_allow_current_process(struct fuse_conn *fc)
1028{ 1028{
1029 const struct cred *cred; 1029 const struct cred *cred;
1030 1030
1031 if (fc->flags & FUSE_ALLOW_OTHER) 1031 if (fc->allow_other)
1032 return 1; 1032 return 1;
1033 1033
1034 cred = current_cred(); 1034 cred = current_cred();
@@ -1104,7 +1104,7 @@ static int fuse_permission(struct inode *inode, int mask)
1104 /* 1104 /*
1105 * If attributes are needed, refresh them before proceeding 1105 * If attributes are needed, refresh them before proceeding
1106 */ 1106 */
1107 if ((fc->flags & FUSE_DEFAULT_PERMISSIONS) || 1107 if (fc->default_permissions ||
1108 ((mask & MAY_EXEC) && S_ISREG(inode->i_mode))) { 1108 ((mask & MAY_EXEC) && S_ISREG(inode->i_mode))) {
1109 struct fuse_inode *fi = get_fuse_inode(inode); 1109 struct fuse_inode *fi = get_fuse_inode(inode);
1110 1110
@@ -1117,7 +1117,7 @@ static int fuse_permission(struct inode *inode, int mask)
1117 } 1117 }
1118 } 1118 }
1119 1119
1120 if (fc->flags & FUSE_DEFAULT_PERMISSIONS) { 1120 if (fc->default_permissions) {
1121 err = generic_permission(inode, mask); 1121 err = generic_permission(inode, mask);
1122 1122
1123 /* If permission is denied, try to refresh file 1123 /* If permission is denied, try to refresh file
@@ -1618,7 +1618,7 @@ int fuse_do_setattr(struct inode *inode, struct iattr *attr,
1618 int err; 1618 int err;
1619 bool trust_local_cmtime = is_wb && S_ISREG(inode->i_mode); 1619 bool trust_local_cmtime = is_wb && S_ISREG(inode->i_mode);
1620 1620
1621 if (!(fc->flags & FUSE_DEFAULT_PERMISSIONS)) 1621 if (!fc->default_permissions)
1622 attr->ia_valid |= ATTR_FORCE; 1622 attr->ia_valid |= ATTR_FORCE;
1623 1623
1624 err = inode_change_ok(inode, attr); 1624 err = inode_change_ok(inode, attr);
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index e8d96ec22533..24ada5dc4dae 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -37,15 +37,6 @@
37/** Number of dentries for each connection in the control filesystem */ 37/** Number of dentries for each connection in the control filesystem */
38#define FUSE_CTL_NUM_DENTRIES 5 38#define FUSE_CTL_NUM_DENTRIES 5
39 39
40/** If the FUSE_DEFAULT_PERMISSIONS flag is given, the filesystem
41 module will check permissions based on the file mode. Otherwise no
42 permission checking is done in the kernel */
43#define FUSE_DEFAULT_PERMISSIONS (1 << 0)
44
45/** If the FUSE_ALLOW_OTHER flag is given, then not only the user
46 doing the mount will be allowed to access the filesystem */
47#define FUSE_ALLOW_OTHER (1 << 1)
48
49/** Number of page pointers embedded in fuse_req */ 40/** Number of page pointers embedded in fuse_req */
50#define FUSE_REQ_INLINE_PAGES 1 41#define FUSE_REQ_INLINE_PAGES 1
51 42
@@ -470,9 +461,6 @@ struct fuse_conn {
470 /** The group id for this mount */ 461 /** The group id for this mount */
471 kgid_t group_id; 462 kgid_t group_id;
472 463
473 /** The fuse mount flags for this mount */
474 unsigned flags;
475
476 /** Maximum read size */ 464 /** Maximum read size */
477 unsigned max_read; 465 unsigned max_read;
478 466
@@ -631,6 +619,12 @@ struct fuse_conn {
631 /** Does the filesystem support posix acls? */ 619 /** Does the filesystem support posix acls? */
632 unsigned posix_acl:1; 620 unsigned posix_acl:1;
633 621
622 /** Check permissions based on the file mode or not? */
623 unsigned default_permissions:1;
624
625 /** Allow other than the mounter user to access the filesystem ? */
626 unsigned allow_other:1;
627
634 /** The number of requests waiting for completion */ 628 /** The number of requests waiting for completion */
635 atomic_t num_waiting; 629 atomic_t num_waiting;
636 630
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 16ac9d86c507..17141099f2e7 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -67,7 +67,8 @@ struct fuse_mount_data {
67 unsigned rootmode_present:1; 67 unsigned rootmode_present:1;
68 unsigned user_id_present:1; 68 unsigned user_id_present:1;
69 unsigned group_id_present:1; 69 unsigned group_id_present:1;
70 unsigned flags; 70 unsigned default_permissions:1;
71 unsigned allow_other:1;
71 unsigned max_read; 72 unsigned max_read;
72 unsigned blksize; 73 unsigned blksize;
73}; 74};
@@ -193,7 +194,7 @@ void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr,
193 * check in may_delete(). 194 * check in may_delete().
194 */ 195 */
195 fi->orig_i_mode = inode->i_mode; 196 fi->orig_i_mode = inode->i_mode;
196 if (!(fc->flags & FUSE_DEFAULT_PERMISSIONS)) 197 if (!fc->default_permissions)
197 inode->i_mode &= ~S_ISVTX; 198 inode->i_mode &= ~S_ISVTX;
198 199
199 fi->orig_ino = attr->ino; 200 fi->orig_ino = attr->ino;
@@ -534,11 +535,11 @@ static int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev)
534 break; 535 break;
535 536
536 case OPT_DEFAULT_PERMISSIONS: 537 case OPT_DEFAULT_PERMISSIONS:
537 d->flags |= FUSE_DEFAULT_PERMISSIONS; 538 d->default_permissions = 1;
538 break; 539 break;
539 540
540 case OPT_ALLOW_OTHER: 541 case OPT_ALLOW_OTHER:
541 d->flags |= FUSE_ALLOW_OTHER; 542 d->allow_other = 1;
542 break; 543 break;
543 544
544 case OPT_MAX_READ: 545 case OPT_MAX_READ:
@@ -572,9 +573,9 @@ static int fuse_show_options(struct seq_file *m, struct dentry *root)
572 573
573 seq_printf(m, ",user_id=%u", from_kuid_munged(&init_user_ns, fc->user_id)); 574 seq_printf(m, ",user_id=%u", from_kuid_munged(&init_user_ns, fc->user_id));
574 seq_printf(m, ",group_id=%u", from_kgid_munged(&init_user_ns, fc->group_id)); 575 seq_printf(m, ",group_id=%u", from_kgid_munged(&init_user_ns, fc->group_id));
575 if (fc->flags & FUSE_DEFAULT_PERMISSIONS) 576 if (fc->default_permissions)
576 seq_puts(m, ",default_permissions"); 577 seq_puts(m, ",default_permissions");
577 if (fc->flags & FUSE_ALLOW_OTHER) 578 if (fc->allow_other)
578 seq_puts(m, ",allow_other"); 579 seq_puts(m, ",allow_other");
579 if (fc->max_read != ~0) 580 if (fc->max_read != ~0)
580 seq_printf(m, ",max_read=%u", fc->max_read); 581 seq_printf(m, ",max_read=%u", fc->max_read);
@@ -917,7 +918,7 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
917 if (arg->time_gran && arg->time_gran <= 1000000000) 918 if (arg->time_gran && arg->time_gran <= 1000000000)
918 fc->sb->s_time_gran = arg->time_gran; 919 fc->sb->s_time_gran = arg->time_gran;
919 if ((arg->flags & FUSE_POSIX_ACL)) { 920 if ((arg->flags & FUSE_POSIX_ACL)) {
920 fc->flags |= FUSE_DEFAULT_PERMISSIONS; 921 fc->default_permissions = 1;
921 fc->posix_acl = 1; 922 fc->posix_acl = 1;
922 fc->sb->s_xattr = fuse_acl_xattr_handlers; 923 fc->sb->s_xattr = fuse_acl_xattr_handlers;
923 } 924 }
@@ -1119,7 +1120,8 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
1119 fc->dont_mask = 1; 1120 fc->dont_mask = 1;
1120 sb->s_flags |= MS_POSIXACL; 1121 sb->s_flags |= MS_POSIXACL;
1121 1122
1122 fc->flags = d.flags; 1123 fc->default_permissions = d.default_permissions;
1124 fc->allow_other = d.allow_other;
1123 fc->user_id = d.user_id; 1125 fc->user_id = d.user_id;
1124 fc->group_id = d.group_id; 1126 fc->group_id = d.group_id;
1125 fc->max_read = max_t(unsigned, 4096, d.max_read); 1127 fc->max_read = max_t(unsigned, 4096, d.max_read);