Skip to content

file_system test: run to its summary under Wine (RT-451) - #6313

Open
cynbun wants to merge 1 commit into
ItsNotRexed:mainfrom
cynbun:rt-451-file-system-wine
Open

cynbun wants to merge 1 commit into
ItsNotRexed:mainfrom
cynbun:rt-451-file-system-wine

Conversation

@cynbun

@cynbun cynbun commented Nov 23, 2026

Copy link
Copy Markdown

RT-451 (claim: #5934 (comment), finding: #5934 (comment)).

Under Wine 11.20 on main 561b65a83, file_system_test fails 3 checks besides the 6 MAXIMUM_ALLOWED ones that #5617 fixes. It then exits with code 3 before its summary line and leaves its folder behind, and that folder breaks the next run.

Causes

1. Exit 3, and the leftover folder.

  • The RT-257 check denies FILE_LIST_DIRECTORY on overlay/.gta6rt-deleted/acl (runtime/test/file_system_test.cpp:292-333 on main).
  • Wine turns that DACL into the folder's unix mode: sd_to_mode in server/file.c drops the owner and group read bits, so the folder becomes d-wx-wxr-x.
  • Wine opens a folder with open(name, O_RDONLY) (server/fd.c, open_fd), which now fails with EACCES. The restore through the folder's name (SetNamedSecurityInfoW, :330) therefore can't open the folder again, and the mode stays as it is.
  • The closing std::filesystem::remove_all(root) (:1159) then throws, so the process ends with exit 3 and prints no summary.
  • Wine gives the test the same process id in every fresh prefix (32 here), so the next run's remove_all at :121 throws too, with no output at all.

2. a cancel flag set before the copy cancels it (host CopyFile2 ...) (:624): a shim gap.

  • Wine 11.20's CopyFile2 ignores pfCancel. dlls/kernelbase/file.c, copy_file logs FIXME("pfCancel is not supported\n") and copies the file anyway.
  • The shim already answered a cancel flag that is set before the call, but only in its CopyFileExW fallback (runtime/shims/file_system.cpp:1228-1229). On a host that has CopyFile2 the call went straight to the host.

3. the listing shows the new case, once (:1137) and the listing shows the folder's new case (:1152): Wine behaves differently from Windows.

  • A case-only rename of an overlay entry is the host's own MoveFileExW (file_system.cpp:1028-1029).
  • Wine looks up the new name without regard to case and finds the file itself. set_fd_name (server/fd.c) sees the same inode and returns success without renaming, so the old spelling stays.
  • The shim's logic is right here. The host does not change the case.

Fix

  • Test, ACL check: a FolderDeny RAII guard opens one READ_CONTROL | WRITE_DAC handle before the deny. It applies the deny and restores the old DACL through that handle (GetSecurityInfo/SetSecurityInfo), and the destructor restores it on every way out of the check. A new check confirms the folder can be listed again once the old DACL is back. Windows checks access when a handle is opened, so the handle keeps WRITE_DAC there as well.
  • Test, cleanup:
    • The folder name is leonida_file_system_<pid>_<QueryPerformanceCounter>, so an earlier run's folder can't collide with it.
    • Both remove_all calls take an error_code. A folder that can't be removed prints a NOTE.
    • The checks run in run_checks(). An exception from one of them counts as a failure, and the folder is still removed and the summary still printed.
  • Shim: copy_file2 answers a cancel flag that is already set with ERROR_REQUEST_ABORTED before it calls the host's CopyFile2, as the fallback did. The duplicate check is removed from the fallback. Windows returns the same, so nothing changes there.
  • Test, case rename: host_renames_case() renames a scratch file with the host's own MoveFileW and lists the folder.
    • Where the new spelling shows up (Windows), the original two checks run unchanged.
    • Where it doesn't (Wine), the test prints SKIP the host's MoveFileW keeps the old case on a case-only rename (Wine): ... and checks only that the entry is listed once.
    • The rest of that block (the move succeeds, the bytes, the package-file case rename, the folder rules) runs everywhere.

#5617 also edits this test file. This PR doesn't depend on it, and the touched regions are separate: git merge-tree of the two heads is clean.

Tested

All on Linux: clang-cl/lld-link cross-build against xwin, Wine 11.20, fresh prefix, CPU only. Not run on native Windows. A native run of file_system_test would confirm that the FolderDeny restore and the case-rename probe behave as described there.

  • main 561b65a83:
    • file_system_test: 251 PASS, 9 FAIL, then exit 3 and no summary line.
    • It leaves leonida_file_system_32/overlay/.gta6rt-deleted/acl behind at mode d-wx-wxr-x.
    • The next run in the same prefix ends with exit 3 and prints nothing.
  • This branch, ctest -R '^file_system$' twice in a row in the same prefix:
  • This branch merged with file_system: a MAXIMUM_ALLOWED open of the overlay copy can write under Wine (RT-414) #5617: 267 check(s), 0 failure(s), exit 0, twice in a row.
  • Full ctest (serial, --timeout 600):
    • main: 200 passed, 16 failed, 30 skipped.
    • This branch: 199 passed, 17 failed, 30 skipped, with the same 16 failures plus vk_pipeline_check_cli.
    • vk_pipeline_check_cli then failed the same way on main when re-run ("expected usage error, got Process terminated due to timeout": Wine's startup hit the 5 s limit). Its binary contains no file this PR changes.
    • The other binaries that compile shims/file_system.cpp (gta6rt, xgameruntime_*_test) pass.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

Under Wine 11.20 the test aborted with exit 3 before its summary and left
a folder that broke the next run, and three checks failed:

- The RT-257 unlistable-marker-folder check put the old DACL back through
  the folder's name. Wine maps the deny to the folder's unix mode (the read
  bits go) and opens a folder with open(O_RDONLY), so the restore could not
  open it again; the closing remove_all threw. The deny and the restore now
  go through one handle opened before the deny (FolderDeny), the restore is
  checked, the folder name carries a per-run counter next to the process id
  (Wine reuses small ids in a fresh prefix), and the closing cleanup no
  longer throws; an exception from a check is reported as a failure and the
  summary is still printed.
- CopyFile2 with a cancel flag already set: Wine's CopyFile2 ignores
  pfCancel. The shim answered it only in its CopyFileExW fallback; it now
  answers it before the host's CopyFile2 too.
- A case-only rename of an overlay entry: Wine's rename finds the file
  itself and returns success without changing the case. The test probes
  the host's MoveFileW and checks the new spelling only where the host
  changes it; the "listed once" part is checked everywhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant