[csw-maintainers] [csw-devel] [PATCH 1/4] Test for O_DIRECTORY

Maciej (Matchek) Bliziński maciej at opencsw.org
Fri Mar 2 10:15:50 CET 2012


Hello maintainers,

Here's a porting topic. It started with me working on a VLC build.
O_DIRECTORY is not available on Solaris 10 and my patch to set it to 0
has been rejected. I'm looking for a better solution. More below.

2012/2/29 Joerg Schilling <Joerg.Schilling at fokus.fraunhofer.de>:
> Maciej Blizinski <maciej at opencsw.org> wrote:
>
>> O_DIRECTORY is not declared on Solaris 10. Test for it and only use it when
>> available.
>> ---
>>  configure.ac          |    1 +
>>  modules/misc/gnutls.c |    6 +++++-
>>  2 files changed, 6 insertions(+), 1 deletions(-)
>>
>> diff --git a/configure.ac b/configure.ac
>> index efb2e99..6ce41f5 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -492,6 +492,7 @@ dnl Check for usual libc functions
>>  AC_CHECK_DECLS([nanosleep],,,[#include <time.h>])
>>  AC_CHECK_FUNCS([daemon fcntl fstatvfs fork getenv getpwuid_r if_nameindex if_nametoindex isatty lstat memalign mmap openat pread posix_fadvise posix_madvise setlocale stricmp strnicmp strptime uselocale])
>>  AC_REPLACE_FUNCS([atof atoll dirfd fdopendir flockfile fsync getdelim getpid gmtime_r inet_pton lldiv localtime_r nrand48 poll rewind setenv strcasecmp strcasestr strdup strlcpy strncasecmp strndup strnlen strsep strtof strtok_r strtoll swab tdestroy strverscmp])
>> +AC_CHECK_DECLS([O_DIRECTORY])
>>  AC_CHECK_FUNCS(fdatasync,,
>>    [AC_DEFINE(fdatasync, fsync, [Alias fdatasync() to fsync() if missing.])
>>  ])
>
> Why?

General incompetence on my part. I'm still looking for a solution.

> POSIX grants this to be a #define, so you may safely use:
>
> #ifdef  O_DIRECTORY

My patch to set O_DIRECTORY to 0 was rejected:

http://mailman.videolan.org/pipermail/vlc-devel/2012-March/086989.html

What else can we do? We can't check first and open second, because
that would introduce a race condition. Can we open first, and then
test the file descriptor if it's a directory? I'm thinking that if
this were possible or easy, the O_DIRECTORY flag wouldn't have been
created in the first place.

Maciej


More information about the maintainers mailing list