Skip to content

NAR: the eager walk reads exactly the size the open file reports, as upstream's dump does - #115

Merged
AniAthena merged 1 commit into
mainfrom
nar/eager-read-recorded-size
Dec 4, 2026
Merged

AniAthena merged 1 commit into
mainfrom
nar/eager-read-recorded-size

Conversation

@AniAthena

@AniAthena AniAthena commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

The eager walk read a regular file with BS.readFile, to end of input, so an entry replaced by a FIFO between its lstat and its read, or a file that changed while it was read, was archived with whatever the read returned. Upstream's dump reads exactly the size it recorded and fails if the file ends early (archive.cc).

readFileBytes now opens the file, reads its size from the handle and reads exactly that many bytes, refusing an early end, and hFileSize refuses an open that finds no regular file, as the stream already does. The walk asks the executable-bit resolver before the read, in the stream's order, and a test uses that resolver to swap the file for a FIFO between the classification and the read.

Neither walk opens with O_NOFOLLOW as upstream does, so a file swapped for a symlink to another regular file is still read through the link; that is the same in the stream and is left for a change to both.

Closes #106

@AniAthena
AniAthena force-pushed the nar/eager-read-recorded-size branch from 8ab4287 to 0be8623 Compare December 4, 2026 19:43
@AniAthena
AniAthena marked this pull request as ready for review December 4, 2026 19:43
@AniAthena
AniAthena force-pushed the nar/eager-read-recorded-size branch from 0be8623 to e4d743d Compare December 4, 2026 20:09
@AniAthena
AniAthena merged commit 6e029bd into main Dec 4, 2026
12 checks passed
@AniAthena
AniAthena deleted the nar/eager-read-recorded-size branch December 4, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NAR: the eager walk reads a file to end of input instead of the size it recorded

2 participants