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

From: Paul Eggert <[email-masked]>
Date: Sun, 18 Dec 2011 14:24:00 -0800

On 12/18/11 02:31, Joachim Schmitz wrote:
> it seems to go wrong in fcntl.c, line 194:
> 
>             /* Haiku alpha 2 loses fd flags on original.  */
>             int flags = fcntl (fd, F_GETFD);    <==
>             if (flags < 0)
>               {
>                 result = -1;
>                 break;
>               }
> 
> that fcntl() returns a -1 with errno set to EBADF.

What is the value of fd at that point?
Is it actually an invalid file descriptor?

> For some reason I can step into that fcntl(), guess it is calling the system's fcntl here?

Yes, that's how it's supposed to work.

If you plant a breakpoint on the parent fts_build,
and single step through that, can you find out whether
continue_readdir is true?  If it's true, then please
investigate why dirfd (fts.c line 1285)
returned an invalid file descriptor.  If it's false,
then please investigate why opendirat (..., &dir_fd)
(fts.c line 1301) succeeded but set dir_fd to an
invalid file descriptor.