bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] openat: port to AIX 7.1 with large files


From: Paul Eggert
Subject: [PATCH] openat: port to AIX 7.1 with large files
Date: Mon, 05 Sep 2011 17:46:53 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.21) Gecko/20110831 Thunderbird/3.1.13

Further investigation into problems GNU tar has on AIX 7.1
revealed a problem with openat that is similar to the recent
fstatat problem.  I installed the following to fix it.
Given the email cited below, this should be the last such
issue with AIX 7.1, as gnulib now addresses the issue for openat, stat,
lstat, and fstatat, and it doesn't wrap creat or fstat.


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
<http://lists.gnu.org/archive/html/bug-tar/2011-09/msg00032.html>.
* lib/openat.c (__need_system_fcntl_h): Define first.
Include <fcntl.h> and <sys/types.h> before undefining.
(orig_openat) [HAVE_OPENAT]: New inline function.
(openat) [HAVE_OPENAT]: Do not undef.
(rpl_openat): Use orig_openat, not openat.
diff --git a/lib/openat.c b/lib/openat.c
index 18491a6..cc4b9d0 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 <fcntl.h>, let it include only
+   the system's <fcntl.h> here, so that orig_openat doesn't recurse to
+   rpl_openat.  */
+#define __need_system_fcntl_h
 #include <config.h>

+/* Get the original definition of open.  It might be defined as a macro.  */
+#include <fcntl.h>
+#include <sys/types.h>
+#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 <stdarg.h>
@@ -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,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]