XFSCTL(3)
π NAME π
okay so bestie, meet xfsctl β that's the section 3 girlie from the Library Functions Manual, and her whole job is literally controlling XFS filesystems and individual files. that's it. that's the gig. π
πΈ C SYNOPSIS πΈ
like, this is how you call her:
#include <xfs/xfs.h>
int xfsctl(const char *path, int fd, int cmd, void *ptr);
int platform_test_xfs_fd(int fd);
int platform_test_xfs_path(const char *path);
β¨ DESCRIPTION β¨
so some functionality that's specific to the XFS filesystem is accessible to applications through platform-specific system call interfaces. these operations split into two sections β the ones that operate on individual files, and the ones that operate on the filesystem itself.
bestie, be careful out here. when you're issuing xfsctl() calls, make sure the target path and the file descriptor (yes, you have to supply BOTH) actually do represent a file from an XFS filesystem. π«Ά
the statfs(2) and fstatfs(2) system calls can be used to figure out whether or not some arbitrary path or file descriptor belongs to an XFS filesystem. the thing is, they're not portable though β so the routines platform_test_xfs_fd() and platform_test_xfs_path() give you a platform-independent mechanism instead. slay. β¨
π File Operations π
to effect an operation on an individual file, the pathname and descriptor arguments you pass to xfsctl identify the file being operated on. the final argument described below refers to the final argument of xfsctl. all of the data structures and macros mentioned below are defined in the <xfs/xfs_fs.h> header file.
XFS_IOC_ALLOCSP,XFS_IOC_ALLOCSP64,XFS_IOC_FREESP,XFS_IOC_FREESP64β alter the storage space associated with a section of the ordinary file specified. the section is specified by a variable of typexfs_flock64_t, pointed to by the final argument. the data typexfs_flock64_tcontains these members:l_whenceis0,1, or2to indicate that the relative offsetl_startwill be measured from the start of the file, the current position, or the end of the file, respectively (i.e.,l_startis the offset from the position specified inl_whence). if the offset specified is before the current end of file, any data previously written into this section is no longer accessible. if the offset specified is beyond the current end of file, the file is grown and filled with zeroes. thel_lenfield is currently ignored, and should be set to zero.
XFS_IOC_ALLOCSP, XFS_IOC_ALLOCSP64, XFS_IOC_FREESP and XFS_IOC_FREESP64 operations are all identical.
π¨ these ioctls are no longer supported as of Linux 5.17.
XFS_IOC_FSSETDMβ set thedi_dmevmaskanddi_dmstatefields in an XFS on-disk inode. the only legitimate values for these fields are the ones previously returned in thebs_dmevmaskandbs_dmstatefields of the bulkstat structure. the data referred to by the final argument is astruct fsdmidata. this structure's members arefsd_dmevmaskandfsd_dmstate. thedi_dmevmaskfield gets set to the value infsd_dmevmask, and thedi_dmstatefield gets set to the value infsd_dmstate. this command is restricted to root or to processes with device management capabilities. its sole purpose is to let backup and restore programs restore those critical on-disk inode fields, iykyk.
π¨ this ioctl is not supported as of Linux 5.5.
XFS_IOC_DIOINFOβ get the info required to perform direct I/O on the specified file descriptor. direct I/O is performed directly to and from a user's data buffer. since the kernel's buffer cache is no longer between the two, the user's data buffer has to conform to the same type of constraints as required for accessing a raw disk partition. the final argument points to a variable of typestruct dioattr, which contains these members:d_memis the memory alignment requirement of the user's data buffer.d_minioszspecifies block size, minimum I/O request size, and I/O alignment β the size of all I/O requests must be a multiple of this amount, and the value of the seek pointer at the time of the I/O request must also be an integer multiple of this amount.d_maxioszis the maximum I/O request size which can be performed on the file descriptor. if an I/O request does not meet these constraints, theread(2)orwrite(2)will fail withEINVAL. π all I/O requests are kept consistent with any data brought into the cache with an access through a non-direct I/O file descriptor.XFS_IOC_FSGETXATTR,XFS_IOC_FSGETXATTRA,XFS_IOC_FSSETXATTRβ seeioctl_xfs_fsgetxattr(2)for more information. β¨XFS_IOC_GETBMAP,XFS_IOC_GETBMAPA,XFS_IOC_GETBMAPXβ seeioctl_getbmap(2)for more information. β¨XFS_IOC_RESVSP,XFS_IOC_RESVSP64β this command allocates space to a file. a range of bytes is specified using a pointer to a variable of typexfs_flock64_tin the final argument. the blocks are allocated, but not zeroed, and the file size does not change. if the XFS filesystem is configured to flag unwritten file extents, performance will be negatively affected when writing to preallocated space, since extra filesystem transactions are required to convert extent flags on the range of the file written. ifxfs_info(8)reportsunwritten=1, then the filesystem was made to flag unwritten extents.XFS_IOC_UNRESVSP,XFS_IOC_UNRESVSP64β this command frees space from a file. a range of bytes is specified using a pointer to a variable of typexfs_flock64_tin the final argument. partial filesystem blocks are zeroed, and whole filesystem blocks are removed from the file. the file size does not change. π§XFS_IOC_ZERO_RANGEβ this command converts a range of a file to zeros without issuing data IO. a range of bytes is specified using a pointer to a variable of typexfs_flock64_tin the final argument. blocks are preallocated for regions that span holes in the file, and the entire range is converted to unwritten extents. this operation is a fast method of overwriting any from the range specified with zeros without removing any blocks or having to write zeros to disk. any subsequent read in the given range will return zeros until new data is written. this functionality requires filesystems to support unwritten extents. ifxfs_info(8)reportsunwritten=1, then the filesystem was made to flag unwritten extents.XFS_IOC_PATH_TO_HANDLE,XFS_IOC_PATH_TO_FSHANDLE,XFS_IOC_FD_TO_HANDLE,XFS_IOC_OPEN_BY_HANDLE,XFS_IOC_READLINK_BY_HANDLE,XFS_IOC_ATTR_LIST_BY_HANDLE,XFS_IOC_ATTR_MULTI_BY_HANDLE,XFS_IOC_FSSETDM_BY_HANDLEβ these are all interfaces that are used to implement various libhandle functions (seeopen_by_handle(3)). they are all subject to change and should not be called directly by applications.
π¨XFS_IOC_FSSETDM_BY_HANDLEis not supported as of Linux5.5.
π¦ Filesystem Operations π¦
to effect one of the following operations, the pathname and descriptor arguments passed to xfsctl() can be any open file in the XFS filesystem in question. easy. π
XFS_IOC_FSINUMBERSβ seeioctl_xfs_fsinumbers(2)for more information.XFS_IOC_FSGEOMETRYβ seeioctl_xfs_fsgeometry(2)for more information.XFS_IOC_AG_GEOMETRYβ seeioctl_xfs_ag_geometry(2)for more information.XFS_IOC_FSBULKSTATorXFS_IOC_FSBULKSTAT_SINGLEβ seeioctl_xfs_fsbulkstat(2)for more information.XFS_IOC_SCRUB_METADATAβ seeioctl_xfs_scrub_metadata(2)for more information.XFS_IOC_FSCOUNTSβ seeioctl_xfs_fscounts(2)for more information.XFS_IOC_GET_RESBLKS,XFS_IOC_SET_RESBLKSβ seeioctl_xfs_getresblks(2)for more information. bestie, save yourself a lot of frustration and avoid these ioctls. genuinely. πXFS_IOC_GOINGDOWNβ seeioctl_xfs_goingdown(2)for more information.XFS_IOC_THAW,XFS_IOC_FREEZE,XFS_IOC_FSGROWFSDATA,XFS_IOC_FSGROWFSLOG,XFS_IOC_FSGROWFSRTβ these interfaces are used to implement various filesystem internal operations on XFS filesystems. the remainder of these operations will not be described further as they are not of general use to applications. moving on π
π SEE ALSO π
ioctl_xfs_fsgetxattr(2), ioctl_xfs_fsgeometry(2), ioctl_xfs_fsbulkstat(2), ioctl_xfs_scrub_metadata(2), ioctl_xfs_fsinumbers(2), ioctl_xfs_fscounts(2), ioctl_xfs_getresblks(2), ioctl_xfs_getbmap(2), ioctl_xfs_goingdown(2), fstatfs(2), statfs(2), xfs(5), xfs_info(8).
and that's a wrap, bestie π«Ά this one lives in the Library Functions Manual and signs off at the bottom with just XFSCTL(3) β no extra date, no version drama, just the name and the number. iconic behavior, honestly. go forth and xfsctl responsibly πβ¨
π¦ where this page comes from
- alpine 3.22: xfsprogs-doc 6.14.0-r0 Β· LGPL-2.1-or-later
- alpine 3.23: xfsprogs-doc 6.17.0-r0 Β· LGPL-2.1-or-later
- alpine 3.24: xfsprogs-doc 7.0.1-r0 Β· LGPL-2.1-or-later
- arch rolling: xfsprogs 7.2.0-1
- arch rolling: xfsprogs 7.2.1-1 Β· GPL-2.0-only AND LGPL-2.1-only
- centos-stream 10: xfsprogs-devel 6.16.0-1.el10 Β· GPL-1.0-or-later AND LGPL-2.1-or-later
- centos-stream 9: xfsprogs-devel 6.4.0-9.el9 Β· GPL+ and LGPLv2+
- centos-stream 9: xfsprogs-devel 6.4.0-9.el9 Β· GPL+ and LGPLv2+
- debian bookworm: xfslibs-dev 6.1.0-1 Β· GPL-2.0-only
- debian trixie: xfslibs-dev 6.13.0-2+deb13u1 Β· GPL-2.0-only
- fedora 43: xfsprogs-devel 6.15.0-3.fc43 Β· GPL-1.0-or-later AND LGPL-2.1-or-later
- fedora 43: xfsprogs-devel 6.15.0-3.fc43 Β· GPL-1.0-or-later AND LGPL-2.1-or-later
- fedora 44: xfsprogs-devel 6.18.0-2.fc44 Β· GPL-1.0-or-later AND LGPL-2.1-or-later
- fedora 44: xfsprogs-devel 6.18.0-2.fc44 Β· GPL-1.0-or-later AND LGPL-2.1-or-later
- fedora 44: xfsprogs-devel 7.1.1-1.fc44 Β· GPL-1.0-or-later AND LGPL-2.1-or-later
- fedora 44: xfsprogs-devel 7.1.1-1.fc44 Β· GPL-1.0-or-later AND LGPL-2.1-or-later
- nixos 26.05: xfsprogs 6.19.0
- nixpkgs unstable: xfsprogs 7.2.1
- opensuse-leap 16.0: xfsprogs-devel 6.19.0-160000.3.1 Β· GPL-2.0-or-later
- opensuse-leap 16.0: xfsprogs-devel 6.19.0-160000.3.1 Β· GPL-2.0-or-later
- opensuse-leap 16.0: xfsprogs-devel 6.19.0-160000.3.1 Β· GPL-2.0-or-later
- opensuse-leap 16.0: xfsprogs-devel 6.19.0-160000.3.1 Β· GPL-2.0-or-later
- ubuntu noble: xfslibs-dev 6.6.0-1ubuntu2 Β· GPL-2.0-only
- ubuntu noble: xfslibs-dev 6.6.0-1ubuntu2.1 Β· GPL-2.0-only
- ubuntu questing: xfslibs-dev 6.13.0-2ubuntu2
- ubuntu resolute: xfslibs-dev 6.18.0-3 Β· GPL-2.0-only
- ubuntu stonking: xfslibs-dev 6.19.0-1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms