[SCM] Socket Wrapper Repository - branch master updated

Andreas Schneider asn at samba.org
Thu Apr 6 07:19:15 UTC 2017


The branch, master has been updated
       via  9088344 swrap: Add fopen64() on systems which provide it
       via  fb810a6 cmake: Check for fopen64() function
       via  b139b7c swrap: Add open64() on systems which provide it
       via  ef67998 cmake: Check for open64() function
       via  f64d6bd cmake: Do not check for LFS support
       via  502ab86 swrap: Increase max wrapped interfaces
      from  7ca7d61 tests: Fix test_close_failure test case

https://git.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 908834465e11736796e418dfdee6425f71959590
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Apr 6 09:05:26 2017 +0200

    swrap: Add fopen64() on systems which provide it
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit fb810a68eae6cb369d799805d3f0cd529f6d893c
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Apr 6 09:02:21 2017 +0200

    cmake: Check for fopen64() function
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit b139b7c2dae519a8fdd589b4bdff14b9a657fc4a
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Mar 28 09:09:06 2017 +0200

    swrap: Add open64() on systems which provide it
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12694
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit ef679984f4a85b4b75a85fc41df4d16a92f26721
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Mar 28 09:03:02 2017 +0200

    cmake: Check for open64() function
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12694
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit f64d6bd6526b046c350e8e421204461ee66cf9b8
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Mar 28 08:58:14 2017 +0200

    cmake: Do not check for LFS support
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12694
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 502ab86d4863802ef183cedbbf3283bf4bc07ab9
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Mar 20 11:25:40 2017 +0100

    swrap: Increase max wrapped interfaces
    
    We are hitting the limit of 40 interfaces with Samba. So increase it to
    64.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 ConfigureChecks.cmake                   |  2 +
 cmake/Modules/DefineCompilerFlags.cmake | 29 ----------
 config.h.cmake                          |  2 +
 src/socket_wrapper.c                    | 99 ++++++++++++++++++++++++++++++++-
 4 files changed, 102 insertions(+), 30 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 71b34ce..0691c8a 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -63,6 +63,8 @@ check_function_exists(eventfd HAVE_EVENTFD)
 check_function_exists(timerfd_create HAVE_TIMERFD_CREATE)
 check_function_exists(bindresvport HAVE_BINDRESVPORT)
 check_function_exists(accept4 HAVE_ACCEPT4)
+check_function_exists(open64 HAVE_OPEN64)
+check_function_exists(fopen64 HAVE_FOPEN64)
 
 check_function_exists(pledge HAVE_PLEDGE)
 
diff --git a/cmake/Modules/DefineCompilerFlags.cmake b/cmake/Modules/DefineCompilerFlags.cmake
index 53481c3..c60e586 100644
--- a/cmake/Modules/DefineCompilerFlags.cmake
+++ b/cmake/Modules/DefineCompilerFlags.cmake
@@ -53,35 +53,6 @@ if (UNIX AND NOT WIN32)
         endif()
     endif (${CMAKE_C_COMPILER_ID} MATCHES "(GNU|Clang)")
 
-    #
-    # Check for large filesystem support
-    #
-    if (CMAKE_SIZEOF_VOID_P MATCHES "8")
-        # with large file support
-        execute_process(
-            COMMAND
-                getconf LFS64_CFLAGS
-            OUTPUT_VARIABLE
-                _lfs_CFLAGS
-            ERROR_QUIET
-            OUTPUT_STRIP_TRAILING_WHITESPACE
-        )
-    else (CMAKE_SIZEOF_VOID_P MATCHES "8")
-        # with large file support
-        execute_process(
-            COMMAND
-                getconf LFS_CFLAGS
-            OUTPUT_VARIABLE
-                _lfs_CFLAGS
-            ERROR_QUIET
-            OUTPUT_STRIP_TRAILING_WHITESPACE
-        )
-    endif (CMAKE_SIZEOF_VOID_P MATCHES "8")
-    if (_lfs_CFLAGS)
-        string(REGEX REPLACE "[\r\n]" " " "${_lfs_CFLAGS}" "${${_lfs_CFLAGS}}")
-        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_lfs_CFLAGS}")
-    endif (_lfs_CFLAGS)
-
 endif (UNIX AND NOT WIN32)
 
 if (MSVC)
diff --git a/config.h.cmake b/config.h.cmake
index 6786b8a..2f494a4 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -40,6 +40,8 @@
 #cmakedefine HAVE_TIMERFD_CREATE 1
 #cmakedefine HAVE_BINDRESVPORT 1
 #cmakedefine HAVE_ACCEPT4 1
+#cmakedefine HAVE_OPEN64 1
+#cmakedefine HAVE_FOPEN64 1
 #cmakedefine HAVE_PLEDGE 1
 
 #cmakedefine HAVE_ACCEPT_PSOCKLEN_T 1
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 1d94a89..395d0d7 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -264,7 +264,7 @@ do { \
 /* This limit is to avoid broadcast sendto() needing to stat too many
  * files.  It may be raised (with a performance cost) to up to 254
  * without changing the format above */
-#define MAX_WRAPPED_INTERFACES 40
+#define MAX_WRAPPED_INTERFACES 64
 
 struct swrap_address {
 	socklen_t sa_socklen;
@@ -421,6 +421,9 @@ typedef int (*__libc_dup)(int fd);
 typedef int (*__libc_dup2)(int oldfd, int newfd);
 typedef int (*__libc_fcntl)(int fd, int cmd, ...);
 typedef FILE *(*__libc_fopen)(const char *name, const char *mode);
+#ifdef HAVE_FOPEN64
+typedef FILE *(*__libc_fopen64)(const char *name, const char *mode);
+#endif
 #ifdef HAVE_EVENTFD
 typedef int (*__libc_eventfd)(int count, int flags);
 #endif
@@ -438,6 +441,9 @@ typedef int (*__libc_getsockopt)(int sockfd,
 typedef int (*__libc_ioctl)(int d, unsigned long int request, ...);
 typedef int (*__libc_listen)(int sockfd, int backlog);
 typedef int (*__libc_open)(const char *pathname, int flags, mode_t mode);
+#ifdef HAVE_OPEN64
+typedef int (*__libc_open64)(const char *pathname, int flags, mode_t mode);
+#endif /* HAVE_OPEN64 */
 typedef int (*__libc_openat)(int dirfd, const char *path, int flags, ...);
 typedef int (*__libc_pipe)(int pipefd[2]);
 typedef int (*__libc_read)(int fd, void *buf, size_t count);
@@ -493,6 +499,9 @@ struct swrap_libc_symbols {
 	SWRAP_SYMBOL_ENTRY(dup2);
 	SWRAP_SYMBOL_ENTRY(fcntl);
 	SWRAP_SYMBOL_ENTRY(fopen);
+#ifdef HAVE_FOPEN64
+	SWRAP_SYMBOL_ENTRY(fopen64);
+#endif
 #ifdef HAVE_EVENTFD
 	SWRAP_SYMBOL_ENTRY(eventfd);
 #endif
@@ -502,6 +511,9 @@ struct swrap_libc_symbols {
 	SWRAP_SYMBOL_ENTRY(ioctl);
 	SWRAP_SYMBOL_ENTRY(listen);
 	SWRAP_SYMBOL_ENTRY(open);
+#ifdef HAVE_OPEN64
+	SWRAP_SYMBOL_ENTRY(open64);
+#endif
 	SWRAP_SYMBOL_ENTRY(openat);
 	SWRAP_SYMBOL_ENTRY(pipe);
 	SWRAP_SYMBOL_ENTRY(read);
@@ -852,6 +864,15 @@ static FILE *libc_fopen(const char *name, const char *mode)
 	return swrap.libc.symbols._libc_fopen.f(name, mode);
 }
 
+#ifdef HAVE_FOPEN64
+static FILE *libc_fopen64(const char *name, const char *mode)
+{
+	swrap_bind_symbol_libc(fopen64);
+
+	return swrap.libc.symbols._libc_fopen64.f(name, mode);
+}
+#endif /* HAVE_FOPEN64 */
+
 static int libc_vopen(const char *pathname, int flags, va_list ap)
 {
 	long int mode = 0;
@@ -878,6 +899,22 @@ static int libc_open(const char *pathname, int flags, ...)
 	return fd;
 }
 
+#ifdef HAVE_OPEN64
+static int libc_vopen64(const char *pathname, int flags, va_list ap)
+{
+	long int mode = 0;
+	int fd;
+
+	swrap_bind_symbol_libc(open64);
+
+	mode = va_arg(ap, long int);
+
+	fd = swrap.libc.symbols._libc_open64.f(pathname, flags, (mode_t)mode);
+
+	return fd;
+}
+#endif /* HAVE_OPEN64 */
+
 static int libc_vopenat(int dirfd, const char *path, int flags, va_list ap)
 {
 	long int mode = 0;
@@ -3576,6 +3613,31 @@ FILE *fopen(const char *name, const char *mode)
 }
 
 /****************************************************************************
+ *   FOPEN64
+ ***************************************************************************/
+
+#ifdef HAVE_FOPEN64
+static FILE *swrap_fopen64(const char *name, const char *mode)
+{
+	FILE *fp;
+
+	fp = libc_fopen64(name, mode);
+	if (fp != NULL) {
+		int fd = fileno(fp);
+
+		swrap_remove_stale(fd);
+	}
+
+	return fp;
+}
+
+FILE *fopen64(const char *name, const char *mode)
+{
+	return swrap_fopen64(name, mode);
+}
+#endif /* HAVE_FOPEN64 */
+
+/****************************************************************************
  *   OPEN
  ***************************************************************************/
 
@@ -3609,6 +3671,41 @@ int open(const char *pathname, int flags, ...)
 }
 
 /****************************************************************************
+ *   OPEN64
+ ***************************************************************************/
+
+#ifdef HAVE_OPEN64
+static int swrap_vopen64(const char *pathname, int flags, va_list ap)
+{
+	int ret;
+
+	ret = libc_vopen64(pathname, flags, ap);
+	if (ret != -1) {
+		/*
+		 * There are methods for closing descriptors (libc-internal code
+		 * paths, direct syscalls) which close descriptors in ways that
+		 * we can't intercept, so try to recover when we notice that
+		 * that's happened
+		 */
+		swrap_remove_stale(ret);
+	}
+	return ret;
+}
+
+int open64(const char *pathname, int flags, ...)
+{
+	va_list ap;
+	int fd;
+
+	va_start(ap, flags);
+	fd = swrap_vopen64(pathname, flags, ap);
+	va_end(ap);
+
+	return fd;
+}
+#endif /* HAVE_OPEN64 */
+
+/****************************************************************************
  *   OPENAT
  ***************************************************************************/
 


-- 
Socket Wrapper Repository



More information about the samba-cvs mailing list