posix-fallocate · shipping · also POSIX file-space allocation

posix_fallocate

A POSIX library function that reserves storage for a file byte range and reports failure by returning an error number directly.

Related Observatory article: posix_fallocate on hesela.com

It returns zero on success; do not test for -1 or use errno as its result. glibc 2.40 tries native allocation first and uses emulation after EOPNOTSUPP. Its read/write fallback can race concurrent modifications; this is not a universal property of native allocation or every C library.

Relations

related
file-preallocation, sparse-file, unwritten-extent

Citations

  1. Linux man-pages: posix_fallocate(3), return convention and glibc caveats (accessed 2026-10-16)
  2. glibc 2.40: Linux posix_fallocate dispatch to emulation on EOPNOTSUPP (accessed 2026-10-16)
  3. glibc 2.40: generic posix_fallocate read/write emulation (accessed 2026-10-16)
  4. Sparse files, preallocation and thin-pool capacity (accessed 2026-10-16)

JSON: /data/terms/posix-fallocate.json