This is the mail archive of the
cygwin-developers@cygwin.com
mailing list for the Cygwin project.
Re: [Fwd: symboilc link does not expand if followed by /..]
- From: Christopher Faylor <me at cgf dot cx>
- To: cygwin-developers at cygwin dot com
- Date: Wed, 14 Jul 2004 08:46:44 -0400
- Subject: Re: [Fwd: symboilc link does not expand if followed by /..]
- References: <20040714115555.GS1389@cygbert.vinschen.de>
- Reply-to: cygwin-developers at cygwin dot com
On Wed, Jul 14, 2004 at 01:55:55PM +0200, Corinna Vinschen wrote:
>----- Forwarded message from Vinay Kumar -----
>> Date: Tue, 13 Jul 2004 21:06:08 +0000 (GMT)
>> From: Vinay Kumar
>> Subject: symboilc link does not expand if followed by /..
>> To: cygwin-list
>>
>> Hi all,
>> I found a problem with symbolic link expansion in cygwin. Symbolic
>> link does not expand properly if it is followed by /.. . To see it at
>> your place please do the following.
>> cd /tmp
>> mkdir dir1
>> mkdir dir2
>> touch dir1/1.c
>> cd dir2
>> ln -s ../dir1 symlink
>>
>> if we do ls symlink it gives 1.c as expected.
>> But if we do ls symlink/.. then it list contents of present directory.
>>
>> @/tmp/dir2
>> $ ls symlink
>> 1.c
>>
>> @/tmp/dir2
>> $ ls symlink/..
>> symlink
>>
>> I think it should list contents of /tmp directory.
>> Could somebody throw some light over it.
>>
>> regards
>> Vinay
>----- End forwarded message -----
>
>Looks like he has his point. Under Linux it works as he describes it.
>In Cygwin the following happens.
>
>normalize_posix_path simplifies the path first and strippes ".." by
>removing the previous entry in the path. Then path_conv::check checks
>for symlinks and directories. So, the incoming path /tmp/dir2/symlink/..
>becomes /tmp/dir2 after the call to normalize_posix_path and the symlink
>expansion in path_conv::check doesn't even see a symlink.
>
>That reflects the typical behaviour in tcsh with the setting
>`set symlinks expand', but it doesn't allow any other behaviour.
>
>It looks like a fix would require to change the order in path_conv::check.
>The symlink expansion would have to be done before the path gets normalized.
>Or the symlink expansion could be moved into normalize_posix_path.
I thought about this and I think it would be tricky to get this right.
You have to do path normalization before you check the mount table to
even figure out where something like /foo/../symlink really lives.
symlink could also be a mount point.
cgf