diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2011-09-01 12:53:10 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2011-09-01 12:53:28 -0700 |
commit | de1fa2ac9aeb9f70a042ee3faa2b7712e65a278b (patch) | |
tree | a089c8ebf36c658c4d00785f6191155c14edd4f4 /lib/fstatat.c | |
parent | 8b18afa751dc5b8ab392fa5c566d25e14f5825ab (diff) | |
download | gnulib-de1fa2ac9aeb9f70a042ee3faa2b7712e65a278b.tar.gz |
openat: work around AIX 7.1 fstatat issue
This should fix the problem that was not properly fixed
in the previous change, dated 2011-08-30.
* lib/fstatat.c: Include <sys/stat.h> twice, the first with
__need_system_stat_h defined.
(orig_fstatat) [HAVE_FSTATAT]: New function.
(rpl_fstatat): Go back to the old way of doing things,
except call orig_fstatat instead of fstatat.
* m4/openat.m4 (gl_FUNC_FSTATAT): Remove unnecessary check for openat.
Remove unnecessary check whether fstatat fills in st_size etc.
Diffstat (limited to 'lib/fstatat.c')
-rw-r--r-- | lib/fstatat.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/lib/fstatat.c b/lib/fstatat.c index b217126beb..d592d60fc0 100644 --- a/lib/fstatat.c +++ b/lib/fstatat.c @@ -17,15 +17,31 @@ /* Written by Paul Eggert and Jim Meyering. */ +/* If the user's config.h happens to include <sys/stat.h>, let it include only + the system's <sys/stat.h> here, so that orig_fstatat doesn't recurse to + rpl_fstatat. */ +#define __need_system_sys_stat_h #include <config.h> +/* Get the original definition of fstatat. It might be defined as a macro. */ +#include <sys/stat.h> +#undef __need_system_sys_stat_h + +#if HAVE_FSTATAT +static inline int +orig_fstatat (int fd, char const *filename, struct stat *buf, int flags) +{ + return fstatat (fd, filename, buf, flags); +} +#endif + #include <sys/stat.h> #include <errno.h> #include <fcntl.h> #include <string.h> -#if HAVE_FSTATAT && ! FSTATAT_ST_SIZE_ETC_BROKEN +#if HAVE_FSTATAT # undef fstatat @@ -38,7 +54,7 @@ int rpl_fstatat (int fd, char const *file, struct stat *st, int flag) { - int result = fstatat (fd, file, st, flag); + int result = orig_fstatat (fd, file, st, flag); size_t len; if (result != 0) @@ -65,12 +81,7 @@ rpl_fstatat (int fd, char const *file, struct stat *st, int flag) return result; } -#else /* ! (HAVE_FSTATAT && ! FSTATAT_ST_SIZE_ETC_BROKEN) */ - -# if HAVE_FSTATAT -# undef fstatat -# define fstatat rpl_fstatat -# endif +#else /* !HAVE_FSTATAT */ /* On mingw, the gnulib <sys/stat.h> defines `stat' as a function-like macro; but using it in AT_FUNC_F2 causes compilation failure @@ -112,4 +123,4 @@ stat_func (char const *name, struct stat *st) # undef AT_FUNC_POST_FILE_PARAM_DECLS # undef AT_FUNC_POST_FILE_ARGS -#endif /* ! (HAVE_FSTATAT && ! FSTATAT_ST_SIZE_ETC_BROKEN) */ +#endif /* !HAVE_FSTATAT */ |