Eric Blake wrote: > Jim, what do you think of this patch, making it possible to avoid > including "openat.h" if you only use the POSIX 2008 interfaces?
That's definitely the right thing to do. Thanks for working on this. I haven't looked at it carefully yet, but already your mention of AT_EACCESS inspired me to fix (on coreutils' next) a long-time infelicity: having to call euidaccess on the full relative name of each file processed by rm without -f. The expense of processing an N-component name at each iteration would make "rm -r" an O(N^2) process. I'm adjusting it to use faccessat with AT_EACCESS instead. That brings up the lack of an faccessat replacement in gnulib. For now, I may just punt and guard the use with #if, (and added check for existence of that function) diff --git a/src/remove.c b/src/remove.c index 32f67a1..99e652a 100644 --- a/src/remove.c +++ b/src/remove.c @@ -172,6 +172,13 @@ write_protected_non_symlink (int fd_cwd, mess up with long file names). */ { + /* Use faccessat if possible, so as to avoid the expense + of processing an N-component name. */ +#if HAVE_FACCESSAT && AT_EACCESS + if (faccessat (fd_cwd, file, W_OK, AT_EACCESS) == 0) + return 0; +#endif + /* This implements #5: */ size_t file_name_len = strlen (full_name); But in the long run, we should provide a replacement function, as we do for all other *at functions.