16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2607ca46eSDavid Howells /* 3607ca46eSDavid Howells * FS_IOC_FIEMAP ioctl infrastructure. 4607ca46eSDavid Howells * 5607ca46eSDavid Howells * Some portions copyright (C) 2007 Cluster File Systems, Inc 6607ca46eSDavid Howells * 7607ca46eSDavid Howells * Authors: Mark Fasheh <[email protected]> 8607ca46eSDavid Howells * Kalpak Shah <[email protected]> 9607ca46eSDavid Howells * Andreas Dilger <[email protected]> 10607ca46eSDavid Howells */ 11607ca46eSDavid Howells 1210c5db28SChristoph Hellwig #ifndef _UAPI_LINUX_FIEMAP_H 1310c5db28SChristoph Hellwig #define _UAPI_LINUX_FIEMAP_H 14607ca46eSDavid Howells 15607ca46eSDavid Howells #include <linux/types.h> 16607ca46eSDavid Howells 17*135ec43eSRandy Dunlap /** 18*135ec43eSRandy Dunlap * struct fiemap_extent - description of one fiemap extent 19*135ec43eSRandy Dunlap * @fe_logical: byte offset of the extent in the file 20*135ec43eSRandy Dunlap * @fe_physical: byte offset of extent on disk 21*135ec43eSRandy Dunlap * @fe_length: length in bytes for this extent 22*135ec43eSRandy Dunlap * @fe_flags: FIEMAP_EXTENT_* flags for this extent 23*135ec43eSRandy Dunlap */ 24607ca46eSDavid Howells struct fiemap_extent { 25*135ec43eSRandy Dunlap __u64 fe_logical; 26*135ec43eSRandy Dunlap __u64 fe_physical; 27*135ec43eSRandy Dunlap __u64 fe_length; 28*135ec43eSRandy Dunlap /* private: */ 29607ca46eSDavid Howells __u64 fe_reserved64[2]; 30*135ec43eSRandy Dunlap /* public: */ 31*135ec43eSRandy Dunlap __u32 fe_flags; 32*135ec43eSRandy Dunlap /* private: */ 33607ca46eSDavid Howells __u32 fe_reserved[3]; 34607ca46eSDavid Howells }; 35607ca46eSDavid Howells 36*135ec43eSRandy Dunlap /** 37*135ec43eSRandy Dunlap * struct fiemap - file extent mappings 38*135ec43eSRandy Dunlap * @fm_start: byte offset (inclusive) at which to start mapping (in) 39*135ec43eSRandy Dunlap * @fm_length: logical length of mapping which userspace wants (in) 40*135ec43eSRandy Dunlap * @fm_flags: FIEMAP_FLAG_* flags for request (in/out) 41*135ec43eSRandy Dunlap * @fm_mapped_extents: number of extents that were mapped (out) 42*135ec43eSRandy Dunlap * @fm_extent_count: size of fm_extents array (in) 43*135ec43eSRandy Dunlap * @fm_extents: array of mapped extents (out) 44*135ec43eSRandy Dunlap */ 45607ca46eSDavid Howells struct fiemap { 46*135ec43eSRandy Dunlap __u64 fm_start; 47*135ec43eSRandy Dunlap __u64 fm_length; 48*135ec43eSRandy Dunlap __u32 fm_flags; 49*135ec43eSRandy Dunlap __u32 fm_mapped_extents; 50*135ec43eSRandy Dunlap __u32 fm_extent_count; 51*135ec43eSRandy Dunlap /* private: */ 52607ca46eSDavid Howells __u32 fm_reserved; 53*135ec43eSRandy Dunlap /* public: */ 54*135ec43eSRandy Dunlap struct fiemap_extent fm_extents[]; 55607ca46eSDavid Howells }; 56607ca46eSDavid Howells 57607ca46eSDavid Howells #define FIEMAP_MAX_OFFSET (~0ULL) 58607ca46eSDavid Howells 59*135ec43eSRandy Dunlap /* flags used in fm_flags: */ 60607ca46eSDavid Howells #define FIEMAP_FLAG_SYNC 0x00000001 /* sync file data before map */ 61607ca46eSDavid Howells #define FIEMAP_FLAG_XATTR 0x00000002 /* map extended attribute tree */ 627869a4a6STheodore Ts'o #define FIEMAP_FLAG_CACHE 0x00000004 /* request caching of the extents */ 63607ca46eSDavid Howells 64607ca46eSDavid Howells #define FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR) 65607ca46eSDavid Howells 66*135ec43eSRandy Dunlap /* flags used in fe_flags: */ 67607ca46eSDavid Howells #define FIEMAP_EXTENT_LAST 0x00000001 /* Last extent in file. */ 68607ca46eSDavid Howells #define FIEMAP_EXTENT_UNKNOWN 0x00000002 /* Data location unknown. */ 69607ca46eSDavid Howells #define FIEMAP_EXTENT_DELALLOC 0x00000004 /* Location still pending. 70607ca46eSDavid Howells * Sets EXTENT_UNKNOWN. */ 71607ca46eSDavid Howells #define FIEMAP_EXTENT_ENCODED 0x00000008 /* Data can not be read 72607ca46eSDavid Howells * while fs is unmounted */ 73607ca46eSDavid Howells #define FIEMAP_EXTENT_DATA_ENCRYPTED 0x00000080 /* Data is encrypted by fs. 74607ca46eSDavid Howells * Sets EXTENT_NO_BYPASS. */ 75607ca46eSDavid Howells #define FIEMAP_EXTENT_NOT_ALIGNED 0x00000100 /* Extent offsets may not be 76607ca46eSDavid Howells * block aligned. */ 77607ca46eSDavid Howells #define FIEMAP_EXTENT_DATA_INLINE 0x00000200 /* Data mixed with metadata. 78607ca46eSDavid Howells * Sets EXTENT_NOT_ALIGNED.*/ 79607ca46eSDavid Howells #define FIEMAP_EXTENT_DATA_TAIL 0x00000400 /* Multiple files in block. 80607ca46eSDavid Howells * Sets EXTENT_NOT_ALIGNED.*/ 81607ca46eSDavid Howells #define FIEMAP_EXTENT_UNWRITTEN 0x00000800 /* Space allocated, but 82607ca46eSDavid Howells * no data (i.e. zero). */ 83607ca46eSDavid Howells #define FIEMAP_EXTENT_MERGED 0x00001000 /* File does not natively 84607ca46eSDavid Howells * support extents. Result 85607ca46eSDavid Howells * merged for efficiency. */ 86607ca46eSDavid Howells #define FIEMAP_EXTENT_SHARED 0x00002000 /* Space shared with other 87607ca46eSDavid Howells * files. */ 88607ca46eSDavid Howells 8910c5db28SChristoph Hellwig #endif /* _UAPI_LINUX_FIEMAP_H */ 90