vfs_gpfs: Move mapping to sharemode deny to helper function
authorChristof Schmitt <cs@samba.org>
Mon, 30 Dec 2019 22:39:43 +0000 (15:39 -0700)
committerJeremy Allison <jra@samba.org>
Wed, 8 Jan 2020 00:01:36 +0000 (00:01 +0000)
Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_gpfs.c

index c25a2b9e0562541e48319a049617c4247a4aae56..dde45156ffc08085c86fac7fae2d97fa8036076c 100644 (file)
@@ -91,6 +91,29 @@ static unsigned int vfs_gpfs_access_mask_to_allow(uint32_t access_mask)
        return allow;
 }
 
+static unsigned int vfs_gpfs_share_access_to_deny(uint32_t share_access)
+{
+       unsigned int deny = GPFS_DENY_NONE;
+
+       if (!(share_access & FILE_SHARE_WRITE)) {
+               deny |= GPFS_DENY_WRITE;
+       }
+       if (!(share_access & FILE_SHARE_READ)) {
+               deny |= GPFS_DENY_READ;
+       }
+
+       /*
+        * GPFS_DENY_DELETE can only be set together with either
+        * GPFS_DENY_WRITE or GPFS_DENY_READ.
+        */
+       if ((deny & (GPFS_DENY_WRITE|GPFS_DENY_READ)) &&
+           !(share_access & FILE_SHARE_DELETE)) {
+               deny |= GPFS_DENY_DELETE;
+       }
+
+       return deny;
+}
+
 static bool set_gpfs_sharemode(files_struct *fsp, uint32_t access_mask,
                               uint32_t share_access)
 {
@@ -104,19 +127,7 @@ static bool set_gpfs_sharemode(files_struct *fsp, uint32_t access_mask,
                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;
-
-               /*
-                * GPFS_DENY_DELETE can only be set together with either
-                * GPFS_DENY_WRITE or GPFS_DENY_READ.
-                */
-               if (deny & (GPFS_DENY_WRITE|GPFS_DENY_READ)) {
-                       deny |= (share_access & (FILE_SHARE_DELETE)) ?
-                               0 : GPFS_DENY_DELETE;
-               }
+               deny = vfs_gpfs_share_access_to_deny(share_access);
        }
        DEBUG(10, ("am=%x, allow=%d, sa=%x, deny=%d\n",
                   access_mask, allow, share_access, deny));