int f2fs_init_acl(struct inode *inode, struct inode *dir, struct page *ipage) { struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); struct posix_acl *acl = NULL; int error = 0; if (!S_ISLNK(inode->i_mode)) { if (test_opt(sbi, POSIX_ACL)) { acl = f2fs_get_acl(dir, ACL_TYPE_DEFAULT); if (IS_ERR(acl)) return PTR_ERR(acl); } if (!acl) inode->i_mode &= ~current_umask(); } if (!test_opt(sbi, POSIX_ACL) || !acl) goto cleanup; if (S_ISDIR(inode->i_mode)) { error = f2fs_set_acl(inode, ACL_TYPE_DEFAULT, acl, ipage); if (error) goto cleanup; } error = posix_acl_create(&acl, GFP_KERNEL, &inode->i_mode); if (error < 0) return error; if (error > 0) error = f2fs_set_acl(inode, ACL_TYPE_ACCESS, acl, ipage); cleanup: posix_acl_release(acl); return error; }
static int f2fs_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, size_t size, int flags, int type) { struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb); struct inode *inode = dentry->d_inode; struct posix_acl *acl = NULL; int error; if (strcmp(name, "") != 0) return -EINVAL; if (!test_opt(sbi, POSIX_ACL)) return -EOPNOTSUPP; if (!inode_owner_or_capable(inode)) return -EPERM; if (value) { acl = posix_acl_from_xattr(&init_user_ns, value, size); if (IS_ERR(acl)) return PTR_ERR(acl); if (acl) { error = posix_acl_valid(acl); if (error) goto release_and_out; } } else { acl = NULL; } error = f2fs_set_acl(inode, type, acl, NULL); release_and_out: posix_acl_release(acl); return error; }
int f2fs_acl_chmod(struct inode *inode) { struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); struct posix_acl *acl, *clone; int error; mode_t mode = get_inode_mode(inode); if (!test_opt(sbi, POSIX_ACL)) return 0; if (S_ISLNK(mode)) return -EOPNOTSUPP; acl = f2fs_get_acl(inode, ACL_TYPE_ACCESS); if (IS_ERR(acl) || !acl) return PTR_ERR(acl); //error = posix_acl_chmod(&acl, GFP_KERNEL, mode); clone = posix_acl_clone(acl, GFP_KERNEL); posix_acl_release(acl); if (!clone) return -ENOMEM; error = posix_acl_chmod_masq(clone, inode->i_mode); if (error) return error; error = f2fs_set_acl(inode, ACL_TYPE_ACCESS, acl); posix_acl_release(acl); return error; }
int f2fs_init_acl(struct inode *inode, struct inode *dir) { struct posix_acl *acl = NULL; mode_t mode; struct posix_acl *clone; struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); int error = 0; if (!S_ISLNK(inode->i_mode)) { if (test_opt(sbi, POSIX_ACL)) { acl = f2fs_get_acl(dir, ACL_TYPE_DEFAULT); if (IS_ERR(acl)) return PTR_ERR(acl); } if (!acl) inode->i_mode &= ~current_umask(); } if (test_opt(sbi, POSIX_ACL) && acl) { if (S_ISDIR(inode->i_mode)) { error = f2fs_set_acl(inode, ACL_TYPE_DEFAULT, acl); if (error) goto cleanup; } //error = posix_acl_create(&acl, GFP_KERNEL, &inode->i_mode); clone = posix_acl_clone(acl, GFP_KERNEL); error = -ENOMEM; if (!clone) goto cleanup; mode = inode->i_mode; error = posix_acl_create_masq(clone, &mode); if (error < 0) return error; if (error > 0) error = f2fs_set_acl(inode, ACL_TYPE_ACCESS, acl); } cleanup: posix_acl_release(acl); return error; }