162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 262306a36Sopenharmony_ci#ifndef _UAPI_FALLOC_H_ 362306a36Sopenharmony_ci#define _UAPI_FALLOC_H_ 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#define FALLOC_FL_KEEP_SIZE 0x01 /* default is extend size */ 662306a36Sopenharmony_ci#define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */ 762306a36Sopenharmony_ci#define FALLOC_FL_NO_HIDE_STALE 0x04 /* reserved codepoint */ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci/* 1062306a36Sopenharmony_ci * FALLOC_FL_COLLAPSE_RANGE is used to remove a range of a file 1162306a36Sopenharmony_ci * without leaving a hole in the file. The contents of the file beyond 1262306a36Sopenharmony_ci * the range being removed is appended to the start offset of the range 1362306a36Sopenharmony_ci * being removed (i.e. the hole that was punched is "collapsed"), 1462306a36Sopenharmony_ci * resulting in a file layout that looks like the range that was 1562306a36Sopenharmony_ci * removed never existed. As such collapsing a range of a file changes 1662306a36Sopenharmony_ci * the size of the file, reducing it by the same length of the range 1762306a36Sopenharmony_ci * that has been removed by the operation. 1862306a36Sopenharmony_ci * 1962306a36Sopenharmony_ci * Different filesystems may implement different limitations on the 2062306a36Sopenharmony_ci * granularity of the operation. Most will limit operations to 2162306a36Sopenharmony_ci * filesystem block size boundaries, but this boundary may be larger or 2262306a36Sopenharmony_ci * smaller depending on the filesystem and/or the configuration of the 2362306a36Sopenharmony_ci * filesystem or file. 2462306a36Sopenharmony_ci * 2562306a36Sopenharmony_ci * Attempting to collapse a range that crosses the end of the file is 2662306a36Sopenharmony_ci * considered an illegal operation - just use ftruncate(2) if you need 2762306a36Sopenharmony_ci * to collapse a range that crosses EOF. 2862306a36Sopenharmony_ci */ 2962306a36Sopenharmony_ci#define FALLOC_FL_COLLAPSE_RANGE 0x08 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci/* 3262306a36Sopenharmony_ci * FALLOC_FL_ZERO_RANGE is used to convert a range of file to zeros preferably 3362306a36Sopenharmony_ci * without issuing data IO. Blocks should be preallocated for the regions that 3462306a36Sopenharmony_ci * span holes in the file, and the entire range is preferable converted to 3562306a36Sopenharmony_ci * unwritten extents - even though file system may choose to zero out the 3662306a36Sopenharmony_ci * extent or do whatever which will result in reading zeros from the range 3762306a36Sopenharmony_ci * while the range remains allocated for the file. 3862306a36Sopenharmony_ci * 3962306a36Sopenharmony_ci * This can be also used to preallocate blocks past EOF in the same way as 4062306a36Sopenharmony_ci * with fallocate. Flag FALLOC_FL_KEEP_SIZE should cause the inode 4162306a36Sopenharmony_ci * size to remain the same. 4262306a36Sopenharmony_ci */ 4362306a36Sopenharmony_ci#define FALLOC_FL_ZERO_RANGE 0x10 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci/* 4662306a36Sopenharmony_ci * FALLOC_FL_INSERT_RANGE is use to insert space within the file size without 4762306a36Sopenharmony_ci * overwriting any existing data. The contents of the file beyond offset are 4862306a36Sopenharmony_ci * shifted towards right by len bytes to create a hole. As such, this 4962306a36Sopenharmony_ci * operation will increase the size of the file by len bytes. 5062306a36Sopenharmony_ci * 5162306a36Sopenharmony_ci * Different filesystems may implement different limitations on the granularity 5262306a36Sopenharmony_ci * of the operation. Most will limit operations to filesystem block size 5362306a36Sopenharmony_ci * boundaries, but this boundary may be larger or smaller depending on 5462306a36Sopenharmony_ci * the filesystem and/or the configuration of the filesystem or file. 5562306a36Sopenharmony_ci * 5662306a36Sopenharmony_ci * Attempting to insert space using this flag at OR beyond the end of 5762306a36Sopenharmony_ci * the file is considered an illegal operation - just use ftruncate(2) or 5862306a36Sopenharmony_ci * fallocate(2) with mode 0 for such type of operations. 5962306a36Sopenharmony_ci */ 6062306a36Sopenharmony_ci#define FALLOC_FL_INSERT_RANGE 0x20 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci/* 6362306a36Sopenharmony_ci * FALLOC_FL_UNSHARE_RANGE is used to unshare shared blocks within the 6462306a36Sopenharmony_ci * file size without overwriting any existing data. The purpose of this 6562306a36Sopenharmony_ci * call is to preemptively reallocate any blocks that are subject to 6662306a36Sopenharmony_ci * copy-on-write. 6762306a36Sopenharmony_ci * 6862306a36Sopenharmony_ci * Different filesystems may implement different limitations on the 6962306a36Sopenharmony_ci * granularity of the operation. Most will limit operations to filesystem 7062306a36Sopenharmony_ci * block size boundaries, but this boundary may be larger or smaller 7162306a36Sopenharmony_ci * depending on the filesystem and/or the configuration of the filesystem 7262306a36Sopenharmony_ci * or file. 7362306a36Sopenharmony_ci * 7462306a36Sopenharmony_ci * This flag can only be used with allocate-mode fallocate, which is 7562306a36Sopenharmony_ci * to say that it cannot be used with the punch, zero, collapse, or 7662306a36Sopenharmony_ci * insert range modes. 7762306a36Sopenharmony_ci */ 7862306a36Sopenharmony_ci#define FALLOC_FL_UNSHARE_RANGE 0x40 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ci#endif /* _UAPI_FALLOC_H_ */ 81