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: Jerry DeLisle <jvdelisle at verizon dot net>
- To: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- Cc: Fortran List <fortran at gcc dot gnu dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 31 Jul 2010 21:03:31 -0700
- Subject: Re: [Patch, libfortran] Use access(2) instead of stat(2) to test file existence
- References: <AANLkTikbqPA0r_0j2O1QRFp71n-a_ubquvX5dfjtKPnm@mail.gmail.com>
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?