Skip to content

programs: check recursive inputs on Windows too - #5109

Open
Cyan4973 wants to merge 1 commit into
devfrom
win32-recursive-identities
Open

Cyan4973 wants to merge 1 commit into
devfrom
win32-recursive-identities

Conversation

@Cyan4973

@Cyan4973 Cyan4973 commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #5107, as suggested in its review.

Problem

Since #5107, the files selected by -r are checked when compression, decompression, test and list open them: a file replaced since the expansion is refused (changed while opening -- ignored).
This only works on POSIX: Windows stat_t carries no file identity, so the Windows expansion records none, and nothing is checked.

Fix

On Windows, a file's identity is its volume serial number and file index, as already compared by UTIL_isSameFileWin32().

  • The Windows expansion reads it for each selected file, by opening it for attributes only. Files named on the command line get it too, when they are regular files.
  • FIO_openSrcFile() reads it from the handle of the opened file, and compares it with the recorded one, through the new UTIL_isSameOpenedFileIdentity(). On POSIX, this is the existing fstat() check.
  • UTIL_isSameFileWin32() now uses the same helpers.

Out of scope, for a later PR: on Windows, the stat()/fopen() check of FIO_openSrcFile() and the --rm check of FIO_removeFile() still compare a path with itself, and so always pass.

Test

  • Builds with -Werror on Linux (gcc) and with x86_64-w64-mingw32-gcc; C90 syntax check of util.c and fileio.c with both.
  • Linux: the CLI tests pass, including the *-parent-race.sh tests, which check that replaced inputs are refused.
  • Windows: playTests.sh runs several -r cases (with --rm, -d, --output-dir-flat), so CI checks that unchanged files are still accepted. The race itself is not tested on Windows: the race tests use an LD_PRELOAD interposer, Linux only.

Since #5107, the files selected by -r are checked when compress,
decompress, test and list open them, but only on POSIX: Windows stat_t
carries no file identity, so the Windows expansion recorded none.

On Windows, the identity is the volume serial number and file index,
as already compared by UTIL_isSameFileWin32().
- the Windows expansion reads it for each selected file, by opening it
  for attributes only;
- FIO_openSrcFile() reads it from the handle of the opened file, and
  compares it with the recorded one, with UTIL_isSameOpenedFileIdentity().

UTIL_isSameFileWin32() now uses the same helpers.
@Cyan4973 Cyan4973 added the build label Dec 4, 2026
@meta-cla meta-cla Bot added the CLA Signed label Dec 4, 2026
@Cyan4973 Cyan4973 removed the build label Dec 4, 2026
@Cyan4973 Cyan4973 self-assigned this Dec 4, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant