vfs_glusterfs: remove init_search_op handling
[nivanova/samba-autobuild/.git] / source3 / modules / vfs_glusterfs.c
index 870983ea8fc5f247551ad8a9dab2f2eb2849b682..9489d9d4990550bc0cf265420183447df8038ee3 100644 (file)
@@ -38,7 +38,7 @@
 #include "includes.h"
 #include "smbd/smbd.h"
 #include <stdio.h>
-#include "api/glfs.h"
+#include <glusterfs/api/glfs.h>
 #include "lib/util/dlinklist.h"
 #include "lib/util/tevent_unix.h"
 #include "smbd/globals.h"
@@ -352,6 +352,16 @@ static int vfs_gluster_connect(struct vfs_handle_struct *handle,
                          volume, strerror(errno)));
                goto done;
        }
+
+       /*
+        * The shadow_copy2 module will fail to export subdirectories
+        * of a gluster volume unless we specify the mount point,
+        * because the detection fails if the file system is not
+        * locally mounted:
+        * https://bugzilla.samba.org/show_bug.cgi?id=13091
+        */
+       lp_do_parameter(SNUM(handle->conn), "shadow:mountpoint", "/");
+
 done:
        if (ret < 0) {
                if (fs)
@@ -420,16 +430,16 @@ vfs_gluster_set_quota(struct vfs_handle_struct *handle,
 }
 
 static int vfs_gluster_statvfs(struct vfs_handle_struct *handle,
-                              const char *path,
-                              struct vfs_statvfs_struct *vfs_statvfs)
+                               const struct smb_filename *smb_fname,
+                               struct vfs_statvfs_struct *vfs_statvfs)
 {
        struct statvfs statvfs = { 0, };
        int ret;
 
-       ret = glfs_statvfs(handle->data, path, &statvfs);
+       ret = glfs_statvfs(handle->data, smb_fname->base_name, &statvfs);
        if (ret < 0) {
                DEBUG(0, ("glfs_statvfs(%s) failed: %s\n",
-                         path, strerror(errno)));
+                         smb_fname->base_name, strerror(errno)));
                return -1;
        }
 
@@ -531,12 +541,6 @@ static void vfs_gluster_rewinddir(struct vfs_handle_struct *handle, DIR *dirp)
        glfs_seekdir((void *)dirp, 0);
 }
 
-static void vfs_gluster_init_search_op(struct vfs_handle_struct *handle,
-                                      DIR *dirp)
-{
-       return;
-}
-
 static int vfs_gluster_mkdir(struct vfs_handle_struct *handle,
                             const struct smb_filename *smb_fname,
                             mode_t mode)
@@ -1070,15 +1074,18 @@ static int vfs_gluster_lchown(struct vfs_handle_struct *handle,
        return glfs_lchown(handle->data, smb_fname->base_name, uid, gid);
 }
 
-static int vfs_gluster_chdir(struct vfs_handle_struct *handle, const char *path)
+static int vfs_gluster_chdir(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname)
 {
-       return glfs_chdir(handle->data, path);
+       return glfs_chdir(handle->data, smb_fname->base_name);
 }
 
-static char *vfs_gluster_getwd(struct vfs_handle_struct *handle)
+static struct smb_filename *vfs_gluster_getwd(struct vfs_handle_struct *handle,
+                               TALLOC_CTX *ctx)
 {
        char *cwd;
        char *ret;
+       struct smb_filename *smb_fname = NULL;
 
        cwd = SMB_CALLOC_ARRAY(char, PATH_MAX);
        if (cwd == NULL) {
@@ -1086,10 +1093,17 @@ static char *vfs_gluster_getwd(struct vfs_handle_struct *handle)
        }
 
        ret = glfs_getcwd(handle->data, cwd, PATH_MAX - 1);
-       if (ret == 0) {
-               free(cwd);
+       if (ret == NULL) {
+               SAFE_FREE(cwd);
+               return NULL;
        }
-       return ret;
+       smb_fname = synthetic_smb_fname(ctx,
+                                       ret,
+                                       NULL,
+                                       NULL,
+                                       0);
+       SAFE_FREE(cwd);
+       return smb_fname;
 }
 
 static int vfs_gluster_ntimes(struct vfs_handle_struct *handle,
@@ -1140,10 +1154,12 @@ static int vfs_gluster_fallocate(struct vfs_handle_struct *handle,
        return -1;
 }
 
-static char *vfs_gluster_realpath(struct vfs_handle_struct *handle,
-                                 const char *path)
+static struct smb_filename *vfs_gluster_realpath(struct vfs_handle_struct *handle,
+                               TALLOC_CTX *ctx,
+                               const struct smb_filename *smb_fname)
 {
        char *result = NULL;
+       struct smb_filename *result_fname = NULL;
        char *resolved_path = SMB_MALLOC_ARRAY(char, PATH_MAX+1);
 
        if (resolved_path == NULL) {
@@ -1151,12 +1167,15 @@ static char *vfs_gluster_realpath(struct vfs_handle_struct *handle,
                return NULL;
        }
 
-       result = glfs_realpath(handle->data, path, resolved_path);
-       if (result == NULL) {
-               SAFE_FREE(resolved_path);
+       result = glfs_realpath(handle->data,
+                       smb_fname->base_name,
+                       resolved_path);
+       if (result != NULL) {
+               result_fname = synthetic_smb_fname(ctx, result, NULL, NULL, 0);
        }
 
-       return result;
+       SAFE_FREE(resolved_path);
+       return result_fname;
 }
 
 static bool vfs_gluster_lock(struct vfs_handle_struct *handle,
@@ -1234,15 +1253,20 @@ static bool vfs_gluster_getlock(struct vfs_handle_struct *handle,
 }
 
 static int vfs_gluster_symlink(struct vfs_handle_struct *handle,
-                              const char *oldpath, const char *newpath)
+                               const char *link_target,
+                               const struct smb_filename *new_smb_fname)
 {
-       return glfs_symlink(handle->data, oldpath, newpath);
+       return glfs_symlink(handle->data,
+                       link_target,
+                       new_smb_fname->base_name);
 }
 
 static int vfs_gluster_readlink(struct vfs_handle_struct *handle,
-                               const char *path, char *buf, size_t bufsiz)
+                               const struct smb_filename *smb_fname,
+                               char *buf,
+                               size_t bufsiz)
 {
-       return glfs_readlink(handle->data, path, buf, bufsiz);
+       return glfs_readlink(handle->data, smb_fname->base_name, buf, bufsiz);
 }
 
 static int vfs_gluster_link(struct vfs_handle_struct *handle,
@@ -1303,7 +1327,7 @@ static int vfs_gluster_get_real_filename(struct vfs_handle_struct *handle,
 }
 
 static const char *vfs_gluster_connectpath(struct vfs_handle_struct *handle,
-                                          const char *filename)
+                               const struct smb_filename *smb_fname)
 {
        return handle->conn->connectpath;
 }
@@ -1404,7 +1428,6 @@ static struct vfs_fn_pointers glusterfs_fns = {
        .mkdir_fn = vfs_gluster_mkdir,
        .rmdir_fn = vfs_gluster_rmdir,
        .closedir_fn = vfs_gluster_closedir,
-       .init_search_op_fn = vfs_gluster_init_search_op,
 
        /* File Operations */
 
@@ -1454,8 +1477,6 @@ static struct vfs_fn_pointers glusterfs_fns = {
        .realpath_fn = vfs_gluster_realpath,
        .chflags_fn = vfs_gluster_chflags,
        .file_id_create_fn = NULL,
-       .copy_chunk_send_fn = NULL,
-       .copy_chunk_recv_fn = NULL,
        .streaminfo_fn = NULL,
        .get_real_filename_fn = vfs_gluster_get_real_filename,
        .connectpath_fn = vfs_gluster_connectpath,
@@ -1463,8 +1484,7 @@ static struct vfs_fn_pointers glusterfs_fns = {
        .brl_lock_windows_fn = NULL,
        .brl_unlock_windows_fn = NULL,
        .brl_cancel_windows_fn = NULL,
-       .strict_lock_fn = NULL,
-       .strict_unlock_fn = NULL,
+       .strict_lock_check_fn = NULL,
        .translate_name_fn = NULL,
        .fsctl_fn = NULL,