fs/xfs/xfs_ioctl.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_ioctl.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_ioctl.c- Extension
.c- Size
- 36136 bytes
- Lines
- 1473
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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_inode.hxfs_rtalloc.hxfs_iwalk.hxfs_itable.hxfs_error.hxfs_da_format.hxfs_da_btree.hxfs_attr.hxfs_bmap.hxfs_bmap_util.hxfs_fsops.hxfs_discard.hxfs_quota.hxfs_trace.hxfs_icache.hxfs_trans.hxfs_btree.hlinux/fsmap.hxfs_fsmap.hscrub/xfs_scrub.hxfs_sb.hxfs_ag.hxfs_health.hxfs_reflink.hxfs_ioctl.h
Detected Declarations
function Copyrightfunction xfs_fsinumbers_fmtfunction xfs_ioc_fsbulkstatfunction xfs_bulkstat_fmtfunction xfs_bulk_ireq_setupfunction xfs_bulk_ireq_teardownfunction xfs_ioc_bulkstatfunction xfs_inumbers_fmtfunction xfs_ioc_inumbersfunction xfs_ioc_fsgeometryfunction xfs_ioc_ag_geometryfunction xfs_rtgroup_report_write_pointerfunction xfs_ioc_rtgroup_geometryfunction xfs_fill_fsxattrfunction xfs_ioc_fsgetxattrafunction xfs_fileattr_getfunction xfs_ioctl_setattr_xflagsfunction xfs_ioctl_setattr_prepare_daxfunction xfs_ioctl_setattr_get_transfunction xfs_ioctl_setattr_check_extsizefunction xfs_ioctl_setattr_check_cowextsizefunction xfs_ioctl_setattr_check_projidfunction xfs_fileattr_setfunction xfs_getbmap_formatfunction xfs_ioc_getbmapfunction xfs_ioc_swapextfunction xfs_ioc_getlabelfunction xfs_ioc_setlabelfunction xfs_fs_eofblocks_from_userfunction xfs_ioctl_getset_resblocksfunction xfs_ioctl_fs_countsfunction xfs_file_ioctl
Annotated Snippet
switch (hdr->ino) {
case XFS_BULK_IREQ_SPECIAL_ROOT:
breq->startino = mp->m_sb.sb_rootino;
break;
default:
return -EINVAL;
}
breq->icount = 1;
}
/*
* The IREQ_AGNO flag means that we only want results from a given AG.
* If @hdr->ino is zero, we start iterating in that AG. If @hdr->ino is
* beyond the specified AG then we return no results.
*/
if (hdr->flags & XFS_BULK_IREQ_AGNO) {
if (hdr->agno >= mp->m_sb.sb_agcount)
return -EINVAL;
if (breq->startino == 0)
breq->startino = XFS_AGINO_TO_INO(mp, hdr->agno, 0);
else if (XFS_INO_TO_AGNO(mp, breq->startino) < hdr->agno)
return -EINVAL;
breq->iwalk_flags |= XFS_IWALK_SAME_AG;
/* Asking for an inode past the end of the AG? We're done! */
if (XFS_INO_TO_AGNO(mp, breq->startino) > hdr->agno)
return -ECANCELED;
} else if (hdr->agno)
return -EINVAL;
/* Asking for an inode past the end of the FS? We're done! */
if (XFS_INO_TO_AGNO(mp, breq->startino) >= mp->m_sb.sb_agcount)
return -ECANCELED;
if (hdr->flags & XFS_BULK_IREQ_NREXT64)
breq->flags |= XFS_IBULK_NREXT64;
/* Caller wants to see metadata directories in bulkstat output. */
if (hdr->flags & XFS_BULK_IREQ_METADIR)
breq->flags |= XFS_IBULK_METADIR;
return 0;
}
/*
* Update the userspace bulk request @hdr to reflect the end state of the
* internal bulk request @breq.
*/
static void
xfs_bulk_ireq_teardown(
struct xfs_bulk_ireq *hdr,
struct xfs_ibulk *breq)
{
hdr->ino = breq->startino;
hdr->ocount = breq->ocount;
}
/* Handle the v5 bulkstat ioctl. */
STATIC int
xfs_ioc_bulkstat(
struct file *file,
unsigned int cmd,
struct xfs_bulkstat_req __user *arg)
{
struct xfs_mount *mp = XFS_I(file_inode(file))->i_mount;
struct xfs_bulk_ireq hdr;
struct xfs_ibulk breq = {
.mp = mp,
.idmap = file_mnt_idmap(file),
};
int error;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
if (xfs_is_shutdown(mp))
return -EIO;
if (copy_from_user(&hdr, &arg->hdr, sizeof(hdr)))
return -EFAULT;
error = xfs_bulk_ireq_setup(mp, &hdr, &breq, arg->bulkstat);
if (error == -ECANCELED)
goto out_teardown;
if (error < 0)
return error;
error = xfs_bulkstat(&breq, xfs_bulkstat_fmt);
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_inode.h`.
- Detected declarations: `function Copyright`, `function xfs_fsinumbers_fmt`, `function xfs_ioc_fsbulkstat`, `function xfs_bulkstat_fmt`, `function xfs_bulk_ireq_setup`, `function xfs_bulk_ireq_teardown`, `function xfs_ioc_bulkstat`, `function xfs_inumbers_fmt`, `function xfs_ioc_inumbers`, `function xfs_ioc_fsgeometry`.
- 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.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.