X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fopenat.c;h=a12fe20dc5ff8710bd607c80b01a19167af56c7e;hb=f16415c07025fdec551dfc1dc7275c2a88819d44;hp=55e12e2111018191c9f3388af45085a584a0a480;hpb=d60f3b0c6b0f93a601acd1cfd3923f94ca05abb0;p=gnulib.git diff --git a/lib/openat.c b/lib/openat.c index 55e12e211..a12fe20dc 100644 --- a/lib/openat.c +++ b/lib/openat.c @@ -16,23 +16,43 @@ /* 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 + +/* Write "fcntl.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates + this include because of the preliminary #include above. */ +#include "fcntl.h" + #include "openat.h" #include +#include #include #include #include -#include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ +#include "dosname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ #include "openat-priv.h" #include "save-cwd.h" #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, ...) @@ -53,7 +73,7 @@ rpl_openat (int dfd, char const *filename, int flags, ...) va_end (arg); } -#if OPEN_TRAILING_SLASH_BUG +# if OPEN_TRAILING_SLASH_BUG /* If the filename ends in a slash and one of O_CREAT, O_WRONLY, O_RDWR is specified, then fail. Rationale: POSIX @@ -84,11 +104,11 @@ rpl_openat (int dfd, char const *filename, int flags, ...) return -1; } } -#endif +# endif - fd = openat (dfd, filename, flags, mode); + fd = orig_openat (dfd, filename, flags, mode); -#if OPEN_TRAILING_SLASH_BUG +# if OPEN_TRAILING_SLASH_BUG /* If the filename ends in a slash and fd does not refer to a directory, then fail. Rationale: POSIX @@ -117,7 +137,7 @@ rpl_openat (int dfd, char const *filename, int flags, ...) } } } -#endif +# endif return fd; }