/* * Inode operation get_posix_acl(). * * inode->i_sem: down * BKL held [before 2.5.x] */ struct posix_acl * reiserfs_get_acl(struct inode *inode, int type) { char *name, *value; struct posix_acl *acl, **p_acl; size_t size; int retval; struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode); switch (type) { case ACL_TYPE_ACCESS: name = XATTR_NAME_ACL_ACCESS; p_acl = &reiserfs_i->i_acl_access; break; case ACL_TYPE_DEFAULT: name = XATTR_NAME_ACL_DEFAULT; p_acl = &reiserfs_i->i_acl_default; break; default: return ERR_PTR (-EINVAL); } if (IS_ERR (*p_acl)) { if (PTR_ERR (*p_acl) == -ENODATA) return NULL; } else if (*p_acl != NULL) return posix_acl_dup (*p_acl); size = reiserfs_xattr_get (inode, name, NULL, 0); if ((int)size < 0) { if (size == -ENODATA || size == -ENOSYS) { *p_acl = ERR_PTR (-ENODATA); return NULL; } return ERR_PTR (size); } value = kmalloc (size, GFP_NOFS); if (!value) return ERR_PTR (-ENOMEM); retval = reiserfs_xattr_get(inode, name, value, size); if (retval == -ENODATA || retval == -ENOSYS) { /* This shouldn't actually happen as it should have been caught above.. but just in case */ acl = NULL; *p_acl = ERR_PTR (-ENODATA); } else if (retval < 0) { acl = ERR_PTR(retval); } else { acl = posix_acl_from_disk(value, retval); *p_acl = posix_acl_dup (acl); } kfree(value); return acl; }
/* * Inode operation get_posix_acl(). * * inode->i_mutex: down * BKL held [before 2.5.x] */ struct posix_acl *reiserfs_get_acl(struct inode *inode, int type) { char *name, *value; struct posix_acl *acl; int size; int retval; acl = get_cached_acl(inode, type); if (acl != ACL_NOT_CACHED) return acl; switch (type) { case ACL_TYPE_ACCESS: name = POSIX_ACL_XATTR_ACCESS; break; case ACL_TYPE_DEFAULT: name = POSIX_ACL_XATTR_DEFAULT; break; default: BUG(); } size = reiserfs_xattr_get(inode, name, NULL, 0); if (size < 0) { if (size == -ENODATA || size == -ENOSYS) { set_cached_acl(inode, type, NULL); return NULL; } return ERR_PTR(size); } value = kmalloc(size, GFP_NOFS); if (!value) return ERR_PTR(-ENOMEM); retval = reiserfs_xattr_get(inode, name, value, size); if (retval == -ENODATA || retval == -ENOSYS) { /* This shouldn't actually happen as it should have been caught above.. but just in case */ acl = NULL; } else if (retval < 0) { acl = ERR_PTR(retval); } else { acl = posix_acl_from_disk(value, retval); } if (!IS_ERR(acl)) set_cached_acl(inode, type, acl); kfree(value); return acl; }