]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
rm: use gnulib faccessat
authorEric Blake <ebb9@byu.net>
Fri, 4 Sep 2009 03:59:54 +0000 (21:59 -0600)
committerJim Meyering <meyering@redhat.com>
Fri, 11 Sep 2009 12:08:58 +0000 (14:08 +0200)
* bootstrap.conf (gnulib_modules): Add faccessat.  Replace strdup
with strdup-posix.
* m4/jm-macros.m4 (coreutils_MACROS): Revert previous change, now
that gnulib does it for us.
* src/remove.c (write_protected_non_symlink): Use faccessat in
more situations.

bootstrap.conf
m4/jm-macros.m4
src/remove.c

index 8390ffb0fa21e6f6bb4eb5cc8acfa48d52e5c307..9cdfb79d6c6f5914920dfea33e100b97abbe8b77 100644 (file)
@@ -78,6 +78,7 @@ gnulib_modules="
   euidaccess
   exclude
   exitfail
+  faccessat
   fchdir
   fcntl
   fcntl-safer
@@ -197,7 +198,7 @@ gnulib_modules="
   stdlib-safer
   stpcpy
   stpncpy
-  strdup
+  strdup-posix
   strftime
   strpbrk
   strtoimax
index 75ee75e2d3616b18451e309057574f492f14f1aa..f4d43f1dda5c6756d51f9c21c1b524d8a461a9c0 100644 (file)
@@ -92,9 +92,6 @@ AC_DEFUN([coreutils_MACROS],
   # for cp.c
   AC_CHECK_FUNCS_ONCE([utimensat])
 
-  # for remove.c
-  AC_CHECK_FUNCS_ONCE([faccessat])
-
   dnl This can't use AC_REQUIRE; I'm not quite sure why.
   cu_PREREQ_STAT_PROG
 
index 2db38590921c4b98586b7d7668d6355a1302d35a..d6d680316bfc5492f123da1acda083ab363fa0cc 100644 (file)
@@ -172,12 +172,11 @@ 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)
+    /* This implements #1: on decent systems, either faccessat is
+       native or /proc/self/fd allows us to skip a chdir.  */
+    if (!openat_needs_fchdir ()
+        && faccessat (fd_cwd, file, W_OK, AT_EACCESS) == 0)
       return 0;
-#endif
 
     /* This implements #5: */
     size_t file_name_len = strlen (full_name);