fs/nfs/nfs3acl.c

Source file repositories/reference/linux-study-clean/fs/nfs/nfs3acl.c

File Facts

System
Linux kernel
Corpus path
fs/nfs/nfs3acl.c
Extension
.c
Size
8228 bytes
Lines
344
Domain
Core OS
Bucket
VFS And Filesystem Core
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

switch(type) {
		case ACL_TYPE_ACCESS:
			alloc = get_inode_acl(inode, ACL_TYPE_DEFAULT);
			if (IS_ERR(alloc))
				goto fail;
			dfacl = alloc;
			break;

		case ACL_TYPE_DEFAULT:
			alloc = get_inode_acl(inode, ACL_TYPE_ACCESS);
			if (IS_ERR(alloc))
				goto fail;
			dfacl = acl;
			acl = alloc;
			break;
		}
	}

	if (acl == NULL) {
		alloc = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
		if (IS_ERR(alloc))
			goto fail;
		acl = alloc;
	}
	status = __nfs3_proc_setacls(inode, acl, dfacl);
out:
	if (acl != orig)
		posix_acl_release(acl);
	if (dfacl != orig)
		posix_acl_release(dfacl);
	return status;

fail:
	status = PTR_ERR(alloc);
	goto out;
}

static int
nfs3_list_one_acl(struct inode *inode, int type, const char *name, void *data,
		size_t size, ssize_t *result)
{
	struct posix_acl *acl;
	char *p = data + *result;

	acl = get_inode_acl(inode, type);
	if (IS_ERR_OR_NULL(acl))
		return 0;

	posix_acl_release(acl);

	*result += strlen(name);
	*result += 1;
	if (!size)
		return 0;
	if (*result > size)
		return -ERANGE;

	strcpy(p, name);
	return 0;
}

ssize_t
nfs3_listxattr(struct dentry *dentry, char *data, size_t size)
{
	struct inode *inode = d_inode(dentry);
	ssize_t result = 0;
	int error;

	error = nfs3_list_one_acl(inode, ACL_TYPE_ACCESS,
			XATTR_NAME_POSIX_ACL_ACCESS, data, size, &result);
	if (error)
		return error;

	error = nfs3_list_one_acl(inode, ACL_TYPE_DEFAULT,
			XATTR_NAME_POSIX_ACL_DEFAULT, data, size, &result);
	if (error)
		return error;
	return result;
}

Annotation

Implementation Notes