[PATCHES] Reorganize code for wrapping gpfs library

Christof Schmitt cs at samba.org
Wed Feb 11 16:11:48 MST 2015


The attached patch series cleans up and reorganizes the wrapper around
the gpfs library. The library is only dynamically loaded to avoid
packaging dependencies between Samba and gpfs and to also allow the
usage of one Samba build across different gpfs versions; missing
functions are only a soft-error with fallback to the default code paths.

Currently, the various parts of the vfs_gpfs module are spread across
the vfs_gpfs.c and gpfs.c files. After this patch series, the vfs_gpfs.c
file contains all functionality and the (renamed) gpfswrap.c is only a
thin wrapper around the gpfs library.

Regards,

Christof
-------------- next part --------------
From 45c5aab47be03ddffbf5f4bdbdca90bd16a60cf3 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Fri, 5 Dec 2014 11:10:50 -0700
Subject: [PATCH 01/32] gpfs: Always use gpfs_fcntl.h headerfile

gpfs_gpl.h no longer exists, everything from that header file has been
merged to gpfs.h. gpfs_fcntl.h implicitly includes gpfs.h. Simplify the
code by only looking for gpfs_fcntl.h and including that file.

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c     |    3 +--
 source3/modules/vfs_gpfs.c |    2 +-
 source3/wscript            |    2 +-
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index 284e65b..a9f267d 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -22,9 +22,8 @@
 #include "smbd/smbd.h"
 
 #include <fcntl.h>
+#include <gpfs_fcntl.h>
 #include "libcli/security/security.h"
-#include "gpfs_fcntl.h"
-#include "gpfs_gpl.h"
 #include "vfs_gpfs.h"
 
 static int (*gpfs_set_share_fn)(int fd, unsigned int allow, unsigned int deny);
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 6ead65b..83c5f5b 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -30,7 +30,7 @@
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_VFS
 
-#include <gpfs_gpl.h>
+#include <gpfs_fcntl.h>
 #include "nfs4_acls.h"
 #include "vfs_gpfs.h"
 #include "system/filesys.h"
diff --git a/source3/wscript b/source3/wscript
index bb0f19d..f1dda51 100644
--- a/source3/wscript
+++ b/source3/wscript
@@ -1492,7 +1492,7 @@ main() {
             Logs.warn("pthreadpool support cannot be enabled when pthread support was not found")
             conf.undefine('WITH_PTHREADPOOL')
 
-    if conf.CHECK_HEADERS('gpfs_gpl.h'):
+    if conf.CHECK_HEADERS('gpfs_fcntl.h'):
         conf.DEFINE('HAVE_GPFS', '1')
 
     if (conf.CHECK_HEADERS('linux/ioctl.h sys/ioctl.h linux/fs.h') and
-- 
1.7.1


From 3016551fe6010634cf507705893d59bbdd46f3ab Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Fri, 5 Dec 2014 11:42:30 -0700
Subject: [PATCH 02/32] gpfs: Look for gpfs header files also in /usr/lpp/mmfs/include/

That is the default directory for the gpfs header files.

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/wscript_build |    3 ++-
 source3/wscript               |    3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/source3/modules/wscript_build b/source3/modules/wscript_build
index e2d4fde..7fe66ec 100644
--- a/source3/modules/wscript_build
+++ b/source3/modules/wscript_build
@@ -279,7 +279,8 @@ bld.SAMBA3_MODULE('vfs_gpfs',
                  deps='NFS4_ACLS non_posix_acls',
                  init_function='',
                  internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_gpfs'),
-                 enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_gpfs'))
+                 enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_gpfs'),
+                 includes=bld.CONFIG_GET('CPPPATH_GPFS'))
 
 vfs_notify_fam_deps='samba-util '
 if bld.CONFIG_SET('SAMBA_FAM_LIBS'):
diff --git a/source3/wscript b/source3/wscript
index f1dda51..63bca9d 100644
--- a/source3/wscript
+++ b/source3/wscript
@@ -1492,7 +1492,8 @@ main() {
             Logs.warn("pthreadpool support cannot be enabled when pthread support was not found")
             conf.undefine('WITH_PTHREADPOOL')
 
-    if conf.CHECK_HEADERS('gpfs_fcntl.h'):
+    conf.env['CPPPATH_GPFS'] = '/usr/lpp/mmfs/include/'
+    if conf.CHECK_HEADERS('gpfs_fcntl.h', False, False, "gpfs"):
         conf.DEFINE('HAVE_GPFS', '1')
 
     if (conf.CHECK_HEADERS('linux/ioctl.h sys/ioctl.h linux/fs.h') and
-- 
1.7.1


From 5fdef746fa0711329c1620b328927e9ac623b536 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Fri, 5 Dec 2014 11:46:25 -0700
Subject: [PATCH 03/32] gpfs: Remove search for libgpfs_gpl.so

Similar to the header files, libgpfs_gpl.so no longer exists. The
library is now always called libgpfs.so.

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c |   12 ++----------
 1 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index a9f267d..b2ca704 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -369,17 +369,9 @@ static bool init_gpfs_function_lib(void *plibhandle_pointer,
 static bool init_gpfs_function(void *fn_pointer, const char *fn_name)
 {
 	static void *libgpfs_handle = NULL;
-	static void *libgpfs_gpl_handle = NULL;
 
-	if (init_gpfs_function_lib(&libgpfs_handle, "libgpfs.so",
-				   fn_pointer, fn_name)) {
-		return true;
-	}
-	if (init_gpfs_function_lib(&libgpfs_gpl_handle, "libgpfs_gpl.so",
-				   fn_pointer, fn_name)) {
-		return true;
-	}
-	return false;
+	return init_gpfs_function_lib(&libgpfs_handle, "libgpfs.so",
+				      fn_pointer, fn_name);
 }
 
 void init_gpfs(void)
-- 
1.7.1


From 03d0495f49ba43fa08810ac4ad5ebf38e900a0ed Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 14:45:20 -0700
Subject: [PATCH 04/32] gpfs: Simplify initialization for gpfs library wrapper

Merge the code for initializing the function pointers in one function.

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c     |   97 +++++++++++++++-----------------------------
 source3/modules/vfs_gpfs.c |    7 +++-
 source3/modules/vfs_gpfs.h |    2 +-
 3 files changed, 40 insertions(+), 66 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index b2ca704..d2f032f 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -44,6 +44,39 @@ static int (*gpfs_quotactl_fn)(char *pathname, int cmd, int id, void *bufferP);
 static int (*gpfs_fcntl_fn)(gpfs_file_t fileDesc, void *fcntlArgP);
 static int (*gpfs_getfilesetid_fn)(char *pathname, char *name, int *idP);
 
+#define INIT_GPFS_FUNC(lib, name) { name ## _fn = dlsym(lib,  #name); }
+
+int gpfswrap_init(void)
+{
+	static void *lib;
+
+	if (lib == NULL) {
+		lib = dlopen("libgpfs.so", RTLD_LAZY);
+	}
+
+	if (lib == NULL) {
+		return -1;
+	}
+
+	INIT_GPFS_FUNC(lib, gpfs_set_share);
+	INIT_GPFS_FUNC(lib, gpfs_set_lease);
+	INIT_GPFS_FUNC(lib, gpfs_getacl);
+	INIT_GPFS_FUNC(lib, gpfs_putacl);
+	INIT_GPFS_FUNC(lib, gpfs_get_realfilename_path);
+	INIT_GPFS_FUNC(lib, gpfs_set_winattrs_path);
+	INIT_GPFS_FUNC(lib, gpfs_get_winattrs_path);
+	INIT_GPFS_FUNC(lib, gpfs_get_winattrs);
+	INIT_GPFS_FUNC(lib, gpfs_prealloc);
+	INIT_GPFS_FUNC(lib, gpfs_ftruncate);
+	INIT_GPFS_FUNC(lib, gpfs_lib_init);
+	INIT_GPFS_FUNC(lib, gpfs_set_times_path);
+	INIT_GPFS_FUNC(lib, gpfs_quotactl);
+	INIT_GPFS_FUNC(lib, gpfs_fcntl);
+	INIT_GPFS_FUNC(lib, gpfs_getfilesetid);
+
+	return 0;
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -331,67 +364,3 @@ int smbd_gpfs_set_times_path(char *path, struct smb_file_time *ft)
 
 	return rc;
 }
-
-static bool init_gpfs_function_lib(void *plibhandle_pointer,
-				   const char *libname,
-				   void *pfn_pointer, const char *fn_name)
-{
-	bool did_open_here = false;
-	void **libhandle_pointer = (void **)plibhandle_pointer;
-	void **fn_pointer = (void **)pfn_pointer;
-
-	DEBUG(10, ("trying to load name %s from %s\n",
-		   fn_name, libname));
-
-	if (*libhandle_pointer == NULL) {
-		*libhandle_pointer = dlopen(libname, RTLD_LAZY);
-		did_open_here = true;
-	}
-	if (*libhandle_pointer == NULL) {
-		DEBUG(10, ("Could not open lib %s\n", libname));
-		return false;
-	}
-
-	*fn_pointer = dlsym(*libhandle_pointer, fn_name);
-	if (*fn_pointer == NULL) {
-		DEBUG(10, ("Did not find symbol %s in lib %s\n",
-			   fn_name, libname));
-		if (did_open_here) {
-			dlclose(*libhandle_pointer);
-			*libhandle_pointer = NULL;
-		}
-		return false;
-	}
-
-	return true;
-}
-
-static bool init_gpfs_function(void *fn_pointer, const char *fn_name)
-{
-	static void *libgpfs_handle = NULL;
-
-	return init_gpfs_function_lib(&libgpfs_handle, "libgpfs.so",
-				      fn_pointer, fn_name);
-}
-
-void init_gpfs(void)
-{
-	init_gpfs_function(&gpfs_set_share_fn, "gpfs_set_share");
-	init_gpfs_function(&gpfs_set_lease_fn, "gpfs_set_lease");
-	init_gpfs_function(&gpfs_getacl_fn, "gpfs_getacl");
-	init_gpfs_function(&gpfs_putacl_fn, "gpfs_putacl");
-	init_gpfs_function(&gpfs_get_realfilename_path_fn,
-			   "gpfs_get_realfilename_path");
-	init_gpfs_function(&gpfs_get_winattrs_path_fn,"gpfs_get_winattrs_path");
-        init_gpfs_function(&gpfs_set_winattrs_path_fn,"gpfs_set_winattrs_path");
-        init_gpfs_function(&gpfs_get_winattrs_fn,"gpfs_get_winattrs");
-	init_gpfs_function(&gpfs_prealloc_fn, "gpfs_prealloc");
-	init_gpfs_function(&gpfs_ftruncate_fn, "gpfs_ftruncate");
-        init_gpfs_function(&gpfs_lib_init_fn,"gpfs_lib_init");
-	init_gpfs_function(&gpfs_set_times_path_fn, "gpfs_set_times_path");
-	init_gpfs_function(&gpfs_quotactl_fn, "gpfs_quotactl");
-	init_gpfs_function(&gpfs_fcntl_fn, "gpfs_fcntl");
-	init_gpfs_function(&gpfs_getfilesetid_fn, "gpfs_getfilesetid");
-
-	return;
-}
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 83c5f5b..4a488a3 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -2347,7 +2347,12 @@ static struct vfs_fn_pointers vfs_gpfs_fns = {
 NTSTATUS vfs_gpfs_init(void);
 NTSTATUS vfs_gpfs_init(void)
 {
-	init_gpfs();
+	int ret;
+
+	ret = gpfswrap_init();
+	if (ret != 0) {
+		DEBUG(1, ("Could not initialize GPFS library wrapper\n"));
+	}
 
 	return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "gpfs",
 				&vfs_gpfs_fns);
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index 728231f..d0964da 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -44,5 +44,5 @@ int get_gpfs_quota(const char *pathname, int type, int id,
 int get_gpfs_fset_id(const char *pathname, int *fset_id);
 int smbd_gpfs_set_times_path(char *path, struct smb_file_time *ft);
 
-void init_gpfs(void);
 void smbd_gpfs_lib_init(void);
+int gpfswrap_init(void);
-- 
1.7.1


From ef4038aeea3bb92387f1e817b45a8ae1871f06c0 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 14:52:15 -0700
Subject: [PATCH 05/32] gpfs: Add helper macro for calling library functions

The check whether the function is available is always the same, the
macro avoids some duplicated code.

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index d2f032f..4aea812 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -77,6 +77,15 @@ int gpfswrap_init(void)
 	return 0;
 }
 
+#define GPFS_CALL_LIB_FN(fn, ...)				\
+	{							\
+		if (fn == NULL) {				\
+			errno = ENOSYS;			\
+			return -1;				\
+		}						\
+		return fn ## _fn(__VA_ARGS__);			\
+	}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
-- 
1.7.1


From d806b857094bd7bab4849d223d9e92f5b0171c50 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 15:01:00 -0700
Subject: [PATCH 06/32] gpfs: Introduce wrapper for gpfs_set_share

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c     |   16 +++++++++-------
 source3/modules/vfs_gpfs.h |    1 +
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index 4aea812..c696eca 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -86,6 +86,11 @@ int gpfswrap_init(void)
 		return fn ## _fn(__VA_ARGS__);			\
 	}
 
+int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny)
+{
+	GPFS_CALL_LIB_FN(gpfs_set_share, fd, allow, deny);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -93,10 +98,6 @@ bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 	unsigned int deny = GPFS_DENY_NONE;
 	int result;
 
-	if (gpfs_set_share_fn == NULL) {
-		return False;
-	}
-
 	if ((fsp == NULL) || (fsp->fh == NULL) || (fsp->fh->fd < 0)) {
 		/* No real file, don't disturb */
 		return True;
@@ -119,11 +120,12 @@ bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 	DEBUG(10, ("am=%x, allow=%d, sa=%x, deny=%d\n",
 		   access_mask, allow, share_access, deny));
 
-	result = gpfs_set_share_fn(fsp->fh->fd, allow, deny);
+	result = gpfswrap_set_share(fsp->fh->fd, allow, deny);
 	if (result != 0) {
 		if (errno == ENOSYS) {
-			DEBUG(5, ("VFS module vfs_gpfs loaded, but no gpfs "
-				  "support has been compiled into Samba. Allowing access\n"));
+			DEBUG(5, ("VFS module vfs_gpfs loaded, but gpfs "
+				  "set_share function support not available. "
+				  "Allowing access\n"));
 			return True;
 		} else {
 			DEBUG(10, ("gpfs_set_share failed: %s\n",
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index d0964da..b348c69 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -27,6 +27,7 @@
 #define GPFS_GETACL_NATIVE 0x00000004
 #endif
 
+int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny);
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access);
 int set_gpfs_lease(int fd, int leasetype);
-- 
1.7.1


From c39bed2f0e20dcdb486db78aab5e91e507019724 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 15:06:02 -0700
Subject: [PATCH 07/32] gpfs: Introduce wrapper for gpfs_set_lease

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c     |   14 +++++++-------
 source3/modules/vfs_gpfs.h |    1 +
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index c696eca..4913de8 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -27,7 +27,7 @@
 #include "vfs_gpfs.h"
 
 static int (*gpfs_set_share_fn)(int fd, unsigned int allow, unsigned int deny);
-static int (*gpfs_set_lease_fn)(int fd, unsigned int leaseType);
+static int (*gpfs_set_lease_fn)(int fd, unsigned int type);
 static int (*gpfs_getacl_fn)(char *pathname, int flags, void *acl);
 static int (*gpfs_putacl_fn)(char *pathname, int flags, void *acl);
 static int (*gpfs_get_realfilename_path_fn)(char *pathname, char *filenamep,
@@ -91,6 +91,11 @@ int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny)
 	GPFS_CALL_LIB_FN(gpfs_set_share, fd, allow, deny);
 }
 
+int gpfswrap_set_lease(int fd, unsigned int type)
+{
+	GPFS_CALL_LIB_FN(gpfs_set_lease, fd, type);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -140,11 +145,6 @@ int set_gpfs_lease(int fd, int leasetype)
 {
 	int gpfs_type = GPFS_LEASE_NONE;
 
-	if (gpfs_set_lease_fn == NULL) {
-		errno = EINVAL;
-		return -1;
-	}
-
 	if (leasetype == F_RDLCK) {
 		gpfs_type = GPFS_LEASE_READ;
 	}
@@ -158,7 +158,7 @@ int set_gpfs_lease(int fd, int leasetype)
 	   each time we try this with the wrong capabilities set
 	*/
 	linux_set_lease_capability();
-	return gpfs_set_lease_fn(fd, gpfs_type);
+	return gpfswrap_set_lease(fd, gpfs_type);
 }
 
 int smbd_gpfs_getacl(char *pathname, int flags, void *acl)
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index b348c69..b85282e 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -28,6 +28,7 @@
 #endif
 
 int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny);
+int gpfswrap_set_lease(int fd, unsigned int type);
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access);
 int set_gpfs_lease(int fd, int leasetype);
-- 
1.7.1


From 89819ba28121c7de7d011c830c3ea1a93d616030 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 15:09:07 -0700
Subject: [PATCH 08/32] gpfs: Rename wrapper for gpfs_getacl

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c     |   15 +++++----------
 source3/modules/vfs_gpfs.c |    2 +-
 source3/modules/vfs_gpfs.h |    2 +-
 3 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index 4913de8..413421f 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -96,6 +96,11 @@ int gpfswrap_set_lease(int fd, unsigned int type)
 	GPFS_CALL_LIB_FN(gpfs_set_lease, fd, type);
 }
 
+int gpfswrap_getacl(char *pathname, int flags, void *acl)
+{
+	GPFS_CALL_LIB_FN(gpfs_getacl, pathname, flags, acl);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -161,16 +166,6 @@ int set_gpfs_lease(int fd, int leasetype)
 	return gpfswrap_set_lease(fd, gpfs_type);
 }
 
-int smbd_gpfs_getacl(char *pathname, int flags, void *acl)
-{
-	if (gpfs_getacl_fn == NULL) {
-		errno = ENOSYS;
-		return -1;
-	}
-
-	return gpfs_getacl_fn(pathname, flags, acl);
-}
-
 int smbd_gpfs_putacl(char *pathname, int flags, void *acl)
 {
 	if (gpfs_putacl_fn == NULL) {
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 4a488a3..19ee6b5 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -327,7 +327,7 @@ again:
 	*len = size;
 
 	errno = 0;
-	ret = smbd_gpfs_getacl(discard_const_p(char, fname), flags, aclbuf);
+	ret = gpfswrap_getacl(discard_const_p(char, fname), flags, aclbuf);
 	if ((ret != 0) && (errno == ENOSPC)) {
 		/*
 		 * get the size needed to accommodate the complete buffer
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index b85282e..5b70c4c 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -29,10 +29,10 @@
 
 int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny);
 int gpfswrap_set_lease(int fd, unsigned int type);
+int gpfswrap_getacl(char *pathname, int flags, void *acl);
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access);
 int set_gpfs_lease(int fd, int leasetype);
-int smbd_gpfs_getacl(char *pathname, int flags, void *acl);
 int smbd_gpfs_putacl(char *pathname, int flags, void *acl);
 int smbd_gpfs_get_realfilename_path(char *pathname, char *filenamep,
 				    int *buflen);
-- 
1.7.1


From 5ae72990795ef0558b672a191a1e8994270b1ed9 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 15:11:18 -0700
Subject: [PATCH 09/32] gpfs: Rename wrapper for gpfs_putacl

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c     |   15 +++++----------
 source3/modules/vfs_gpfs.c |   14 +++++++-------
 source3/modules/vfs_gpfs.h |    2 +-
 3 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index 413421f..57860e2 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -101,6 +101,11 @@ int gpfswrap_getacl(char *pathname, int flags, void *acl)
 	GPFS_CALL_LIB_FN(gpfs_getacl, pathname, flags, acl);
 }
 
+int gpfswrap_putacl(char *pathname, int flags, void *acl)
+{
+	GPFS_CALL_LIB_FN(gpfs_putacl, pathname, flags, acl);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -166,16 +171,6 @@ int set_gpfs_lease(int fd, int leasetype)
 	return gpfswrap_set_lease(fd, gpfs_type);
 }
 
-int smbd_gpfs_putacl(char *pathname, int flags, void *acl)
-{
-	if (gpfs_putacl_fn == NULL) {
-		errno = ENOSYS;
-		return -1;
-	}
-
-	return gpfs_putacl_fn(pathname, flags, acl);
-}
-
 int smbd_gpfs_ftruncate(int fd, gpfs_off64_t length)
 {
 	if (gpfs_ftruncate_fn == NULL) {
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 19ee6b5..dcd866a 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -646,8 +646,8 @@ static bool gpfsacl_process_smbacl(vfs_handle_struct *handle,
 	if (gacl == NULL) { /* out of memory */
 		return False;
 	}
-	ret = smbd_gpfs_putacl(fsp->fsp_name->base_name,
-			       GPFS_PUTACL_STRUCT | GPFS_ACL_SAMBA, gacl);
+	ret = gpfswrap_putacl(fsp->fsp_name->base_name,
+			      GPFS_PUTACL_STRUCT | GPFS_ACL_SAMBA, gacl);
 
 	if ((ret != 0) && (errno == EINVAL)) {
 		DEBUG(10, ("Retry without nfs41 control flags\n"));
@@ -656,9 +656,9 @@ static bool gpfsacl_process_smbacl(vfs_handle_struct *handle,
 		if (gacl == NULL) { /* out of memory */
 			return False;
 		}
-		ret = smbd_gpfs_putacl(fsp->fsp_name->base_name,
-				       GPFS_PUTACL_STRUCT | GPFS_ACL_SAMBA,
-				       gacl);
+		ret = gpfswrap_putacl(fsp->fsp_name->base_name,
+				      GPFS_PUTACL_STRUCT | GPFS_ACL_SAMBA,
+				      gacl);
 	}
 
 	if (ret != 0) {
@@ -1127,8 +1127,8 @@ static int gpfsacl_sys_acl_set_file(vfs_handle_struct *handle,
 		return -1;
 	}
 
-	result = smbd_gpfs_putacl(discard_const_p(char, name),
-				  GPFS_PUTACL_STRUCT|GPFS_ACL_SAMBA, gpfs_acl);
+	result = gpfswrap_putacl(discard_const_p(char, name),
+				 GPFS_PUTACL_STRUCT|GPFS_ACL_SAMBA, gpfs_acl);
 
 	SAFE_FREE(gpfs_acl);
 	return result;
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index 5b70c4c..8e630f5 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -30,10 +30,10 @@
 int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny);
 int gpfswrap_set_lease(int fd, unsigned int type);
 int gpfswrap_getacl(char *pathname, int flags, void *acl);
+int gpfswrap_putacl(char *pathname, int flags, void *acl);
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access);
 int set_gpfs_lease(int fd, int leasetype);
-int smbd_gpfs_putacl(char *pathname, int flags, void *acl);
 int smbd_gpfs_get_realfilename_path(char *pathname, char *filenamep,
 				    int *buflen);
 int smbd_fget_gpfs_winattrs(int fd, struct gpfs_winattr *attrs);
-- 
1.7.1


From 71e957887b7e919b8041d6065b535bb66cc7a6a4 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 15:15:53 -0700
Subject: [PATCH 10/32] gpfs: Rename wrapper for gpfs_get_realfilename_path

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c     |   18 ++++++------------
 source3/modules/vfs_gpfs.c |    4 ++--
 source3/modules/vfs_gpfs.h |    3 +--
 3 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index 57860e2..b36f736 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -31,7 +31,7 @@ static int (*gpfs_set_lease_fn)(int fd, unsigned int type);
 static int (*gpfs_getacl_fn)(char *pathname, int flags, void *acl);
 static int (*gpfs_putacl_fn)(char *pathname, int flags, void *acl);
 static int (*gpfs_get_realfilename_path_fn)(char *pathname, char *filenamep,
-					    int *buflen);
+					    int *len);
 static int (*gpfs_set_winattrs_path_fn)(char *pathname, int flags, struct gpfs_winattr *attrs);
 static int (*gpfs_get_winattrs_path_fn)(char *pathname, struct gpfs_winattr *attrs);
 static int (*gpfs_get_winattrs_fn)(int fd, struct gpfs_winattr *attrs);
@@ -106,6 +106,11 @@ int gpfswrap_putacl(char *pathname, int flags, void *acl)
 	GPFS_CALL_LIB_FN(gpfs_putacl, pathname, flags, acl);
 }
 
+int gpfswrap_get_realfilename_path(char *pathname, char *filenamep, int *len)
+{
+	GPFS_CALL_LIB_FN(gpfs_get_realfilename_path, pathname, filenamep, len);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -181,17 +186,6 @@ int smbd_gpfs_ftruncate(int fd, gpfs_off64_t length)
 	return gpfs_ftruncate_fn(fd, length);
 }
 
-int smbd_gpfs_get_realfilename_path(char *pathname, char *filenamep,
-				    int *buflen)
-{
-	if (gpfs_get_realfilename_path_fn == NULL) {
-		errno = ENOSYS;
-		return -1;
-	}
-
-	return gpfs_get_realfilename_path_fn(pathname, filenamep, buflen);
-}
-
 int get_gpfs_winattrs(char *pathname,struct gpfs_winattr *attrs)
 {
 	if (gpfs_get_winattrs_path_fn == NULL) {
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index dcd866a..92af873 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -181,8 +181,8 @@ static int vfs_gpfs_get_real_filename(struct vfs_handle_struct *handle,
 
 	buflen = sizeof(real_pathname) - 1;
 
-	result = smbd_gpfs_get_realfilename_path(full_path, real_pathname,
-						 &buflen);
+	result = gpfswrap_get_realfilename_path(full_path, real_pathname,
+						&buflen);
 
 	TALLOC_FREE(full_path);
 
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index 8e630f5..e788956 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -31,11 +31,10 @@ int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny);
 int gpfswrap_set_lease(int fd, unsigned int type);
 int gpfswrap_getacl(char *pathname, int flags, void *acl);
 int gpfswrap_putacl(char *pathname, int flags, void *acl);
+int gpfswrap_get_realfilename_path(char *pathname, char *filenamep, int *len);
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access);
 int set_gpfs_lease(int fd, int leasetype);
-int smbd_gpfs_get_realfilename_path(char *pathname, char *filenamep,
-				    int *buflen);
 int smbd_fget_gpfs_winattrs(int fd, struct gpfs_winattr *attrs);
 int get_gpfs_winattrs(char * pathname,struct gpfs_winattr *attrs);
 int set_gpfs_winattrs(char * pathname,int flags,struct gpfs_winattr *attrs);
-- 
1.7.1


From 2509bc553f965544f40b0d4d21d4e72cf8a90678 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 15:22:27 -0700
Subject: [PATCH 11/32] gpfs: Rename wrapper for gpfs_set_winattrs_path

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c     |   20 ++++++++------------
 source3/modules/vfs_gpfs.c |    9 +++++----
 source3/modules/vfs_gpfs.h |    3 ++-
 3 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index b36f736..e1fb26d 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -32,7 +32,8 @@ static int (*gpfs_getacl_fn)(char *pathname, int flags, void *acl);
 static int (*gpfs_putacl_fn)(char *pathname, int flags, void *acl);
 static int (*gpfs_get_realfilename_path_fn)(char *pathname, char *filenamep,
 					    int *len);
-static int (*gpfs_set_winattrs_path_fn)(char *pathname, int flags, struct gpfs_winattr *attrs);
+static int (*gpfs_set_winattrs_path_fn)(char *pathname, int flags,
+					struct gpfs_winattr *attrs);
 static int (*gpfs_get_winattrs_path_fn)(char *pathname, struct gpfs_winattr *attrs);
 static int (*gpfs_get_winattrs_fn)(int fd, struct gpfs_winattr *attrs);
 static int (*gpfs_prealloc_fn)(int fd, gpfs_off64_t startOffset, gpfs_off64_t bytesToPrealloc);
@@ -111,6 +112,12 @@ int gpfswrap_get_realfilename_path(char *pathname, char *filenamep, int *len)
 	GPFS_CALL_LIB_FN(gpfs_get_realfilename_path, pathname, filenamep, len);
 }
 
+int gpfswrap_set_winattrs_path(char *pathname, int flags,
+			       struct gpfs_winattr *attrs)
+{
+	GPFS_CALL_LIB_FN(gpfs_set_winattrs_path, pathname, flags, attrs);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -216,17 +223,6 @@ int smbd_gpfs_prealloc(int fd, gpfs_off64_t start, gpfs_off64_t bytes)
 	return gpfs_prealloc_fn(fd, start, bytes);
 }
 
-int set_gpfs_winattrs(char *pathname,int flags,struct gpfs_winattr *attrs)
-{
-	if (gpfs_set_winattrs_path_fn == NULL) {
-                errno = ENOSYS;
-                return -1;
-        }
-
-        DEBUG(10, ("gpfs_set_winattrs_path:open call %s\n",pathname));
-        return gpfs_set_winattrs_path_fn(pathname,flags, attrs);
-}
-
 int get_gpfs_quota(const char *pathname, int type, int id,
 		   struct gpfs_quotaInfo *qi)
 {
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 92af873..8214352 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -1425,8 +1425,8 @@ static int gpfs_set_xattr(struct vfs_handle_struct *handle,  const char *path,
 	}
 
 
-        ret = set_gpfs_winattrs(discard_const_p(char, path),
-				GPFS_WINATTR_SET_ATTRS, &attrs);
+	ret = gpfswrap_set_winattrs_path(discard_const_p(char, path),
+					 GPFS_WINATTR_SET_ATTRS, &attrs);
         if ( ret == -1){
 		if (errno == ENOSYS) {
 			return SMB_VFS_NEXT_SETXATTR(handle, path, name, value,
@@ -1726,8 +1726,9 @@ static int vfs_gpfs_ntimes(struct vfs_handle_struct *handle,
         attrs.creationTime.tv_sec = ft->create_time.tv_sec;
         attrs.creationTime.tv_nsec = ft->create_time.tv_nsec;
 
-        ret = set_gpfs_winattrs(discard_const_p(char, path),
-                                GPFS_WINATTR_SET_CREATION_TIME, &attrs);
+	ret = gpfswrap_set_winattrs_path(discard_const_p(char, path),
+					 GPFS_WINATTR_SET_CREATION_TIME,
+					 &attrs);
         if(ret == -1 && errno != ENOSYS){
                 DEBUG(1,("vfs_gpfs_ntimes: set GPFS ntimes failed %d\n",ret));
 	        return -1;
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index e788956..9db3d9d 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -32,12 +32,13 @@ int gpfswrap_set_lease(int fd, unsigned int type);
 int gpfswrap_getacl(char *pathname, int flags, void *acl);
 int gpfswrap_putacl(char *pathname, int flags, void *acl);
 int gpfswrap_get_realfilename_path(char *pathname, char *filenamep, int *len);
+int gpfswrap_set_winattrs_path(char *pathname, int flags,
+			       struct gpfs_winattr *attrs);
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access);
 int set_gpfs_lease(int fd, int leasetype);
 int smbd_fget_gpfs_winattrs(int fd, struct gpfs_winattr *attrs);
 int get_gpfs_winattrs(char * pathname,struct gpfs_winattr *attrs);
-int set_gpfs_winattrs(char * pathname,int flags,struct gpfs_winattr *attrs);
 int smbd_gpfs_prealloc(int fd, gpfs_off64_t start, gpfs_off64_t bytes);
 int smbd_gpfs_ftruncate(int fd, gpfs_off64_t length);
 int get_gpfs_quota(const char *pathname, int type, int id,
-- 
1.7.1


From 334b2d64dea85949fcf16fb1c19d284c7ff010a7 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 15:27:05 -0700
Subject: [PATCH 12/32] gpfs: Rename wrapper for gpfs_get_winattrs_path

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c     |   18 +++++++-----------
 source3/modules/vfs_gpfs.c |    8 ++++----
 source3/modules/vfs_gpfs.h |    2 +-
 3 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index e1fb26d..87f4168 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -34,7 +34,8 @@ static int (*gpfs_get_realfilename_path_fn)(char *pathname, char *filenamep,
 					    int *len);
 static int (*gpfs_set_winattrs_path_fn)(char *pathname, int flags,
 					struct gpfs_winattr *attrs);
-static int (*gpfs_get_winattrs_path_fn)(char *pathname, struct gpfs_winattr *attrs);
+static int (*gpfs_get_winattrs_path_fn)(char *pathname,
+					struct gpfs_winattr *attrs);
 static int (*gpfs_get_winattrs_fn)(int fd, struct gpfs_winattr *attrs);
 static int (*gpfs_prealloc_fn)(int fd, gpfs_off64_t startOffset, gpfs_off64_t bytesToPrealloc);
 static int (*gpfs_ftruncate_fn)(int fd, gpfs_off64_t length);
@@ -118,6 +119,11 @@ int gpfswrap_set_winattrs_path(char *pathname, int flags,
 	GPFS_CALL_LIB_FN(gpfs_set_winattrs_path, pathname, flags, attrs);
 }
 
+int gpfswrap_get_winattrs_path(char *pathname, struct gpfs_winattr *attrs)
+{
+	GPFS_CALL_LIB_FN(gpfs_get_winattrs_path, pathname, attrs);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -193,16 +199,6 @@ int smbd_gpfs_ftruncate(int fd, gpfs_off64_t length)
 	return gpfs_ftruncate_fn(fd, length);
 }
 
-int get_gpfs_winattrs(char *pathname,struct gpfs_winattr *attrs)
-{
-	if (gpfs_get_winattrs_path_fn == NULL) {
-                errno = ENOSYS;
-                return -1;
-        }
-        DEBUG(10, ("gpfs_get_winattrs_path:open call %s\n",pathname));
-        return gpfs_get_winattrs_path_fn(pathname, attrs);
-}
-
 int smbd_fget_gpfs_winattrs(int fd, struct gpfs_winattr *attrs)
 {
 	if (gpfs_get_winattrs_fn == NULL) {
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 8214352..0ea72e9 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -1466,7 +1466,7 @@ static ssize_t gpfs_get_xattr(struct vfs_handle_struct *handle,  const char *pat
                 return SMB_VFS_NEXT_GETXATTR(handle,path,name,value,size);
         }
 
-        ret = get_gpfs_winattrs(discard_const_p(char, path), &attrs);
+	ret = gpfswrap_get_winattrs_path(discard_const_p(char, path), &attrs);
         if ( ret == -1){
 		int dbg_lvl;
 
@@ -1584,7 +1584,7 @@ static int vfs_gpfs_stat(struct vfs_handle_struct *handle,
 		errno = map_errno_from_nt_status(status);
 		return -1;
 	}
-	ret = get_gpfs_winattrs(discard_const_p(char, fname), &attrs);
+	ret = gpfswrap_get_winattrs_path(discard_const_p(char, fname), &attrs);
 	TALLOC_FREE(fname);
 	if (ret == 0) {
 		smb_fname->st.st_ex_calculated_birthtime = false;
@@ -1660,7 +1660,7 @@ static int vfs_gpfs_lstat(struct vfs_handle_struct *handle,
 		errno = map_errno_from_nt_status(status);
 		return -1;
 	}
-	ret = get_gpfs_winattrs(discard_const_p(char, path), &attrs);
+	ret = gpfswrap_get_winattrs_path(discard_const_p(char, path), &attrs);
 	TALLOC_FREE(path);
 	if (ret == 0) {
 		smb_fname->st.st_ex_calculated_birthtime = false;
@@ -1818,7 +1818,7 @@ static bool vfs_gpfs_is_offline(struct vfs_handle_struct *handle,
 		return -1;
 	}
 
-	ret = get_gpfs_winattrs(path, &attrs);
+	ret = gpfswrap_get_winattrs_path(path, &attrs);
 	if (ret == -1) {
 		TALLOC_FREE(path);
 		return false;
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index 9db3d9d..afb8884 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -34,11 +34,11 @@ int gpfswrap_putacl(char *pathname, int flags, void *acl);
 int gpfswrap_get_realfilename_path(char *pathname, char *filenamep, int *len);
 int gpfswrap_set_winattrs_path(char *pathname, int flags,
 			       struct gpfs_winattr *attrs);
+int gpfswrap_get_winattrs_path(char *pathname, struct gpfs_winattr *attrs);
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access);
 int set_gpfs_lease(int fd, int leasetype);
 int smbd_fget_gpfs_winattrs(int fd, struct gpfs_winattr *attrs);
-int get_gpfs_winattrs(char * pathname,struct gpfs_winattr *attrs);
 int smbd_gpfs_prealloc(int fd, gpfs_off64_t start, gpfs_off64_t bytes);
 int smbd_gpfs_ftruncate(int fd, gpfs_off64_t length);
 int get_gpfs_quota(const char *pathname, int type, int id,
-- 
1.7.1


From 5d260a3ba7b1b5777a206845beb59290d58e07ed Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 15:29:19 -0700
Subject: [PATCH 13/32] gpfs: Rename wrapper for gpfs_get_winattrs

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c     |   15 +++++----------
 source3/modules/vfs_gpfs.c |    2 +-
 source3/modules/vfs_gpfs.h |    2 +-
 3 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index 87f4168..0b18cb3 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -124,6 +124,11 @@ int gpfswrap_get_winattrs_path(char *pathname, struct gpfs_winattr *attrs)
 	GPFS_CALL_LIB_FN(gpfs_get_winattrs_path, pathname, attrs);
 }
 
+int gpfswrap_get_winattrs(int fd, struct gpfs_winattr *attrs)
+{
+	GPFS_CALL_LIB_FN(gpfs_get_winattrs, fd, attrs);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -199,16 +204,6 @@ int smbd_gpfs_ftruncate(int fd, gpfs_off64_t length)
 	return gpfs_ftruncate_fn(fd, length);
 }
 
-int smbd_fget_gpfs_winattrs(int fd, struct gpfs_winattr *attrs)
-{
-	if (gpfs_get_winattrs_fn == NULL) {
-                errno = ENOSYS;
-                return -1;
-        }
-        DEBUG(10, ("gpfs_get_winattrs:open call %d\n", fd));
-        return gpfs_get_winattrs_fn(fd, attrs);
-}
-
 int smbd_gpfs_prealloc(int fd, gpfs_off64_t start, gpfs_off64_t bytes)
 {
 	if (gpfs_prealloc_fn == NULL) {
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 0ea72e9..4e3ea95 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -1616,7 +1616,7 @@ static int vfs_gpfs_fstat(struct vfs_handle_struct *handle,
 		return 0;
 	}
 
-	ret = smbd_fget_gpfs_winattrs(fsp->fh->fd, &attrs);
+	ret = gpfswrap_get_winattrs(fsp->fh->fd, &attrs);
 	if (ret == 0) {
 		sbuf->st_ex_calculated_birthtime = false;
 		sbuf->st_ex_btime.tv_sec = attrs.creationTime.tv_sec;
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index afb8884..c5e0a20 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -35,10 +35,10 @@ int gpfswrap_get_realfilename_path(char *pathname, char *filenamep, int *len);
 int gpfswrap_set_winattrs_path(char *pathname, int flags,
 			       struct gpfs_winattr *attrs);
 int gpfswrap_get_winattrs_path(char *pathname, struct gpfs_winattr *attrs);
+int gpfswrap_get_winattrs(int fd, struct gpfs_winattr *attrs);
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access);
 int set_gpfs_lease(int fd, int leasetype);
-int smbd_fget_gpfs_winattrs(int fd, struct gpfs_winattr *attrs);
 int smbd_gpfs_prealloc(int fd, gpfs_off64_t start, gpfs_off64_t bytes);
 int smbd_gpfs_ftruncate(int fd, gpfs_off64_t length);
 int get_gpfs_quota(const char *pathname, int type, int id,
-- 
1.7.1


From 582e63a2b44cb544500d03d1e3a8da32c00b366e Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 15:31:42 -0700
Subject: [PATCH 14/32] gpfs: Rename wrapper for gpfs_prealloc

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c     |   17 ++++++-----------
 source3/modules/vfs_gpfs.c |    2 +-
 source3/modules/vfs_gpfs.h |    2 +-
 3 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index 0b18cb3..e6b0c17 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -37,7 +37,7 @@ static int (*gpfs_set_winattrs_path_fn)(char *pathname, int flags,
 static int (*gpfs_get_winattrs_path_fn)(char *pathname,
 					struct gpfs_winattr *attrs);
 static int (*gpfs_get_winattrs_fn)(int fd, struct gpfs_winattr *attrs);
-static int (*gpfs_prealloc_fn)(int fd, gpfs_off64_t startOffset, gpfs_off64_t bytesToPrealloc);
+static int (*gpfs_prealloc_fn)(int fd, gpfs_off64_t start, gpfs_off64_t bytes);
 static int (*gpfs_ftruncate_fn)(int fd, gpfs_off64_t length);
 static int (*gpfs_lib_init_fn)(int flags);
 static int (*gpfs_set_times_path_fn)(char *pathname, int flags,
@@ -129,6 +129,11 @@ int gpfswrap_get_winattrs(int fd, struct gpfs_winattr *attrs)
 	GPFS_CALL_LIB_FN(gpfs_get_winattrs, fd, attrs);
 }
 
+int gpfswrap_prealloc(int fd, gpfs_off64_t start, gpfs_off64_t bytes)
+{
+	GPFS_CALL_LIB_FN(gpfs_prealloc, fd, start, bytes);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -204,16 +209,6 @@ int smbd_gpfs_ftruncate(int fd, gpfs_off64_t length)
 	return gpfs_ftruncate_fn(fd, length);
 }
 
-int smbd_gpfs_prealloc(int fd, gpfs_off64_t start, gpfs_off64_t bytes)
-{
-	if (gpfs_prealloc_fn == NULL) {
-		errno = ENOSYS;
-		return -1;
-	}
-
-	return gpfs_prealloc_fn(fd, start, bytes);
-}
-
 int get_gpfs_quota(const char *pathname, int type, int id,
 		   struct gpfs_quotaInfo *qi)
 {
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 4e3ea95..99b2121 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -1760,7 +1760,7 @@ static int vfs_gpfs_fallocate(struct vfs_handle_struct *handle,
 		return -1;
 	}
 
-	ret = smbd_gpfs_prealloc(fsp->fh->fd, offset, len);
+	ret = gpfswrap_prealloc(fsp->fh->fd, offset, len);
 
 	if (ret == -1 && errno != ENOSYS) {
 		DEBUG(0, ("GPFS prealloc failed: %s\n", strerror(errno)));
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index c5e0a20..9c87b59 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -36,10 +36,10 @@ int gpfswrap_set_winattrs_path(char *pathname, int flags,
 			       struct gpfs_winattr *attrs);
 int gpfswrap_get_winattrs_path(char *pathname, struct gpfs_winattr *attrs);
 int gpfswrap_get_winattrs(int fd, struct gpfs_winattr *attrs);
+int gpfswrap_prealloc(int fd, gpfs_off64_t start, gpfs_off64_t bytes);
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access);
 int set_gpfs_lease(int fd, int leasetype);
-int smbd_gpfs_prealloc(int fd, gpfs_off64_t start, gpfs_off64_t bytes);
 int smbd_gpfs_ftruncate(int fd, gpfs_off64_t length);
 int get_gpfs_quota(const char *pathname, int type, int id,
 		   struct gpfs_quotaInfo *qi);
-- 
1.7.1


From 90d029ea2438c03d02334f45f27e96879a571da5 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 15:33:23 -0700
Subject: [PATCH 15/32] gpfs: Rename wrapper for gpfs_ftruncate

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c     |   15 +++++----------
 source3/modules/vfs_gpfs.c |    2 +-
 source3/modules/vfs_gpfs.h |    2 +-
 3 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index e6b0c17..e80f02d 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -134,6 +134,11 @@ int gpfswrap_prealloc(int fd, gpfs_off64_t start, gpfs_off64_t bytes)
 	GPFS_CALL_LIB_FN(gpfs_prealloc, fd, start, bytes);
 }
 
+int gpfswrap_ftruncate(int fd, gpfs_off64_t length)
+{
+	GPFS_CALL_LIB_FN(gpfs_ftruncate, fd, length);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -199,16 +204,6 @@ int set_gpfs_lease(int fd, int leasetype)
 	return gpfswrap_set_lease(fd, gpfs_type);
 }
 
-int smbd_gpfs_ftruncate(int fd, gpfs_off64_t length)
-{
-	if (gpfs_ftruncate_fn == NULL) {
-		errno = ENOSYS;
-		return -1;
-	}
-
-	return gpfs_ftruncate_fn(fd, length);
-}
-
 int get_gpfs_quota(const char *pathname, int type, int id,
 		   struct gpfs_quotaInfo *qi)
 {
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 99b2121..25910ad 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -1787,7 +1787,7 @@ static int vfs_gpfs_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
 		return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
 	}
 
-	result = smbd_gpfs_ftruncate(fsp->fh->fd, len);
+	result = gpfswrap_ftruncate(fsp->fh->fd, len);
 	if ((result == -1) && (errno == ENOSYS)) {
 		return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
 	}
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index 9c87b59..dfe149d 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -37,10 +37,10 @@ int gpfswrap_set_winattrs_path(char *pathname, int flags,
 int gpfswrap_get_winattrs_path(char *pathname, struct gpfs_winattr *attrs);
 int gpfswrap_get_winattrs(int fd, struct gpfs_winattr *attrs);
 int gpfswrap_prealloc(int fd, gpfs_off64_t start, gpfs_off64_t bytes);
+int gpfswrap_ftruncate(int fd, gpfs_off64_t length);
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access);
 int set_gpfs_lease(int fd, int leasetype);
-int smbd_gpfs_ftruncate(int fd, gpfs_off64_t length);
 int get_gpfs_quota(const char *pathname, int type, int id,
 		   struct gpfs_quotaInfo *qi);
 int get_gpfs_fset_id(const char *pathname, int *fset_id);
-- 
1.7.1


From 61110fbf0919fb822ba40ca021544112944b4d0d Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 15:34:59 -0700
Subject: [PATCH 16/32] gpfs: Rename wrapper for gpfs_lib_init

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c     |   16 +++++-----------
 source3/modules/vfs_gpfs.c |    2 +-
 source3/modules/vfs_gpfs.h |    2 +-
 3 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index e80f02d..cc881a2 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -139,6 +139,11 @@ int gpfswrap_ftruncate(int fd, gpfs_off64_t length)
 	GPFS_CALL_LIB_FN(gpfs_ftruncate, fd, length);
 }
 
+int gpfswrap_lib_init(int flags)
+{
+	GPFS_CALL_LIB_FN(gpfs_lib_init, flags);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -283,17 +288,6 @@ int get_gpfs_fset_id(const char *pathname, int *fset_id)
 	return err;
 }
 
-void smbd_gpfs_lib_init()
-{
-	if (gpfs_lib_init_fn) {
-		int rc = gpfs_lib_init_fn(0);
-		DEBUG(10, ("gpfs_lib_init() finished with rc %d "
-			   "and errno %d\n", rc, errno));
-	} else {
-		DEBUG(10, ("libgpfs lacks gpfs_lib_init\n"));
-	}
-}
-
 static void timespec_to_gpfs_time(struct timespec ts, gpfs_timestruc_t *gt,
 				  int idx, int *flags)
 {
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 25910ad..46cfde6 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -1858,7 +1858,7 @@ static int vfs_gpfs_connect(struct vfs_handle_struct *handle,
 	struct gpfs_config_data *config;
 	int ret;
 
-	smbd_gpfs_lib_init();
+	gpfswrap_lib_init(0);
 
 	config = talloc_zero(handle->conn, struct gpfs_config_data);
 	if (!config) {
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index dfe149d..d3496fa 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -38,6 +38,7 @@ int gpfswrap_get_winattrs_path(char *pathname, struct gpfs_winattr *attrs);
 int gpfswrap_get_winattrs(int fd, struct gpfs_winattr *attrs);
 int gpfswrap_prealloc(int fd, gpfs_off64_t start, gpfs_off64_t bytes);
 int gpfswrap_ftruncate(int fd, gpfs_off64_t length);
+int gpfswrap_lib_init(int flags);
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access);
 int set_gpfs_lease(int fd, int leasetype);
@@ -46,5 +47,4 @@ int get_gpfs_quota(const char *pathname, int type, int id,
 int get_gpfs_fset_id(const char *pathname, int *fset_id);
 int smbd_gpfs_set_times_path(char *path, struct smb_file_time *ft);
 
-void smbd_gpfs_lib_init(void);
 int gpfswrap_init(void);
-- 
1.7.1


From 41da34e5a62798a617a5cf495f473da144bd9ee6 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 15:40:16 -0700
Subject: [PATCH 17/32] gpfs: Introduce wrapper for gpfs_set_times_path

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c     |   15 ++++++++-------
 source3/modules/vfs_gpfs.h |    2 ++
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index cc881a2..d58ab47 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -144,6 +144,12 @@ int gpfswrap_lib_init(int flags)
 	GPFS_CALL_LIB_FN(gpfs_lib_init, flags);
 }
 
+int gpfswrap_set_times_path(char *pathname, int flags,
+			    gpfs_timestruc_t times[4])
+{
+	GPFS_CALL_LIB_FN(gpfs_set_times_path, pathname, flags, times);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -305,11 +311,6 @@ int smbd_gpfs_set_times_path(char *path, struct smb_file_time *ft)
 	int flags = 0;
 	int rc;
 
-	if (!gpfs_set_times_path_fn) {
-		errno = ENOSYS;
-		return -1;
-	}
-
 	ZERO_ARRAY(gpfs_times);
 	timespec_to_gpfs_time(ft->atime, gpfs_times, 0, &flags);
 	timespec_to_gpfs_time(ft->mtime, gpfs_times, 1, &flags);
@@ -321,9 +322,9 @@ int smbd_gpfs_set_times_path(char *path, struct smb_file_time *ft)
 		return 0;
 	}
 
-	rc = gpfs_set_times_path_fn(path, flags, gpfs_times);
+	rc = gpfswrap_set_times_path(path, flags, gpfs_times);
 
-	if (rc != 0) {
+	if (rc != 0 && errno != ENOSYS) {
 		DEBUG(1,("gpfs_set_times() returned with error %s\n",
 			strerror(errno)));
 	}
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index d3496fa..583cff3 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -39,6 +39,8 @@ int gpfswrap_get_winattrs(int fd, struct gpfs_winattr *attrs);
 int gpfswrap_prealloc(int fd, gpfs_off64_t start, gpfs_off64_t bytes);
 int gpfswrap_ftruncate(int fd, gpfs_off64_t length);
 int gpfswrap_lib_init(int flags);
+int gpfswrap_set_times_path(char *pathname, int flags,
+			    gpfs_timestruc_t times[4]);
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access);
 int set_gpfs_lease(int fd, int leasetype);
-- 
1.7.1


From 2e1f78dd516cfc56306e5f6b9034efc52620611b Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 15:42:32 -0700
Subject: [PATCH 18/32] gpfs: Introduce wrapper for gpfs_quotactl

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c     |   18 +++++++++---------
 source3/modules/vfs_gpfs.h |    1 +
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index d58ab47..733de00 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -42,7 +42,7 @@ static int (*gpfs_ftruncate_fn)(int fd, gpfs_off64_t length);
 static int (*gpfs_lib_init_fn)(int flags);
 static int (*gpfs_set_times_path_fn)(char *pathname, int flags,
 				     gpfs_timestruc_t times[4]);
-static int (*gpfs_quotactl_fn)(char *pathname, int cmd, int id, void *bufferP);
+static int (*gpfs_quotactl_fn)(char *pathname, int cmd, int id, void *bufp);
 static int (*gpfs_fcntl_fn)(gpfs_file_t fileDesc, void *fcntlArgP);
 static int (*gpfs_getfilesetid_fn)(char *pathname, char *name, int *idP);
 
@@ -150,6 +150,11 @@ int gpfswrap_set_times_path(char *pathname, int flags,
 	GPFS_CALL_LIB_FN(gpfs_set_times_path, pathname, flags, times);
 }
 
+int gpfswrap_quotactl(char *pathname, int cmd, int id, void *bufp)
+{
+	GPFS_CALL_LIB_FN(gpfs_quotactl, pathname, cmd, id, bufp);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -220,19 +225,14 @@ int get_gpfs_quota(const char *pathname, int type, int id,
 {
 	int ret;
 
-	if (!gpfs_quotactl_fn) {
-		errno = ENOSYS;
-		return -1;
-	}
-
 	ZERO_STRUCTP(qi);
-	ret = gpfs_quotactl_fn(discard_const_p(char, pathname),
-			       GPFS_QCMD(Q_GETQUOTA, type), id, qi);
+	ret = gpfswrap_quotactl(discard_const_p(char, pathname),
+				GPFS_QCMD(Q_GETQUOTA, type), id, qi);
 
 	if (ret) {
 		if (errno == GPFS_E_NO_QUOTA_INST) {
 			DEBUG(10, ("Quotas disabled on GPFS filesystem.\n"));
-		} else {
+		} else if (errno != ENOSYS) {
 			DEBUG(0, ("Get quota failed, type %d, id, %d, "
 				  "errno %d.\n", type, id, errno));
 		}
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index 583cff3..56c3a42 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -41,6 +41,7 @@ int gpfswrap_ftruncate(int fd, gpfs_off64_t length);
 int gpfswrap_lib_init(int flags);
 int gpfswrap_set_times_path(char *pathname, int flags,
 			    gpfs_timestruc_t times[4]);
+int gpfswrap_quotactl(char *pathname, int cmd, int id, void *bufp);
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access);
 int set_gpfs_lease(int fd, int leasetype);
-- 
1.7.1


From 27d25d52e8d80dac8e19fb1c5456cc3067896b2a Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 15:46:07 -0700
Subject: [PATCH 19/32] gpfs: Introduce wrapper for gpfs_fcntl

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c     |   17 ++++++++++++-----
 source3/modules/vfs_gpfs.h |    1 +
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index 733de00..020e138 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -43,7 +43,7 @@ static int (*gpfs_lib_init_fn)(int flags);
 static int (*gpfs_set_times_path_fn)(char *pathname, int flags,
 				     gpfs_timestruc_t times[4]);
 static int (*gpfs_quotactl_fn)(char *pathname, int cmd, int id, void *bufp);
-static int (*gpfs_fcntl_fn)(gpfs_file_t fileDesc, void *fcntlArgP);
+static int (*gpfs_fcntl_fn)(int fd, void *argp);
 static int (*gpfs_getfilesetid_fn)(char *pathname, char *name, int *idP);
 
 #define INIT_GPFS_FUNC(lib, name) { name ## _fn = dlsym(lib,  #name); }
@@ -155,6 +155,11 @@ int gpfswrap_quotactl(char *pathname, int cmd, int id, void *bufp)
 	GPFS_CALL_LIB_FN(gpfs_quotactl, pathname, cmd, id, bufp);
 }
 
+int gpfswrap_fcntl(int fd, void *argp)
+{
+	GPFS_CALL_LIB_FN(gpfs_fcntl, fd, argp);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -256,7 +261,7 @@ int get_gpfs_fset_id(const char *pathname, int *fset_id)
 		gpfsGetFilesetName_t fsn;
 	} arg;
 
-	if (!gpfs_fcntl_fn || !gpfs_getfilesetid_fn) {
+	if (!gpfs_getfilesetid_fn) {
 		errno = ENOSYS;
 		return -1;
 	}
@@ -274,14 +279,16 @@ int get_gpfs_fset_id(const char *pathname, int *fset_id)
 		return fd;
 	}
 
-	err = gpfs_fcntl_fn(fd, &arg);
+	err = gpfswrap_fcntl(fd, &arg);
 	errno_fcntl = errno;
 	close(fd);
 
 	if (err) {
 		errno = errno_fcntl;
-		DEBUG(1, ("GPFS_FCNTL_GET_FILESETNAME for %s failed: %s\n",
-			  pathname, strerror(errno)));
+		if (errno != ENOSYS) {
+			DEBUG(1, ("GPFS_FCNTL_GET_FILESETNAME for %s failed: "
+				  "%s\n", pathname, strerror(errno)));
+		}
 		return err;
 	}
 
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index 56c3a42..baf96b3 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -42,6 +42,7 @@ int gpfswrap_lib_init(int flags);
 int gpfswrap_set_times_path(char *pathname, int flags,
 			    gpfs_timestruc_t times[4]);
 int gpfswrap_quotactl(char *pathname, int cmd, int id, void *bufp);
+int gpfswrap_fcntl(int fd, void *argp);
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access);
 int set_gpfs_lease(int fd, int leasetype);
-- 
1.7.1


From a04fd403a1b8be0c4807b80e110d814386134eff Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 15:47:46 -0700
Subject: [PATCH 20/32] gpfs: Introduce wrapper for gpfs_getfilesetid

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c     |   18 +++++++++---------
 source3/modules/vfs_gpfs.h |    1 +
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index 020e138..b04f1be 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -44,7 +44,7 @@ static int (*gpfs_set_times_path_fn)(char *pathname, int flags,
 				     gpfs_timestruc_t times[4]);
 static int (*gpfs_quotactl_fn)(char *pathname, int cmd, int id, void *bufp);
 static int (*gpfs_fcntl_fn)(int fd, void *argp);
-static int (*gpfs_getfilesetid_fn)(char *pathname, char *name, int *idP);
+static int (*gpfs_getfilesetid_fn)(char *pathname, char *name, int *idp);
 
 #define INIT_GPFS_FUNC(lib, name) { name ## _fn = dlsym(lib,  #name); }
 
@@ -160,6 +160,11 @@ int gpfswrap_fcntl(int fd, void *argp)
 	GPFS_CALL_LIB_FN(gpfs_fcntl, fd, argp);
 }
 
+int gpfswrap_getfilesetid(char *pathname, char *name, int *idp)
+{
+	GPFS_CALL_LIB_FN(gpfs_getfilesetid, pathname, name, idp);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -261,11 +266,6 @@ int get_gpfs_fset_id(const char *pathname, int *fset_id)
 		gpfsGetFilesetName_t fsn;
 	} arg;
 
-	if (!gpfs_getfilesetid_fn) {
-		errno = ENOSYS;
-		return -1;
-	}
-
 	arg.hdr.totalLength = sizeof(arg);
 	arg.hdr.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION;
 	arg.hdr.fcntlReserved = 0;
@@ -292,9 +292,9 @@ int get_gpfs_fset_id(const char *pathname, int *fset_id)
 		return err;
 	}
 
-	err = gpfs_getfilesetid_fn(discard_const_p(char, pathname),
-				   arg.fsn.buffer, fset_id);
-	if (err) {
+	err = gpfswrap_getfilesetid(discard_const_p(char, pathname),
+				    arg.fsn.buffer, fset_id);
+	if (err && errno != ENOSYS) {
 		DEBUG(1, ("gpfs_getfilesetid for %s failed: %s\n",
 			  pathname, strerror(errno)));
 	}
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index baf96b3..dcae142 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -43,6 +43,7 @@ int gpfswrap_set_times_path(char *pathname, int flags,
 			    gpfs_timestruc_t times[4]);
 int gpfswrap_quotactl(char *pathname, int cmd, int id, void *bufp);
 int gpfswrap_fcntl(int fd, void *argp);
+int gpfswrap_getfilesetid(char *pathname, char *name, int *idp);
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access);
 int set_gpfs_lease(int fd, int leasetype);
-- 
1.7.1


From 748652469c58cbb82ba439f10fc200cf8a834e45 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 15:49:25 -0700
Subject: [PATCH 21/32] gpfs: Move set_gpfs_sharemode to vfs_gpfs.c

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c     |   46 --------------------------------------------
 source3/modules/vfs_gpfs.c |   46 ++++++++++++++++++++++++++++++++++++++++++++
 source3/modules/vfs_gpfs.h |    2 -
 3 files changed, 46 insertions(+), 48 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index b04f1be..e816295 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -23,7 +23,6 @@
 
 #include <fcntl.h>
 #include <gpfs_fcntl.h>
-#include "libcli/security/security.h"
 #include "vfs_gpfs.h"
 
 static int (*gpfs_set_share_fn)(int fd, unsigned int allow, unsigned int deny);
@@ -165,51 +164,6 @@ int gpfswrap_getfilesetid(char *pathname, char *name, int *idp)
 	GPFS_CALL_LIB_FN(gpfs_getfilesetid, pathname, name, idp);
 }
 
-bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
-			uint32 share_access)
-{
-	unsigned int allow = GPFS_SHARE_NONE;
-	unsigned int deny = GPFS_DENY_NONE;
-	int result;
-
-	if ((fsp == NULL) || (fsp->fh == NULL) || (fsp->fh->fd < 0)) {
-		/* No real file, don't disturb */
-		return True;
-	}
-
-	allow |= (access_mask & (FILE_WRITE_DATA|FILE_APPEND_DATA|
-				 DELETE_ACCESS)) ? GPFS_SHARE_WRITE : 0;
-	allow |= (access_mask & (FILE_READ_DATA|FILE_EXECUTE)) ?
-		GPFS_SHARE_READ : 0;
-
-	if (allow == GPFS_SHARE_NONE) {
-		DEBUG(10, ("special case am=no_access:%x\n",access_mask));
-	}
-	else {	
-		deny |= (share_access & FILE_SHARE_WRITE) ?
-			0 : GPFS_DENY_WRITE;
-		deny |= (share_access & (FILE_SHARE_READ)) ?
-			0 : GPFS_DENY_READ;
-	}
-	DEBUG(10, ("am=%x, allow=%d, sa=%x, deny=%d\n",
-		   access_mask, allow, share_access, deny));
-
-	result = gpfswrap_set_share(fsp->fh->fd, allow, deny);
-	if (result != 0) {
-		if (errno == ENOSYS) {
-			DEBUG(5, ("VFS module vfs_gpfs loaded, but gpfs "
-				  "set_share function support not available. "
-				  "Allowing access\n"));
-			return True;
-		} else {
-			DEBUG(10, ("gpfs_set_share failed: %s\n",
-				   strerror(errno)));
-		}
-	}
-
-	return (result == 0);
-}
-
 int set_gpfs_lease(int fd, int leasetype)
 {
 	int gpfs_type = GPFS_LEASE_NONE;
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 46cfde6..a0532e2 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -26,6 +26,7 @@
 #include "librpc/gen_ndr/ndr_xattr.h"
 #include "include/smbprofile.h"
 #include "modules/non_posix_acls.h"
+#include "libcli/security/security.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_VFS
@@ -71,6 +72,51 @@ static inline gpfs_ace_v4_t *gpfs_ace_ptr(gpfs_acl_t *gacl, unsigned int i)
 	return &gacl->ace_v4[i];
 }
 
+static bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
+			       uint32 share_access)
+{
+	unsigned int allow = GPFS_SHARE_NONE;
+	unsigned int deny = GPFS_DENY_NONE;
+	int result;
+
+	if ((fsp == NULL) || (fsp->fh == NULL) || (fsp->fh->fd < 0)) {
+		/* No real file, don't disturb */
+		return True;
+	}
+
+	allow |= (access_mask & (FILE_WRITE_DATA|FILE_APPEND_DATA|
+				 DELETE_ACCESS)) ? GPFS_SHARE_WRITE : 0;
+	allow |= (access_mask & (FILE_READ_DATA|FILE_EXECUTE)) ?
+		GPFS_SHARE_READ : 0;
+
+	if (allow == GPFS_SHARE_NONE) {
+		DEBUG(10, ("special case am=no_access:%x\n",access_mask));
+	}
+	else {
+		deny |= (share_access & FILE_SHARE_WRITE) ?
+			0 : GPFS_DENY_WRITE;
+		deny |= (share_access & (FILE_SHARE_READ)) ?
+			0 : GPFS_DENY_READ;
+	}
+	DEBUG(10, ("am=%x, allow=%d, sa=%x, deny=%d\n",
+		   access_mask, allow, share_access, deny));
+
+	result = gpfswrap_set_share(fsp->fh->fd, allow, deny);
+	if (result != 0) {
+		if (errno == ENOSYS) {
+			DEBUG(5, ("VFS module vfs_gpfs loaded, but gpfs "
+				  "set_share function support not available. "
+				  "Allowing access\n"));
+			return True;
+		} else {
+			DEBUG(10, ("gpfs_set_share failed: %s\n",
+				   strerror(errno)));
+		}
+	}
+
+	return (result == 0);
+}
+
 static int vfs_gpfs_kernel_flock(vfs_handle_struct *handle, files_struct *fsp,
 				 uint32 share_mode, uint32 access_mask)
 {
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index dcae142..9c58b2f 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -44,8 +44,6 @@ int gpfswrap_set_times_path(char *pathname, int flags,
 int gpfswrap_quotactl(char *pathname, int cmd, int id, void *bufp);
 int gpfswrap_fcntl(int fd, void *argp);
 int gpfswrap_getfilesetid(char *pathname, char *name, int *idp);
-bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
-			uint32 share_access);
 int set_gpfs_lease(int fd, int leasetype);
 int get_gpfs_quota(const char *pathname, int type, int id,
 		   struct gpfs_quotaInfo *qi);
-- 
1.7.1


From 492d505ddcbc43e0826ac38f3de847cfb8c2b870 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 15:50:14 -0700
Subject: [PATCH 22/32] gpfs: Move set_gpfs_lease to vfs_gpfs.c

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c     |   20 --------------------
 source3/modules/vfs_gpfs.c |   20 ++++++++++++++++++++
 source3/modules/vfs_gpfs.h |    1 -
 3 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index e816295..5c4e809 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -164,26 +164,6 @@ int gpfswrap_getfilesetid(char *pathname, char *name, int *idp)
 	GPFS_CALL_LIB_FN(gpfs_getfilesetid, pathname, name, idp);
 }
 
-int set_gpfs_lease(int fd, int leasetype)
-{
-	int gpfs_type = GPFS_LEASE_NONE;
-
-	if (leasetype == F_RDLCK) {
-		gpfs_type = GPFS_LEASE_READ;
-	}
-	if (leasetype == F_WRLCK) {
-		gpfs_type = GPFS_LEASE_WRITE;
-	}
-
-	/* we unconditionally set CAP_LEASE, rather than looking for
-	   -1/EACCES as there is a bug in some versions of
-	   libgpfs_gpl.so which results in a leaked fd on /dev/ss0
-	   each time we try this with the wrong capabilities set
-	*/
-	linux_set_lease_capability();
-	return gpfswrap_set_lease(fd, gpfs_type);
-}
-
 int get_gpfs_quota(const char *pathname, int type, int id,
 		   struct gpfs_quotaInfo *qi)
 {
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index a0532e2..8fae8ca 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -161,6 +161,26 @@ static int vfs_gpfs_close(vfs_handle_struct *handle, files_struct *fsp)
 	return SMB_VFS_NEXT_CLOSE(handle, fsp);
 }
 
+static int set_gpfs_lease(int fd, int leasetype)
+{
+	int gpfs_type = GPFS_LEASE_NONE;
+
+	if (leasetype == F_RDLCK) {
+		gpfs_type = GPFS_LEASE_READ;
+	}
+	if (leasetype == F_WRLCK) {
+		gpfs_type = GPFS_LEASE_WRITE;
+	}
+
+	/* we unconditionally set CAP_LEASE, rather than looking for
+	   -1/EACCES as there is a bug in some versions of
+	   libgpfs_gpl.so which results in a leaked fd on /dev/ss0
+	   each time we try this with the wrong capabilities set
+	*/
+	linux_set_lease_capability();
+	return gpfswrap_set_lease(fd, gpfs_type);
+}
+
 static int vfs_gpfs_setlease(vfs_handle_struct *handle, files_struct *fsp, 
 			     int leasetype)
 {
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index 9c58b2f..fb41d2f 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -44,7 +44,6 @@ int gpfswrap_set_times_path(char *pathname, int flags,
 int gpfswrap_quotactl(char *pathname, int cmd, int id, void *bufp);
 int gpfswrap_fcntl(int fd, void *argp);
 int gpfswrap_getfilesetid(char *pathname, char *name, int *idp);
-int set_gpfs_lease(int fd, int leasetype);
 int get_gpfs_quota(const char *pathname, int type, int id,
 		   struct gpfs_quotaInfo *qi);
 int get_gpfs_fset_id(const char *pathname, int *fset_id);
-- 
1.7.1


From fe7d1be954b87093da6506d23d89088432585ce0 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 15:51:17 -0700
Subject: [PATCH 23/32] gpfs: Move get_gpfs_quota to vfs_gpfs.c

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c     |   27 ---------------------------
 source3/modules/vfs_gpfs.c |   27 +++++++++++++++++++++++++++
 source3/modules/vfs_gpfs.h |    2 --
 3 files changed, 27 insertions(+), 29 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index 5c4e809..3815eaf 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -164,33 +164,6 @@ int gpfswrap_getfilesetid(char *pathname, char *name, int *idp)
 	GPFS_CALL_LIB_FN(gpfs_getfilesetid, pathname, name, idp);
 }
 
-int get_gpfs_quota(const char *pathname, int type, int id,
-		   struct gpfs_quotaInfo *qi)
-{
-	int ret;
-
-	ZERO_STRUCTP(qi);
-	ret = gpfswrap_quotactl(discard_const_p(char, pathname),
-				GPFS_QCMD(Q_GETQUOTA, type), id, qi);
-
-	if (ret) {
-		if (errno == GPFS_E_NO_QUOTA_INST) {
-			DEBUG(10, ("Quotas disabled on GPFS filesystem.\n"));
-		} else if (errno != ENOSYS) {
-			DEBUG(0, ("Get quota failed, type %d, id, %d, "
-				  "errno %d.\n", type, id, errno));
-		}
-
-		return ret;
-	}
-
-	DEBUG(10, ("quota type %d, id %d, blk u:%lld h:%lld s:%lld gt:%u\n",
-		   type, id, qi->blockUsage, qi->blockHardLimit,
-		   qi->blockSoftLimit, qi->blockGraceTime));
-
-	return ret;
-}
-
 int get_gpfs_fset_id(const char *pathname, int *fset_id)
 {
 	int err, fd, errno_fcntl;
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 8fae8ca..6674c5e 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -2005,6 +2005,33 @@ static int vfs_gpfs_connect(struct vfs_handle_struct *handle,
 	return 0;
 }
 
+static int get_gpfs_quota(const char *pathname, int type, int id,
+			  struct gpfs_quotaInfo *qi)
+{
+	int ret;
+
+	ZERO_STRUCTP(qi);
+	ret = gpfswrap_quotactl(discard_const_p(char, pathname),
+				GPFS_QCMD(Q_GETQUOTA, type), id, qi);
+
+	if (ret) {
+		if (errno == GPFS_E_NO_QUOTA_INST) {
+			DEBUG(10, ("Quotas disabled on GPFS filesystem.\n"));
+		} else if (errno != ENOSYS) {
+			DEBUG(0, ("Get quota failed, type %d, id, %d, "
+				  "errno %d.\n", type, id, errno));
+		}
+
+		return ret;
+	}
+
+	DEBUG(10, ("quota type %d, id %d, blk u:%lld h:%lld s:%lld gt:%u\n",
+		   type, id, qi->blockUsage, qi->blockHardLimit,
+		   qi->blockSoftLimit, qi->blockGraceTime));
+
+	return ret;
+}
+
 static int vfs_gpfs_get_quotas(const char *path, uid_t uid, gid_t gid,
 			       int *fset_id,
 			       struct gpfs_quotaInfo *qi_user,
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index fb41d2f..4996992 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -44,8 +44,6 @@ int gpfswrap_set_times_path(char *pathname, int flags,
 int gpfswrap_quotactl(char *pathname, int cmd, int id, void *bufp);
 int gpfswrap_fcntl(int fd, void *argp);
 int gpfswrap_getfilesetid(char *pathname, char *name, int *idp);
-int get_gpfs_quota(const char *pathname, int type, int id,
-		   struct gpfs_quotaInfo *qi);
 int get_gpfs_fset_id(const char *pathname, int *fset_id);
 int smbd_gpfs_set_times_path(char *path, struct smb_file_time *ft);
 
-- 
1.7.1


From 80a0bf05ddc616d89961c726cbb927dfc935b560 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 15:55:19 -0700
Subject: [PATCH 24/32] gpfs: Move get_gpfs_fset_id to vfs_gpfs.c

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c     |   44 --------------------------------------------
 source3/modules/vfs_gpfs.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
 source3/modules/vfs_gpfs.h |    1 -
 3 files changed, 44 insertions(+), 45 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index 3815eaf..e88f3c8 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -164,50 +164,6 @@ int gpfswrap_getfilesetid(char *pathname, char *name, int *idp)
 	GPFS_CALL_LIB_FN(gpfs_getfilesetid, pathname, name, idp);
 }
 
-int get_gpfs_fset_id(const char *pathname, int *fset_id)
-{
-	int err, fd, errno_fcntl;
-
-	struct {
-		gpfsFcntlHeader_t hdr;
-		gpfsGetFilesetName_t fsn;
-	} arg;
-
-	arg.hdr.totalLength = sizeof(arg);
-	arg.hdr.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION;
-	arg.hdr.fcntlReserved = 0;
-	arg.fsn.structLen = sizeof(arg.fsn);
-	arg.fsn.structType = GPFS_FCNTL_GET_FILESETNAME;
-
-	fd = open(pathname, O_RDONLY);
-	if (fd == -1) {
-		DEBUG(1, ("Could not open %s: %s\n",
-			  pathname, strerror(errno)));
-		return fd;
-	}
-
-	err = gpfswrap_fcntl(fd, &arg);
-	errno_fcntl = errno;
-	close(fd);
-
-	if (err) {
-		errno = errno_fcntl;
-		if (errno != ENOSYS) {
-			DEBUG(1, ("GPFS_FCNTL_GET_FILESETNAME for %s failed: "
-				  "%s\n", pathname, strerror(errno)));
-		}
-		return err;
-	}
-
-	err = gpfswrap_getfilesetid(discard_const_p(char, pathname),
-				    arg.fsn.buffer, fset_id);
-	if (err && errno != ENOSYS) {
-		DEBUG(1, ("gpfs_getfilesetid for %s failed: %s\n",
-			  pathname, strerror(errno)));
-	}
-	return err;
-}
-
 static void timespec_to_gpfs_time(struct timespec ts, gpfs_timestruc_t *gt,
 				  int idx, int *flags)
 {
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 6674c5e..e17eafc 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -2005,6 +2005,50 @@ static int vfs_gpfs_connect(struct vfs_handle_struct *handle,
 	return 0;
 }
 
+static int get_gpfs_fset_id(const char *pathname, int *fset_id)
+{
+	int err, fd, errno_fcntl;
+
+	struct {
+		gpfsFcntlHeader_t hdr;
+		gpfsGetFilesetName_t fsn;
+	} arg;
+
+	arg.hdr.totalLength = sizeof(arg);
+	arg.hdr.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION;
+	arg.hdr.fcntlReserved = 0;
+	arg.fsn.structLen = sizeof(arg.fsn);
+	arg.fsn.structType = GPFS_FCNTL_GET_FILESETNAME;
+
+	fd = open(pathname, O_RDONLY);
+	if (fd == -1) {
+		DEBUG(1, ("Could not open %s: %s\n",
+			  pathname, strerror(errno)));
+		return fd;
+	}
+
+	err = gpfswrap_fcntl(fd, &arg);
+	errno_fcntl = errno;
+	close(fd);
+
+	if (err) {
+		errno = errno_fcntl;
+		if (errno != ENOSYS) {
+			DEBUG(1, ("GPFS_FCNTL_GET_FILESETNAME for %s failed: "
+				  "%s\n", pathname, strerror(errno)));
+		}
+		return err;
+	}
+
+	err = gpfswrap_getfilesetid(discard_const_p(char, pathname),
+				    arg.fsn.buffer, fset_id);
+	if (err && errno != ENOSYS) {
+		DEBUG(1, ("gpfs_getfilesetid for %s failed: %s\n",
+			  pathname, strerror(errno)));
+	}
+	return err;
+}
+
 static int get_gpfs_quota(const char *pathname, int type, int id,
 			  struct gpfs_quotaInfo *qi)
 {
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index 4996992..8878955 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -44,7 +44,6 @@ int gpfswrap_set_times_path(char *pathname, int flags,
 int gpfswrap_quotactl(char *pathname, int cmd, int id, void *bufp);
 int gpfswrap_fcntl(int fd, void *argp);
 int gpfswrap_getfilesetid(char *pathname, char *name, int *idp);
-int get_gpfs_fset_id(const char *pathname, int *fset_id);
 int smbd_gpfs_set_times_path(char *path, struct smb_file_time *ft);
 
 int gpfswrap_init(void);
-- 
1.7.1


From e106989717fbea6a158027c045b210ed962a965b Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 15:56:30 -0700
Subject: [PATCH 25/32] gpfs: Move smbd_gpfs_set_times_path to vfs_gpfs.c

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c     |   38 --------------------------------------
 source3/modules/vfs_gpfs.c |   38 ++++++++++++++++++++++++++++++++++++++
 source3/modules/vfs_gpfs.h |    2 --
 3 files changed, 38 insertions(+), 40 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index e88f3c8..ae32318 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -163,41 +163,3 @@ int gpfswrap_getfilesetid(char *pathname, char *name, int *idp)
 {
 	GPFS_CALL_LIB_FN(gpfs_getfilesetid, pathname, name, idp);
 }
-
-static void timespec_to_gpfs_time(struct timespec ts, gpfs_timestruc_t *gt,
-				  int idx, int *flags)
-{
-	if (!null_timespec(ts)) {
-		*flags |= 1 << idx;
-		gt[idx].tv_sec = ts.tv_sec;
-		gt[idx].tv_nsec = ts.tv_nsec;
-		DEBUG(10, ("Setting GPFS time %d, flags 0x%x\n", idx, *flags));
-	}
-}
-
-int smbd_gpfs_set_times_path(char *path, struct smb_file_time *ft)
-{
-	gpfs_timestruc_t gpfs_times[4];
-	int flags = 0;
-	int rc;
-
-	ZERO_ARRAY(gpfs_times);
-	timespec_to_gpfs_time(ft->atime, gpfs_times, 0, &flags);
-	timespec_to_gpfs_time(ft->mtime, gpfs_times, 1, &flags);
-	/* No good mapping from LastChangeTime to ctime, not storing */
-	timespec_to_gpfs_time(ft->create_time, gpfs_times, 3, &flags);
-
-	if (!flags) {
-		DEBUG(10, ("nothing to do, return to avoid EINVAL\n"));
-		return 0;
-	}
-
-	rc = gpfswrap_set_times_path(path, flags, gpfs_times);
-
-	if (rc != 0 && errno != ENOSYS) {
-		DEBUG(1,("gpfs_set_times() returned with error %s\n",
-			strerror(errno)));
-	}
-
-	return rc;
-}
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index e17eafc..0c69908 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -1736,6 +1736,44 @@ static int vfs_gpfs_lstat(struct vfs_handle_struct *handle,
 	return 0;
 }
 
+static void timespec_to_gpfs_time(struct timespec ts, gpfs_timestruc_t *gt,
+				  int idx, int *flags)
+{
+	if (!null_timespec(ts)) {
+		*flags |= 1 << idx;
+		gt[idx].tv_sec = ts.tv_sec;
+		gt[idx].tv_nsec = ts.tv_nsec;
+		DEBUG(10, ("Setting GPFS time %d, flags 0x%x\n", idx, *flags));
+	}
+}
+
+static int smbd_gpfs_set_times_path(char *path, struct smb_file_time *ft)
+{
+	gpfs_timestruc_t gpfs_times[4];
+	int flags = 0;
+	int rc;
+
+	ZERO_ARRAY(gpfs_times);
+	timespec_to_gpfs_time(ft->atime, gpfs_times, 0, &flags);
+	timespec_to_gpfs_time(ft->mtime, gpfs_times, 1, &flags);
+	/* No good mapping from LastChangeTime to ctime, not storing */
+	timespec_to_gpfs_time(ft->create_time, gpfs_times, 3, &flags);
+
+	if (!flags) {
+		DEBUG(10, ("nothing to do, return to avoid EINVAL\n"));
+		return 0;
+	}
+
+	rc = gpfswrap_set_times_path(path, flags, gpfs_times);
+
+	if (rc != 0 && errno != ENOSYS) {
+		DEBUG(1,("gpfs_set_times() returned with error %s\n",
+			strerror(errno)));
+	}
+
+	return rc;
+}
+
 static int vfs_gpfs_ntimes(struct vfs_handle_struct *handle,
                         const struct smb_filename *smb_fname,
 			struct smb_file_time *ft)
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index 8878955..6d244e8 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -44,6 +44,4 @@ int gpfswrap_set_times_path(char *pathname, int flags,
 int gpfswrap_quotactl(char *pathname, int cmd, int id, void *bufp);
 int gpfswrap_fcntl(int fd, void *argp);
 int gpfswrap_getfilesetid(char *pathname, char *name, int *idp);
-int smbd_gpfs_set_times_path(char *path, struct smb_file_time *ft);
-
 int gpfswrap_init(void);
-- 
1.7.1


From 801067e744f572eccbb666338fd576231085a413 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 15:57:22 -0700
Subject: [PATCH 26/32] gpfs: Move definition of GPFS_GETACL_NATIVE to vfs_gpfs.c

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/vfs_gpfs.c |    4 ++++
 source3/modules/vfs_gpfs.h |    4 ----
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 0c69908..cde3e88 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -38,6 +38,10 @@
 #include "auth.h"
 #include "lib/util/tevent_unix.h"
 
+#ifndef GPFS_GETACL_NATIVE
+#define GPFS_GETACL_NATIVE 0x00000004
+#endif
+
 struct gpfs_config_data {
 	bool sharemodes;
 	bool leases;
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index 6d244e8..cd6d393 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -23,10 +23,6 @@
 
 */
 
-#ifndef GPFS_GETACL_NATIVE
-#define GPFS_GETACL_NATIVE 0x00000004
-#endif
-
 int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny);
 int gpfswrap_set_lease(int fd, unsigned int type);
 int gpfswrap_getacl(char *pathname, int flags, void *acl);
-- 
1.7.1


From 783a9e8d182963e1b3e6032037873800883670a0 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 11 Feb 2015 14:09:10 -0700
Subject: [PATCH 27/32] gpfs: Include gpfs_fcntl.h only from vfs_gpfs header file

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c     |    1 -
 source3/modules/vfs_gpfs.c |    1 -
 source3/modules/vfs_gpfs.h |    2 ++
 3 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index ae32318..f0f863e 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -22,7 +22,6 @@
 #include "smbd/smbd.h"
 
 #include <fcntl.h>
-#include <gpfs_fcntl.h>
 #include "vfs_gpfs.h"
 
 static int (*gpfs_set_share_fn)(int fd, unsigned int allow, unsigned int deny);
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index cde3e88..abba9cc 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -31,7 +31,6 @@
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_VFS
 
-#include <gpfs_fcntl.h>
 #include "nfs4_acls.h"
 #include "vfs_gpfs.h"
 #include "system/filesys.h"
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index cd6d393..ac18fdb 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -23,6 +23,8 @@
 
 */
 
+#include <gpfs_fcntl.h>
+
 int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny);
 int gpfswrap_set_lease(int fd, unsigned int type);
 int gpfswrap_getacl(char *pathname, int flags, void *acl);
-- 
1.7.1


From cfb36f4543e5698028f460c2d3b2eb72ba5f93b6 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 11 Feb 2015 14:22:07 -0700
Subject: [PATCH 28/32] gpfs: Move DBGC_CLASS definition below includes

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/vfs_gpfs.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index abba9cc..2e4a98f 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -27,16 +27,15 @@
 #include "include/smbprofile.h"
 #include "modules/non_posix_acls.h"
 #include "libcli/security/security.h"
-
-#undef DBGC_CLASS
-#define DBGC_CLASS DBGC_VFS
-
 #include "nfs4_acls.h"
 #include "vfs_gpfs.h"
 #include "system/filesys.h"
 #include "auth.h"
 #include "lib/util/tevent_unix.h"
 
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_VFS
+
 #ifndef GPFS_GETACL_NATIVE
 #define GPFS_GETACL_NATIVE 0x00000004
 #endif
-- 
1.7.1


From 6b2c3c69f0446e2fb891902456edf4920cf7b47e Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 11 Feb 2015 14:22:50 -0700
Subject: [PATCH 29/32] gpfs: Remove unncessary includes from gpfs.c

replace.h provides everything that is required (errno and ENOSYS).

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index f0f863e..189a914 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -17,11 +17,7 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "includes.h"
-#include "system/filesys.h"
-#include "smbd/smbd.h"
-
-#include <fcntl.h>
+#include "replace.h"
 #include "vfs_gpfs.h"
 
 static int (*gpfs_set_share_fn)(int fd, unsigned int allow, unsigned int deny);
-- 
1.7.1


From b78865a440f451f58812175ca7941ff28200e839 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 16:02:37 -0700
Subject: [PATCH 30/32] gpfs: Update file headers

Update file headers to reflect the new code organization and reformat
for consistency.

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c     |    3 ++-
 source3/modules/vfs_gpfs.c |   41 ++++++++++++++++++++---------------------
 source3/modules/vfs_gpfs.h |   44 +++++++++++++++++++++-----------------------
 3 files changed, 43 insertions(+), 45 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index 189a914..2af4891 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -1,7 +1,8 @@
 /*
  *  Unix SMB/CIFS implementation.
- *  Provide a connection to GPFS specific features
+ *  Wrapper for GPFS library
  *  Copyright (C) Volker Lendecke 2005
+ *  Copyright (C) Christof Schmitt 2015
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 2e4a98f..6bacac5 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -1,25 +1,24 @@
 /*
-   Unix SMB/CIFS implementation.
-   Wrap gpfs calls in vfs functions.
-
-   Copyright (C) Christian Ambach <cambach1 at de.ibm.com> 2006
-
-   Major code contributions by Chetan Shringarpure <chetan.sh at in.ibm.com>
-                            and Gomati Mohanan <gomati.mohanan at in.ibm.com>
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
+ *  Unix SMB/CIFS implementation.
+ *  Samba VFS module for GPFS filesystem
+ *  Copyright (C) Christian Ambach <cambach1 at de.ibm.com> 2006
+ *  Copyright (C) Christof Schmitt 2015
+ *  Major code contributions by Chetan Shringarpure <chetan.sh at in.ibm.com>
+ *                           and Gomati Mohanan <gomati.mohanan at in.ibm.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
 
 #include "includes.h"
 #include "smbd/smbd.h"
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index ac18fdb..efe69c7 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -1,27 +1,25 @@
 /*
-   Unix SMB/CIFS implementation.
-   Wrap gpfs calls in vfs functions.
-
-   Copyright (C) Christian Ambach <cambach1 at de.ibm.com> 2006
-
-   Major code contributions by Chetan Shringarpure <chetan.sh at in.ibm.com>
-                            and Gomati Mohanan <gomati.mohanan at in.ibm.com>
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
+ *  Unix SMB/CIFS implementation.
+ *  Wrapper for GPFS library
+ *  Copyright (C) Christian Ambach <cambach1 at de.ibm.com> 2006
+ *  Copyright (C) Christof Schmitt 2015
+ *
+ *  Major code contributions by Chetan Shringarpure <chetan.sh at in.ibm.com>
+ *                           and Gomati Mohanan <gomati.mohanan at in.ibm.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
 
 #include <gpfs_fcntl.h>
 
-- 
1.7.1


From 99ecc780eaf407bedcb4127c2c2bd69fca135405 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 10 Dec 2014 16:05:16 -0700
Subject: [PATCH 31/32] gpfs: Rename library wrapper to gpfswrap

The code in gpfs.c and vfs_gpfs.h now only wraps the gpfs library.
Rename the files to gpfswrap to make it clear that this is the only
purpose of that file.

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfs.c        |  161 -----------------------------------------
 source3/modules/gpfswrap.c    |  161 +++++++++++++++++++++++++++++++++++++++++
 source3/modules/gpfswrap.h    |   43 +++++++++++
 source3/modules/vfs_gpfs.c    |    2 +-
 source3/modules/vfs_gpfs.h    |   43 -----------
 source3/modules/wscript_build |    2 +-
 6 files changed, 206 insertions(+), 206 deletions(-)
 delete mode 100644 source3/modules/gpfs.c
 create mode 100644 source3/modules/gpfswrap.c
 create mode 100644 source3/modules/gpfswrap.h
 delete mode 100644 source3/modules/vfs_gpfs.h

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
deleted file mode 100644
index 2af4891..0000000
--- a/source3/modules/gpfs.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- *  Unix SMB/CIFS implementation.
- *  Wrapper for GPFS library
- *  Copyright (C) Volker Lendecke 2005
- *  Copyright (C) Christof Schmitt 2015
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "replace.h"
-#include "vfs_gpfs.h"
-
-static int (*gpfs_set_share_fn)(int fd, unsigned int allow, unsigned int deny);
-static int (*gpfs_set_lease_fn)(int fd, unsigned int type);
-static int (*gpfs_getacl_fn)(char *pathname, int flags, void *acl);
-static int (*gpfs_putacl_fn)(char *pathname, int flags, void *acl);
-static int (*gpfs_get_realfilename_path_fn)(char *pathname, char *filenamep,
-					    int *len);
-static int (*gpfs_set_winattrs_path_fn)(char *pathname, int flags,
-					struct gpfs_winattr *attrs);
-static int (*gpfs_get_winattrs_path_fn)(char *pathname,
-					struct gpfs_winattr *attrs);
-static int (*gpfs_get_winattrs_fn)(int fd, struct gpfs_winattr *attrs);
-static int (*gpfs_prealloc_fn)(int fd, gpfs_off64_t start, gpfs_off64_t bytes);
-static int (*gpfs_ftruncate_fn)(int fd, gpfs_off64_t length);
-static int (*gpfs_lib_init_fn)(int flags);
-static int (*gpfs_set_times_path_fn)(char *pathname, int flags,
-				     gpfs_timestruc_t times[4]);
-static int (*gpfs_quotactl_fn)(char *pathname, int cmd, int id, void *bufp);
-static int (*gpfs_fcntl_fn)(int fd, void *argp);
-static int (*gpfs_getfilesetid_fn)(char *pathname, char *name, int *idp);
-
-#define INIT_GPFS_FUNC(lib, name) { name ## _fn = dlsym(lib,  #name); }
-
-int gpfswrap_init(void)
-{
-	static void *lib;
-
-	if (lib == NULL) {
-		lib = dlopen("libgpfs.so", RTLD_LAZY);
-	}
-
-	if (lib == NULL) {
-		return -1;
-	}
-
-	INIT_GPFS_FUNC(lib, gpfs_set_share);
-	INIT_GPFS_FUNC(lib, gpfs_set_lease);
-	INIT_GPFS_FUNC(lib, gpfs_getacl);
-	INIT_GPFS_FUNC(lib, gpfs_putacl);
-	INIT_GPFS_FUNC(lib, gpfs_get_realfilename_path);
-	INIT_GPFS_FUNC(lib, gpfs_set_winattrs_path);
-	INIT_GPFS_FUNC(lib, gpfs_get_winattrs_path);
-	INIT_GPFS_FUNC(lib, gpfs_get_winattrs);
-	INIT_GPFS_FUNC(lib, gpfs_prealloc);
-	INIT_GPFS_FUNC(lib, gpfs_ftruncate);
-	INIT_GPFS_FUNC(lib, gpfs_lib_init);
-	INIT_GPFS_FUNC(lib, gpfs_set_times_path);
-	INIT_GPFS_FUNC(lib, gpfs_quotactl);
-	INIT_GPFS_FUNC(lib, gpfs_fcntl);
-	INIT_GPFS_FUNC(lib, gpfs_getfilesetid);
-
-	return 0;
-}
-
-#define GPFS_CALL_LIB_FN(fn, ...)				\
-	{							\
-		if (fn == NULL) {				\
-			errno = ENOSYS;			\
-			return -1;				\
-		}						\
-		return fn ## _fn(__VA_ARGS__);			\
-	}
-
-int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny)
-{
-	GPFS_CALL_LIB_FN(gpfs_set_share, fd, allow, deny);
-}
-
-int gpfswrap_set_lease(int fd, unsigned int type)
-{
-	GPFS_CALL_LIB_FN(gpfs_set_lease, fd, type);
-}
-
-int gpfswrap_getacl(char *pathname, int flags, void *acl)
-{
-	GPFS_CALL_LIB_FN(gpfs_getacl, pathname, flags, acl);
-}
-
-int gpfswrap_putacl(char *pathname, int flags, void *acl)
-{
-	GPFS_CALL_LIB_FN(gpfs_putacl, pathname, flags, acl);
-}
-
-int gpfswrap_get_realfilename_path(char *pathname, char *filenamep, int *len)
-{
-	GPFS_CALL_LIB_FN(gpfs_get_realfilename_path, pathname, filenamep, len);
-}
-
-int gpfswrap_set_winattrs_path(char *pathname, int flags,
-			       struct gpfs_winattr *attrs)
-{
-	GPFS_CALL_LIB_FN(gpfs_set_winattrs_path, pathname, flags, attrs);
-}
-
-int gpfswrap_get_winattrs_path(char *pathname, struct gpfs_winattr *attrs)
-{
-	GPFS_CALL_LIB_FN(gpfs_get_winattrs_path, pathname, attrs);
-}
-
-int gpfswrap_get_winattrs(int fd, struct gpfs_winattr *attrs)
-{
-	GPFS_CALL_LIB_FN(gpfs_get_winattrs, fd, attrs);
-}
-
-int gpfswrap_prealloc(int fd, gpfs_off64_t start, gpfs_off64_t bytes)
-{
-	GPFS_CALL_LIB_FN(gpfs_prealloc, fd, start, bytes);
-}
-
-int gpfswrap_ftruncate(int fd, gpfs_off64_t length)
-{
-	GPFS_CALL_LIB_FN(gpfs_ftruncate, fd, length);
-}
-
-int gpfswrap_lib_init(int flags)
-{
-	GPFS_CALL_LIB_FN(gpfs_lib_init, flags);
-}
-
-int gpfswrap_set_times_path(char *pathname, int flags,
-			    gpfs_timestruc_t times[4])
-{
-	GPFS_CALL_LIB_FN(gpfs_set_times_path, pathname, flags, times);
-}
-
-int gpfswrap_quotactl(char *pathname, int cmd, int id, void *bufp)
-{
-	GPFS_CALL_LIB_FN(gpfs_quotactl, pathname, cmd, id, bufp);
-}
-
-int gpfswrap_fcntl(int fd, void *argp)
-{
-	GPFS_CALL_LIB_FN(gpfs_fcntl, fd, argp);
-}
-
-int gpfswrap_getfilesetid(char *pathname, char *name, int *idp)
-{
-	GPFS_CALL_LIB_FN(gpfs_getfilesetid, pathname, name, idp);
-}
diff --git a/source3/modules/gpfswrap.c b/source3/modules/gpfswrap.c
new file mode 100644
index 0000000..618f083
--- /dev/null
+++ b/source3/modules/gpfswrap.c
@@ -0,0 +1,161 @@
+/*
+ *  Unix SMB/CIFS implementation.
+ *  Wrapper for GPFS library
+ *  Copyright (C) Volker Lendecke 2005
+ *  Copyright (C) Christof Schmitt 2015
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "replace.h"
+#include "gpfswrap.h"
+
+static int (*gpfs_set_share_fn)(int fd, unsigned int allow, unsigned int deny);
+static int (*gpfs_set_lease_fn)(int fd, unsigned int type);
+static int (*gpfs_getacl_fn)(char *pathname, int flags, void *acl);
+static int (*gpfs_putacl_fn)(char *pathname, int flags, void *acl);
+static int (*gpfs_get_realfilename_path_fn)(char *pathname, char *filenamep,
+					    int *len);
+static int (*gpfs_set_winattrs_path_fn)(char *pathname, int flags,
+					struct gpfs_winattr *attrs);
+static int (*gpfs_get_winattrs_path_fn)(char *pathname,
+					struct gpfs_winattr *attrs);
+static int (*gpfs_get_winattrs_fn)(int fd, struct gpfs_winattr *attrs);
+static int (*gpfs_prealloc_fn)(int fd, gpfs_off64_t start, gpfs_off64_t bytes);
+static int (*gpfs_ftruncate_fn)(int fd, gpfs_off64_t length);
+static int (*gpfs_lib_init_fn)(int flags);
+static int (*gpfs_set_times_path_fn)(char *pathname, int flags,
+				     gpfs_timestruc_t times[4]);
+static int (*gpfs_quotactl_fn)(char *pathname, int cmd, int id, void *bufp);
+static int (*gpfs_fcntl_fn)(int fd, void *argp);
+static int (*gpfs_getfilesetid_fn)(char *pathname, char *name, int *idp);
+
+#define INIT_GPFS_FUNC(lib, name) { name ## _fn = dlsym(lib,  #name); }
+
+int gpfswrap_init(void)
+{
+	static void *lib;
+
+	if (lib == NULL) {
+		lib = dlopen("libgpfs.so", RTLD_LAZY);
+	}
+
+	if (lib == NULL) {
+		return -1;
+	}
+
+	INIT_GPFS_FUNC(lib, gpfs_set_share);
+	INIT_GPFS_FUNC(lib, gpfs_set_lease);
+	INIT_GPFS_FUNC(lib, gpfs_getacl);
+	INIT_GPFS_FUNC(lib, gpfs_putacl);
+	INIT_GPFS_FUNC(lib, gpfs_get_realfilename_path);
+	INIT_GPFS_FUNC(lib, gpfs_set_winattrs_path);
+	INIT_GPFS_FUNC(lib, gpfs_get_winattrs_path);
+	INIT_GPFS_FUNC(lib, gpfs_get_winattrs);
+	INIT_GPFS_FUNC(lib, gpfs_prealloc);
+	INIT_GPFS_FUNC(lib, gpfs_ftruncate);
+	INIT_GPFS_FUNC(lib, gpfs_lib_init);
+	INIT_GPFS_FUNC(lib, gpfs_set_times_path);
+	INIT_GPFS_FUNC(lib, gpfs_quotactl);
+	INIT_GPFS_FUNC(lib, gpfs_fcntl);
+	INIT_GPFS_FUNC(lib, gpfs_getfilesetid);
+
+	return 0;
+}
+
+#define GPFS_CALL_LIB_FN(fn, ...)				\
+	{							\
+		if (fn == NULL) {				\
+			errno = ENOSYS;			\
+			return -1;				\
+		}						\
+		return fn ## _fn(__VA_ARGS__);			\
+	}
+
+int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny)
+{
+	GPFS_CALL_LIB_FN(gpfs_set_share, fd, allow, deny);
+}
+
+int gpfswrap_set_lease(int fd, unsigned int type)
+{
+	GPFS_CALL_LIB_FN(gpfs_set_lease, fd, type);
+}
+
+int gpfswrap_getacl(char *pathname, int flags, void *acl)
+{
+	GPFS_CALL_LIB_FN(gpfs_getacl, pathname, flags, acl);
+}
+
+int gpfswrap_putacl(char *pathname, int flags, void *acl)
+{
+	GPFS_CALL_LIB_FN(gpfs_putacl, pathname, flags, acl);
+}
+
+int gpfswrap_get_realfilename_path(char *pathname, char *filenamep, int *len)
+{
+	GPFS_CALL_LIB_FN(gpfs_get_realfilename_path, pathname, filenamep, len);
+}
+
+int gpfswrap_set_winattrs_path(char *pathname, int flags,
+			       struct gpfs_winattr *attrs)
+{
+	GPFS_CALL_LIB_FN(gpfs_set_winattrs_path, pathname, flags, attrs);
+}
+
+int gpfswrap_get_winattrs_path(char *pathname, struct gpfs_winattr *attrs)
+{
+	GPFS_CALL_LIB_FN(gpfs_get_winattrs_path, pathname, attrs);
+}
+
+int gpfswrap_get_winattrs(int fd, struct gpfs_winattr *attrs)
+{
+	GPFS_CALL_LIB_FN(gpfs_get_winattrs, fd, attrs);
+}
+
+int gpfswrap_prealloc(int fd, gpfs_off64_t start, gpfs_off64_t bytes)
+{
+	GPFS_CALL_LIB_FN(gpfs_prealloc, fd, start, bytes);
+}
+
+int gpfswrap_ftruncate(int fd, gpfs_off64_t length)
+{
+	GPFS_CALL_LIB_FN(gpfs_ftruncate, fd, length);
+}
+
+int gpfswrap_lib_init(int flags)
+{
+	GPFS_CALL_LIB_FN(gpfs_lib_init, flags);
+}
+
+int gpfswrap_set_times_path(char *pathname, int flags,
+			    gpfs_timestruc_t times[4])
+{
+	GPFS_CALL_LIB_FN(gpfs_set_times_path, pathname, flags, times);
+}
+
+int gpfswrap_quotactl(char *pathname, int cmd, int id, void *bufp)
+{
+	GPFS_CALL_LIB_FN(gpfs_quotactl, pathname, cmd, id, bufp);
+}
+
+int gpfswrap_fcntl(int fd, void *argp)
+{
+	GPFS_CALL_LIB_FN(gpfs_fcntl, fd, argp);
+}
+
+int gpfswrap_getfilesetid(char *pathname, char *name, int *idp)
+{
+	GPFS_CALL_LIB_FN(gpfs_getfilesetid, pathname, name, idp);
+}
diff --git a/source3/modules/gpfswrap.h b/source3/modules/gpfswrap.h
new file mode 100644
index 0000000..efe69c7
--- /dev/null
+++ b/source3/modules/gpfswrap.h
@@ -0,0 +1,43 @@
+/*
+ *  Unix SMB/CIFS implementation.
+ *  Wrapper for GPFS library
+ *  Copyright (C) Christian Ambach <cambach1 at de.ibm.com> 2006
+ *  Copyright (C) Christof Schmitt 2015
+ *
+ *  Major code contributions by Chetan Shringarpure <chetan.sh at in.ibm.com>
+ *                           and Gomati Mohanan <gomati.mohanan at in.ibm.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gpfs_fcntl.h>
+
+int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny);
+int gpfswrap_set_lease(int fd, unsigned int type);
+int gpfswrap_getacl(char *pathname, int flags, void *acl);
+int gpfswrap_putacl(char *pathname, int flags, void *acl);
+int gpfswrap_get_realfilename_path(char *pathname, char *filenamep, int *len);
+int gpfswrap_set_winattrs_path(char *pathname, int flags,
+			       struct gpfs_winattr *attrs);
+int gpfswrap_get_winattrs_path(char *pathname, struct gpfs_winattr *attrs);
+int gpfswrap_get_winattrs(int fd, struct gpfs_winattr *attrs);
+int gpfswrap_prealloc(int fd, gpfs_off64_t start, gpfs_off64_t bytes);
+int gpfswrap_ftruncate(int fd, gpfs_off64_t length);
+int gpfswrap_lib_init(int flags);
+int gpfswrap_set_times_path(char *pathname, int flags,
+			    gpfs_timestruc_t times[4]);
+int gpfswrap_quotactl(char *pathname, int cmd, int id, void *bufp);
+int gpfswrap_fcntl(int fd, void *argp);
+int gpfswrap_getfilesetid(char *pathname, char *name, int *idp);
+int gpfswrap_init(void);
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 6bacac5..0af90b2 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -27,10 +27,10 @@
 #include "modules/non_posix_acls.h"
 #include "libcli/security/security.h"
 #include "nfs4_acls.h"
-#include "vfs_gpfs.h"
 #include "system/filesys.h"
 #include "auth.h"
 #include "lib/util/tevent_unix.h"
+#include "gpfswrap.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_VFS
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
deleted file mode 100644
index efe69c7..0000000
--- a/source3/modules/vfs_gpfs.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- *  Unix SMB/CIFS implementation.
- *  Wrapper for GPFS library
- *  Copyright (C) Christian Ambach <cambach1 at de.ibm.com> 2006
- *  Copyright (C) Christof Schmitt 2015
- *
- *  Major code contributions by Chetan Shringarpure <chetan.sh at in.ibm.com>
- *                           and Gomati Mohanan <gomati.mohanan at in.ibm.com>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <gpfs_fcntl.h>
-
-int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny);
-int gpfswrap_set_lease(int fd, unsigned int type);
-int gpfswrap_getacl(char *pathname, int flags, void *acl);
-int gpfswrap_putacl(char *pathname, int flags, void *acl);
-int gpfswrap_get_realfilename_path(char *pathname, char *filenamep, int *len);
-int gpfswrap_set_winattrs_path(char *pathname, int flags,
-			       struct gpfs_winattr *attrs);
-int gpfswrap_get_winattrs_path(char *pathname, struct gpfs_winattr *attrs);
-int gpfswrap_get_winattrs(int fd, struct gpfs_winattr *attrs);
-int gpfswrap_prealloc(int fd, gpfs_off64_t start, gpfs_off64_t bytes);
-int gpfswrap_ftruncate(int fd, gpfs_off64_t length);
-int gpfswrap_lib_init(int flags);
-int gpfswrap_set_times_path(char *pathname, int flags,
-			    gpfs_timestruc_t times[4]);
-int gpfswrap_quotactl(char *pathname, int cmd, int id, void *bufp);
-int gpfswrap_fcntl(int fd, void *argp);
-int gpfswrap_getfilesetid(char *pathname, char *name, int *idp);
-int gpfswrap_init(void);
diff --git a/source3/modules/wscript_build b/source3/modules/wscript_build
index 7fe66ec..a4afcd7 100644
--- a/source3/modules/wscript_build
+++ b/source3/modules/wscript_build
@@ -275,7 +275,7 @@ bld.SAMBA3_MODULE('vfs_commit',
 
 bld.SAMBA3_MODULE('vfs_gpfs',
                  subsystem='vfs',
-                 source='vfs_gpfs.c gpfs.c',
+                 source='vfs_gpfs.c gpfswrap.c',
                  deps='NFS4_ACLS non_posix_acls',
                  init_function='',
                  internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_gpfs'),
-- 
1.7.1


From 12954be667508c42de0f1e043e639db8e931f087 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 11 Feb 2015 13:28:08 -0700
Subject: [PATCH 32/32] gpfs: Add include guard to gpfswrap.h

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/gpfswrap.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/source3/modules/gpfswrap.h b/source3/modules/gpfswrap.h
index efe69c7..f34b1ca 100644
--- a/source3/modules/gpfswrap.h
+++ b/source3/modules/gpfswrap.h
@@ -21,6 +21,9 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#ifndef __GPFSWRAP_H__
+#define __GPFSWRAP_H__
+
 #include <gpfs_fcntl.h>
 
 int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny);
@@ -41,3 +44,5 @@ int gpfswrap_quotactl(char *pathname, int cmd, int id, void *bufp);
 int gpfswrap_fcntl(int fd, void *argp);
 int gpfswrap_getfilesetid(char *pathname, char *name, int *idp);
 int gpfswrap_init(void);
+
+#endif
-- 
1.7.1



More information about the samba-technical mailing list