/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _UAPI_LINUX_FS_H #define _UAPI_LINUX_FS_H /* * This file has definitions for some important file table structures * and constants and structures used by various generic file system * ioctl's. Please do not make any changes in this file before * sending patches for review to [email protected] and * [email protected]. */ #include <linux/limits.h> #include <linux/ioctl.h> #include <linux/types.h> #ifndef __KERNEL__ #include <linux/fscrypt.h> #endif /* Use of MS_* flags within the kernel is restricted to core mount(2) code. */ #if !defined(__KERNEL__) #include <linux/mount.h> #endif /* * It's silly to have NR_OPEN bigger than NR_FILE, but you can change * the file limit at runtime and only root can increase the per-process * nr_file rlimit, so it's safe to set up a ridiculously high absolute * upper limit on files-per-process. * * Some programs (notably those using select()) may have to be * recompiled to take full advantage of the new limits.. */ /* Fixed constants first: */ #undef NR_OPEN #define INR_OPEN_CUR … #define INR_OPEN_MAX … #define BLOCK_SIZE_BITS … #define BLOCK_SIZE … #define SEEK_SET … #define SEEK_CUR … #define SEEK_END … #define SEEK_DATA … #define SEEK_HOLE … #define SEEK_MAX … #define RENAME_NOREPLACE … #define RENAME_EXCHANGE … #define RENAME_WHITEOUT … struct file_clone_range { … }; struct fstrim_range { … }; /* * We include a length field because some filesystems (vfat) have an identifier * that we do want to expose as a UUID, but doesn't have the standard length. * * We use a fixed size buffer beacuse this interface will, by fiat, never * support "UUIDs" longer than 16 bytes; we don't want to force all downstream * users to have to deal with that. */ struct fsuuid2 { … }; struct fs_sysfs_path { … }; /* extent-same (dedupe) ioctls; these MUST match the btrfs ioctl definitions */ #define FILE_DEDUPE_RANGE_SAME … #define FILE_DEDUPE_RANGE_DIFFERS … /* from struct btrfs_ioctl_file_extent_same_info */ struct file_dedupe_range_info { … }; /* from struct btrfs_ioctl_file_extent_same_args */ struct file_dedupe_range { … }; /* And dynamically-tunable limits and defaults: */ struct files_stat_struct { … }; struct inodes_stat_t { … }; #define NR_FILE … /* * Structure for FS_IOC_FSGETXATTR[A] and FS_IOC_FSSETXATTR. */ struct fsxattr { … }; /* * Flags for the fsx_xflags field */ #define FS_XFLAG_REALTIME … #define FS_XFLAG_PREALLOC … #define FS_XFLAG_IMMUTABLE … #define FS_XFLAG_APPEND … #define FS_XFLAG_SYNC … #define FS_XFLAG_NOATIME … #define FS_XFLAG_NODUMP … #define FS_XFLAG_RTINHERIT … #define FS_XFLAG_PROJINHERIT … #define FS_XFLAG_NOSYMLINKS … #define FS_XFLAG_EXTSIZE … #define FS_XFLAG_EXTSZINHERIT … #define FS_XFLAG_NODEFRAG … #define FS_XFLAG_FILESTREAM … #define FS_XFLAG_DAX … #define FS_XFLAG_COWEXTSIZE … #define FS_XFLAG_HASATTR … /* the read-only stuff doesn't really belong here, but any other place is probably as bad and I don't want to create yet another include file. */ #define BLKROSET … #define BLKROGET … #define BLKRRPART … #define BLKGETSIZE … #define BLKFLSBUF … #define BLKRASET … #define BLKRAGET … #define BLKFRASET … #define BLKFRAGET … #define BLKSECTSET … #define BLKSECTGET … #define BLKSSZGET … #if 0 #define BLKPG … /* Some people are morons. Do not use sizeof! */ #define BLKELVGET … #define BLKELVSET … /* This was here just to show that the number is taken - probably all these _IO(0x12,*) ioctls should be moved to blkpg.h. */ #endif /* A jump here: 108-111 have been used for various private purposes. */ #define BLKBSZGET … #define BLKBSZSET … #define BLKGETSIZE64 … #define BLKTRACESETUP … #define BLKTRACESTART … #define BLKTRACESTOP … #define BLKTRACETEARDOWN … #define BLKDISCARD … #define BLKIOMIN … #define BLKIOOPT … #define BLKALIGNOFF … #define BLKPBSZGET … #define BLKDISCARDZEROES … #define BLKSECDISCARD … #define BLKROTATIONAL … #define BLKZEROOUT … #define BLKGETDISKSEQ … /* * A jump here: 130-136 are reserved for zoned block devices * (see uapi/linux/blkzoned.h) */ #define BMAP_IOCTL … #define FIBMAP … #define FIGETBSZ … #define FIFREEZE … #define FITHAW … #define FITRIM … #define FICLONE … #define FICLONERANGE … #define FIDEDUPERANGE … #define FSLABEL_MAX … #define FS_IOC_GETFLAGS … #define FS_IOC_SETFLAGS … #define FS_IOC_GETVERSION … #define FS_IOC_SETVERSION … #define FS_IOC_FIEMAP … #define FS_IOC32_GETFLAGS … #define FS_IOC32_SETFLAGS … #define FS_IOC32_GETVERSION … #define FS_IOC32_SETVERSION … #define FS_IOC_FSGETXATTR … #define FS_IOC_FSSETXATTR … #define FS_IOC_GETFSLABEL … #define FS_IOC_SETFSLABEL … /* Returns the external filesystem UUID, the same one blkid returns */ #define FS_IOC_GETFSUUID … /* * Returns the path component under /sys/fs/ that refers to this filesystem; * also /sys/kernel/debug/ for filesystems with debugfs exports */ #define FS_IOC_GETFSSYSFSPATH … /* * Inode flags (FS_IOC_GETFLAGS / FS_IOC_SETFLAGS) * * Note: for historical reasons, these flags were originally used and * defined for use by ext2/ext3, and then other file systems started * using these flags so they wouldn't need to write their own version * of chattr/lsattr (which was shipped as part of e2fsprogs). You * should think twice before trying to use these flags in new * contexts, or trying to assign these flags, since they are used both * as the UAPI and the on-disk encoding for ext2/3/4. Also, we are * almost out of 32-bit flags. :-) * * We have recently hoisted FS_IOC_FSGETXATTR / FS_IOC_FSSETXATTR from * XFS to the generic FS level interface. This uses a structure that * has padding and hence has more room to grow, so it may be more * appropriate for many new use cases. * * Please do not change these flags or interfaces before checking with * [email protected] and [email protected]. */ #define FS_SECRM_FL … #define FS_UNRM_FL … #define FS_COMPR_FL … #define FS_SYNC_FL … #define FS_IMMUTABLE_FL … #define FS_APPEND_FL … #define FS_NODUMP_FL … #define FS_NOATIME_FL … /* Reserved for compression usage... */ #define FS_DIRTY_FL … #define FS_COMPRBLK_FL … #define FS_NOCOMP_FL … /* End compression flags --- maybe not all used */ #define FS_ENCRYPT_FL … #define FS_BTREE_FL … #define FS_INDEX_FL … #define FS_IMAGIC_FL … #define FS_JOURNAL_DATA_FL … #define FS_NOTAIL_FL … #define FS_DIRSYNC_FL … #define FS_TOPDIR_FL … #define FS_HUGE_FILE_FL … #define FS_EXTENT_FL … #define FS_VERITY_FL … #define FS_EA_INODE_FL … #define FS_EOFBLOCKS_FL … #define FS_NOCOW_FL … #define FS_DAX_FL … #define FS_INLINE_DATA_FL … #define FS_PROJINHERIT_FL … #define FS_CASEFOLD_FL … #define FS_RESERVED_FL … #define FS_FL_USER_VISIBLE … #define FS_FL_USER_MODIFIABLE … #define SYNC_FILE_RANGE_WAIT_BEFORE … #define SYNC_FILE_RANGE_WRITE … #define SYNC_FILE_RANGE_WAIT_AFTER … #define SYNC_FILE_RANGE_WRITE_AND_WAIT … /* * Flags for preadv2/pwritev2: */ __kernel_rwf_t; /* high priority request, poll if possible */ #define RWF_HIPRI … /* per-IO O_DSYNC */ #define RWF_DSYNC … /* per-IO O_SYNC */ #define RWF_SYNC … /* per-IO, return -EAGAIN if operation would block */ #define RWF_NOWAIT … /* per-IO O_APPEND */ #define RWF_APPEND … /* per-IO negation of O_APPEND */ #define RWF_NOAPPEND … /* Atomic Write */ #define RWF_ATOMIC … /* mask of flags supported by the kernel */ #define RWF_SUPPORTED … #define PROCFS_IOCTL_MAGIC … /* Pagemap ioctl */ #define PAGEMAP_SCAN … /* Bitmasks provided in pm_scan_args masks and reported in page_region.categories. */ #define PAGE_IS_WPALLOWED … #define PAGE_IS_WRITTEN … #define PAGE_IS_FILE … #define PAGE_IS_PRESENT … #define PAGE_IS_SWAPPED … #define PAGE_IS_PFNZERO … #define PAGE_IS_HUGE … #define PAGE_IS_SOFT_DIRTY … /* * struct page_region - Page region with flags * @start: Start of the region * @end: End of the region (exclusive) * @categories: PAGE_IS_* category bitmask for the region */ struct page_region { … }; /* Flags for PAGEMAP_SCAN ioctl */ #define PM_SCAN_WP_MATCHING … #define PM_SCAN_CHECK_WPASYNC … /* * struct pm_scan_arg - Pagemap ioctl argument * @size: Size of the structure * @flags: Flags for the IOCTL * @start: Starting address of the region * @end: Ending address of the region * @walk_end Address where the scan stopped (written by kernel). * walk_end == end (address tags cleared) informs that the scan completed on entire range. * @vec: Address of page_region struct array for output * @vec_len: Length of the page_region struct array * @max_pages: Optional limit for number of returned pages (0 = disabled) * @category_inverted: PAGE_IS_* categories which values match if 0 instead of 1 * @category_mask: Skip pages for which any category doesn't match * @category_anyof_mask: Skip pages for which no category matches * @return_mask: PAGE_IS_* categories that are to be reported in `page_region`s returned */ struct pm_scan_arg { … }; /* /proc/<pid>/maps ioctl */ #define PROCMAP_QUERY … enum procmap_query_flags { … }; /* * Input/output argument structured passed into ioctl() call. It can be used * to query a set of VMAs (Virtual Memory Areas) of a process. * * Each field can be one of three kinds, marked in a short comment to the * right of the field: * - "in", input argument, user has to provide this value, kernel doesn't modify it; * - "out", output argument, kernel sets this field with VMA data; * - "in/out", input and output argument; user provides initial value (used * to specify maximum allowable buffer size), and kernel sets it to actual * amount of data written (or zero, if there is no data). * * If matching VMA is found (according to criterias specified by * query_addr/query_flags, all the out fields are filled out, and ioctl() * returns 0. If there is no matching VMA, -ENOENT will be returned. * In case of any other error, negative error code other than -ENOENT is * returned. * * Most of the data is similar to the one returned as text in /proc/<pid>/maps * file, but procmap_query provides more querying flexibility. There are no * consistency guarantees between subsequent ioctl() calls, but data returned * for matched VMA is self-consistent. */ struct procmap_query { … }; #endif /* _UAPI_LINUX_FS_H */