Re: permissions not honoured by /bin/pwd aka getcwd

From: Anton Ivanov (
Date: Thu Feb 24 2000 - 11:25:10 EST


On 24-Feb-2000 Jesse Pollard wrote:
> Anton Ivanov <>:
> ...
>>mkdir -p /tmp/crap/crap1 ; ln -s /tmp/crap /tmp/crap2 ; cd /tmp/crap2/crap1 ;
>>on linux it returns /tmp/crap2/crap1
>>on solaris it returns /tmp/crap/crap1
>>If permissions on crap are 000 solaris bummersm, linux does not. This is on
>>debian-potato and sol 2.6 respectively.
>>And this is gnu fileutils not linux as such.
>>In btw1: at least in some slackware (2.?) long ago pwd was working properly
>>sol's behaviour is considered proper.
> Both are proper - if the command given is "pwd" and a pwd command happens
> to be implemented in the shell (bash/csh). The shell "pwd" outputs tracks of
> the "cd" command and just displays what is seen in this track. Each cd
> command replaces/appends to the list depending on how the parameter specifies
> the path. This was done to optimize a frequently used (in shell scripts
> anyway) command to eliminate the multiple directory open/close cycles needed
> to implement a generic "pwd" utility. BTW, when the shell version is used,
> there is no file access checks made
> The program /bin/pwd gives the expected answer by reading the current
> directory
> to find .., then reading it to locate the inode reference to the current
> unnamed directory (well, known as . -> alias is looked up in .. by searching
> for the inode number). This cycle repeats until /bin/pwd reaches the root
> directory.

My goof off this time. I did forgot to use /bin/pwd one of the times... Ufhh...

Still, the strange fact that when using /bin/pwd solaris returns an error and
linux returns a full path is still there.

pwd (GNU sh-utils) 2.0

strace on linux shows a call to getcwd (3). Return is correct path and no

truss on solaris shows exactly what you describe.

Cheers ;-)

- ----------------------------------
Anton R. Ivanov
IP Engineer Level3 Communications
RIPE: ARI2-RIPE E-Mail: Anton Ivanov <>
@*** Clarke's Law of Revolutionary Ideas ***
      1) "The check is in the mail."
      2) "I'm from the government and I'm here to help you."
      3) "Of course I'll respect you in the morning."

- ----------------------------------
Version: GnuPG v1.0.0 (GNU/Linux)
Comment: For info see


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

This archive was generated by hypermail 2b29 : Tue Feb 29 2000 - 21:00:10 EST