On Sun, Feb 01, 2009 at 05:08:41PM +0100, Jim Meyering wrote: > ko...@comcast.net wrote: > > It looks like the file descriptor returned by dirfd is used mainly by > > fts_safe_changedir to allow fts to work correctly even when parts of > > the file system are changed while being traversed. I wonder if a > > fallback to the less robust changing directory by name would be the > > appropriate fix here? > > Trying to do without a file descriptor looks like it'd add too > much complexity in already-hairy code. Not worth it just for mingw.
Yes, understood. I agree. > If you're interested in pursuing it, I'd suggest trying harder to get a > file descriptor. I.e., on mingw, if dirfd returns -1, resort to calling > openat or open on the directory name Unfortunately, I've pursued it far enough to determine that calling open() on a directory results in a "permission denied" error, so it looks like that approach isn't going to work out. I'll go through the mingw runtime to see what would be involved in exporting a file descriptor in the DIR structure, and also see what the Cygwin crew have done in this area, but it's beginning to look like I'll have to track down or write a simple path name based file tree walker. Thanks for helping to identify the problem nonetheless. BTW, it looks like the more Posixly correct action for dirfd to take when no file descriptor will ever be available is to set errno to ENOTSUP prior to returning -1. Just something to consider. -- John Kodis.