1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * FS_IOC_FIEMAP ioctl infrastructure. 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * Some portions copyright (C) 2007 Cluster File Systems, Inc 6*4882a593Smuzhiyun * 7*4882a593Smuzhiyun * Authors: Mark Fasheh <mfasheh@suse.com> 8*4882a593Smuzhiyun * Kalpak Shah <kalpak.shah@sun.com> 9*4882a593Smuzhiyun * Andreas Dilger <adilger@sun.com> 10*4882a593Smuzhiyun */ 11*4882a593Smuzhiyun 12*4882a593Smuzhiyun #ifndef _UAPI_LINUX_FIEMAP_H 13*4882a593Smuzhiyun #define _UAPI_LINUX_FIEMAP_H 14*4882a593Smuzhiyun 15*4882a593Smuzhiyun #include <linux/types.h> 16*4882a593Smuzhiyun 17*4882a593Smuzhiyun struct fiemap_extent { 18*4882a593Smuzhiyun __u64 fe_logical; /* logical offset in bytes for the start of 19*4882a593Smuzhiyun * the extent from the beginning of the file */ 20*4882a593Smuzhiyun __u64 fe_physical; /* physical offset in bytes for the start 21*4882a593Smuzhiyun * of the extent from the beginning of the disk */ 22*4882a593Smuzhiyun __u64 fe_length; /* length in bytes for this extent */ 23*4882a593Smuzhiyun __u64 fe_reserved64[2]; 24*4882a593Smuzhiyun __u32 fe_flags; /* FIEMAP_EXTENT_* flags for this extent */ 25*4882a593Smuzhiyun __u32 fe_reserved[3]; 26*4882a593Smuzhiyun }; 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun struct fiemap { 29*4882a593Smuzhiyun __u64 fm_start; /* logical offset (inclusive) at 30*4882a593Smuzhiyun * which to start mapping (in) */ 31*4882a593Smuzhiyun __u64 fm_length; /* logical length of mapping which 32*4882a593Smuzhiyun * userspace wants (in) */ 33*4882a593Smuzhiyun __u32 fm_flags; /* FIEMAP_FLAG_* flags for request (in/out) */ 34*4882a593Smuzhiyun __u32 fm_mapped_extents;/* number of extents that were mapped (out) */ 35*4882a593Smuzhiyun __u32 fm_extent_count; /* size of fm_extents array (in) */ 36*4882a593Smuzhiyun __u32 fm_reserved; 37*4882a593Smuzhiyun struct fiemap_extent fm_extents[0]; /* array of mapped extents (out) */ 38*4882a593Smuzhiyun }; 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun #define FIEMAP_MAX_OFFSET (~0ULL) 41*4882a593Smuzhiyun 42*4882a593Smuzhiyun #define FIEMAP_FLAG_SYNC 0x00000001 /* sync file data before map */ 43*4882a593Smuzhiyun #define FIEMAP_FLAG_XATTR 0x00000002 /* map extended attribute tree */ 44*4882a593Smuzhiyun #define FIEMAP_FLAG_CACHE 0x00000004 /* request caching of the extents */ 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun #define FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR) 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun #define FIEMAP_EXTENT_LAST 0x00000001 /* Last extent in file. */ 49*4882a593Smuzhiyun #define FIEMAP_EXTENT_UNKNOWN 0x00000002 /* Data location unknown. */ 50*4882a593Smuzhiyun #define FIEMAP_EXTENT_DELALLOC 0x00000004 /* Location still pending. 51*4882a593Smuzhiyun * Sets EXTENT_UNKNOWN. */ 52*4882a593Smuzhiyun #define FIEMAP_EXTENT_ENCODED 0x00000008 /* Data can not be read 53*4882a593Smuzhiyun * while fs is unmounted */ 54*4882a593Smuzhiyun #define FIEMAP_EXTENT_DATA_ENCRYPTED 0x00000080 /* Data is encrypted by fs. 55*4882a593Smuzhiyun * Sets EXTENT_NO_BYPASS. */ 56*4882a593Smuzhiyun #define FIEMAP_EXTENT_NOT_ALIGNED 0x00000100 /* Extent offsets may not be 57*4882a593Smuzhiyun * block aligned. */ 58*4882a593Smuzhiyun #define FIEMAP_EXTENT_DATA_INLINE 0x00000200 /* Data mixed with metadata. 59*4882a593Smuzhiyun * Sets EXTENT_NOT_ALIGNED.*/ 60*4882a593Smuzhiyun #define FIEMAP_EXTENT_DATA_TAIL 0x00000400 /* Multiple files in block. 61*4882a593Smuzhiyun * Sets EXTENT_NOT_ALIGNED.*/ 62*4882a593Smuzhiyun #define FIEMAP_EXTENT_UNWRITTEN 0x00000800 /* Space allocated, but 63*4882a593Smuzhiyun * no data (i.e. zero). */ 64*4882a593Smuzhiyun #define FIEMAP_EXTENT_MERGED 0x00001000 /* File does not natively 65*4882a593Smuzhiyun * support extents. Result 66*4882a593Smuzhiyun * merged for efficiency. */ 67*4882a593Smuzhiyun #define FIEMAP_EXTENT_SHARED 0x00002000 /* Space shared with other 68*4882a593Smuzhiyun * files. */ 69*4882a593Smuzhiyun 70*4882a593Smuzhiyun #endif /* _UAPI_LINUX_FIEMAP_H */ 71