odd behavior of symlinks on Win XP SP2

Igor Pechtchanski pechtcha@cs.nyu.edu
Sat Jan 15 01:31:00 GMT 2005

On Fri, 14 Jan 2005, Jeff.Hodges wrote:

> I've searched this list and googled and all, and can't find anything
> about this issue, so perhaps it's some cockpit error on my part.
> Anyways, here's the issue/question...
>   cygwin symlinks (aka cygwin-created windows shortcuts) seem to work
>   differently, and incorrectly, from the windows perspective, on Win XP
>   SP2 than they did on (say) Win 2000 Pro.
> On Win2k, I got into the habit of creating many of my symlinks/shortcuts
> via Cygwin ("ln -s" of course) because then they were available, and
> worked correctly, from both the Cygwin and windows perspectives.
> Mostly these are symlinks to directories which I use to more
> conveniently traipse around my filesystem. This was true of all my
> cygwin install/upgrades on Win2k from say 1999 thru 2004. The native Win
> filesystem has been NTFS in all cases, fwiw.
> However, now on Win XP SP2 (professional) -- I moved to XP SP2 from
> Win2k in Nov-2004 -- I notice the following behavior with both existing
> symlinks/shortcuts copied over to XP from my Win2k box and with new
> symlinks I've created with my newly-upgraded (27-Dec-2004) cygwin
> install (on XP)...
> 1. cygwin-created (via "ln -s") symlinks/shortcuts pointing to a
> directory are displayed in windows file dialogs with the windows default
> "funky file" icon (I dunno what it's actual name is) rather than the
> windows folder icon as used to be the case on win2k/cygwin.
> 2. cygwin-created (via "ln -s") symlinks/shortcuts pointing to a
> directory are displayed in some windows file-open or file-save dialogs,
> but not in others. On win2k/cygwin, they were always displayed and
> always behaved exactly like windows-created shortcuts pointing to a
> directory. In terms of how they are behaving on WinXP/cygwin..
> 2.1. In the cases where they *are* displayed in windows file-open or
> file-save dialogs, e.g. using windows version of OpenOffice 1.1.3, the
> program in question attempts to either open the symlink/shortcut file
> itself or overwrite it, respectively.
> 2.2. In the cases where they "are not* displayed in the windows dialog
> (whether open or save), e.g. as done by Firefox 1.0 in the file-save
> case, well, the symlink/shortcut simply isn't listed in the dialog, when
> on win2k/cygwin they were displayed (and behaved) just fine.

Hmm, interesting.  I've never noticed this, but your mail prompted me to
look on my own machine.  And, lo and behold, on a plain WinXP SP1 (note,
no SP2) I get the same behavior.

> I suspect either there's some cockpit error I've committed (or am
> committing) either or both on the Win XP side or the Cygwin side, OR,
> there's something different with Win XP SP2 wrt shortcuts that's causing
> this.

I'd say the latter (except it applies to WinXP in general, not just SP2).

> I do have a symlink or two that I'd created on win2k/cygwin that I
> copied over to the WinXP/cygwin machine (as a part of a copied-over
> filesystem subtree) that behaves (on XP) as it did on win2k. Yet there
> are other symlinks/shortcuts in the same filesystem subtree that now
> work incorrectly.
> Has anyone else noticed this behavior? If so do you have any ideas on
> how to get it rectified?

I've noticed this.  Further, after a quick look at the structure of the
symlinks[*] shows that the shortcuts created by WinXP have much more stuff
in them (513 bytes vs. 115 bytes), and they seem to have most of the stuff
(comments and paths) in Unicode.  I suspect that WinXP doesn't really deal
well with non-Unicode shortcuts.

Perhaps an update to Cygwin's symlink() implementation is in order?  The
one that's there now actually has the structure of a Windows symlink
hard-coded in (which apparently fails on XP).  See path.cc in
src/winsup/cygwin.  <http://cygwin.com/acronyms/#PTC>.
[*] BTW, if you have a symlink named "foo", run "attrib -R foo.lnk" to be
able to view (and maybe even edit, if you know what you're doing) the
contents in vi, and then "attrib +R foo.lnk" to turn it back to a symlink.
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"The Sun will pass between the Earth and the Moon tonight for a total
Lunar eclipse..." -- WCBS Radio Newsbrief, Oct 27 2004, 12:01 pm EDT

Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

More information about the Cygwin mailing list