int ocfs2_acl_chmod(struct inode *inode) { struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); struct posix_acl *acl, *clone; int ret; if (S_ISLNK(inode->i_mode)) return -EOPNOTSUPP; if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) return 0; acl = ocfs2_get_acl(inode, ACL_TYPE_ACCESS); if (IS_ERR(acl) || !acl) return PTR_ERR(acl); clone = posix_acl_clone(acl, GFP_KERNEL); posix_acl_release(acl); if (!clone) return -ENOMEM; ret = posix_acl_chmod_masq(clone, inode->i_mode); if (!ret) ret = ocfs2_set_acl(NULL, inode, NULL, ACL_TYPE_ACCESS, clone, NULL, NULL); posix_acl_release(clone); return ret; }
int ocfs2_check_acl(struct inode *inode, int mask) { struct posix_acl *acl = ocfs2_get_acl(inode, ACL_TYPE_ACCESS); if (IS_ERR(acl)) return PTR_ERR(acl); if (acl) { int ret = posix_acl_permission(inode, acl, mask); posix_acl_release(acl); return ret; } return -EAGAIN; }
static int ocfs2_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size) { struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); struct posix_acl *acl; int ret; if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) return -EOPNOTSUPP; acl = ocfs2_get_acl(inode, type); if (IS_ERR(acl)) return PTR_ERR(acl); if (acl == NULL) return -ENODATA; ret = posix_acl_to_xattr(acl, buffer, size); posix_acl_release(acl); return ret; }
static int ocfs2_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer, size_t size, int type) { struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); struct posix_acl *acl; int ret; if (strcmp(name, "") != 0) return -EINVAL; if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) return -EOPNOTSUPP; acl = ocfs2_get_acl(dentry->d_inode, type); if (IS_ERR(acl)) return PTR_ERR(acl); if (acl == NULL) return -ENODATA; ret = posix_acl_to_xattr(acl, buffer, size); posix_acl_release(acl); return ret; }