s3:vfs fix up vfs_gpfs after function pointer renames
[kai/samba.git] / source3 / modules / vfs_gpfs.c
index 72976778763abfe92ea8526200c6246ab8ef3104..ba6ec6dca3d3f3e561ad36eb141ac44895c75b92 100644 (file)
@@ -24,6 +24,7 @@
 #include "includes.h"
 #include "smbd/smbd.h"
 #include "librpc/gen_ndr/ndr_xattr.h"
+#include "include/smbprofile.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_VFS
 #include <gpfs_gpl.h>
 #include "nfs4_acls.h"
 #include "vfs_gpfs.h"
+#include "system/filesys.h"
 
 struct gpfs_config_data {
        bool sharemodes;
        bool leases;
        bool hsm;
+       bool syncio;
 };
 
 
@@ -182,7 +185,7 @@ static int vfs_gpfs_get_real_filename(struct vfs_handle_struct *handle,
 
 static void gpfs_dumpacl(int level, struct gpfs_acl *gacl)
 {
-       int     i;
+       gpfs_aclCount_t i;
        if (gacl==NULL)
        {
                DEBUG(0, ("gpfs acl is NULL\n"));
@@ -252,7 +255,7 @@ static struct gpfs_acl *gpfs_getacl_alloc(const char *fname, gpfs_aclType_t type
  */
 static int gpfs_get_nfs4_acl(const char *fname, SMB4ACL_T **ppacl)
 {
-       int i;
+       gpfs_aclCount_t i;
        struct gpfs_acl *gacl = NULL;
        DEBUG(10, ("gpfs_get_nfs4_acl invoked for %s\n", fname));
 
@@ -506,7 +509,7 @@ static NTSTATUS gpfsacl_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp
 static SMB_ACL_T gpfs2smb_acl(const struct gpfs_acl *pacl)
 {
        SMB_ACL_T result;
-       int i;
+       gpfs_aclCount_t i;
 
        result = sys_acl_init(pacl->acl_nace);
        if (result == NULL) {
@@ -997,7 +1000,7 @@ static int gpfs_set_xattr(struct vfs_handle_struct *handle,  const char *path,
        }
 
 
-        ret = set_gpfs_winattrs(CONST_DISCARD(char *, path),
+        ret = set_gpfs_winattrs(discard_const_p(char, path),
                                GPFS_WINATTR_SET_ATTRS, &attrs);
         if ( ret == -1){
                if (errno == ENOSYS) {
@@ -1028,7 +1031,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(CONST_DISCARD(char *, path), &attrs);
+        ret = get_gpfs_winattrs(discard_const_p(char, path), &attrs);
         if ( ret == -1){
                if (errno == ENOSYS) {
                        return SMB_VFS_NEXT_GETXATTR(handle, path, name, value,
@@ -1082,11 +1085,12 @@ static int vfs_gpfs_stat(struct vfs_handle_struct *handle,
                errno = map_errno_from_nt_status(status);
                return -1;
        }
-       ret = get_gpfs_winattrs(CONST_DISCARD(char *, fname), &attrs);
+       ret = get_gpfs_winattrs(discard_const_p(char, fname), &attrs);
        TALLOC_FREE(fname);
        if (ret == 0) {
                smb_fname->st.st_ex_btime.tv_sec = attrs.creationTime.tv_sec;
                smb_fname->st.st_ex_btime.tv_nsec = attrs.creationTime.tv_nsec;
+               smb_fname->st.vfs_private = attrs.winAttrs;
        }
        return 0;
 }
@@ -1129,11 +1133,12 @@ static int vfs_gpfs_lstat(struct vfs_handle_struct *handle,
                errno = map_errno_from_nt_status(status);
                return -1;
        }
-       ret = get_gpfs_winattrs(CONST_DISCARD(char *, path), &attrs);
+       ret = get_gpfs_winattrs(discard_const_p(char, path), &attrs);
        TALLOC_FREE(path);
        if (ret == 0) {
                smb_fname->st.st_ex_btime.tv_sec = attrs.creationTime.tv_sec;
                smb_fname->st.st_ex_btime.tv_nsec = attrs.creationTime.tv_nsec;
+               smb_fname->st.vfs_private = attrs.winAttrs;
        }
        return 0;
 }
@@ -1169,7 +1174,7 @@ 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(CONST_DISCARD(char *, path),
+        ret = set_gpfs_winattrs(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));
@@ -1198,18 +1203,23 @@ static bool vfs_gpfs_is_offline(struct vfs_handle_struct *handle,
        struct gpfs_winattr attrs;
        char *path = NULL;
        NTSTATUS status;
-       int ret;
 
        status = get_full_smb_filename(talloc_tos(), fname, &path);
        if (!NT_STATUS_IS_OK(status)) {
                errno = map_errno_from_nt_status(status);
                return -1;
        }
-       ret = get_gpfs_winattrs(path, &attrs);
 
-       if (ret == -1) {
-               TALLOC_FREE(path);
-               return false;
+       if (VALID_STAT(*sbuf)) {
+               attrs.winAttrs = sbuf->vfs_private;
+       } else {
+               int ret;
+               ret = get_gpfs_winattrs(path, &attrs);
+
+               if (ret == -1) {
+                       TALLOC_FREE(path);
+                       return false;
+               }
        }
        if ((attrs.winAttrs & GPFS_WINATTR_OFFLINE) != 0) {
                DEBUG(10, ("%s is offline\n", path));
@@ -1227,10 +1237,24 @@ static bool vfs_gpfs_aio_force(struct vfs_handle_struct *handle,
        return vfs_gpfs_is_offline(handle, fsp->fsp_name, &fsp->fsp_name->st);
 }
 
+static ssize_t vfs_gpfs_sendfile(vfs_handle_struct *handle, int tofd,
+                                files_struct *fsp, const DATA_BLOB *hdr,
+                                SMB_OFF_T offset, size_t n)
+{
+       if ((fsp->fsp_name->st.vfs_private & GPFS_WINATTR_OFFLINE) != 0) {
+               errno = ENOSYS;
+               return -1;
+       }
+       return SMB_VFS_NEXT_SENDFILE(handle, tofd, fsp, hdr, offset, n);
+}
+
 int vfs_gpfs_connect(struct vfs_handle_struct *handle, const char *service,
                        const char *user)
 {
        struct gpfs_config_data *config;
+
+       smbd_gpfs_lib_init();
+
        int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
 
        if (ret < 0) {
@@ -1252,8 +1276,11 @@ int vfs_gpfs_connect(struct vfs_handle_struct *handle, const char *service,
        config->hsm = lp_parm_bool(SNUM(handle->conn), "gpfs",
                                   "hsm", false);
 
+       config->syncio = lp_parm_bool(SNUM(handle->conn), "gpfs",
+                                     "syncio", false);
+
        SMB_VFS_HANDLE_SET_DATA(handle, config,
-                               NULL, struct syncops_config_data,
+                               NULL, struct gpfs_config_data,
                                return -1);
 
        return 0;
@@ -1277,33 +1304,51 @@ static uint32_t vfs_gpfs_capabilities(struct vfs_handle_struct *handle,
        return next;
 }
 
+static int vfs_gpfs_open(struct vfs_handle_struct *handle,
+                        struct smb_filename *smb_fname, files_struct *fsp,
+                        int flags, mode_t mode)
+{
+       struct gpfs_config_data *config;
+
+       SMB_VFS_HANDLE_GET_DATA(handle, config,
+                               struct gpfs_config_data,
+                               return -1);
+
+       if (config->syncio) {
+               flags |= O_SYNC;
+       }
+       return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
+}
+
 
 static struct vfs_fn_pointers vfs_gpfs_fns = {
        .connect_fn = vfs_gpfs_connect,
-       .fs_capabilities = vfs_gpfs_capabilities,
-       .kernel_flock = vfs_gpfs_kernel_flock,
-        .linux_setlease = vfs_gpfs_setlease,
-        .get_real_filename = vfs_gpfs_get_real_filename,
-        .fget_nt_acl = gpfsacl_fget_nt_acl,
-        .get_nt_acl = gpfsacl_get_nt_acl,
-        .fset_nt_acl = gpfsacl_fset_nt_acl,
-        .sys_acl_get_file = gpfsacl_sys_acl_get_file,
-        .sys_acl_get_fd = gpfsacl_sys_acl_get_fd,
-        .sys_acl_set_file = gpfsacl_sys_acl_set_file,
-        .sys_acl_set_fd = gpfsacl_sys_acl_set_fd,
-        .sys_acl_delete_def_file = gpfsacl_sys_acl_delete_def_file,
-        .chmod = vfs_gpfs_chmod,
-        .fchmod = vfs_gpfs_fchmod,
-        .close_fn = vfs_gpfs_close,
-        .setxattr = gpfs_set_xattr,
-        .getxattr = gpfs_get_xattr,
-        .stat = vfs_gpfs_stat,
-        .fstat = vfs_gpfs_fstat,
-        .lstat = vfs_gpfs_lstat,
-       .ntimes = vfs_gpfs_ntimes,
-       .is_offline = vfs_gpfs_is_offline,
-       .aio_force = vfs_gpfs_aio_force,
-       .ftruncate = vfs_gpfs_ftruncate
+       .fs_capabilities_fn = vfs_gpfs_capabilities,
+       .kernel_flock_fn = vfs_gpfs_kernel_flock,
+       .linux_setlease_fn = vfs_gpfs_setlease,
+       .get_real_filename_fn = vfs_gpfs_get_real_filename,
+       .fget_nt_acl_fn = gpfsacl_fget_nt_acl,
+       .get_nt_acl_fn = gpfsacl_get_nt_acl,
+       .fset_nt_acl_fn = gpfsacl_fset_nt_acl,
+       .sys_acl_get_file_fn = gpfsacl_sys_acl_get_file,
+       .sys_acl_get_fd_fn = gpfsacl_sys_acl_get_fd,
+       .sys_acl_set_file_fn = gpfsacl_sys_acl_set_file,
+       .sys_acl_set_fd_fn = gpfsacl_sys_acl_set_fd,
+       .sys_acl_delete_def_file_fn = gpfsacl_sys_acl_delete_def_file,
+       .chmod_fn = vfs_gpfs_chmod,
+       .fchmod_fn = vfs_gpfs_fchmod,
+       .close_fn = vfs_gpfs_close,
+       .setxattr_fn = gpfs_set_xattr,
+       .getxattr_fn = gpfs_get_xattr,
+       .stat_fn = vfs_gpfs_stat,
+       .fstat_fn = vfs_gpfs_fstat,
+       .lstat_fn = vfs_gpfs_lstat,
+       .ntimes_fn = vfs_gpfs_ntimes,
+       .is_offline_fn = vfs_gpfs_is_offline,
+       .aio_force_fn = vfs_gpfs_aio_force,
+       .sendfile_fn = vfs_gpfs_sendfile,
+       .open_fn = vfs_gpfs_open,
+       .ftruncate_fn = vfs_gpfs_ftruncate
 };
 
 NTSTATUS vfs_gpfs_init(void);