r23228: Merge cleanup to the gpfs module from Tridge. Also potentially disable
authorVolker Lendecke <vlendec@samba.org>
Tue, 29 May 2007 19:54:26 +0000 (19:54 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:22:57 +0000 (12:22 -0500)
gpfs share modes in special situations. This might be split up in
several modules later.
(This used to be commit 553fe9245165ce4a14902daa722935c94ff32d61)

source3/modules/gpfs.c

index 19050ad3ca5c2996a9cb3fcf6b2a68c6bc885be1..d274984ec702e363577656a6a8cf8fbbe773bb9e 100644 (file)
@@ -25,6 +25,7 @@
 #include "gpfs_gpl.h"
 
 static void *libgpfs_handle = NULL;
+static BOOL gpfs_share_modes;
 
 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);
@@ -39,6 +40,10 @@ BOOL set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
        unsigned int deny = GPFS_DENY_NONE;
        int result;
 
+       if (!gpfs_share_modes) {
+               return True;
+       }
+
        if (gpfs_set_share_fn == NULL) {
                return False;
        }
@@ -84,6 +89,10 @@ int set_gpfs_lease(int fd, int leasetype)
 {
        int gpfs_type = GPFS_LEASE_NONE;
 
+       if (!gpfs_share_modes) {
+               return True;
+       }
+
        if (gpfs_set_lease_fn == NULL) {
                errno = EINVAL;
                return -1;
@@ -138,15 +147,7 @@ void init_gpfs(void)
        if (gpfs_set_share_fn == NULL) {
                DEBUG(3, ("libgpfs_gpl.so does not contain the symbol "
                          "'gpfs_set_share'\n"));
-               sys_dlclose(libgpfs_handle);
-
-               /* leave libgpfs_handle != NULL around, no point
-                  in trying twice */
-               gpfs_set_share_fn = NULL;
-               gpfs_set_lease_fn = NULL;
-               gpfs_getacl_fn = NULL;
-               gpfs_putacl_fn = NULL;
-               return;
+               goto failed;
        }
 
        gpfs_set_lease_fn = sys_dlsym(libgpfs_handle, "gpfs_set_lease");
@@ -155,45 +156,39 @@ void init_gpfs(void)
                          "'gpfs_set_lease'\n"));
                sys_dlclose(libgpfs_handle);
 
-               /* leave libgpfs_handle != NULL around, no point
-                  in trying twice */
-               gpfs_set_share_fn = NULL;
-               gpfs_set_lease_fn = NULL;
-               gpfs_getacl_fn = NULL;
-               gpfs_putacl_fn = NULL;
-               return;
+               goto failed;
        }
 
        gpfs_getacl_fn = sys_dlsym(libgpfs_handle, "gpfs_getacl");
        if (gpfs_getacl_fn == NULL) {
                DEBUG(3, ("libgpfs_gpl.so does not contain the symbol "
                          "'gpfs_getacl'\n"));
-               sys_dlclose(libgpfs_handle);
-
-               /* leave libgpfs_handle != NULL around, no point
-                  in trying twice */
-               gpfs_set_share_fn = NULL;
-               gpfs_set_lease_fn = NULL;
-               gpfs_getacl_fn = NULL;
-               gpfs_putacl_fn = NULL;
-               return;
+               goto failed;
        }
 
        gpfs_putacl_fn = sys_dlsym(libgpfs_handle, "gpfs_putacl");
        if (gpfs_putacl_fn == NULL) {
                DEBUG(3, ("libgpfs_gpl.so does not contain the symbol "
                          "'gpfs_putacl'\n"));
-               sys_dlclose(libgpfs_handle);
+               goto failed;
+       }
 
-               /* leave libgpfs_handle != NULL around, no point
-                  in trying twice */
-               gpfs_set_share_fn = NULL;
-               gpfs_set_lease_fn = NULL;
-               gpfs_getacl_fn = NULL;
-               gpfs_putacl_fn = NULL;
-               return;
+       if (lp_parm_bool(-1, "gpfs", "sharemodes", True)) {
+               gpfs_share_modes = True;
+       } else {
+               gpfs_share_modes = False;
        }
 
+       return;
+
+failed:
+       sys_dlclose(libgpfs_handle);
+       /* leave libgpfs_handle != NULL around, no point
+          in trying twice */
+       gpfs_set_share_fn = NULL;
+       gpfs_set_lease_fn = NULL;
+       gpfs_getacl_fn = NULL;
+       gpfs_putacl_fn = NULL;
 }
 
 #else