fs/xfs/xfs_attr_list.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_attr_list.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_attr_list.c- Extension
.c- Size
- 15163 bytes
- Lines
- 600
- 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
xfs_platform.hxfs_fs.hxfs_shared.hxfs_format.hxfs_log_format.hxfs_trans_resv.hxfs_mount.hxfs_da_format.hxfs_inode.hxfs_trans.hxfs_bmap.hxfs_da_btree.hxfs_attr.hxfs_attr_sf.hxfs_attr_leaf.hxfs_error.hxfs_trace.hxfs_dir2.hxfs_health.h
Detected Declarations
function Copyrightfunction attr_listfunction xfs_attr_node_list_lookupfunction xfs_attr_node_listfunction attr_listfunction attr_listfunction xfs_attr_list_ilockedfunction xfs_attr_list
Annotated Snippet
if (sbp->hash == cursor->hashval) {
if (cursor->offset == count) {
break;
}
count++;
} else if (sbp->hash > cursor->hashval) {
break;
}
}
if (i == nsbuf)
goto out;
/*
* Loop putting entries into the user buffer.
*/
for ( ; i < nsbuf; i++, sbp++) {
if (cursor->hashval != sbp->hash) {
cursor->hashval = sbp->hash;
cursor->offset = 0;
}
if (XFS_IS_CORRUPT(context->dp->i_mount,
!xfs_attr_namecheck(sbp->flags, sbp->name,
sbp->namelen))) {
xfs_dirattr_mark_sick(context->dp, XFS_ATTR_FORK);
error = -EFSCORRUPTED;
goto out;
}
context->put_listent(context,
sbp->flags,
sbp->name,
sbp->namelen,
sbp->value,
sbp->valuelen);
if (context->seen_enough)
break;
cursor->offset++;
}
out:
kfree(sbuf);
return error;
}
/*
* We didn't find the block & hash mentioned in the cursor state, so
* walk down the attr btree looking for the hash.
*/
STATIC int
xfs_attr_node_list_lookup(
struct xfs_attr_list_context *context,
struct xfs_attrlist_cursor_kern *cursor,
struct xfs_buf **pbp)
{
struct xfs_da3_icnode_hdr nodehdr;
struct xfs_da_intnode *node;
struct xfs_da_node_entry *btree;
struct xfs_inode *dp = context->dp;
struct xfs_mount *mp = dp->i_mount;
struct xfs_trans *tp = context->tp;
struct xfs_buf *bp;
xfs_failaddr_t fa;
int i;
int error = 0;
unsigned int expected_level = 0;
uint16_t magic;
ASSERT(*pbp == NULL);
cursor->blkno = 0;
for (;;) {
error = xfs_da3_node_read(tp, dp, cursor->blkno, &bp,
XFS_ATTR_FORK);
if (error)
return error;
node = bp->b_addr;
magic = be16_to_cpu(node->hdr.info.magic);
if (magic == XFS_ATTR_LEAF_MAGIC ||
magic == XFS_ATTR3_LEAF_MAGIC)
break;
if (magic != XFS_DA_NODE_MAGIC &&
magic != XFS_DA3_NODE_MAGIC) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
node, sizeof(*node));
goto out_corruptbuf;
}
fa = xfs_da3_node_header_check(bp, I_INO(dp));
if (fa)
goto out_corruptbuf;
xfs_da3_node_hdr_from_disk(mp, &nodehdr, node);
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_shared.h`, `xfs_format.h`, `xfs_log_format.h`, `xfs_trans_resv.h`, `xfs_mount.h`, `xfs_da_format.h`.
- Detected declarations: `function Copyright`, `function attr_list`, `function xfs_attr_node_list_lookup`, `function xfs_attr_node_list`, `function attr_list`, `function attr_list`, `function xfs_attr_list_ilocked`, `function xfs_attr_list`.
- 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.