]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/posix_acl.c
fs: make posix_acl_chmod more useful
[karo-tx-linux.git] / fs / posix_acl.c
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);
 
 /*