This is the mail archive of the
mailing list for the GCC project.
Re: [Patch, libfortran] Use access(2) instead of stat(2) to test file existence
- From: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- To: Jerry DeLisle <jvdelisle at verizon dot net>
- Cc: Fortran List <fortran at gcc dot gnu dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 1 Aug 2010 14:23:05 +0300
- Subject: Re: [Patch, libfortran] Use access(2) instead of stat(2) to test file existence
- References: <AANLkTikbqPA0r_0j2O1QRFp71n-a_ubquvX5dfjtKPnm@mail.gmail.com> <4C54F213.firstname.lastname@example.org>
On Sun, Aug 1, 2010 at 07:03, Jerry DeLisle <email@example.com> wrote:
> On 07/31/2010 03:41 PM, Janne Blomqvist wrote:
>> this simple patch uses access(2) instead of stat(2) in the
>> file_exists() function used to test whether a file pathname exists.
>> The reason why this is better is because stat() is potentially a
>> heavyweight operation (as those who have waited half an hour for 'ls
>> -l' to complete on a distributed fs such as Lustre can attest). This
>> does not change any the behavior for any corner cases such as dangling
>> symlinks (see PR 41387), as both access(2) and stat(2) will follow
>> As an aside, we seem to be quite happily using stat(2). One way to
>> reduce it would be to cache the device and inode numbers for open
>> units; as Fortran apparently forbids having multiple units pointing to
>> the same file (?), every time we open a file we walk through all
>> existing units and compare device and inode numbers.
>> Regtested on x86_64-unknown-linux-gnu, ok for trunk?
> OK, thanks.
Thanks, committed as r162798.