falloc.h 3.5 KB

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