Skip to content

Commit

Permalink
amend! Instead of creating Cygwin symlinks, use deep copy by default
Browse files Browse the repository at this point in the history
Instead of creating Cygwin symlinks, use deep copy by default

The new `winsymlinks` mode `deepcopy` (which is made the default) lets
calls to `symlink()` create (deep) copies of the source file/directory.

This is necessary because unlike Cygwin, MSYS2 does not try to be its
own little ecosystem that lives its life separate from regular Win32
programs: the latter have _no idea_ about Cygwin-emulated symbolic links
(i.e. system files whose contents start with `!<symlink>\xff\xfe` and
the remainder consists of the NUL-terminated, UTF-16LE-encoded symlink
target).

To support Cygwin-style symlinks, the new mode `sysfile` is introduced.

Co-authored-by: Johannes Schindelin <[email protected]>
Co-authored-by: Jeremy Drake <[email protected]>
  • Loading branch information
jeremyd2019 and dscho committed Feb 6, 2025
1 parent cf77c3e commit 19b50e4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions winsup/cygwin/path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2160,6 +2160,10 @@ symlink_deepcopy (const char *oldpath, path_conv &win32_newpath)
tmp_pathbuf tp;
path_conv win32_oldpath;

/* **BEGIN** replace this with
resolve_symlink_target (oldpath, win32_newpath. win32_oldpath);
when rebasing over 5a706ff0fceb83fd1fe7f072fc28a741fdde65f2
(probably Cygwin 3.6) */
/* The symlink target is relative to the directory in which the
symlink gets created, not relative to the cwd. Therefore we
have to mangle the path quite a bit before calling path_conv.*/
Expand All @@ -2174,6 +2178,7 @@ symlink_deepcopy (const char *oldpath, path_conv &win32_newpath)
oldpath);
win32_oldpath.check (absoldpath, PC_SYM_NOFOLLOW, stat_suffixes);
}
/* **END** */
if (win32_oldpath.error)
{
set_errno (win32_oldpath.error);
Expand Down

0 comments on commit 19b50e4

Please sign in to comment.