From: Paul Eggert Date: Tue, 6 Sep 2011 00:40:58 +0000 (-0700) Subject: openat: port to AIX 7.1 with large files X-Git-Tag: stable/20110908~6 X-Git-Url: http://erislabs.net/gitweb/?p=gnulib.git;a=commitdiff_plain;h=f4293d352452dd3c03c81ea1e14a4d3dcd050de7 openat: port to AIX 7.1 with large files AIX 7.1 does a "#define openat open64at" if large files are in use, so we can't simply #undef openat. Use the orig_openat trick (similar to orig_open in lib/open.c) to work around the problem. Problem reported by Kevin Brott for GNU tar, in the thread containing . * lib/openat.c (__need_system_fcntl_h): Define first. Include and before undefining. (orig_openat) [HAVE_OPENAT]: New inline function. (openat) [HAVE_OPENAT]: Do not undef. (rpl_openat): Use orig_openat, not openat. (cherry picked from commit a05ce2718959ac0598ae2a30060c10458ed03277) --- diff --git a/ChangeLog b/ChangeLog index d55acfb53..56994bca9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2011-09-05 Paul Eggert + + openat: port to AIX 7.1 with large files + AIX 7.1 does a "#define openat open64at" if large files are in use, + so we can't simply #undef openat. Use the orig_openat trick (similar + to orig_open in lib/open.c) to work around the problem. Problem + reported by Kevin Brott for GNU tar, in the thread containing + . + * lib/openat.c (__need_system_fcntl_h): Define first. + Include and before undefining. + (orig_openat) [HAVE_OPENAT]: New inline function. + (openat) [HAVE_OPENAT]: Do not undef. + (rpl_openat): Use orig_openat, not openat. + 2011-09-03 Paul Eggert openat: test for fstatat (..., 0) bug diff --git a/lib/openat.c b/lib/openat.c index 18491a6f6..cc4b9d073 100644 --- a/lib/openat.c +++ b/lib/openat.c @@ -16,8 +16,25 @@ /* written by Jim Meyering */ +/* If the user's config.h happens to include , let it include only + the system's here, so that orig_openat doesn't recurse to + rpl_openat. */ +#define __need_system_fcntl_h #include +/* Get the original definition of open. It might be defined as a macro. */ +#include +#include +#undef __need_system_fcntl_h + +#if HAVE_OPENAT +static inline int +orig_openat (int fd, char const *filename, int flags, mode_t mode) +{ + return openat (fd, filename, flags, mode); +} +#endif + #include "openat.h" #include @@ -31,8 +48,6 @@ #if HAVE_OPENAT -# undef openat - /* Like openat, but work around Solaris 9 bugs with trailing slash. */ int rpl_openat (int dfd, char const *filename, int flags, ...) @@ -86,7 +101,7 @@ rpl_openat (int dfd, char const *filename, int flags, ...) } # endif - fd = openat (dfd, filename, flags, mode); + fd = orig_openat (dfd, filename, flags, mode); # if OPEN_TRAILING_SLASH_BUG /* If the filename ends in a slash and fd does not refer to a directory,