posix_acl: Clear SGID bit when setting file permissions
[pandora-kernel.git] / fs / btrfs / acl.c
index eb159aa..9f55b54 100644 (file)
@@ -59,22 +59,19 @@ struct posix_acl *btrfs_get_acl(struct inode *inode, int type)
                if (!value)
                        return ERR_PTR(-ENOMEM);
                size = __btrfs_getxattr(inode, name, value, size);
-               if (size > 0) {
-                       acl = posix_acl_from_xattr(value, size);
-                       if (IS_ERR(acl)) {
-                               kfree(value);
-                               return acl;
-                       }
-                       set_cached_acl(inode, type, acl);
-               }
-               kfree(value);
+       }
+       if (size > 0) {
+               acl = posix_acl_from_xattr(value, size);
        } else if (size == -ENOENT || size == -ENODATA || size == 0) {
                /* FIXME, who returns -ENOENT?  I think nobody */
                acl = NULL;
-               set_cached_acl(inode, type, acl);
        } else {
                acl = ERR_PTR(-EIO);
        }
+       kfree(value);
+
+       if (!IS_ERR(acl))
+               set_cached_acl(inode, type, acl);
 
        return acl;
 }
@@ -121,8 +118,8 @@ static int btrfs_set_acl(struct btrfs_trans_handle *trans,
        case ACL_TYPE_ACCESS:
                name = POSIX_ACL_XATTR_ACCESS;
                if (acl) {
-                       ret = posix_acl_equiv_mode(acl, &inode->i_mode);
-                       if (ret < 0)
+                       ret = posix_acl_update_mode(inode, &inode->i_mode, &acl);
+                       if (ret)
                                return ret;
                }
                ret = 0;