xref: /linux/include/uapi/linux/fiemap.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
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 <mfasheh@suse.com>
8607ca46eSDavid Howells  *          Kalpak Shah <kalpak.shah@sun.com>
9607ca46eSDavid Howells  *          Andreas Dilger <adilger@sun.com>
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 
17607ca46eSDavid Howells struct fiemap_extent {
18607ca46eSDavid Howells 	__u64 fe_logical;  /* logical offset in bytes for the start of
19607ca46eSDavid Howells 			    * the extent from the beginning of the file */
20607ca46eSDavid Howells 	__u64 fe_physical; /* physical offset in bytes for the start
21607ca46eSDavid Howells 			    * of the extent from the beginning of the disk */
22607ca46eSDavid Howells 	__u64 fe_length;   /* length in bytes for this extent */
23607ca46eSDavid Howells 	__u64 fe_reserved64[2];
24607ca46eSDavid Howells 	__u32 fe_flags;    /* FIEMAP_EXTENT_* flags for this extent */
25607ca46eSDavid Howells 	__u32 fe_reserved[3];
26607ca46eSDavid Howells };
27607ca46eSDavid Howells 
28607ca46eSDavid Howells struct fiemap {
29607ca46eSDavid Howells 	__u64 fm_start;		/* logical offset (inclusive) at
30607ca46eSDavid Howells 				 * which to start mapping (in) */
31607ca46eSDavid Howells 	__u64 fm_length;	/* logical length of mapping which
32607ca46eSDavid Howells 				 * userspace wants (in) */
33607ca46eSDavid Howells 	__u32 fm_flags;		/* FIEMAP_FLAG_* flags for request (in/out) */
34607ca46eSDavid Howells 	__u32 fm_mapped_extents;/* number of extents that were mapped (out) */
35607ca46eSDavid Howells 	__u32 fm_extent_count;  /* size of fm_extents array (in) */
36607ca46eSDavid Howells 	__u32 fm_reserved;
37*94dfc73eSGustavo A. R. Silva 	struct fiemap_extent fm_extents[]; /* array of mapped extents (out) */
38607ca46eSDavid Howells };
39607ca46eSDavid Howells 
40607ca46eSDavid Howells #define FIEMAP_MAX_OFFSET	(~0ULL)
41607ca46eSDavid Howells 
42607ca46eSDavid Howells #define FIEMAP_FLAG_SYNC	0x00000001 /* sync file data before map */
43607ca46eSDavid Howells #define FIEMAP_FLAG_XATTR	0x00000002 /* map extended attribute tree */
447869a4a6STheodore Ts'o #define FIEMAP_FLAG_CACHE	0x00000004 /* request caching of the extents */
45607ca46eSDavid Howells 
46607ca46eSDavid Howells #define FIEMAP_FLAGS_COMPAT	(FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR)
47607ca46eSDavid Howells 
48607ca46eSDavid Howells #define FIEMAP_EXTENT_LAST		0x00000001 /* Last extent in file. */
49607ca46eSDavid Howells #define FIEMAP_EXTENT_UNKNOWN		0x00000002 /* Data location unknown. */
50607ca46eSDavid Howells #define FIEMAP_EXTENT_DELALLOC		0x00000004 /* Location still pending.
51607ca46eSDavid Howells 						    * Sets EXTENT_UNKNOWN. */
52607ca46eSDavid Howells #define FIEMAP_EXTENT_ENCODED		0x00000008 /* Data can not be read
53607ca46eSDavid Howells 						    * while fs is unmounted */
54607ca46eSDavid Howells #define FIEMAP_EXTENT_DATA_ENCRYPTED	0x00000080 /* Data is encrypted by fs.
55607ca46eSDavid Howells 						    * Sets EXTENT_NO_BYPASS. */
56607ca46eSDavid Howells #define FIEMAP_EXTENT_NOT_ALIGNED	0x00000100 /* Extent offsets may not be
57607ca46eSDavid Howells 						    * block aligned. */
58607ca46eSDavid Howells #define FIEMAP_EXTENT_DATA_INLINE	0x00000200 /* Data mixed with metadata.
59607ca46eSDavid Howells 						    * Sets EXTENT_NOT_ALIGNED.*/
60607ca46eSDavid Howells #define FIEMAP_EXTENT_DATA_TAIL		0x00000400 /* Multiple files in block.
61607ca46eSDavid Howells 						    * Sets EXTENT_NOT_ALIGNED.*/
62607ca46eSDavid Howells #define FIEMAP_EXTENT_UNWRITTEN		0x00000800 /* Space allocated, but
63607ca46eSDavid Howells 						    * no data (i.e. zero). */
64607ca46eSDavid Howells #define FIEMAP_EXTENT_MERGED		0x00001000 /* File does not natively
65607ca46eSDavid Howells 						    * support extents. Result
66607ca46eSDavid Howells 						    * merged for efficiency. */
67607ca46eSDavid Howells #define FIEMAP_EXTENT_SHARED		0x00002000 /* Space shared with other
68607ca46eSDavid Howells 						    * files. */
69607ca46eSDavid Howells 
7010c5db28SChristoph Hellwig #endif /* _UAPI_LINUX_FIEMAP_H */
71