You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ln -s: "./"-prefixed relative targets stored verbatim are unresolvable by native Windows consumers (+ false-negative ENOENT on relative targets) #1101
Found while investigating niubash#109 (unixwin/niubash#109): a user creates a symlink with ln -s ./bds ./q as Administrator, the link is created, but Explorer/PowerShell then report 「文件、目录或卷标名称语法不正确」 (ERROR_INVALID_NAME) when accessing it.
Repro (winuxcmd v1.0.7, ln.cpp identical at HEAD)
D:\ln-t2> mkdir bds
D:\ln-t2> ln -s ./bds ./q # rc=1 (!), but the link IS created
D:\ln-t2> fsutil reparsepoint query D:\ln-t2\q
SubstituteName: "./bds" (5 chars, UTF-16), flags = SYMLINK_FLAG_RELATIVE
create_symlink passes the user-supplied source string to CreateSymbolicLinkW verbatim, so NT stores it as the relative substitute name. The NT object manager does not accept a leading ./ component in a relative symlink substitute name — unlike the Linux kernel, which resolves ./x fine (this is why GNU ln on Unix gets away with it).
Resolution matrix verified on the same machine (all links created by winuxcmd ln, all resolved via native Win32 consumers):
stored substitute
native resolution
bds (bare name)
OK
./bds (dot-slash prefix)
FAIL — ERROR_INVALID_NAME (123)
../bds (dot-dot prefix)
OK
dir/file (contains a slash, no leading ./)
OK
\??\C:\... absolute
OK
Fix: normalize the target before CreateSymbolicLinkW — strip redundant leading ./ components (repeatedly, e.g. ././x → x), leave ../ components untouched (verified working), and consider absolutizing to \??\ form as a fallback. This matches what Git for Windows / MSYS winsymlinks:nativestrict effectively does.
Secondary bug: false-negative ENOENT on relative targets
Observed repeatably on this machine (same binary): for slash-less or ./-prefixed relative targets, CreateSymbolicLinkW returns FALSE with GetLastError() == ERROR_FILE_NOT_FOUNDeven though the reparse point ends up created, so ln prints
ln: failed to create symbolic link './q': No such file or directory (rc=1)
while fsutil reparsepoint query shows the link exists. Targets with ../ or an embedded slash return rc=0 consistently under the same conditions. Suspect a filter-driver interaction or a double-create path in the hardlink-dispatch layer; worth instrumenting. GNU ln prints nothing and exits 0 here.
Expected (GNU) behavior
ln -s ./bds ./q → silent success, rc=0, link resolves. On Windows that additionally requires the stored target to be normalized so native consumers can resolve it.
Environment
winuxcmd v1.0.7 (ln.cpp identical at repo HEAD 13cd487), Windows 10 19044, Administrator (SeCreateSymbolicLink held), NTFS.
Activity
fix(ln): keep the #1101/#1234 symlink-target adaptations in create_sy…
fix(rust2): fold POSIX-absolute symlink targets to native spelling (R…
fix(rust2): fold POSIX-absolute symlink targets to native spelling (R…