Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 #ifndef _UAPI_FALLOC_H_
0003 #define _UAPI_FALLOC_H_
0004 
0005 #define FALLOC_FL_KEEP_SIZE 0x01 /* default is extend size */
0006 #define FALLOC_FL_PUNCH_HOLE    0x02 /* de-allocates range */
0007 #define FALLOC_FL_NO_HIDE_STALE 0x04 /* reserved codepoint */
0008 
0009 /*
0010  * FALLOC_FL_COLLAPSE_RANGE is used to remove a range of a file
0011  * without leaving a hole in the file. The contents of the file beyond
0012  * the range being removed is appended to the start offset of the range
0013  * being removed (i.e. the hole that was punched is "collapsed"),
0014  * resulting in a file layout that looks like the range that was
0015  * removed never existed. As such collapsing a range of a file changes
0016  * the size of the file, reducing it by the same length of the range
0017  * that has been removed by the operation.
0018  *
0019  * Different filesystems may implement different limitations on the
0020  * granularity of the operation. Most will limit operations to
0021  * filesystem block size boundaries, but this boundary may be larger or
0022  * smaller depending on the filesystem and/or the configuration of the
0023  * filesystem or file.
0024  *
0025  * Attempting to collapse a range that crosses the end of the file is
0026  * considered an illegal operation - just use ftruncate(2) if you need
0027  * to collapse a range that crosses EOF.
0028  */
0029 #define FALLOC_FL_COLLAPSE_RANGE    0x08
0030 
0031 /*
0032  * FALLOC_FL_ZERO_RANGE is used to convert a range of file to zeros preferably
0033  * without issuing data IO. Blocks should be preallocated for the regions that
0034  * span holes in the file, and the entire range is preferable converted to
0035  * unwritten extents - even though file system may choose to zero out the
0036  * extent or do whatever which will result in reading zeros from the range
0037  * while the range remains allocated for the file.
0038  *
0039  * This can be also used to preallocate blocks past EOF in the same way as
0040  * with fallocate. Flag FALLOC_FL_KEEP_SIZE should cause the inode
0041  * size to remain the same.
0042  */
0043 #define FALLOC_FL_ZERO_RANGE        0x10
0044 
0045 /*
0046  * FALLOC_FL_INSERT_RANGE is use to insert space within the file size without
0047  * overwriting any existing data. The contents of the file beyond offset are
0048  * shifted towards right by len bytes to create a hole.  As such, this
0049  * operation will increase the size of the file by len bytes.
0050  *
0051  * Different filesystems may implement different limitations on the granularity
0052  * of the operation. Most will limit operations to filesystem block size
0053  * boundaries, but this boundary may be larger or smaller depending on
0054  * the filesystem and/or the configuration of the filesystem or file.
0055  *
0056  * Attempting to insert space using this flag at OR beyond the end of
0057  * the file is considered an illegal operation - just use ftruncate(2) or
0058  * fallocate(2) with mode 0 for such type of operations.
0059  */
0060 #define FALLOC_FL_INSERT_RANGE      0x20
0061 
0062 /*
0063  * FALLOC_FL_UNSHARE_RANGE is used to unshare shared blocks within the
0064  * file size without overwriting any existing data. The purpose of this
0065  * call is to preemptively reallocate any blocks that are subject to
0066  * copy-on-write.
0067  *
0068  * Different filesystems may implement different limitations on the
0069  * granularity of the operation. Most will limit operations to filesystem
0070  * block size boundaries, but this boundary may be larger or smaller
0071  * depending on the filesystem and/or the configuration of the filesystem
0072  * or file.
0073  *
0074  * This flag can only be used with allocate-mode fallocate, which is
0075  * to say that it cannot be used with the punch, zero, collapse, or
0076  * insert range modes.
0077  */
0078 #define FALLOC_FL_UNSHARE_RANGE     0x40
0079 
0080 #endif /* _UAPI_FALLOC_H_ */