1*f80ad8b4SAndroid Build Coastguard Worker /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2*f80ad8b4SAndroid Build Coastguard Worker #ifndef _UAPI_FALLOC_H_ 3*f80ad8b4SAndroid Build Coastguard Worker #define _UAPI_FALLOC_H_ 4*f80ad8b4SAndroid Build Coastguard Worker 5*f80ad8b4SAndroid Build Coastguard Worker #define FALLOC_FL_KEEP_SIZE 0x01 /* default is extend size */ 6*f80ad8b4SAndroid Build Coastguard Worker #define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */ 7*f80ad8b4SAndroid Build Coastguard Worker #define FALLOC_FL_NO_HIDE_STALE 0x04 /* reserved codepoint */ 8*f80ad8b4SAndroid Build Coastguard Worker 9*f80ad8b4SAndroid Build Coastguard Worker /* 10*f80ad8b4SAndroid Build Coastguard Worker * FALLOC_FL_COLLAPSE_RANGE is used to remove a range of a file 11*f80ad8b4SAndroid Build Coastguard Worker * without leaving a hole in the file. The contents of the file beyond 12*f80ad8b4SAndroid Build Coastguard Worker * the range being removed is appended to the start offset of the range 13*f80ad8b4SAndroid Build Coastguard Worker * being removed (i.e. the hole that was punched is "collapsed"), 14*f80ad8b4SAndroid Build Coastguard Worker * resulting in a file layout that looks like the range that was 15*f80ad8b4SAndroid Build Coastguard Worker * removed never existed. As such collapsing a range of a file changes 16*f80ad8b4SAndroid Build Coastguard Worker * the size of the file, reducing it by the same length of the range 17*f80ad8b4SAndroid Build Coastguard Worker * that has been removed by the operation. 18*f80ad8b4SAndroid Build Coastguard Worker * 19*f80ad8b4SAndroid Build Coastguard Worker * Different filesystems may implement different limitations on the 20*f80ad8b4SAndroid Build Coastguard Worker * granularity of the operation. Most will limit operations to 21*f80ad8b4SAndroid Build Coastguard Worker * filesystem block size boundaries, but this boundary may be larger or 22*f80ad8b4SAndroid Build Coastguard Worker * smaller depending on the filesystem and/or the configuration of the 23*f80ad8b4SAndroid Build Coastguard Worker * filesystem or file. 24*f80ad8b4SAndroid Build Coastguard Worker * 25*f80ad8b4SAndroid Build Coastguard Worker * Attempting to collapse a range that crosses the end of the file is 26*f80ad8b4SAndroid Build Coastguard Worker * considered an illegal operation - just use ftruncate(2) if you need 27*f80ad8b4SAndroid Build Coastguard Worker * to collapse a range that crosses EOF. 28*f80ad8b4SAndroid Build Coastguard Worker */ 29*f80ad8b4SAndroid Build Coastguard Worker #define FALLOC_FL_COLLAPSE_RANGE 0x08 30*f80ad8b4SAndroid Build Coastguard Worker 31*f80ad8b4SAndroid Build Coastguard Worker /* 32*f80ad8b4SAndroid Build Coastguard Worker * FALLOC_FL_ZERO_RANGE is used to convert a range of file to zeros preferably 33*f80ad8b4SAndroid Build Coastguard Worker * without issuing data IO. Blocks should be preallocated for the regions that 34*f80ad8b4SAndroid Build Coastguard Worker * span holes in the file, and the entire range is preferable converted to 35*f80ad8b4SAndroid Build Coastguard Worker * unwritten extents - even though file system may choose to zero out the 36*f80ad8b4SAndroid Build Coastguard Worker * extent or do whatever which will result in reading zeros from the range 37*f80ad8b4SAndroid Build Coastguard Worker * while the range remains allocated for the file. 38*f80ad8b4SAndroid Build Coastguard Worker * 39*f80ad8b4SAndroid Build Coastguard Worker * This can be also used to preallocate blocks past EOF in the same way as 40*f80ad8b4SAndroid Build Coastguard Worker * with fallocate. Flag FALLOC_FL_KEEP_SIZE should cause the inode 41*f80ad8b4SAndroid Build Coastguard Worker * size to remain the same. 42*f80ad8b4SAndroid Build Coastguard Worker */ 43*f80ad8b4SAndroid Build Coastguard Worker #define FALLOC_FL_ZERO_RANGE 0x10 44*f80ad8b4SAndroid Build Coastguard Worker 45*f80ad8b4SAndroid Build Coastguard Worker /* 46*f80ad8b4SAndroid Build Coastguard Worker * FALLOC_FL_INSERT_RANGE is use to insert space within the file size without 47*f80ad8b4SAndroid Build Coastguard Worker * overwriting any existing data. The contents of the file beyond offset are 48*f80ad8b4SAndroid Build Coastguard Worker * shifted towards right by len bytes to create a hole. As such, this 49*f80ad8b4SAndroid Build Coastguard Worker * operation will increase the size of the file by len bytes. 50*f80ad8b4SAndroid Build Coastguard Worker * 51*f80ad8b4SAndroid Build Coastguard Worker * Different filesystems may implement different limitations on the granularity 52*f80ad8b4SAndroid Build Coastguard Worker * of the operation. Most will limit operations to filesystem block size 53*f80ad8b4SAndroid Build Coastguard Worker * boundaries, but this boundary may be larger or smaller depending on 54*f80ad8b4SAndroid Build Coastguard Worker * the filesystem and/or the configuration of the filesystem or file. 55*f80ad8b4SAndroid Build Coastguard Worker * 56*f80ad8b4SAndroid Build Coastguard Worker * Attempting to insert space using this flag at OR beyond the end of 57*f80ad8b4SAndroid Build Coastguard Worker * the file is considered an illegal operation - just use ftruncate(2) or 58*f80ad8b4SAndroid Build Coastguard Worker * fallocate(2) with mode 0 for such type of operations. 59*f80ad8b4SAndroid Build Coastguard Worker */ 60*f80ad8b4SAndroid Build Coastguard Worker #define FALLOC_FL_INSERT_RANGE 0x20 61*f80ad8b4SAndroid Build Coastguard Worker 62*f80ad8b4SAndroid Build Coastguard Worker /* 63*f80ad8b4SAndroid Build Coastguard Worker * FALLOC_FL_UNSHARE_RANGE is used to unshare shared blocks within the 64*f80ad8b4SAndroid Build Coastguard Worker * file size without overwriting any existing data. The purpose of this 65*f80ad8b4SAndroid Build Coastguard Worker * call is to preemptively reallocate any blocks that are subject to 66*f80ad8b4SAndroid Build Coastguard Worker * copy-on-write. 67*f80ad8b4SAndroid Build Coastguard Worker * 68*f80ad8b4SAndroid Build Coastguard Worker * Different filesystems may implement different limitations on the 69*f80ad8b4SAndroid Build Coastguard Worker * granularity of the operation. Most will limit operations to filesystem 70*f80ad8b4SAndroid Build Coastguard Worker * block size boundaries, but this boundary may be larger or smaller 71*f80ad8b4SAndroid Build Coastguard Worker * depending on the filesystem and/or the configuration of the filesystem 72*f80ad8b4SAndroid Build Coastguard Worker * or file. 73*f80ad8b4SAndroid Build Coastguard Worker * 74*f80ad8b4SAndroid Build Coastguard Worker * This flag can only be used with allocate-mode fallocate, which is 75*f80ad8b4SAndroid Build Coastguard Worker * to say that it cannot be used with the punch, zero, collapse, or 76*f80ad8b4SAndroid Build Coastguard Worker * insert range modes. 77*f80ad8b4SAndroid Build Coastguard Worker */ 78*f80ad8b4SAndroid Build Coastguard Worker #define FALLOC_FL_UNSHARE_RANGE 0x40 79*f80ad8b4SAndroid Build Coastguard Worker 80*f80ad8b4SAndroid Build Coastguard Worker #endif /* _UAPI_FALLOC_H_ */ 81