public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* cp fails in this symlink case, kernel 2.4.25, reiserfs + ext2
@ 2004-04-07 17:35 Martin Rode
  2004-04-07 19:16 ` Dave Kleikamp
  0 siblings, 1 reply; 6+ messages in thread
From: Martin Rode @ 2004-04-07 17:35 UTC (permalink / raw)
  To: linux-kernel

Dear developers,

After 10 years with linux I am happy I can report something :-). 

I don't know 100% if is a bug, but I think it is.

The example below fails on reiserfs as well as on ext2 for me. I dont
think it should fail, or am I missing something? 

Please cc me personally, I am not a subscriber.

Kernel testet: 2.4.[25|19]
Filesystems testet: reiserfs, ext2

Take Care,
Martin


How to reproduce:
-----------------

In any directory try this:

1) mkdir -p alpha/gamma beta
2) (cd alpha; ln -s ../beta .; ln -s gamma latest;)
3) echo "Test" > alpha/gamma/myfile

4) Check
apu:/home/martin/tmp/bug# find -exec file {} \;
.: directory
./alpha: directory
./alpha/gamma: directory
./alpha/gamma/myfile: ASCII text
./alpha/beta: symbolic link to `../beta'
./alpha/latest: symbolic link to `gamma'
./beta: directory

5) cp fails
apu:/home/martin/tmp/bug# (cd alpha/beta; cp ../latest/myfile .)
cp: cannot stat `../latest/myfile': No such file or directory

6) cp ok
apu:/home/martin/tmp/bug# (cd alpha/; cp latest/myfile beta && echo
"ok")
ok




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: cp fails in this symlink case, kernel 2.4.25, reiserfs + ext2
  2004-04-07 17:35 cp fails in this symlink case, kernel 2.4.25, reiserfs + ext2 Martin Rode
@ 2004-04-07 19:16 ` Dave Kleikamp
  2004-04-08  7:56   ` Martin Rode
  0 siblings, 1 reply; 6+ messages in thread
From: Dave Kleikamp @ 2004-04-07 19:16 UTC (permalink / raw)
  To: Martin Rode; +Cc: linux-kernel

On Wed, 2004-04-07 at 12:35, Martin Rode wrote:
> 5) cp fails
> apu:/home/martin/tmp/bug# (cd alpha/beta; cp ../latest/myfile .)
> cp: cannot stat `../latest/myfile': No such file or directory

When you cd to alpha/beta, your current directory is really
.../tmp/bug/beta.  Your shell may remember that you got there through
the symlink in alpha, but cp will follow .., which is really bug.

-- 
David Kleikamp
IBM Linux Technology Center


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: cp fails in this symlink case, kernel 2.4.25, reiserfs + ext2
  2004-04-07 19:16 ` Dave Kleikamp
@ 2004-04-08  7:56   ` Martin Rode
  2004-04-08  9:24     ` Andreas Schwab
  2004-04-08 21:17     ` Michael Driscoll
  0 siblings, 2 replies; 6+ messages in thread
From: Martin Rode @ 2004-04-08  7:56 UTC (permalink / raw)
  To: Dave Kleikamp; +Cc: linux-kernel

On Wed, 2004-04-07 at 21:16, Dave Kleikamp wrote:
> On Wed, 2004-04-07 at 12:35, Martin Rode wrote:
> > 5) cp fails
> > apu:/home/martin/tmp/bug# (cd alpha/beta; cp ../latest/myfile .)
> > cp: cannot stat `../latest/myfile': No such file or directory
> 
> When you cd to alpha/beta, your current directory is really
> .../tmp/bug/beta.  Your shell may remember that you got there through
> the symlink in alpha, but cp will follow .., which is really bug.

Bug in "cp", "bash" or in the kernel fs-layer? 

Martin

-- 
Zeroscale GmbH & Co.
Game Development


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: cp fails in this symlink case, kernel 2.4.25, reiserfs + ext2
  2004-04-08  7:56   ` Martin Rode
@ 2004-04-08  9:24     ` Andreas Schwab
  2004-04-10 19:52       ` Andries Brouwer
  2004-04-08 21:17     ` Michael Driscoll
  1 sibling, 1 reply; 6+ messages in thread
From: Andreas Schwab @ 2004-04-08  9:24 UTC (permalink / raw)
  To: Martin Rode; +Cc: Dave Kleikamp, linux-kernel

Martin Rode <martin.rode@zeroscale.com> writes:

> On Wed, 2004-04-07 at 21:16, Dave Kleikamp wrote:
>> On Wed, 2004-04-07 at 12:35, Martin Rode wrote:
>> > 5) cp fails
>> > apu:/home/martin/tmp/bug# (cd alpha/beta; cp ../latest/myfile .)
>> > cp: cannot stat `../latest/myfile': No such file or directory
>> 
>> When you cd to alpha/beta, your current directory is really
>> .../tmp/bug/beta.  Your shell may remember that you got there through
>> the symlink in alpha, but cp will follow .., which is really bug.
>
> Bug in "cp", "bash" or in the kernel fs-layer? 

Neither.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: cp fails in this symlink case, kernel 2.4.25, reiserfs + ext2
  2004-04-08  7:56   ` Martin Rode
  2004-04-08  9:24     ` Andreas Schwab
@ 2004-04-08 21:17     ` Michael Driscoll
  1 sibling, 0 replies; 6+ messages in thread
From: Michael Driscoll @ 2004-04-08 21:17 UTC (permalink / raw)
  To: Martin Rode; +Cc: linux-kernel

On Thursday 08 April 2004 01:56, Martin Rode wrote:
> On Wed, 2004-04-07 at 21:16, Dave Kleikamp wrote:
> > When you cd to alpha/beta, your current directory is really
> > .../tmp/bug/beta.  Your shell may remember that you got there through
> > the symlink in alpha, but cp will follow .., which is really bug.
>
> Bug in "cp", "bash" or in the kernel fs-layer?
>
> Martin

Call it a bug in POSIX, if anything ;)

Remember that '..' is a directory entry in the filesystem, not a construct of 
your shell.  Specifically, it is a pointer to the parent directory of the 
directory in which it is found.

Usually /a/b/../c is the same as a/c, but not if /a/b is a symlink to /d as in 
this case.

-- 
Michael Driscoll, fenris@ulfheim.net
"A noble spirit embiggens the smallest man" -- J. Springfield

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: cp fails in this symlink case, kernel 2.4.25, reiserfs + ext2
  2004-04-08  9:24     ` Andreas Schwab
@ 2004-04-10 19:52       ` Andries Brouwer
  0 siblings, 0 replies; 6+ messages in thread
From: Andries Brouwer @ 2004-04-10 19:52 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Martin Rode, Dave Kleikamp, linux-kernel

On Thu, Apr 08, 2004 at 11:24:14AM +0200, Andreas Schwab wrote:

> >> > 5) cp fails
> >> > apu:/home/martin/tmp/bug# (cd alpha/beta; cp ../latest/myfile .)
> >> > cp: cannot stat `../latest/myfile': No such file or directory
> >> 
> >> When you cd to alpha/beta, your current directory is really
> >> .../tmp/bug/beta.  Your shell may remember that you got there through
> >> the symlink in alpha, but cp will follow .., which is really bug.
> >
> > Bug in "cp", "bash" or in the kernel fs-layer? 
> 
> Neither.

POSIX is seriously broken here. It is terrible to have a system
where "cd .." does not go to the directory that is listed by "ls ..".

Thus, one should always set -o physical.

(We should have had a command "cd.." to go back to where we came from,
distinct from "cd ..".)

But also bash is broken and violates POSIX:
% pwd
/foo
% mkdir abc
% cd abc
% pwd
/foo/abc
% mv ../abc ../qqq
% /bin/pwd
/foo/qqq
% pwd
/foo/abc
% pwd -L
/foo/abc
% pwd -P
%

We see two bugs: "pwd -P" gives no output at all, and "pwd"
gives the wrong output.

POSIX says:
       -L     If the PWD environment variable contains  an  abso-
              lute  pathname  of  the current directory that does
              not contain the filenames dot or dot-dot, pwd shall
              write  this pathname to standard output. Otherwise,
              the -L option shall behave as the -P option.

So, in the situation where PWD contains /foo/abc but that is
not an absolute pathname of the current directory, the output
must be /foo/qqq and not $PWD.

Andries

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-04-10 19:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-07 17:35 cp fails in this symlink case, kernel 2.4.25, reiserfs + ext2 Martin Rode
2004-04-07 19:16 ` Dave Kleikamp
2004-04-08  7:56   ` Martin Rode
2004-04-08  9:24     ` Andreas Schwab
2004-04-10 19:52       ` Andries Brouwer
2004-04-08 21:17     ` Michael Driscoll

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox