예제 #1
0
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;
}
예제 #2
0
static int f2fs_xattr_get_acl(struct dentry *dentry, const char *name,
		void *buffer, size_t size, int type)
{
	struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb);
	struct inode *inode = dentry->d_inode;
	struct posix_acl *acl;
	int error;

	if (!test_opt(sbi, POSIX_ACL))
		return -EOPNOTSUPP;

	if (strcmp(name, "") != 0)
		return -EINVAL;

	acl = f2fs_get_acl(inode, type);
	if (IS_ERR(acl))
		return PTR_ERR(acl);
	if (!acl)
		return -ENODATA;

	error = posix_acl_to_xattr(acl, buffer, size);
	posix_acl_release(acl);

	return error;
}
예제 #3
0
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;
}
예제 #4
0
/*
 * add f2fs_get_acl helper function for 2.6.35
 * by Marc Alexander
 */
int f2fs_check_acl(struct inode *inode, int mask)
{
	struct posix_acl *acl = f2fs_get_acl(inode, ACL_TYPE_ACCESS);

	if (IS_ERR(acl))
		return PTR_ERR(acl);
	if (acl) {
		int error = posix_acl_permission(inode, acl, mask);
		posix_acl_release(acl);
		return error;
	}

	return -EAGAIN;
}
예제 #5
0
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;
}
예제 #6
0
int f2fs_check_acl(struct inode *inode, int mask, unsigned int flags)
{
	int error = -EAGAIN;

	if (flags & IPERM_FLAG_RCU) {
		if (!negative_cached_acl(inode, ACL_TYPE_ACCESS))
			error = -ECHILD;
	} else {
		struct posix_acl *acl;

		acl = f2fs_get_acl(inode, ACL_TYPE_ACCESS);
		if (IS_ERR(acl))
			return PTR_ERR(acl);
		if (acl) {
			error = posix_acl_permission(inode, acl, mask);
			posix_acl_release(acl);
		}
	}

	return error;
}