[PATCHES v2] Reorganize code for wrapping gpfs library

Christof Schmitt cs at samba.org
Wed Feb 25 16:49:41 MST 2015


Here is the updated patch series for reorganizing the gpfs library
wrapper code. The idea is to have a very thin wrapper for the gpfs
library to avoid hard link dependencies. The actual logic for the vfs
module is moved to vfs_gpfs.c

Christof
-------------- next part --------------
From df8d44fb4fe5e21bcce0dfa2c76e93ded40e3adf Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 18 Feb 2015 10:12:43 -0700
Subject: [PATCH 01/31] 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 b71b57f..3d99830 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 2cf7e551e65f82e8e660d215a47eb6cd7dd472aa Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 18 Feb 2015 10:13:33 -0700
Subject: [PATCH 02/31] 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 9917819067f3df7baceee801c6e34f152bb42adf Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 18 Feb 2015 10:13:55 -0700
Subject: [PATCH 03/31] 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 921ec0c16148b3d22b2622dccecd660891b02aa2 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 18 Feb 2015 10:14:22 -0700
Subject: [PATCH 04/31] 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     |   96 +++++++++++++++-----------------------------
 source3/modules/vfs_gpfs.c |    7 +++-
 source3/modules/vfs_gpfs.h |    2 +-
 3 files changed, 39 insertions(+), 66 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index b2ca704..933d491 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -44,6 +44,38 @@ 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);
 
+int gpfswrap_init(void)
+{
+	static void *l;
+
+	if (l != NULL) {
+		return 0;
+	}
+
+	l = dlopen("libgpfs.so", RTLD_LAZY);
+	if (l == NULL) {
+		return -1;
+	}
+
+	gpfs_set_share_fn	      = dlsym(l, "gpfs_set_share");
+	gpfs_set_lease_fn	      = dlsym(l, "gpfs_set_lease");
+	gpfs_getacl_fn		      = dlsym(l, "gpfs_getacl");
+	gpfs_putacl_fn		      = dlsym(l, "gpfs_putacl");
+	gpfs_get_realfilename_path_fn = dlsym(l, "gpfs_get_realfilename_path");
+	gpfs_set_winattrs_path_fn     = dlsym(l, "gpfs_set_winattrs_path");
+	gpfs_get_winattrs_path_fn     = dlsym(l, "gpfs_get_winattrs_path");
+	gpfs_get_winattrs_fn	      = dlsym(l, "gpfs_get_winattrs");
+	gpfs_prealloc_fn	      = dlsym(l, "gpfs_prealloc");
+	gpfs_ftruncate_fn	      = dlsym(l, "gpfs_ftruncate");
+	gpfs_lib_init_fn	      = dlsym(l, "gpfs_lib_init");
+	gpfs_set_times_path_fn	      = dlsym(l, "gpfs_set_times_path");
+	gpfs_quotactl_fn	      = dlsym(l, "gpfs_quotactl");
+	gpfs_fcntl_fn		      = dlsym(l, "gpfs_fcntl");
+	gpfs_getfilesetid_fn	      = dlsym(l, "gpfs_getfilesetid");
+
+	return 0;
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -331,67 +363,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 3d99830..7d1ea88 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..37b58f7 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_init(void);
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access);
 int set_gpfs_lease(int fd, int leasetype);
@@ -44,5 +45,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 init_gpfs(void);
 void smbd_gpfs_lib_init(void);
-- 
1.7.1


From 9d571e89d29a1ee24c2b4d6989727cb0577d6952 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 18 Feb 2015 14:22:55 -0700
Subject: [PATCH 05/31] gpfs: Introduce wrapper for gpfs_set_share

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

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index 933d491..e2628a5 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -76,6 +76,16 @@ int gpfswrap_init(void)
 	return 0;
 }
 
+int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny)
+{
+	if (gpfs_set_share_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_set_share_fn(fd, allow, deny);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -83,10 +93,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;
@@ -109,11 +115,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 37b58f7..5ab9ff3 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -28,6 +28,7 @@
 #endif
 
 int gpfswrap_init(void);
+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 2adf125bf148fe75b6816f514d5c3fb7b53dd1ec 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 06/31] gpfs: Introduce wrapper for gpfs_set_lease

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

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index e2628a5..e2a0766 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,
@@ -86,6 +86,16 @@ int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny)
 	return gpfs_set_share_fn(fd, allow, deny);
 }
 
+int gpfswrap_set_lease(int fd, unsigned int type)
+{
+	if (gpfs_set_lease_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_set_lease_fn(fd, type);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -135,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;
 	}
@@ -153,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 5ab9ff3..6ceb5e0 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -29,6 +29,7 @@
 
 int gpfswrap_init(void);
 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 af540070aa67ebe7bc18279850f19617b3b87942 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 07/31] gpfs: Rename wrapper for gpfs_getacl

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

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index e2a0766..de66a1e 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -96,6 +96,16 @@ int gpfswrap_set_lease(int fd, unsigned int type)
 	return gpfs_set_lease_fn(fd, type);
 }
 
+int gpfswrap_getacl(char *pathname, int flags, void *acl)
+{
+	if (gpfs_getacl_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_getacl_fn(pathname, flags, acl);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -161,16 +171,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 7d1ea88..79c0e2c 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 6ceb5e0..83b54c5 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -30,10 +30,10 @@
 int gpfswrap_init(void);
 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 551a2142d035e1b30d1e893b165d21e81c79a896 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 08/31] gpfs: Rename wrapper for gpfs_putacl

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

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index de66a1e..e042a89 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -106,6 +106,16 @@ int gpfswrap_getacl(char *pathname, int flags, void *acl)
 	return gpfs_getacl_fn(pathname, flags, acl);
 }
 
+int gpfswrap_putacl(char *pathname, int flags, void *acl)
+{
+	if (gpfs_putacl_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_putacl_fn(pathname, flags, acl);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -171,16 +181,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 79c0e2c..a461fb3 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 83b54c5..7f5d70c 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -31,10 +31,10 @@ int gpfswrap_init(void);
 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 b7ece3e2535c27938c04443729f293cf72a48d6b 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 09/31] gpfs: Rename wrapper for gpfs_get_realfilename_path

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

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index e042a89..2b12bbe 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);
@@ -116,6 +116,16 @@ int gpfswrap_putacl(char *pathname, int flags, void *acl)
 	return gpfs_putacl_fn(pathname, flags, acl);
 }
 
+int gpfswrap_get_realfilename_path(char *pathname, char *filenamep, int *len)
+{
+	if (gpfs_get_realfilename_path_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_get_realfilename_path_fn(pathname, filenamep, len);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -191,17 +201,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 a461fb3..52b2857 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 7f5d70c..3b4037c 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -32,11 +32,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 68e067329f3f200b5c37115a94c14eb8bf823581 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 10/31] gpfs: Rename wrapper for gpfs_set_winattrs_path

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

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index 2b12bbe..dbcfa32 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);
@@ -126,6 +127,17 @@ int gpfswrap_get_realfilename_path(char *pathname, char *filenamep, int *len)
 	return gpfs_get_realfilename_path_fn(pathname, filenamep, len);
 }
 
+int gpfswrap_set_winattrs_path(char *pathname, int flags,
+			       struct gpfs_winattr *attrs)
+{
+	if (gpfs_set_winattrs_path_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_set_winattrs_path_fn(pathname, flags, attrs);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -231,17 +243,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 52b2857..c2a3e14 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 3b4037c..5637421 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -33,12 +33,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 2d0a446fabd2c404480b08ba7b380d72f6512ac7 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 11/31] gpfs: Rename wrapper for gpfs_get_winattrs_path

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

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index dbcfa32..d029603 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);
@@ -138,6 +139,16 @@ int gpfswrap_set_winattrs_path(char *pathname, int flags,
 	return gpfs_set_winattrs_path_fn(pathname, flags, attrs);
 }
 
+int gpfswrap_get_winattrs_path(char *pathname, struct gpfs_winattr *attrs)
+{
+	if (gpfs_get_winattrs_path_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_get_winattrs_path_fn(pathname, attrs);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -213,16 +224,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 c2a3e14..34a2d04 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 5637421..afe2da4 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -35,11 +35,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 18b9d18d7ead9323c152d4f72a1e68b2fcf41587 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 12/31] gpfs: Rename wrapper for gpfs_get_winattrs

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

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index d029603..bcf5d24 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -149,6 +149,16 @@ int gpfswrap_get_winattrs_path(char *pathname, struct gpfs_winattr *attrs)
 	return gpfs_get_winattrs_path_fn(pathname, attrs);
 }
 
+int gpfswrap_get_winattrs(int fd, struct gpfs_winattr *attrs)
+{
+	if (gpfs_get_winattrs_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_get_winattrs_fn(fd, attrs);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -224,16 +234,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 34a2d04..a24f5d5 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 afe2da4..d4b5845 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -36,10 +36,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 3c3d5a50f0a10ea27a16c384d4897af29f47759e 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 13/31] gpfs: Rename wrapper for gpfs_prealloc

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

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index bcf5d24..eb200ff 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,
@@ -159,6 +159,16 @@ int gpfswrap_get_winattrs(int fd, struct gpfs_winattr *attrs)
 	return gpfs_get_winattrs_fn(fd, attrs);
 }
 
+int gpfswrap_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);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -234,16 +244,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 a24f5d5..8860803 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 d4b5845..83a4a61 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,
 			       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 909b776b94d11dfc7c235ad302b5b240d2f12835 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 14/31] gpfs: Rename wrapper for gpfs_ftruncate

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

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index eb200ff..f67b38c 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -169,6 +169,16 @@ int gpfswrap_prealloc(int fd, gpfs_off64_t start, gpfs_off64_t bytes)
 	return gpfs_prealloc_fn(fd, start, bytes);
 }
 
+int gpfswrap_ftruncate(int fd, gpfs_off64_t length)
+{
+	if (gpfs_ftruncate_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_ftruncate_fn(fd, length);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -234,16 +244,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 8860803..03cded1 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 83a4a61..3e04022 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -38,10 +38,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 db13da15179176782db4b39302cc08cfd2916d16 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 15/31] gpfs: Rename wrapper for gpfs_lib_init

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

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index f67b38c..b90d422 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -179,6 +179,16 @@ int gpfswrap_ftruncate(int fd, gpfs_off64_t length)
 	return gpfs_ftruncate_fn(fd, length);
 }
 
+int gpfswrap_lib_init(int flags)
+{
+	if (gpfs_lib_init_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_lib_init_fn(flags);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -323,17 +333,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 03cded1..883894d 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 3e04022..9d7ed54 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -39,6 +39,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,3 @@ 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);
-
-void smbd_gpfs_lib_init(void);
-- 
1.7.1


From e5248d67e83d04cf9866fa1d5b38d7e57de308f2 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 16/31] gpfs: Introduce wrapper for gpfs_set_times_path

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

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index b90d422..1659f5b 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -189,6 +189,17 @@ int gpfswrap_lib_init(int flags)
 	return gpfs_lib_init_fn(flags);
 }
 
+int gpfswrap_set_times_path(char *pathname, int flags,
+			    gpfs_timestruc_t times[4])
+{
+	if (gpfs_set_times_path_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_set_times_path_fn(pathname, flags, times);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -350,11 +361,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);
@@ -366,9 +372,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 9d7ed54..d56b808 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -40,6 +40,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 e02d4377c8b556fe923e7da81d4fcf439873cb46 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 17/31] gpfs: Introduce wrapper for gpfs_quotactl

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

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index 1659f5b..101b6ff 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);
 
@@ -200,6 +200,16 @@ int gpfswrap_set_times_path(char *pathname, int flags,
 	return gpfs_set_times_path_fn(pathname, flags, times);
 }
 
+int gpfswrap_quotactl(char *pathname, int cmd, int id, void *bufp)
+{
+	if (gpfs_quotactl_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_quotactl_fn(pathname, cmd, id, bufp);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -270,19 +280,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 d56b808..2c3866a 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -42,6 +42,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 292e0a19cfe5b396e37250e7f478bd388f8f7db3 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 18/31] gpfs: Introduce wrapper for gpfs_fcntl

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

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index 101b6ff..4959e1d 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);
 
 int gpfswrap_init(void)
@@ -210,6 +210,16 @@ int gpfswrap_quotactl(char *pathname, int cmd, int id, void *bufp)
 	return gpfs_quotactl_fn(pathname, cmd, id, bufp);
 }
 
+int gpfswrap_fcntl(int fd, void *argp)
+{
+	if (gpfs_fcntl_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_fcntl_fn(fd, argp);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -311,7 +321,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;
 	}
@@ -329,14 +339,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 2c3866a..9f83b97 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -43,6 +43,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 0e9bf66ff2999474f62cc15921e804fbd2ca4361 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 19/31] gpfs: Introduce wrapper for gpfs_getfilesetid

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

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index 4959e1d..44bf6b3 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);
 
 int gpfswrap_init(void)
 {
@@ -220,6 +220,16 @@ int gpfswrap_fcntl(int fd, void *argp)
 	return gpfs_fcntl_fn(fd, argp);
 }
 
+int gpfswrap_getfilesetid(char *pathname, char *name, int *idp)
+{
+	if (gpfs_getfilesetid_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_getfilesetid_fn(pathname, name, idp);
+}
+
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 			uint32 share_access)
 {
@@ -321,11 +331,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;
@@ -352,9 +357,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 9f83b97..5c7dc1b 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -44,6 +44,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 5ec5930c8f53147fb9d26fb152978c6628b6de77 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 20/31] 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 44bf6b3..585c522 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);
@@ -230,51 +229,6 @@ int gpfswrap_getfilesetid(char *pathname, char *name, int *idp)
 	return gpfs_getfilesetid_fn(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 883894d..053b673 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 5c7dc1b..61389b9 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -45,8 +45,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 35fb18bd5e87216d07c482106bfecdf575f39ab9 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 21/31] 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 585c522..c5ed93a 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -229,26 +229,6 @@ int gpfswrap_getfilesetid(char *pathname, char *name, int *idp)
 	return gpfs_getfilesetid_fn(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 053b673..ab9cfee 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 61389b9..b3c3e53 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -45,7 +45,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 9a02a5b11cfad7201f1213354b0aa66d6ec33ffc 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 22/31] 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 c5ed93a..9654bd7 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -229,33 +229,6 @@ int gpfswrap_getfilesetid(char *pathname, char *name, int *idp)
 	return gpfs_getfilesetid_fn(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 ab9cfee..fe506cf 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 b3c3e53..b61a0dd 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -45,7 +45,5 @@ 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 f39a9b6acaab09ac928a30374e4e32b0149d0227 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 23/31] 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 9654bd7..4b9b775 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -229,50 +229,6 @@ int gpfswrap_getfilesetid(char *pathname, char *name, int *idp)
 	return gpfs_getfilesetid_fn(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 fe506cf..d796170 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 b61a0dd..8c8ab74 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -45,5 +45,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 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 6f87fecf8f904f4dc0c2fa3ea8cf48ccd248f409 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 24/31] 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 |    1 -
 3 files changed, 38 insertions(+), 39 deletions(-)

diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index 4b9b775..d05fe50 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -228,41 +228,3 @@ int gpfswrap_getfilesetid(char *pathname, char *name, int *idp)
 
 	return gpfs_getfilesetid_fn(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 d796170..b91e377 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 8c8ab74..4399c9b 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -45,4 +45,3 @@ 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);
-- 
1.7.1


From ac874ab89ddb672490e6558f8029a2ed067369d5 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 18 Feb 2015 15:24:35 -0700
Subject: [PATCH 25/31] 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 b91e377..12d163e 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 4399c9b..dbc4f43 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_init(void);
 int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny);
 int gpfswrap_set_lease(int fd, unsigned int type);
-- 
1.7.1


From 99ea502c23fca628344cb74f00957186ee2162c2 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 18 Feb 2015 15:24:44 -0700
Subject: [PATCH 26/31] 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 d05fe50..6b7af7c 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 12d163e..a3199cb 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 dbc4f43..a96b0a2 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -23,6 +23,8 @@
 
 */
 
+#include <gpfs_fcntl.h>
+
 int gpfswrap_init(void);
 int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny);
 int gpfswrap_set_lease(int fd, unsigned int type);
-- 
1.7.1


From 51e9806244ffac94bd3dbc8047d7b69669571a3b Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 18 Feb 2015 15:24:50 -0700
Subject: [PATCH 27/31] 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 a3199cb..74617a8 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 ebc52ac41606006e5eb98b54c2f5d71e8100bc1e Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 18 Feb 2015 15:24:56 -0700
Subject: [PATCH 28/31] 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 6b7af7c..9e08a1b 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 15586bd30e7f8eaf407ee041daa1e1c3106316fe Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 18 Feb 2015 15:25:02 -0700
Subject: [PATCH 29/31] 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 9e08a1b..05ff992 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 74617a8..c8a5ee2 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 a96b0a2..40b2c9e 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 6156c92f1f123c2a9974650c06c3daf786f18e44 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 30/31] 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        |  226 -----------------------------------------
 source3/modules/gpfswrap.c    |  226 +++++++++++++++++++++++++++++++++++++++++
 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, 271 insertions(+), 271 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 05ff992..0000000
--- a/source3/modules/gpfs.c
+++ /dev/null
@@ -1,226 +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);
-
-int gpfswrap_init(void)
-{
-	static void *l;
-
-	if (l != NULL) {
-		return 0;
-	}
-
-	l = dlopen("libgpfs.so", RTLD_LAZY);
-	if (l == NULL) {
-		return -1;
-	}
-
-	gpfs_set_share_fn	      = dlsym(l, "gpfs_set_share");
-	gpfs_set_lease_fn	      = dlsym(l, "gpfs_set_lease");
-	gpfs_getacl_fn		      = dlsym(l, "gpfs_getacl");
-	gpfs_putacl_fn		      = dlsym(l, "gpfs_putacl");
-	gpfs_get_realfilename_path_fn = dlsym(l, "gpfs_get_realfilename_path");
-	gpfs_set_winattrs_path_fn     = dlsym(l, "gpfs_set_winattrs_path");
-	gpfs_get_winattrs_path_fn     = dlsym(l, "gpfs_get_winattrs_path");
-	gpfs_get_winattrs_fn	      = dlsym(l, "gpfs_get_winattrs");
-	gpfs_prealloc_fn	      = dlsym(l, "gpfs_prealloc");
-	gpfs_ftruncate_fn	      = dlsym(l, "gpfs_ftruncate");
-	gpfs_lib_init_fn	      = dlsym(l, "gpfs_lib_init");
-	gpfs_set_times_path_fn	      = dlsym(l, "gpfs_set_times_path");
-	gpfs_quotactl_fn	      = dlsym(l, "gpfs_quotactl");
-	gpfs_fcntl_fn		      = dlsym(l, "gpfs_fcntl");
-	gpfs_getfilesetid_fn	      = dlsym(l, "gpfs_getfilesetid");
-
-	return 0;
-}
-
-int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny)
-{
-	if (gpfs_set_share_fn == NULL) {
-		errno = ENOSYS;
-		return -1;
-	}
-
-	return gpfs_set_share_fn(fd, allow, deny);
-}
-
-int gpfswrap_set_lease(int fd, unsigned int type)
-{
-	if (gpfs_set_lease_fn == NULL) {
-		errno = ENOSYS;
-		return -1;
-	}
-
-	return gpfs_set_lease_fn(fd, type);
-}
-
-int gpfswrap_getacl(char *pathname, int flags, void *acl)
-{
-	if (gpfs_getacl_fn == NULL) {
-		errno = ENOSYS;
-		return -1;
-	}
-
-	return gpfs_getacl_fn(pathname, flags, acl);
-}
-
-int gpfswrap_putacl(char *pathname, int flags, void *acl)
-{
-	if (gpfs_putacl_fn == NULL) {
-		errno = ENOSYS;
-		return -1;
-	}
-
-	return gpfs_putacl_fn(pathname, flags, acl);
-}
-
-int gpfswrap_get_realfilename_path(char *pathname, char *filenamep, int *len)
-{
-	if (gpfs_get_realfilename_path_fn == NULL) {
-		errno = ENOSYS;
-		return -1;
-	}
-
-	return gpfs_get_realfilename_path_fn(pathname, filenamep, len);
-}
-
-int gpfswrap_set_winattrs_path(char *pathname, int flags,
-			       struct gpfs_winattr *attrs)
-{
-	if (gpfs_set_winattrs_path_fn == NULL) {
-		errno = ENOSYS;
-		return -1;
-	}
-
-	return gpfs_set_winattrs_path_fn(pathname, flags, attrs);
-}
-
-int gpfswrap_get_winattrs_path(char *pathname, struct gpfs_winattr *attrs)
-{
-	if (gpfs_get_winattrs_path_fn == NULL) {
-		errno = ENOSYS;
-		return -1;
-	}
-
-	return gpfs_get_winattrs_path_fn(pathname, attrs);
-}
-
-int gpfswrap_get_winattrs(int fd, struct gpfs_winattr *attrs)
-{
-	if (gpfs_get_winattrs_fn == NULL) {
-		errno = ENOSYS;
-		return -1;
-	}
-
-	return gpfs_get_winattrs_fn(fd, attrs);
-}
-
-int gpfswrap_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 gpfswrap_ftruncate(int fd, gpfs_off64_t length)
-{
-	if (gpfs_ftruncate_fn == NULL) {
-		errno = ENOSYS;
-		return -1;
-	}
-
-	return gpfs_ftruncate_fn(fd, length);
-}
-
-int gpfswrap_lib_init(int flags)
-{
-	if (gpfs_lib_init_fn == NULL) {
-		errno = ENOSYS;
-		return -1;
-	}
-
-	return gpfs_lib_init_fn(flags);
-}
-
-int gpfswrap_set_times_path(char *pathname, int flags,
-			    gpfs_timestruc_t times[4])
-{
-	if (gpfs_set_times_path_fn == NULL) {
-		errno = ENOSYS;
-		return -1;
-	}
-
-	return gpfs_set_times_path_fn(pathname, flags, times);
-}
-
-int gpfswrap_quotactl(char *pathname, int cmd, int id, void *bufp)
-{
-	if (gpfs_quotactl_fn == NULL) {
-		errno = ENOSYS;
-		return -1;
-	}
-
-	return gpfs_quotactl_fn(pathname, cmd, id, bufp);
-}
-
-int gpfswrap_fcntl(int fd, void *argp)
-{
-	if (gpfs_fcntl_fn == NULL) {
-		errno = ENOSYS;
-		return -1;
-	}
-
-	return gpfs_fcntl_fn(fd, argp);
-}
-
-int gpfswrap_getfilesetid(char *pathname, char *name, int *idp)
-{
-	if (gpfs_getfilesetid_fn == NULL) {
-		errno = ENOSYS;
-		return -1;
-	}
-
-	return gpfs_getfilesetid_fn(pathname, name, idp);
-}
diff --git a/source3/modules/gpfswrap.c b/source3/modules/gpfswrap.c
new file mode 100644
index 0000000..aac2f44
--- /dev/null
+++ b/source3/modules/gpfswrap.c
@@ -0,0 +1,226 @@
+/*
+ *  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);
+
+int gpfswrap_init(void)
+{
+	static void *l;
+
+	if (l != NULL) {
+		return 0;
+	}
+
+	l = dlopen("libgpfs.so", RTLD_LAZY);
+	if (l == NULL) {
+		return -1;
+	}
+
+	gpfs_set_share_fn	      = dlsym(l, "gpfs_set_share");
+	gpfs_set_lease_fn	      = dlsym(l, "gpfs_set_lease");
+	gpfs_getacl_fn		      = dlsym(l, "gpfs_getacl");
+	gpfs_putacl_fn		      = dlsym(l, "gpfs_putacl");
+	gpfs_get_realfilename_path_fn = dlsym(l, "gpfs_get_realfilename_path");
+	gpfs_set_winattrs_path_fn     = dlsym(l, "gpfs_set_winattrs_path");
+	gpfs_get_winattrs_path_fn     = dlsym(l, "gpfs_get_winattrs_path");
+	gpfs_get_winattrs_fn	      = dlsym(l, "gpfs_get_winattrs");
+	gpfs_prealloc_fn	      = dlsym(l, "gpfs_prealloc");
+	gpfs_ftruncate_fn	      = dlsym(l, "gpfs_ftruncate");
+	gpfs_lib_init_fn	      = dlsym(l, "gpfs_lib_init");
+	gpfs_set_times_path_fn	      = dlsym(l, "gpfs_set_times_path");
+	gpfs_quotactl_fn	      = dlsym(l, "gpfs_quotactl");
+	gpfs_fcntl_fn		      = dlsym(l, "gpfs_fcntl");
+	gpfs_getfilesetid_fn	      = dlsym(l, "gpfs_getfilesetid");
+
+	return 0;
+}
+
+int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny)
+{
+	if (gpfs_set_share_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_set_share_fn(fd, allow, deny);
+}
+
+int gpfswrap_set_lease(int fd, unsigned int type)
+{
+	if (gpfs_set_lease_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_set_lease_fn(fd, type);
+}
+
+int gpfswrap_getacl(char *pathname, int flags, void *acl)
+{
+	if (gpfs_getacl_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_getacl_fn(pathname, flags, acl);
+}
+
+int gpfswrap_putacl(char *pathname, int flags, void *acl)
+{
+	if (gpfs_putacl_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_putacl_fn(pathname, flags, acl);
+}
+
+int gpfswrap_get_realfilename_path(char *pathname, char *filenamep, int *len)
+{
+	if (gpfs_get_realfilename_path_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_get_realfilename_path_fn(pathname, filenamep, len);
+}
+
+int gpfswrap_set_winattrs_path(char *pathname, int flags,
+			       struct gpfs_winattr *attrs)
+{
+	if (gpfs_set_winattrs_path_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_set_winattrs_path_fn(pathname, flags, attrs);
+}
+
+int gpfswrap_get_winattrs_path(char *pathname, struct gpfs_winattr *attrs)
+{
+	if (gpfs_get_winattrs_path_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_get_winattrs_path_fn(pathname, attrs);
+}
+
+int gpfswrap_get_winattrs(int fd, struct gpfs_winattr *attrs)
+{
+	if (gpfs_get_winattrs_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_get_winattrs_fn(fd, attrs);
+}
+
+int gpfswrap_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 gpfswrap_ftruncate(int fd, gpfs_off64_t length)
+{
+	if (gpfs_ftruncate_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_ftruncate_fn(fd, length);
+}
+
+int gpfswrap_lib_init(int flags)
+{
+	if (gpfs_lib_init_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_lib_init_fn(flags);
+}
+
+int gpfswrap_set_times_path(char *pathname, int flags,
+			    gpfs_timestruc_t times[4])
+{
+	if (gpfs_set_times_path_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_set_times_path_fn(pathname, flags, times);
+}
+
+int gpfswrap_quotactl(char *pathname, int cmd, int id, void *bufp)
+{
+	if (gpfs_quotactl_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_quotactl_fn(pathname, cmd, id, bufp);
+}
+
+int gpfswrap_fcntl(int fd, void *argp)
+{
+	if (gpfs_fcntl_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_fcntl_fn(fd, argp);
+}
+
+int gpfswrap_getfilesetid(char *pathname, char *name, int *idp)
+{
+	if (gpfs_getfilesetid_fn == NULL) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	return gpfs_getfilesetid_fn(pathname, name, idp);
+}
diff --git a/source3/modules/gpfswrap.h b/source3/modules/gpfswrap.h
new file mode 100644
index 0000000..40b2c9e
--- /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_init(void);
+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);
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index c8a5ee2..21707c5 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 40b2c9e..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_init(void);
-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);
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 31dc794ef3d3633ddccafde7e9563ab88e489f57 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Wed, 18 Feb 2015 15:29:45 -0700
Subject: [PATCH 31/31] 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 40b2c9e..d30b05f 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_init(void);
@@ -41,3 +44,5 @@ 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);
+
+#endif
-- 
1.7.1



More information about the samba-technical mailing list