fs/afs/xattr.c

Source file repositories/reference/linux-study-clean/fs/afs/xattr.c

File Facts

System
Linux kernel
Corpus path
fs/afs/xattr.c
Extension
.c
Size
8518 bytes
Lines
364
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

if (size > 0) {
			if (acl->size <= size)
				memcpy(buffer, acl->data, acl->size);
			else
				ret = -ERANGE;
		}
	}

	kfree(acl);
	return ret;
}

static bool afs_make_acl(struct afs_operation *op,
			 const void *buffer, size_t size)
{
	struct afs_acl *acl;

	acl = kmalloc_flex(*acl, data, size);
	if (!acl) {
		afs_op_nomem(op);
		return false;
	}

	acl->size = size;
	memcpy(acl->data, buffer, size);
	op->acl = acl;
	return true;
}

static const struct afs_operation_ops afs_store_acl_operation = {
	.issue_afs_rpc	= afs_fs_store_acl,
	.success	= afs_acl_success,
	.put		= afs_acl_put,
};

/*
 * Set a file's AFS3 ACL.
 */
static int afs_xattr_set_acl(const struct xattr_handler *handler,
			     struct mnt_idmap *idmap,
                             struct dentry *dentry,
                             struct inode *inode, const char *name,
                             const void *buffer, size_t size, int flags)
{
	struct afs_operation *op;
	struct afs_vnode *vnode = AFS_FS_I(inode);

	if (flags == XATTR_CREATE)
		return -EINVAL;

	op = afs_alloc_operation(NULL, vnode->volume);
	if (IS_ERR(op))
		return -ENOMEM;

	afs_op_set_vnode(op, 0, vnode);
	if (!afs_make_acl(op, buffer, size))
		return afs_put_operation(op);

	op->ops = &afs_store_acl_operation;
	return afs_do_sync_operation(op);
}

static const struct xattr_handler afs_xattr_afs_acl_handler = {
	.name   = "afs.acl",
	.get    = afs_xattr_get_acl,
	.set    = afs_xattr_set_acl,
};

static const struct afs_operation_ops yfs_fetch_opaque_acl_operation = {
	.issue_yfs_rpc	= yfs_fs_fetch_opaque_acl,
	.success	= afs_acl_success,
	/* Don't free op->yacl in .put here */
};

/*
 * Get a file's YFS ACL.
 */
static int afs_xattr_get_yfs(const struct xattr_handler *handler,
			     struct dentry *dentry,
			     struct inode *inode, const char *name,
			     void *buffer, size_t size)
{
	struct afs_operation *op;
	struct afs_vnode *vnode = AFS_FS_I(inode);
	struct yfs_acl *yacl = NULL;
	char buf[16], *data;
	int which = 0, dsize, ret = -ENOMEM;

	if (strcmp(name, "acl") == 0)
		which = 0;

Annotation

Implementation Notes