From f9629aee81084d4af39858c83eaf966e72e9e0f0 Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Wed, 10 Dec 2014 15:49:25 -0700 Subject: [PATCH] gpfs: Move set_gpfs_sharemode to vfs_gpfs.c MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Christof Schmitt Reviewed-by: Ralph Böhme --- 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 44bf6b35e2c..585c522f641 100644 --- a/source3/modules/gpfs.c +++ b/source3/modules/gpfs.c @@ -23,7 +23,6 @@ #include #include -#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 883894d5a4a..053b673d717 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 5c7dc1b4ddd..61389b9618a 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); -- 2.11.4.GIT