summaryrefslogtreecommitdiff
path: root/src/remove.c
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2009-09-03 21:59:54 -0600
committerJim Meyering <meyering@redhat.com>2009-09-11 14:08:58 +0200
commitc7563435034fe72cb7fa4f8129062f18eef2906d (patch)
treea938068a94716836629b7fa0c2075bf7723086de /src/remove.c
parent722287e443c93e04e724e2812857a395cfab0b60 (diff)
downloadcoreutils-c7563435034fe72cb7fa4f8129062f18eef2906d.tar.xz
rm: use gnulib faccessat
* 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.
Diffstat (limited to 'src/remove.c')
-rw-r--r--src/remove.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/remove.c b/src/remove.c
index 2db385909..d6d680316 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -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);