Re: [PATCH] Do not trust PWD blindly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Randal,

On Sun, 10 Jul 2011, Randal L. Schwartz wrote:

> >>>>> "Johannes" == Johannes Schindelin <Johannes.Schindelin@xxxxxx> writes:
> 
> Johannes> You might be very surprised, but that is not true on the Linux 
> Johannes> system where one of the 4msysgit.git test cases does _not_ 
> Johannes> break, while it does on Windows.
> 
> If you ever depend on a userspace PWD to be your actual current 
> directory without at least stat()ing it, you've failed.
> 
> In my experience, it is *never* reliable.  It's just a hint.

To be precise, get_pwd_cwd() _does_ stat() what's in PWD, and _does_ 
compare with the stat() of what comes out of getcwd(), but that comparison 
uses only st_dev and st_ino, both of which happen to be 0 in my case -- 
for each and every file/directory.

I can only _guess_ at the reasoning behind get_pwd_cwd(). I _think_ it was 
meant to catch the case when getcwd() and PWD refer to the same directory, 
but PWD goes through symbolic links. I was tempted to just throw that PWD 
handling out for Windows, since we do not have symbolic link handling yet. 
But that is currently actively discussed, so we might need it in the 
future, in which case I have to figure out how to fake reliable st_dev and 
st_ino values into our stat() code.

Ciao,
Dscho

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]