Repository navigation
fix(ln,cp): normalize symlink link text to backslash separators - #1102
Merged
Merged
Conversation
NT resolves reparse-point link targets with the Win32 path parser, which only accepts backslash separators. A target stored with forward slashes (e.g. 'ln -s ./bds q' stored './bds') fails native resolution with ERROR_INVALID_NAME - Explorer and other Win32 callers report 'The filename, directory name, or volume label syntax is incorrect' - even though the reparse point itself is created successfully. Translate forward slashes to backslashes in the link text handed to CreateSymbolicLinkW in ln -s, cp -s and cp --dereference symlink recreation. mv/wpm paths already store canonical backslash targets. Regression tests assert the stored target contains no '/' and that the link resolves through CreateFileW on the plain path.
The previous push was based on a stale local checkout; it clobbered win32_account_matches added to this module on main (used by chgrp, chown and find), breaking the CI unity build. Restore the current main version and re-apply win32_normalize_symlink_target on top.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1101. Also addresses the
ln -sbreakage reported in unixwin/niubash#109.Root cause
NT resolves reparse-point link text with the Win32 path parser, which only accepts backslash separators. A symlink created with a forward-slash target, e.g.
stores the literal string
./bdsin the reparse point. The reparse point is created successfully (rc=0), but native resolution ofqfails withERROR_INVALID_NAME(123) — Explorer reports "The filename, directory name, or volume label syntax is incorrect" — even though MSYS/POSIX-style readers that resolve link text themselves work fine.Verified matrix on this machine (before fix, native
CreateFileWresolution of the link):bds.\bdst1\f..\<path>./bds.\?no —t1/ft1/./f../ln-test/bdsi.e. any forward slash in the stored target breaks native resolution; dot segments with backslashes are fine.
Fix
utils:win32gainswin32_normalize_symlink_target()which translates/→\in the link text.ln -s,cp -sandcp --dereferencesymlink recreation normalize the target beforeCreateSymbolicLinkW. The user-visible link text (verbose output, messages) is unchanged.mvfallback andwpmwere inspected and already store canonical backslash targets.Verification
ln.ln_symlink_dot_slash_target_resolves_natively,ln.ln_symlink_forward_slash_path_target_resolves_natively,cp.cp_symbolic_forward_slash_source_resolves_natively— all assert the stored target contains no/and thatCreateFileWon the plain path resolves.scripts/build-with-vs.ps1(Release,-DENABLE_TESTS_USER_VALUE=ON):ln.*+ new cp test → 16 passed, 0 failed.ln -s ./bds qnow stores.\bdsand resolves natively (was FAIL 123 before).winuxcmd-i18nzh-CN is clean (3559/3559 keys, no drift).