|
From: Vincent R. <fo...@sm...> - 2010-03-22 23:08:34
|
Hi,
Instead of always criticizing mingw I have decided to contribute and to
implement the first step to get support for symbolic link.
So you will find attached two files msys_symlink.{h,c} in which
I rewrote the symbolic link logic.
I made a distinction between a symbolic link to a file and to a folder,
I can sump new behavior as shown below :
On system not using NTFS filesystem we use the old copy logic
symlink_to_file = create_copy_dir;
symlink_to_dir = create_copy_file;
On system using NTFS and before Windows Vista we use hardlinks for file
and recursive copy for folder except if you define an env. var
MSYS_ALLOW_JUNCTION.
In this case we use junction(also called reparse point). I plan to write a
shell extension inspired by TortoiseSVN that is able to display junctions
correctly on Windows 2000/XP and after it will be possible to enable
junction
by default.
Finally on system >= Windows Vista if we have admin permissions we use
native
symbolic link (through the use of CreateSymbolicLinkA loaded dynamically)
and if not the case we go back to junction for dir and hard link for file.
If you want to test native symbolic link, you can start a shell by
choosing "Running as administrator".
As I told it's a first step and now there is a lot of work to
make msys aware of symbolic link(reparse point and native symlink).
If people wants to contribute they should have a look at
source\winsup\cygwin\path.cc
and source\winsup\cygwin\syscalls.cc.
Anyway this patch fix a memory leak in msys_symlink.cc:230
return RecursiveCopy (w_frompath.get_win32 (), w_topath.get_win32 (),
origpath);
...
done:
#if DO_CPP_NEW
delete sb_frompath;
delete sb_topath;
#else
free (sb_frompath);
free (sb_topath);
#endif
return res;
}
where it was returning without deallocating sb_frompath and sb_topath.
You can find new msysCore dll(based on last msysCore) here :
http://www.smartmobili.com/Downloads/msysCore-1.0.14-2-symlink-bin.tar.lzma
REMARK : to implement junctions I had to store path as unicode but msys
didn't
allow to use wcslen, wcscpy, wcscat so finally I have provided
implementations.
TODO :
- see if we can get rid of admin permissions to create native symlink
by playing with NTFS ioctl as we already do with junctions.
- write some comments that will allow to optimize this whole code
- Write a shell extension on Windows 2000/XP
|