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