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.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/slab.hlinux/fs.hlinux/xattr.hinternal.h
Detected Declarations
function pioctlfunction afs_acl_putfunction afs_xattr_get_aclfunction afs_make_aclfunction afs_xattr_set_aclfunction afs_xattr_get_yfsfunction afs_xattr_set_yfsfunction afs_xattr_get_cellfunction afs_xattr_get_fidfunction afs_xattr_get_volume
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
- Immediate include surface: `linux/slab.h`, `linux/fs.h`, `linux/xattr.h`, `internal.h`.
- Detected declarations: `function pioctl`, `function afs_acl_put`, `function afs_xattr_get_acl`, `function afs_make_acl`, `function afs_xattr_set_acl`, `function afs_xattr_get_yfs`, `function afs_xattr_set_yfs`, `function afs_xattr_get_cell`, `function afs_xattr_get_fid`, `function afs_xattr_get_volume`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.