linux/fs/xfs/libxfs/xfs_fs.h

/* SPDX-License-Identifier: LGPL-2.1 */
/*
 * Copyright (c) 1995-2005 Silicon Graphics, Inc.
 * All Rights Reserved.
 */
#ifndef __XFS_FS_H__
#define __XFS_FS_H__

/*
 * SGI's XFS filesystem's major stuff (constants, structures)
 * NOTE: This file must be compile-able with C++ compilers.
 */

/*
 * Direct I/O attribute record used with XFS_IOC_DIOINFO
 * d_miniosz is the min xfer size, xfer size multiple and file seek offset
 * alignment.
 */
#ifndef HAVE_DIOATTR
struct dioattr {};
#endif

/*
 * Structure for XFS_IOC_GETBMAP.
 * On input, fill in bmv_offset and bmv_length of the first structure
 * to indicate the area of interest in the file, and bmv_entries with
 * the number of array elements given back.  The first structure is
 * updated on return to give the offset and length for the next call.
 */
#ifndef HAVE_GETBMAP
struct getbmap {};
#endif

/*
 *	Structure for XFS_IOC_GETBMAPX.	 Fields bmv_offset through bmv_entries
 *	are used exactly as in the getbmap structure.  The getbmapx structure
 *	has additional bmv_iflags and bmv_oflags fields. The bmv_iflags field
 *	is only used for the first structure.  It contains input flags
 *	specifying XFS_IOC_GETBMAPX actions.  The bmv_oflags field is filled
 *	in by the XFS_IOC_GETBMAPX command for each returned structure after
 *	the first.
 */
#ifndef HAVE_GETBMAPX
struct getbmapx {};
#endif

/*	bmv_iflags values - set by XFS_IOC_GETBMAPX caller.	*/
#define BMV_IF_ATTRFORK
#define BMV_IF_NO_DMAPI_READ
#define BMV_IF_PREALLOC
#define BMV_IF_DELALLOC
#define BMV_IF_NO_HOLES
#define BMV_IF_COWFORK
#define BMV_IF_VALID

/*	bmv_oflags values - returned for each non-header segment */
#define BMV_OF_PREALLOC
#define BMV_OF_DELALLOC
#define BMV_OF_LAST
#define BMV_OF_SHARED

/*	fmr_owner special values for FS_IOC_GETFSMAP */
#define XFS_FMR_OWN_FREE
#define XFS_FMR_OWN_UNKNOWN
#define XFS_FMR_OWN_FS
#define XFS_FMR_OWN_LOG
#define XFS_FMR_OWN_AG
#define XFS_FMR_OWN_INOBT
#define XFS_FMR_OWN_INODES
#define XFS_FMR_OWN_REFC
#define XFS_FMR_OWN_COW
#define XFS_FMR_OWN_DEFECTIVE

/*
 * File segment locking set data type for 64 bit access.
 * Also used for all the RESV/FREE interfaces.
 */
xfs_flock64_t;

/*
 * Output for XFS_IOC_FSGEOMETRY_V1
 */
struct xfs_fsop_geom_v1 {};

/*
 * Output for XFS_IOC_FSGEOMETRY_V4
 */
struct xfs_fsop_geom_v4 {};

/*
 * Output for XFS_IOC_FSGEOMETRY
 */
struct xfs_fsop_geom {};

#define XFS_FSOP_GEOM_SICK_COUNTERS
#define XFS_FSOP_GEOM_SICK_UQUOTA
#define XFS_FSOP_GEOM_SICK_GQUOTA
#define XFS_FSOP_GEOM_SICK_PQUOTA
#define XFS_FSOP_GEOM_SICK_RT_BITMAP
#define XFS_FSOP_GEOM_SICK_RT_SUMMARY
#define XFS_FSOP_GEOM_SICK_QUOTACHECK
#define XFS_FSOP_GEOM_SICK_NLINKS

/* Output for XFS_FS_COUNTS */
xfs_fsop_counts_t;

/* Input/Output for XFS_GET_RESBLKS and XFS_SET_RESBLKS */
xfs_fsop_resblks_t;

#define XFS_FSOP_GEOM_VERSION
#define XFS_FSOP_GEOM_VERSION_V5

#define XFS_FSOP_GEOM_FLAGS_ATTR
#define XFS_FSOP_GEOM_FLAGS_NLINK
#define XFS_FSOP_GEOM_FLAGS_QUOTA
#define XFS_FSOP_GEOM_FLAGS_IALIGN
#define XFS_FSOP_GEOM_FLAGS_DALIGN
#define XFS_FSOP_GEOM_FLAGS_SHARED
#define XFS_FSOP_GEOM_FLAGS_EXTFLG
#define XFS_FSOP_GEOM_FLAGS_DIRV2
#define XFS_FSOP_GEOM_FLAGS_LOGV2
#define XFS_FSOP_GEOM_FLAGS_SECTOR
#define XFS_FSOP_GEOM_FLAGS_ATTR2
#define XFS_FSOP_GEOM_FLAGS_PROJID32
#define XFS_FSOP_GEOM_FLAGS_DIRV2CI
	/*  -- Do not use --		(1 << 13)    SGI parent pointers   */
#define XFS_FSOP_GEOM_FLAGS_LAZYSB
#define XFS_FSOP_GEOM_FLAGS_V5SB
#define XFS_FSOP_GEOM_FLAGS_FTYPE
#define XFS_FSOP_GEOM_FLAGS_FINOBT
#define XFS_FSOP_GEOM_FLAGS_SPINODES
#define XFS_FSOP_GEOM_FLAGS_RMAPBT
#define XFS_FSOP_GEOM_FLAGS_REFLINK
#define XFS_FSOP_GEOM_FLAGS_BIGTIME
#define XFS_FSOP_GEOM_FLAGS_INOBTCNT
#define XFS_FSOP_GEOM_FLAGS_NREXT64
#define XFS_FSOP_GEOM_FLAGS_EXCHANGE_RANGE
#define XFS_FSOP_GEOM_FLAGS_PARENT

/*
 * Minimum and maximum sizes need for growth checks.
 *
 * Block counts are in units of filesystem blocks, not basic blocks.
 */
#define XFS_MIN_AG_BLOCKS
#define XFS_MIN_LOG_BLOCKS
#define XFS_MAX_LOG_BLOCKS
#define XFS_MIN_LOG_BYTES

/*
 * Limits on sb_agblocks/sb_agblklog -- mkfs won't format AGs smaller than
 * 16MB or larger than 1TB.
 */
#define XFS_MIN_AG_BYTES
#define XFS_MAX_AG_BYTES
#define XFS_MAX_AG_BLOCKS
#define XFS_MAX_CRC_AG_BLOCKS

#define XFS_MAX_AGNUMBER

/* keep the maximum size under 2^31 by a small amount */
#define XFS_MAX_LOG_BYTES

/* Used for sanity checks on superblock */
#define XFS_MAX_DBLOCKS(s)
#define XFS_MIN_DBLOCKS(s)

/*
 * Output for XFS_IOC_AG_GEOMETRY
 */
struct xfs_ag_geometry {};
#define XFS_AG_GEOM_SICK_SB
#define XFS_AG_GEOM_SICK_AGF
#define XFS_AG_GEOM_SICK_AGFL
#define XFS_AG_GEOM_SICK_AGI
#define XFS_AG_GEOM_SICK_BNOBT
#define XFS_AG_GEOM_SICK_CNTBT
#define XFS_AG_GEOM_SICK_INOBT
#define XFS_AG_GEOM_SICK_FINOBT
#define XFS_AG_GEOM_SICK_RMAPBT
#define XFS_AG_GEOM_SICK_REFCNTBT
#define XFS_AG_GEOM_SICK_INODES

/*
 * Structures for XFS_IOC_FSGROWFSDATA, XFS_IOC_FSGROWFSLOG & XFS_IOC_FSGROWFSRT
 */
xfs_growfs_data_t;

xfs_growfs_log_t;

xfs_growfs_rt_t;


/*
 * Structures returned from ioctl XFS_IOC_FSBULKSTAT & XFS_IOC_FSBULKSTAT_SINGLE
 */
xfs_bstime_t;

struct xfs_bstat {};

/* New bulkstat structure that reports v5 features and fixes padding issues */
struct xfs_bulkstat {};

#define XFS_BULKSTAT_VERSION_V1
#define XFS_BULKSTAT_VERSION_V5

/* bs_sick flags */
#define XFS_BS_SICK_INODE
#define XFS_BS_SICK_BMBTD
#define XFS_BS_SICK_BMBTA
#define XFS_BS_SICK_BMBTC
#define XFS_BS_SICK_DIR
#define XFS_BS_SICK_XATTR
#define XFS_BS_SICK_SYMLINK
#define XFS_BS_SICK_PARENT
#define XFS_BS_SICK_DIRTREE

/*
 * Project quota id helpers (previously projid was 16bit only
 * and using two 16bit values to hold new 32bit projid was chosen
 * to retain compatibility with "old" filesystems).
 */
static inline uint32_t
bstat_get_projid(const struct xfs_bstat *bs)
{}

/*
 * The user-level BulkStat Request interface structure.
 */
struct xfs_fsop_bulkreq {};

/*
 * Structures returned from xfs_inumbers routine (XFS_IOC_FSINUMBERS).
 */
struct xfs_inogrp {};

/* New inumbers structure that reports v5 features and fixes padding issues */
struct xfs_inumbers {};

#define XFS_INUMBERS_VERSION_V1
#define XFS_INUMBERS_VERSION_V5

/* Header for bulk inode requests. */
struct xfs_bulk_ireq {};

/*
 * Only return results from the specified @agno.  If @ino is zero, start
 * with the first inode of @agno.
 */
#define XFS_BULK_IREQ_AGNO

/*
 * Return bulkstat information for a single inode, where @ino value is a
 * special value, not a literal inode number.  See the XFS_BULK_IREQ_SPECIAL_*
 * values below.  Not compatible with XFS_BULK_IREQ_AGNO.
 */
#define XFS_BULK_IREQ_SPECIAL

/*
 * Return data fork extent count via xfs_bulkstat->bs_extents64 field and assign
 * 0 to xfs_bulkstat->bs_extents when the flag is set.  Otherwise, use
 * xfs_bulkstat->bs_extents for returning data fork extent count and set
 * xfs_bulkstat->bs_extents64 to 0. In the second case, return -EOVERFLOW and
 * assign 0 to xfs_bulkstat->bs_extents if data fork extent count is larger than
 * XFS_MAX_EXTCNT_DATA_FORK_OLD.
 */
#define XFS_BULK_IREQ_NREXT64

#define XFS_BULK_IREQ_FLAGS_ALL

/* Operate on the root directory inode. */
#define XFS_BULK_IREQ_SPECIAL_ROOT

/*
 * ioctl structures for v5 bulkstat and inumbers requests
 */
struct xfs_bulkstat_req {};
#define XFS_BULKSTAT_REQ_SIZE(nr)

struct xfs_inumbers_req {};
#define XFS_INUMBERS_REQ_SIZE(nr)

/*
 * Error injection.
 */
xfs_error_injection_t;


/*
 * Speculative preallocation trimming.
 */
#define XFS_EOFBLOCKS_VERSION
struct xfs_fs_eofblocks {};

/* eof_flags values */
#define XFS_EOF_FLAGS_SYNC
#define XFS_EOF_FLAGS_UID
#define XFS_EOF_FLAGS_GID
#define XFS_EOF_FLAGS_PRID
#define XFS_EOF_FLAGS_MINFILESIZE
#define XFS_EOF_FLAGS_UNION
#define XFS_EOF_FLAGS_VALID


/*
 * The user-level Handle Request interface structure.
 */
xfs_fsop_handlereq_t;

/*
 * Compound structures for passing args through Handle Request interfaces
 * xfs_attrlist_by_handle, xfs_attrmulti_by_handle
 * - ioctls: XFS_IOC_ATTRLIST_BY_HANDLE, and XFS_IOC_ATTRMULTI_BY_HANDLE
 */

/*
 * Flags passed in xfs_attr_multiop.am_flags for the attr ioctl interface.
 *
 * NOTE: Must match the values declared in libattr without the XFS_IOC_ prefix.
 */
#define XFS_IOC_ATTR_ROOT
#define XFS_IOC_ATTR_SECURE
#define XFS_IOC_ATTR_CREATE
#define XFS_IOC_ATTR_REPLACE

xfs_attrlist_cursor_t;

/*
 * Define how lists of attribute names are returned to userspace from the
 * XFS_IOC_ATTRLIST_BY_HANDLE ioctl.  struct xfs_attrlist is the header at the
 * beginning of the returned buffer, and a each entry in al_offset contains the
 * relative offset of an xfs_attrlist_ent containing the actual entry.
 *
 * NOTE: struct xfs_attrlist must match struct attrlist defined in libattr, and
 * struct xfs_attrlist_ent must match struct attrlist_ent defined in libattr.
 */
struct xfs_attrlist {};

struct xfs_attrlist_ent {};

xfs_fsop_attrlist_handlereq_t;

xfs_attr_multiop_t;

xfs_fsop_attrmulti_handlereq_t;

/*
 * per machine unique filesystem identifier types.
 */
xfs_fsid_t;

xfs_fid_t;

xfs_handle_t;
#define ha_fsid

/*
 * Structure passed to XFS_IOC_SWAPEXT
 */
xfs_swapext_t;

/*
 * Flags for going down operation
 */
#define XFS_FSOP_GOING_FLAGS_DEFAULT
#define XFS_FSOP_GOING_FLAGS_LOGFLUSH
#define XFS_FSOP_GOING_FLAGS_NOLOGFLUSH

/* metadata scrubbing */
struct xfs_scrub_metadata {};

/*
 * Metadata types and flags for scrub operation.
 */

/* Scrub subcommands. */
#define XFS_SCRUB_TYPE_PROBE
#define XFS_SCRUB_TYPE_SB
#define XFS_SCRUB_TYPE_AGF
#define XFS_SCRUB_TYPE_AGFL
#define XFS_SCRUB_TYPE_AGI
#define XFS_SCRUB_TYPE_BNOBT
#define XFS_SCRUB_TYPE_CNTBT
#define XFS_SCRUB_TYPE_INOBT
#define XFS_SCRUB_TYPE_FINOBT
#define XFS_SCRUB_TYPE_RMAPBT
#define XFS_SCRUB_TYPE_REFCNTBT
#define XFS_SCRUB_TYPE_INODE
#define XFS_SCRUB_TYPE_BMBTD
#define XFS_SCRUB_TYPE_BMBTA
#define XFS_SCRUB_TYPE_BMBTC
#define XFS_SCRUB_TYPE_DIR
#define XFS_SCRUB_TYPE_XATTR
#define XFS_SCRUB_TYPE_SYMLINK
#define XFS_SCRUB_TYPE_PARENT
#define XFS_SCRUB_TYPE_RTBITMAP
#define XFS_SCRUB_TYPE_RTSUM
#define XFS_SCRUB_TYPE_UQUOTA
#define XFS_SCRUB_TYPE_GQUOTA
#define XFS_SCRUB_TYPE_PQUOTA
#define XFS_SCRUB_TYPE_FSCOUNTERS
#define XFS_SCRUB_TYPE_QUOTACHECK
#define XFS_SCRUB_TYPE_NLINKS
#define XFS_SCRUB_TYPE_HEALTHY
#define XFS_SCRUB_TYPE_DIRTREE

/* Number of scrub subcommands. */
#define XFS_SCRUB_TYPE_NR

/*
 * This special type code only applies to the vectored scrub implementation.
 *
 * If any of the previous scrub vectors recorded runtime errors or have
 * sv_flags bits set that match the OFLAG bits in the barrier vector's
 * sv_flags, set the barrier's sv_ret to -ECANCELED and return to userspace.
 */
#define XFS_SCRUB_TYPE_BARRIER

/* i: Repair this metadata. */
#define XFS_SCRUB_IFLAG_REPAIR

/* o: Metadata object needs repair. */
#define XFS_SCRUB_OFLAG_CORRUPT

/*
 * o: Metadata object could be optimized.  It's not corrupt, but
 *    we could improve on it somehow.
 */
#define XFS_SCRUB_OFLAG_PREEN

/* o: Cross-referencing failed. */
#define XFS_SCRUB_OFLAG_XFAIL

/* o: Metadata object disagrees with cross-referenced metadata. */
#define XFS_SCRUB_OFLAG_XCORRUPT

/* o: Scan was not complete. */
#define XFS_SCRUB_OFLAG_INCOMPLETE

/* o: Metadata object looked funny but isn't corrupt. */
#define XFS_SCRUB_OFLAG_WARNING

/*
 * o: IFLAG_REPAIR was set but metadata object did not need fixing or
 *    optimization and has therefore not been altered.
 */
#define XFS_SCRUB_OFLAG_NO_REPAIR_NEEDED

/* i: Rebuild the data structure. */
#define XFS_SCRUB_IFLAG_FORCE_REBUILD

#define XFS_SCRUB_FLAGS_IN
#define XFS_SCRUB_FLAGS_OUT
#define XFS_SCRUB_FLAGS_ALL

/* Vectored scrub calls to reduce the number of kernel transitions. */

struct xfs_scrub_vec {};

/* Vectored metadata scrub control structure. */
struct xfs_scrub_vec_head {};

#define XFS_SCRUB_VEC_FLAGS_ALL

/*
 * ioctl limits
 */
#ifdef XATTR_LIST_MAX
#define XFS_XATTR_LIST_MAX
#else
#define XFS_XATTR_LIST_MAX
#endif

/*
 * Exchange part of file1 with part of the file that this ioctl that is being
 * called against (which we'll call file2).  Filesystems must be able to
 * restart and complete the operation even after the system goes down.
 */
struct xfs_exchange_range {};

/*
 * Using the same definition of file2 as struct xfs_exchange_range, commit the
 * contents of file1 into file2 if file2 has the same inode number, mtime, and
 * ctime as the arguments provided to the call.  The old contents of file2 will
 * be moved to file1.
 *
 * Returns -EBUSY if there isn't an exact match for the file2 fields.
 *
 * Filesystems must be able to restart and complete the operation even after
 * the system goes down.
 */
struct xfs_commit_range {};

/*
 * Exchange file data all the way to the ends of both files, and then exchange
 * the file sizes.  This flag can be used to replace a file's contents with a
 * different amount of data.  length will be ignored.
 */
#define XFS_EXCHANGE_RANGE_TO_EOF

/* Flush all changes in file data and file metadata to disk before returning. */
#define XFS_EXCHANGE_RANGE_DSYNC

/* Dry run; do all the parameter verification but do not change anything. */
#define XFS_EXCHANGE_RANGE_DRY_RUN

/*
 * Exchange only the parts of the two files where the file allocation units
 * mapped to file1's range have been written to.  This can accelerate
 * scatter-gather atomic writes with a temp file if all writes are aligned to
 * the file allocation unit.
 */
#define XFS_EXCHANGE_RANGE_FILE1_WRITTEN

#define XFS_EXCHANGE_RANGE_ALL_FLAGS

/* Iterating parent pointers of files. */

/* target was the root directory */
#define XFS_GETPARENTS_OFLAG_ROOT

/* Cursor is done iterating pptrs */
#define XFS_GETPARENTS_OFLAG_DONE

#define XFS_GETPARENTS_OFLAGS_ALL

#define XFS_GETPARENTS_IFLAGS_ALL

struct xfs_getparents_rec {};

/* Iterate through this file's directory parent pointers */
struct xfs_getparents {};

static inline struct xfs_getparents_rec *
xfs_getparents_first_rec(struct xfs_getparents *gp)
{}

static inline struct xfs_getparents_rec *
xfs_getparents_next_rec(struct xfs_getparents *gp,
			struct xfs_getparents_rec *gpr)
{}

/* Iterate through this file handle's directory parent pointers. */
struct xfs_getparents_by_handle {};

/*
 * ioctl commands that are used by Linux filesystems
 */
#define XFS_IOC_GETXFLAGS
#define XFS_IOC_SETXFLAGS
#define XFS_IOC_GETVERSION

/*
 * ioctl commands that replace IRIX fcntl()'s
 * For 'documentation' purposed more than anything else,
 * the "cmd #" field reflects the IRIX fcntl number.
 */
/*	XFS_IOC_ALLOCSP ------- deprecated 10	 */
/*	XFS_IOC_FREESP -------- deprecated 11	 */
#define XFS_IOC_DIOINFO
#define XFS_IOC_FSGETXATTR
#define XFS_IOC_FSSETXATTR
/*	XFS_IOC_ALLOCSP64 ----- deprecated 36	 */
/*	XFS_IOC_FREESP64 ------ deprecated 37	 */
#define XFS_IOC_GETBMAP
/*      XFS_IOC_FSSETDM ------- deprecated 39    */
#define XFS_IOC_RESVSP
#define XFS_IOC_UNRESVSP
#define XFS_IOC_RESVSP64
#define XFS_IOC_UNRESVSP64
#define XFS_IOC_GETBMAPA
#define XFS_IOC_FSGETXATTRA
/*	XFS_IOC_SETBIOSIZE ---- deprecated 46	   */
/*	XFS_IOC_GETBIOSIZE ---- deprecated 47	   */
#define XFS_IOC_GETBMAPX
#define XFS_IOC_ZERO_RANGE
#define XFS_IOC_FREE_EOFBLOCKS
/*	XFS_IOC_GETFSMAP ------ hoisted 59         */
#define XFS_IOC_SCRUB_METADATA
#define XFS_IOC_AG_GEOMETRY
#define XFS_IOC_GETPARENTS
#define XFS_IOC_GETPARENTS_BY_HANDLE
#define XFS_IOC_SCRUBV_METADATA

/*
 * ioctl commands that replace IRIX syssgi()'s
 */
#define XFS_IOC_FSGEOMETRY_V1
#define XFS_IOC_FSBULKSTAT
#define XFS_IOC_FSBULKSTAT_SINGLE
#define XFS_IOC_FSINUMBERS
#define XFS_IOC_PATH_TO_FSHANDLE
#define XFS_IOC_PATH_TO_HANDLE
#define XFS_IOC_FD_TO_HANDLE
#define XFS_IOC_OPEN_BY_HANDLE
#define XFS_IOC_READLINK_BY_HANDLE
#define XFS_IOC_SWAPEXT
#define XFS_IOC_FSGROWFSDATA
#define XFS_IOC_FSGROWFSLOG
#define XFS_IOC_FSGROWFSRT
#define XFS_IOC_FSCOUNTS
#define XFS_IOC_SET_RESBLKS
#define XFS_IOC_GET_RESBLKS
#define XFS_IOC_ERROR_INJECTION
#define XFS_IOC_ERROR_CLEARALL
/*	XFS_IOC_ATTRCTL_BY_HANDLE -- deprecated 118	 */

#define XFS_IOC_FREEZE
#define XFS_IOC_THAW

/*      XFS_IOC_FSSETDM_BY_HANDLE -- deprecated 121      */
#define XFS_IOC_ATTRLIST_BY_HANDLE
#define XFS_IOC_ATTRMULTI_BY_HANDLE
#define XFS_IOC_FSGEOMETRY_V4
#define XFS_IOC_GOINGDOWN
#define XFS_IOC_FSGEOMETRY
#define XFS_IOC_BULKSTAT
#define XFS_IOC_INUMBERS
#define XFS_IOC_EXCHANGE_RANGE
#define XFS_IOC_START_COMMIT
#define XFS_IOC_COMMIT_RANGE
/*	XFS_IOC_GETFSUUID ---------- deprecated 140	 */


#ifndef HAVE_BBMACROS
/*
 * Block I/O parameterization.	A basic block (BB) is the lowest size of
 * filesystem allocation, and must equal 512.  Length units given to bio
 * routines are in BB's.
 */
#define BBSHIFT
#define BBSIZE
#define BBMASK
#define BTOBB(bytes)
#define BTOBBT(bytes)
#define BBTOB(bbs)
#endif

#endif	/* __XFS_FS_H__ */