Bastien ROUCARIES wrote:
> If chdir is a problem, why not using a heavy weight approach (better safe than
> sorry particularly if gnulib is used for a lot of project):
> - fork and exec an helper for name resolution
> - pass fd using a socket
>
> It is really heavy but it is on the safe side

Expensive indeed.
We've used that approach as a fallback in a couple of other areas
(see gnulib's lib/savewd.c and its uses in coreutils:
http://git.sv.gnu.org/cgit/coreutils.git/commit/?id=b67faf329ce),
but never in functions as heavily used as openat, statat, chownat, etc.

Adding a single "stat" call to the inner loop behind "chown -R ..."
can add about 25% to the run-time duration.  Adding a fork may be
prohibitive.  The trouble is that we cannot resort to using "fork"
only when the faster f?chdir-based implementation fails, since once it
has failed it is too late.

If someone tries this, I'll be interested to see the cost it incurs.

Reply via email to