Re: cp fails in this symlink case, kernel 2.4.25, reiserfs + ext2

From: Andries Brouwer
Date: Sat Apr 10 2004 - 14:54:04 EST


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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/