fs: make posix_acl_chmod more useful
authorChristoph Hellwig <hch@infradead.org>
Fri, 20 Dec 2013 13:16:41 +0000 (05:16 -0800)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 26 Jan 2014 04:58:18 +0000 (23:58 -0500)
Rename the current posix_acl_chmod to __posix_acl_chmod and add
a fully featured ACL chmod helper that uses the ->set_acl inode
operation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
16 files changed:
fs/9p/acl.c
fs/btrfs/acl.c
fs/ext2/acl.c
fs/ext3/acl.c
fs/ext4/acl.c
fs/f2fs/acl.c
fs/generic_acl.c
fs/gfs2/acl.c
fs/hfsplus/posix_acl.c
fs/jffs2/acl.c
fs/jfs/acl.c
fs/ocfs2/acl.c
fs/posix_acl.c
fs/reiserfs/xattr_acl.c
fs/xfs/xfs_acl.c
include/linux/posix_acl.h

index 7af425f53beef91a6d21dc86b76e161ff7ed1696..f5ce5c50c57e0d43e36306d73f6f6cdd93be77a9 100644 (file)
@@ -156,7 +156,7 @@ int v9fs_acl_chmod(struct inode *inode, struct p9_fid *fid)
                return -EOPNOTSUPP;
        acl = v9fs_get_cached_acl(inode, ACL_TYPE_ACCESS);
        if (acl) {
-               retval = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
+               retval = __posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
                if (retval)
                        return retval;
                set_cached_acl(inode, ACL_TYPE_ACCESS, acl);
index 0890c83643e944f69e43a22f4151e381e7503f04..1af04ff889869c8a6f48fac3f3a8002cef846143 100644 (file)
@@ -256,7 +256,7 @@ int btrfs_acl_chmod(struct inode *inode)
        if (IS_ERR_OR_NULL(acl))
                return PTR_ERR(acl);
 
-       ret = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
+       ret = __posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
        if (ret)
                return ret;
        ret = btrfs_set_acl(NULL, inode, acl, ACL_TYPE_ACCESS);
index 110b6b371a4edc353fc1904bcc79299580087184..7006ced453246fef25abde2c328b672d59365d5b 100644 (file)
@@ -308,7 +308,7 @@ ext2_acl_chmod(struct inode *inode)
        acl = ext2_get_acl(inode, ACL_TYPE_ACCESS);
        if (IS_ERR(acl) || !acl)
                return PTR_ERR(acl);
-       error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
+       error = __posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
        if (error)
                return error;
        error = ext2_set_acl(inode, ACL_TYPE_ACCESS, acl);
index dbb5ad59a7fc3c22380ce30b9034f8942bec967b..6691a6c6b2111facc974bc46814b2c0f769e4854 100644 (file)
@@ -314,7 +314,7 @@ ext3_acl_chmod(struct inode *inode)
        acl = ext3_get_acl(inode, ACL_TYPE_ACCESS);
        if (IS_ERR(acl) || !acl)
                return PTR_ERR(acl);
-       error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
+       error = __posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
        if (error)
                return error;
 retry:
index 39a54a0e9fe4a9a6290f75b961cde9ccea06f669..2eebe02fdf09ebc87aa6427352f80ccf45964ed8 100644 (file)
@@ -320,7 +320,7 @@ ext4_acl_chmod(struct inode *inode)
        acl = ext4_get_acl(inode, ACL_TYPE_ACCESS);
        if (IS_ERR(acl) || !acl)
                return PTR_ERR(acl);
-       error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
+       error = __posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
        if (error)
                return error;
 retry:
index d0fc287efeff4511fa7f4e84369cf77f0ae31538..14c4df0ede34a4485e91c7d8b33c8ebc834204c3 100644 (file)
@@ -311,7 +311,7 @@ int f2fs_acl_chmod(struct inode *inode)
        if (IS_ERR(acl) || !acl)
                return PTR_ERR(acl);
 
-       error = posix_acl_chmod(&acl, GFP_KERNEL, mode);
+       error = __posix_acl_chmod(&acl, GFP_KERNEL, mode);
        if (error)
                return error;
 
index b3f3676796d31a6870a771ed6952977cfc16d448..46a5076e9776695b2e55c7e59fe45506f20be160 100644 (file)
@@ -158,7 +158,7 @@ generic_acl_chmod(struct inode *inode)
                return -EOPNOTSUPP;
        acl = get_cached_acl(inode, ACL_TYPE_ACCESS);
        if (acl) {
-               error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
+               error = __posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
                if (error)
                        return error;
                set_cached_acl(inode, ACL_TYPE_ACCESS, acl);
index f69ac0af5496cd456bf6df4d0c932747b6767779..3e200c7ca7ad5d317f97fda4b646edca39eba370 100644 (file)
@@ -162,7 +162,7 @@ int gfs2_acl_chmod(struct gfs2_inode *ip, struct iattr *attr)
        if (!acl)
                return gfs2_setattr_simple(inode, attr);
 
-       error = posix_acl_chmod(&acl, GFP_NOFS, attr->ia_mode);
+       error = __posix_acl_chmod(&acl, GFP_NOFS, attr->ia_mode);
        if (error)
                return error;
 
index b609cc14c72e03c21063abbda72372c4ef94b1c7..cab5fd6fdb72b781d8b2811ed7c59ae08865fd9d 100644 (file)
@@ -167,7 +167,7 @@ int hfsplus_posix_acl_chmod(struct inode *inode)
        if (IS_ERR(acl) || !acl)
                return PTR_ERR(acl);
 
-       err = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
+       err = __posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
        if (unlikely(err))
                return err;
 
index 223283c301116f3d8d88cb70cf30aa030a54c456..5853969a51bc150981fc41995e82ab65e2bd0637 100644 (file)
@@ -335,7 +335,7 @@ int jffs2_acl_chmod(struct inode *inode)
        acl = jffs2_get_acl(inode, ACL_TYPE_ACCESS);
        if (IS_ERR(acl) || !acl)
                return PTR_ERR(acl);
-       rc = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
+       rc = __posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
        if (rc)
                return rc;
        rc = jffs2_set_acl(inode, ACL_TYPE_ACCESS, acl);
index d254d6d3599565fbca59621cf840d105d9cd4971..9c0fca8073da54de913029df13ad97cd5dfc0e6b 100644 (file)
@@ -161,7 +161,7 @@ int jfs_acl_chmod(struct inode *inode)
        if (IS_ERR(acl) || !acl)
                return PTR_ERR(acl);
 
-       rc = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
+       rc = __posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
        if (rc)
                return rc;
 
index b4f788e0ca318955ab797f2350f8dffa320a53cb..73ccf0e22ec5d8af5a0668d63488fe3b0426b024 100644 (file)
@@ -350,7 +350,7 @@ int ocfs2_acl_chmod(struct inode *inode)
        acl = ocfs2_get_acl(inode, ACL_TYPE_ACCESS);
        if (IS_ERR(acl) || !acl)
                return PTR_ERR(acl);
-       ret = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
+       ret = __posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
        if (ret)
                return ret;
        ret = ocfs2_set_acl(NULL, inode, NULL, ACL_TYPE_ACCESS,
index e699b076cdd8a51974777c3ae3548f2c6e3ce1df..08218550b0dbc6b393313a89d877b0460085d46d 100644 (file)
@@ -364,7 +364,7 @@ static int posix_acl_create_masq(struct posix_acl *acl, umode_t *mode_p)
 /*
  * Modify the ACL for the chmod syscall.
  */
-static int posix_acl_chmod_masq(struct posix_acl *acl, umode_t mode)
+static int __posix_acl_chmod_masq(struct posix_acl *acl, umode_t mode)
 {
        struct posix_acl_entry *group_obj = NULL, *mask_obj = NULL;
        struct posix_acl_entry *pa, *pe;
@@ -428,12 +428,12 @@ posix_acl_create(struct posix_acl **acl, gfp_t gfp, umode_t *mode_p)
 EXPORT_SYMBOL(posix_acl_create);
 
 int
-posix_acl_chmod(struct posix_acl **acl, gfp_t gfp, umode_t mode)
+__posix_acl_chmod(struct posix_acl **acl, gfp_t gfp, umode_t mode)
 {
        struct posix_acl *clone = posix_acl_clone(*acl, gfp);
        int err = -ENOMEM;
        if (clone) {
-               err = posix_acl_chmod_masq(clone, mode);
+               err = __posix_acl_chmod_masq(clone, mode);
                if (err) {
                        posix_acl_release(clone);
                        clone = NULL;
@@ -443,6 +443,30 @@ posix_acl_chmod(struct posix_acl **acl, gfp_t gfp, umode_t mode)
        *acl = clone;
        return err;
 }
+EXPORT_SYMBOL(__posix_acl_chmod);
+
+int
+posix_acl_chmod(struct inode *inode)
+{
+       struct posix_acl *acl;
+       int ret = 0;
+
+       if (!IS_POSIXACL(inode))
+               return 0;
+       if (!inode->i_op->set_acl)
+               return -EOPNOTSUPP;
+
+       acl = get_acl(inode, ACL_TYPE_ACCESS);
+       if (IS_ERR_OR_NULL(acl))
+               return PTR_ERR(acl);
+
+       ret = __posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
+       if (ret)
+               return ret;
+       ret = inode->i_op->set_acl(inode, acl, ACL_TYPE_ACCESS);
+       posix_acl_release(acl);
+       return ret;
+}
 EXPORT_SYMBOL(posix_acl_chmod);
 
 /*
index 6f721ea9403919ea6ed22b628ff210d1b0d77238..ea4e44351f769fa8835ba03e384dd942afef7777 100644 (file)
@@ -463,7 +463,7 @@ int reiserfs_acl_chmod(struct inode *inode)
                return 0;
        if (IS_ERR(acl))
                return PTR_ERR(acl);
-       error = posix_acl_chmod(&acl, GFP_NOFS, inode->i_mode);
+       error = __posix_acl_chmod(&acl, GFP_NOFS, inode->i_mode);
        if (error)
                return error;
 
index 370eb3e121d1b2f292c65ddabd660ad08ae65537..4eac1058b680149b56136624240562850d2287ae 100644 (file)
@@ -334,7 +334,7 @@ xfs_acl_chmod(struct inode *inode)
        if (IS_ERR(acl) || !acl)
                return PTR_ERR(acl);
 
-       error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
+       error = __posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
        if (error)
                return error;
 
index a8d9918c0b20f2ffb2e9dddd4ce3a2b8a495736d..8b64e7899989924a53d779cb14c6bbbf10c98954 100644 (file)
@@ -89,12 +89,14 @@ extern int posix_acl_permission(struct inode *, const struct posix_acl *, int);
 extern struct posix_acl *posix_acl_from_mode(umode_t, gfp_t);
 extern int posix_acl_equiv_mode(const struct posix_acl *, umode_t *);
 extern int posix_acl_create(struct posix_acl **, gfp_t, umode_t *);
-extern int posix_acl_chmod(struct posix_acl **, gfp_t, umode_t);
+extern int __posix_acl_chmod(struct posix_acl **, gfp_t, umode_t);
 
 extern struct posix_acl *get_posix_acl(struct inode *, int);
 extern int set_posix_acl(struct inode *, int, struct posix_acl *);
 
 #ifdef CONFIG_FS_POSIX_ACL
+extern int posix_acl_chmod(struct inode *);
+
 static inline struct posix_acl **acl_by_type(struct inode *inode, int type)
 {
        switch (type) {
@@ -165,15 +167,22 @@ static inline void forget_all_cached_acls(struct inode *inode)
        if (old_default != ACL_NOT_CACHED)
                posix_acl_release(old_default);
 }
-#endif
 
 static inline void cache_no_acl(struct inode *inode)
 {
-#ifdef CONFIG_FS_POSIX_ACL
        inode->i_acl = NULL;
        inode->i_default_acl = NULL;
-#endif
 }
+#else
+static inline int posix_acl_chmod(struct inode *inode)
+{
+       return 0;
+}
+
+static inline void cache_no_acl(struct inode *inode)
+{
+}
+#endif /* CONFIG_FS_POSIX_ACL */
 
 struct posix_acl *get_acl(struct inode *inode, int type);