xref: /linux/include/uapi/linux/falloc.h (revision 00f5e61998dd17f5375d9dfc01331f104b83f841)
1607ca46eSDavid Howells #ifndef _UAPI_FALLOC_H_
2607ca46eSDavid Howells #define _UAPI_FALLOC_H_
3607ca46eSDavid Howells 
4607ca46eSDavid Howells #define FALLOC_FL_KEEP_SIZE	0x01 /* default is extend size */
5607ca46eSDavid Howells #define FALLOC_FL_PUNCH_HOLE	0x02 /* de-allocates range */
6607ca46eSDavid Howells #define FALLOC_FL_NO_HIDE_STALE	0x04 /* reserved codepoint */
7607ca46eSDavid Howells 
8*00f5e619SNamjae Jeon /*
9*00f5e619SNamjae Jeon  * FALLOC_FL_COLLAPSE_RANGE is used to remove a range of a file
10*00f5e619SNamjae Jeon  * without leaving a hole in the file. The contents of the file beyond
11*00f5e619SNamjae Jeon  * the range being removed is appended to the start offset of the range
12*00f5e619SNamjae Jeon  * being removed (i.e. the hole that was punched is "collapsed"),
13*00f5e619SNamjae Jeon  * resulting in a file layout that looks like the range that was
14*00f5e619SNamjae Jeon  * removed never existed. As such collapsing a range of a file changes
15*00f5e619SNamjae Jeon  * the size of the file, reducing it by the same length of the range
16*00f5e619SNamjae Jeon  * that has been removed by the operation.
17*00f5e619SNamjae Jeon  *
18*00f5e619SNamjae Jeon  * Different filesystems may implement different limitations on the
19*00f5e619SNamjae Jeon  * granularity of the operation. Most will limit operations to
20*00f5e619SNamjae Jeon  * filesystem block size boundaries, but this boundary may be larger or
21*00f5e619SNamjae Jeon  * smaller depending on the filesystem and/or the configuration of the
22*00f5e619SNamjae Jeon  * filesystem or file.
23*00f5e619SNamjae Jeon  *
24*00f5e619SNamjae Jeon  * Attempting to collapse a range that crosses the end of the file is
25*00f5e619SNamjae Jeon  * considered an illegal operation - just use ftruncate(2) if you need
26*00f5e619SNamjae Jeon  * to collapse a range that crosses EOF.
27*00f5e619SNamjae Jeon  */
28*00f5e619SNamjae Jeon #define FALLOC_FL_COLLAPSE_RANGE	0x08
29607ca46eSDavid Howells 
30607ca46eSDavid Howells #endif /* _UAPI_FALLOC_H_ */
31