FALLOC_FL_INSERT_RANGE
The Linux insert-range operation inserts a hole inside a Linux file, shifts existing data right and increases the file size.
Transformation: inserting length L at offset O moves existing bytes at O and above to offsets larger by L. Logical length grows by L. Equal aligned chunks ABCD become A(hole)BCD when inserting before B; existing payload is retained on success. [1]
Boundaries: O must be nonnegative and strictly below old EOF, with positive L. O+L need not fit inside the old file, but the resulting size must respect filesystem limits. Support and alignment are filesystem-dependent. No other mode flag, including KEEP_SIZE, is allowed. [2]
Interface: util-linux exposes --insert-range (-i). A hole insertion differs from overwriting existing bytes with zeros or preallocating their storage. Linux v6.12 uses EOPNOTSUPP for conflicting modes; a manual's errno list is not universal. [3] [4]
Persistence: retaining payload while moving offsets does not establish crash-atomic editing. Applications still need an appropriate synchronization and recovery protocol. [5]
Observed offset trap: a bounded Linux/ext4 probe kept the open-file position at byte 8192 while collapse changed its next byte from C to D and insert from C to B. This is one environment, not a portability guarantee. [7]
Relations
Citations
- Linux v6.12: fallocate range-mode contracts
- Linux man-pages: fallocate(2), range boundaries and mode restrictions
- util-linux v2.41.2: fallocate command options
- Linux v6.12: vfs_fallocate flag validation
- Linux man-pages: fsync(2), data and metadata synchronization
- Hesela: Native range transformation and cursor observation
Further reading
Sources & caveats
- Primary-documentation synthesis with logical illustrations and a separately scoped native Linux/ext4 byte-and-cursor probe; not a performance or crash measurement.
- Pinned Linux v6.12 and util-linux v2.41.2 sources do not establish support for every filesystem configuration.