# When bytes move but a file cursor does not

Hesela native observation, 5 December 2026.

A file offset is a numerical position, not a handle to a particular byte.
In this probe, collapse and insertion moved data while both already-open
file descriptions stayed at byte 8192. An application retaining old offsets
must not assume that they still address the same records.

| Separate operation on ABCD | Length after (bytes) | Cursor after (bytes) | Next byte |
| --- | ---: | ---: | --- |
| Collapse B | 12288 | 8192 | D |
| Insert one zero-reading chunk before B | 20480 | 8192 | B |
| Punch B | 16384 | 8192 | C |

Each letter represents 4096 identical ASCII bytes, not one byte.
Each operation starts from a fresh 16384-byte file. Successful full-file
readback is checked against a separately constructed byte-string expectation
and recorded as SHA-256. A duplicated descriptor shares the advancing cursor;
a separately opened descriptor retains its own position.

## Reproduce

Requires Linux, Python 3, glibc fallocate64, stat and findmnt, plus a filesystem
supporting the tested modes. No packages, privileged mounts or block devices
are used. The probe only creates files in a new temporary directory and
removes that directory when finished.

```sh
python3 -B probe.py --directory /path/to/disposable-parent
python3 -B probe.py --check results.json
python3 -B -m unittest discover -s . -p test_probe.py
python3 -B -O -m unittest discover -s . -p test_probe.py
```

The first command emits a fresh report. It does not overwrite the checked-in
observation. Unsupported operations fail visibly, not as passing tests.
The remaining commands validate saved evidence and its exact probe hash;
they do not rerun syscalls or prove portability to the current host.

## Evidence and boundaries

[results.json](results.json) records Linux 6.8.0-151-generic, x86_64, glibc 2.39,
Python 3.12.3 and an ext4 mount identified by findmnt. The separate statfs type
label is ext2/ext3; that shared magic label alone cannot distinguish ext4.
The fixed 4096-byte chunk is a tested fixture size, not a universal alignment
requirement. Six invalid calls were rejected without changing fixture bytes
or its cursor. KEEP_SIZE combinations returned numeric errno 95, whose Python
label is ENOTSUP (the Linux EOPNOTSUPP alias); EOF and alignment cases returned
22. These are observed errors, not a universal ordering of validation checks.

This is nine small, deterministic syscall observations on one mount, not a
fleet sample, latency benchmark, crash test, media-sanitization test or native
replication of a research paper. No inference about physical allocation,
power-loss persistence, concurrent writers or other filesystems is made.
fsync calls in the setup and successful path do not simulate power loss.

Primary contract references: [fallocate(2)](https://man7.org/linux/man-pages/man2/fallocate.2.html),
[lseek(2)](https://man7.org/linux/man-pages/man2/lseek.2.html) and the pinned
[Linux v6.12 VFS implementation](https://raw.githubusercontent.com/torvalds/linux/v6.12/fs/open.c).
The source-review version and executed kernel are deliberately distinguished.
Return to the [capacity guide](https://hesela.com/analyses/sparse-files-preallocation-thin-capacity/#range-transformations).

Files: [probe.py](probe.py), [test_probe.py](test_probe.py), [results.json](results.json).
New probe and tests: MIT, see [LICENSE](LICENSE). Third-party source files are linked,
not redistributed or relicensed.
