# Directory notifications after a file name is replaced

A directory event can name a displaced open file even though a later lookup of
that name reaches its replacement. IN_EXCL_UNLINK filters events generated
through the removed entry; it does not retract a MODIFY queued before removal.

Read the [analysis](https://hesela.com/analyses/inotify-change-detection/#unlinked-event-names)
and [inotify record](https://hesela.dev/terms/inotify/).

## Evidence and limits

- Original sample: seven schedules x three repetitions x ext4/tmpfs = 42 fixtures,
  with 84 paired observer streams on Linux 6.8.0-149-generic.
- Separate review replay of the Python probe: 42 fixtures, not added to that sample.
- Separately implemented C controls: five schedules x two filesystems x two
  compiler modes = 20 fixtures, with 40 paired streams.
- All executions used the same host/kernel. This is not independent-laboratory
  replication, human peer review, a newly discovered kernel defect or a measured
  backup failure rate. Paired observers are not independent trials.
- Rename/delete warnings and positive controls remained visible. No wholly
  silent replacement, concurrent backup, crash or network filesystem was tested.

The [table](table.json) is generated only after raw-buffer, byte, identity,
phase-order, population and frozen-file verification. Original observations:
[observations.json](observations.json). Separate C observations:
[observations-c.json](../inotify-unlinked-review/observations-c.json).

## Reproduce

Download both sibling directories, inotify-unlinked and inotify-unlinked-review,
from the paths listed in [publication-manifest.json](publication-manifest.json).
The original SHA256SUMS and the review SHA256SUMS are retained unchanged.
The original README and draft insertion describe their historical, pre-publication
status; this page describes the integrated evidence. No frozen source was rewritten.

From inotify-unlinked:

~~~sh
sha256sum -c SHA256SUMS
python3 -B verify.py observations.json --check-generated
python3 -B -m unittest test_probe
python3 -B -O -m unittest test_probe
~~~

From the sibling inotify-unlinked-review:

~~~sh
sha256sum -c SHA256SUMS
python3 -B verify_review.py observations-c.json
python3 -B -m unittest test_review
python3 -B -O -m unittest test_review
python3 -B run_review.py /tmp/fresh-unlinked-control.json
python3 -B verify_review.py /tmp/fresh-unlinked-control.json
~~~

Use a new output name. Native reproduction requires unprivileged Linux, Python
standard library, a C compiler and findmnt. It creates and removes private
temporary fixtures; it does not operate on an existing user tree. The retained
verifier deliberately requires its documented ext4/tmpfs matrix.

## Sources and interpretation

[inotify(7)](https://man7.org/linux/man-pages/man7/inotify.7.html) documents
unlinked-child filtering and pathname lifetime. The pinned
[dispatch predicate](https://github.com/torvalds/linux/blob/v6.8/fs/notify/fsnotify.c#L240)
checks the event path's dentry; [d_unlinked](https://github.com/torvalds/linux/blob/v6.8/include/linux/dcache.h#L345)
does not test the inode's link count. The complete
[fsnotify_file hook](https://github.com/torvalds/linux/blob/v6.8/include/linux/fsnotify.h#L92)
is lines 92-101, correcting the original source-map locator without changing its hash.
Upstream v6.8 is explanatory source, not byte-identical attestation of the
distribution kernel. Upstream source files are not redistributed.

Engineering inference: reconcile namespace transitions and check the object
actually read. An open descriptor identifies an object but does not freeze
its bytes. Neither filtering nor parent observation alone establishes a snapshot.
All original code, prose and captures in this package are CC0-1.0.
