Windows: guest file names that are DOS device names or end in a dot or space are rewritten by Win32 #12550
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-28T19:15:48Z.
What happens
On Windows, a guest file whose name is a DOS device name, or ends in a dot or a space, doesn't map to a file with that name. On the PS5 (FreeBSD), these are ordinary names.
The cause is that host paths shorter than
MAX_PATHreach the Win32 API without the\?\verbatim prefix. Only longer paths get it, inNativeMetadataPath(core/libs/prx/libkernel/File/src/Open.cpp) andHostOpenName(core/libs/prx/libc/src/FileAndHeap.cpp). Win32 path normalization then rewrites the name.Measured
Windows 11 Enterprise 10.0.22621, WinLibs GCC 15.2.0 UCRT r7. A small native program creates each name with
_wopen(dir + L"\\" + name, _O_WRONLY | _O_CREAT | _O_TRUNC), writes one byte, reportsGetFileTypeand then lists the directory:nulfile.andfilefile, so the two names collapse into one filename.namecon,CON,con.txt,aux,aux.json,com1,com1.bin,lpt1.txt,prn,conin$,nul.datThe last row is a Windows 11 relaxation. On Windows 10,
CON,PRN,AUX,NUL,COM1–COM9andLPT1–LPT9, with or without an extension, are devices, so the affected set is larger there. I haven't measured it on Windows 10.Impact
Probably rare: save data and asset names are usually fixed identifiers. A guest name that is exactly
nul, or that ends in.or, would silently lose data or alias another file. On Windows 10, so wouldaux.dat,con.txtand the like.Possible direction
Use the verbatim
\?\form for any host path with a component that Win32 would rewrite (a trailing.or space, or a reserved device stem), not only for long paths. Since the verbatim form is already used for long paths, the remaining work is making every guest-path entry point go through one such helper. Right nowopen,mkdir,rename, directory listing andstatbuild host paths in different places.AnyPS5 commit
main319621ba2e.AI-assisted: yes (Claude Code).