[vlc-devel] vlc_loaddir always falis on Mac OSX

Naohiro KORIYAMA nkoriyama at gmail.com
Tue Oct 11 12:08:20 CEST 2011


2011/10/11 Naohiro KORIYAMA <nkoriyama at gmail.com>:
> 2011/10/11 Rémi Denis-Courmont <remi at remlab.net>:
>> On Tue, 11 Oct 2011 17:40:03 +0900, Naohiro KORIYAMA <nkoriyama at gmail.com>
>> wrote:
>>>> Yes, the bug must be somewhere else or ,,,. but it exists no doubt on
>>>> Mac.
>>>> Everywhere using vlc_readdir(), fpathconf always renturns -1 and errno
>>>> = EBADF(9).
>>
>> If that's true, then it looks like a bug in MacOS.

Finally, I found why fpathconf  always returns -1.
It's not fault on fpathconf, but dirfd.
Because on Mac OSX, dirfd is a macro, and configure script judge Mac
OS X does not have dirfd.
The dirfd function implemented at compat/dirfd.c, but implement for
SunOS only. For other OSes, always returns -1.
So, it's necessary to implement dirfd for Mac OSX.
On dirent.h, dirfd is defined:
#define	dirfd(dirp)	((dirp)->__dd_fd)

So If I modify dirfd function like this:
int dirfd (DIR *dir)
{
#if defined (__sun__)
    return dir->dd_fd;
#elif defined(__APPLE__)
    return dir->__dd_fd;
#else
    (void) dir;
# ifdef ENOTSUP
    errno = ENOTSUP;
# endif
    return -1;
#endif
}

fpathconf never returns -1 but 255.

-- 
KORIYAMA, Naohiro
nkoriyama at gmail.com



More information about the vlc-devel mailing list