Overview
| Artifact ID: | 1b2bd46b328401e1ef518293185f58697a2b598ce788a8bd901edd9314ca06ce |
|---|---|
| Ticket: | c8d4f01a54d7ecf819f4881fb02467ad14fc7b0c
Windows: NTFS symbolic links are not supported by [file] |
| User & Date: | serhiy.storchaka on 2026-10-17 10:53:34 |
Changes
- foundin changed to: "8.6.18, 9.0.5, 9.1.0"
- icomment:
Still present in 8.6.18, 9.0.5 and 9.1 on Windows 11: <nowiki>[file readlink]</nowiki> fails on every real symlink, and only junctions work: <verbatim> % file readlink dirlink ;# mklink /D dirlink target could not read link "dirlink": invalid argument % file readlink filelink ;# mklink filelink a.txt, or [file link -symbolic filelink a.txt] could not read link "filelink": not a directory </verbatim> So a file link that Tcl itself has created with <nowiki>[file link -symbolic]</nowiki> since 8.6.11 ([548cd945d6]) cannot be read back. Cause, in win/tclWinFile.c: <tt>WinReadLink()</tt> returns ENOTDIR for anything that is not a directory. For directories, <tt>WinReadLinkDirectory()</tt> does have a case for symlinks, but it tests <tt>IO_REPARSE_TAG_SYMBOLIC_LINK</tt>. The SDK and mingw-w64 headers do not define that name (theirs is <tt>IO_REPARSE_TAG_SYMLINK</tt>, <tt>0xA000000C</tt>), so the fallback <tt>#define ... IO_REPARSE_TAG_RESERVED_ZERO</tt> makes it 0. The symlink tag never matches and the function ends in EINVAL. The same function is used by <tt>TclpObjNormalizePath()</tt>, so directory symlinks in the middle of a path are not resolved by <nowiki>[file normalize]</nowiki> either. A fix needs more than the constant: symlink reparse data uses <tt>SymbolicLinkReparseBuffer</tt> (it has an extra <tt>Flags</tt> field and can hold a relative target), not <tt>MountPointReparseBuffer</tt>, and the name should be read at <tt>SubstituteNameOffset</tt>.
- login: "serhiy.storchaka"
- mimetype: "text/x-fossil-wiki"