Subject: Re: bug#10305: coreutils-8.14, "rm -r" fails with EBADF

From: Jim Meyering <[email-masked]>
Date: Fri, 20 Jul 2012 15:54:25 +0200

Joachim Schmitz wrote:
...
> I just saw that my patch removed 2 functions more than your's, mine also
> removes cache_stat_ok() and is_nondir_lstat().
> Intention? Used where?

Here's the patch:

>From c1263bb95e8ff84e819753c9050b96d16441aa81 Mon Sep 17 00:00:00 2001
From: Joachim Schmitz <[email-masked]>
Date: Fri, 20 Jul 2012 15:52:10 +0200
Subject: [PATCH] maint: rm: remove two more unused static inline functions

* src/remove.c (cache_stat_ok, is_nondir_lstat): Remove unused
functions.
---
 src/remove.c | 22 ----------------------
 1 file changed, 22 deletions(-)

diff --git a/src/remove.c b/src/remove.c
index 42f2063..5ebd2ce 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -88,13 +88,6 @@ cache_stat_init (struct stat *st)
   return st;
 }

-/* Return true if *ST has been statted successfully.  */
-static inline bool
-cache_stat_ok (struct stat *st)
-{
-  return (0 <= st->st_size);
-}
-
 /* Return 1 if FILE is an unwritable non-symlink,
    0 if it is writable or some other type of file,
    -1 and set errno if there is some problem in determining the answer.
@@ -304,21 +297,6 @@ prompt (FTS const *fts, FTSENT const *ent, bool is_dir,
   return RM_OK;
 }

-/* Return true if FILENAME is a non-directory.
-   Otherwise, including the case in which lstat fails, return false.
-   *ST is FILENAME's tstatus.
-   Do not modify errno.  */
-static inline bool
-is_nondir_lstat (int fd_cwd, char const *filename, struct stat *st)
-{
-  int saved_errno = errno;
-  bool is_non_dir =
-    (cache_fstatat (fd_cwd, filename, st, AT_SYMLINK_NOFOLLOW) == 0
-     && !S_ISDIR (st->st_mode));
-  errno = saved_errno;
-  return is_non_dir;
-}
-
 /* When a function like unlink, rmdir, or fstatat fails with an errno
    value of ERRNUM, return true if the specified file system object
    is guaranteed not to exist;  otherwise, return false.  */
--
1.7.11.2.194.g7bdb748