Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4e34e719 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Al Viro
Browse files

fs: take the ACL checks to common code



Replace the ->check_acl method with a ->get_acl method that simply reads an
ACL from disk after having a cache miss.  This means we can replace the ACL
checking boilerplate code with a single implementation in namei.c.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent edde854e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ ata *);
	void (*put_link) (struct dentry *, struct nameidata *, void *);
	void (*truncate) (struct inode *);
	int (*permission) (struct inode *, int, unsigned int);
	int (*check_acl)(struct inode *, int);
	int (*get_acl)(struct inode *, int);
	int (*setattr) (struct dentry *, struct iattr *);
	int (*getattr) (struct vfsmount *, struct dentry *, struct kstat *);
	int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
@@ -80,7 +80,7 @@ put_link: no
truncate:	yes		(see below)
setattr:	yes
permission:	no (may not block if called in rcu-walk mode)
check_acl:	no
get_acl:	no
getattr:	no
setxattr:	yes
getxattr:	no
+4 −3
Original line number Diff line number Diff line
@@ -407,10 +407,11 @@ to some pointer to returning that pointer. On errors return ERR_PTR(...).

--
[mandatory]
	->permission(), generic_permission() and ->check_acl() have lost flags
	->permission() and generic_permission()have lost flags
argument; instead of passing IPERM_FLAG_RCU we add MAY_NOT_BLOCK into mask.
	generic_permission() has also lost the check_acl argument; if you want
non-NULL to be used for that inode, put it into ->i_op->check_acl.
	generic_permission() has also lost the check_acl argument; ACL checking
has been taken to VFS and filesystems need to provide a non-NULL ->i_op->get_acl
to read an ACL from disk.

--
[mandatory]
+1 −1
Original line number Diff line number Diff line
@@ -356,7 +356,7 @@ struct inode_operations {
        void (*put_link) (struct dentry *, struct nameidata *, void *);
	void (*truncate) (struct inode *);
	int (*permission) (struct inode *, int);
	int (*check_acl)(struct inode *, int);
	int (*get_acl)(struct inode *, int);
	int (*setattr) (struct dentry *, struct iattr *);
	int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
	int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
+3 −11
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ static struct posix_acl *v9fs_get_cached_acl(struct inode *inode, int type)
	return acl;
}

int v9fs_check_acl(struct inode *inode, int mask)
struct posix_acl *v9fs_iop_get_acl(struct inode *inode, int type)
{
	struct posix_acl *acl;
	struct v9fs_session_info *v9ses;
@@ -108,18 +108,10 @@ int v9fs_check_acl(struct inode *inode, int mask)
		 * On access = client  and acl = on mode get the acl
		 * values from the server
		 */
		return -EAGAIN;
		return NULL;
	}
	acl = v9fs_get_cached_acl(inode, ACL_TYPE_ACCESS);
	return v9fs_get_cached_acl(inode, type);

	if (IS_ERR(acl))
		return PTR_ERR(acl);
	if (acl) {
		int error = posix_acl_permission(inode, acl, mask);
		posix_acl_release(acl);
		return error;
	}
	return -EAGAIN;
}

static int v9fs_set_acl(struct dentry *dentry, int type, struct posix_acl *acl)
+2 −2
Original line number Diff line number Diff line
@@ -16,14 +16,14 @@

#ifdef CONFIG_9P_FS_POSIX_ACL
extern int v9fs_get_acl(struct inode *, struct p9_fid *);
extern int v9fs_check_acl(struct inode *inode, int mask);
extern struct posix_acl *v9fs_iop_get_acl(struct inode *inode, int type);
extern int v9fs_acl_chmod(struct dentry *);
extern int v9fs_set_create_acl(struct dentry *,
			       struct posix_acl **, struct posix_acl **);
extern int v9fs_acl_mode(struct inode *dir, mode_t *modep,
			 struct posix_acl **dpacl, struct posix_acl **pacl);
#else
#define v9fs_check_acl NULL
#define v9fs_iop_get_acl NULL
static inline int v9fs_get_acl(struct inode *inode, struct p9_fid *fid)
{
	return 0;
Loading