fs/xfs/xfs_handle.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_handle.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_handle.c- Extension
.c- Size
- 21625 bytes
- Lines
- 923
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
xfs_platform.hxfs_fs.hxfs_format.hxfs_log_format.hxfs_shared.hxfs_trans_resv.hxfs_mount.hxfs_bmap_btree.hxfs_inode.hxfs_error.hxfs_trace.hxfs_trans.hxfs_da_format.hxfs_da_btree.hxfs_attr.hxfs_ioctl.hxfs_parent.hxfs_handle.hxfs_health.hxfs_icache.hxfs_export.hxfs_xattr.hxfs_acl.hlinux/namei.h
Detected Declarations
struct xfs_getparents_ctxfunction Copyrightfunction xfs_filehandle_initfunction xfs_fshandle_initfunction xfs_find_handlefunction xfs_handle_acceptablefunction xfs_khandle_to_dentryfunction xfs_khandle_to_inodefunction xfs_handle_to_dentryfunction xfs_handlereq_to_dentryfunction xfs_open_by_handlefunction xfs_readlink_by_handlefunction xfs_ioc_attr_put_listentfunction xfs_attr_filterfunction xfs_xattr_flagsfunction xfs_ioc_attr_listfunction xfs_attrlist_by_handlefunction xfs_attrmulti_attr_getfunction xfs_attrmulti_attr_setfunction xfs_ioc_attrmulti_onefunction xfs_attrmulti_by_handlefunction xfs_getparents_rec_sizeoffunction xfs_getparents_put_listentfunction xfs_getparents_expand_lastrecfunction xfs_getparentsfunction xfs_ioc_getparentsfunction xfs_ioc_getparents_by_handle
Annotated Snippet
struct xfs_getparents_ctx {
struct xfs_attr_list_context context;
struct xfs_getparents_by_handle gph;
/* File to target */
struct xfs_inode *ip;
/* Internal buffer where we format records */
void *krecords;
/* Last record filled out */
struct xfs_getparents_rec *lastrec;
unsigned int count;
};
static inline unsigned int
xfs_getparents_rec_sizeof(
unsigned int namelen)
{
return round_up(sizeof(struct xfs_getparents_rec) + namelen + 1,
sizeof(uint64_t));
}
static void
xfs_getparents_put_listent(
struct xfs_attr_list_context *context,
int flags,
unsigned char *name,
int namelen,
void *value,
int valuelen)
{
struct xfs_getparents_ctx *gpx =
container_of(context, struct xfs_getparents_ctx, context);
struct xfs_inode *ip = context->dp;
struct xfs_mount *mp = ip->i_mount;
struct xfs_getparents *gp = &gpx->gph.gph_request;
struct xfs_getparents_rec *gpr = gpx->krecords + context->firstu;
unsigned short reclen =
xfs_getparents_rec_sizeof(namelen);
xfs_ino_t ino;
uint32_t gen;
int error;
if (!(flags & XFS_ATTR_PARENT))
return;
error = xfs_parent_from_attr(mp, flags, name, namelen, value, valuelen,
&ino, &gen);
if (error) {
xfs_inode_mark_sick(ip, XFS_SICK_INO_PARENT);
context->seen_enough = -EFSCORRUPTED;
return;
}
/*
* We found a parent pointer, but we've filled up the buffer. Signal
* to the caller that we did /not/ reach the end of the parent pointer
* recordset.
*/
if (context->firstu > context->bufsize - reclen) {
context->seen_enough = 1;
return;
}
/* Format the parent pointer directly into the caller buffer. */
gpr->gpr_reclen = reclen;
xfs_filehandle_init(mp, ino, gen, &gpr->gpr_parent);
memcpy(gpr->gpr_name, name, namelen);
gpr->gpr_name[namelen] = 0;
trace_xfs_getparents_put_listent(ip, gp, context, gpr);
context->firstu += reclen;
gpx->count++;
gpx->lastrec = gpr;
}
/* Expand the last record to fill the rest of the caller's buffer. */
static inline void
xfs_getparents_expand_lastrec(
struct xfs_getparents_ctx *gpx)
{
struct xfs_getparents *gp = &gpx->gph.gph_request;
struct xfs_getparents_rec *gpr = gpx->lastrec;
if (!gpx->lastrec)
gpr = gpx->krecords;
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_format.h`, `xfs_log_format.h`, `xfs_shared.h`, `xfs_trans_resv.h`, `xfs_mount.h`, `xfs_bmap_btree.h`.
- Detected declarations: `struct xfs_getparents_ctx`, `function Copyright`, `function xfs_filehandle_init`, `function xfs_fshandle_init`, `function xfs_find_handle`, `function xfs_handle_acceptable`, `function xfs_khandle_to_dentry`, `function xfs_khandle_to_inode`, `function xfs_handle_to_dentry`, `function xfs_handlereq_to_dentry`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.