[rfc] Proposal: fake symlinks support on windows

Alexander Belchenko bialix at ukr.net
Wed May 17 12:39:42 BST 2006


Today I'm playing a bit with cygwin, ssh and paramiko.
And I faced with symlinks.

I'm not surprised that cygwin has emulation of symlinks but it looks
very nice and I think it possible to bzr use cygwin approach on native
windows too.

Format of cygwin's symlink file:

First symbol is '!'
Then follow string '<symlink>'
Then follow path
Last symbol is '\0'

E.g.:

/bin/awk.exe in standard cygwin installation has following content:

'!<symlink>gawk.exe\0'

This fake symlinks in windows explorer has attribute 'System' is set.
This flag prevent direct changing of file in windows. Without this
attribute cygwin does not interpret this file as symlink.

Despite the fact that cygwin create symlink to directory as standard
windows shortcut (and this shortcut very well works in native windows),
cygwin interpret above described symlinks for directory as symlinks to
directory. Undesirable effect of creating symlink to directory as
windows shortcut is changing name of symlink: extension '.lnk' is
appended to the file name.

I propose reuse cygwin format and gain full compatibility with cygwin.

I propose to make special methods in bzrlib/osutils.py module:

bzrlib.osutils.readlink  -> extract file path from fake symlink
bzrlib.osutils.symlink   -> create fake symlink

that will simulate work with symlinks for native windows. This methods
for all other systems that has support of symlinks should be
transparently directed to

bzrlib.osutils.readlink = os.readlink
bzrlib.osutils.readlink = os.symlink

Also it require to have more intelligent detection of file type on
windows (during add), i.e. plain files with system attribute should be
checked for '!<symlink>...\0' signature.

I think it doable. Because I need fake symlink support for my
inter-platform work, I want to implement this approach. May be a little
help and hints needed.

This implementation will be ad-hoc and probably we can't test it properly.

Any comments? Suggestions?

--
Alexander






More information about the bazaar mailing list