#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"
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)
{
uint32_t caps = FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES;
+#ifdef HAVE_GFAPI_VER_6
+ caps |= FILE_SUPPORTS_SPARSE_FILES;
+#endif
+
#ifdef STAT_HAVE_NSEC
*p_ts_res = TIMESTAMP_SET_NT_OR_BETTER;
#endif
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)
if (glfd == NULL) {
return -1;
}
- p_tmp = (glfs_fd_t **)VFS_ADD_FSP_EXTENSION(handle, fsp,
- glfs_fd_t *, NULL);
+ p_tmp = VFS_ADD_FSP_EXTENSION(handle, fsp, glfs_fd_t *, NULL);
*p_tmp = glfd;
/* An arbitrary value for error reporting, so you know its us. */
return 13371337;
return glfs_close(glfd);
}
-static ssize_t vfs_gluster_read(struct vfs_handle_struct *handle,
- files_struct *fsp, void *data, size_t n)
-{
- return glfs_read(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), data, n, 0);
-}
-
static ssize_t vfs_gluster_pread(struct vfs_handle_struct *handle,
files_struct *fsp, void *data, size_t n,
off_t offset)
return ret;
}
-static ssize_t vfs_gluster_write(struct vfs_handle_struct *handle,
- files_struct *fsp, const void *data, size_t n)
-{
- return glfs_write(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), data, n, 0);
-}
-
static ssize_t vfs_gluster_pwrite(struct vfs_handle_struct *handle,
files_struct *fsp, const void *data,
size_t n, off_t offset)
smb_fname_dst->base_name);
}
-static int vfs_gluster_fsync(struct vfs_handle_struct *handle,
- files_struct *fsp)
-{
- return glfs_fsync(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp));
-}
-
static struct tevent_req *vfs_gluster_fsync_send(struct vfs_handle_struct
*handle, TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
PROFILE_TIMESTAMP(&state->start);
ret = glfs_fsync_async(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle,
- fsp), aio_glusterfs_done, req);
+ fsp), aio_glusterfs_done, state);
if (ret < 0) {
tevent_req_error(req, -ret);
return tevent_req_post(req, ev);
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) {
}
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,
uint32_t mode,
off_t offset, off_t len)
{
- /* TODO: add support using glfs_fallocate() and glfs_zerofill() */
+#ifdef HAVE_GFAPI_VER_6
+ int keep_size, punch_hole;
+
+ keep_size = mode & VFS_FALLOCATE_FL_KEEP_SIZE;
+ punch_hole = mode & VFS_FALLOCATE_FL_PUNCH_HOLE;
+
+ mode &= ~(VFS_FALLOCATE_FL_KEEP_SIZE|VFS_FALLOCATE_FL_PUNCH_HOLE);
+ if (mode != 0) {
+ errno = ENOTSUP;
+ return -1;
+ }
+
+ if (punch_hole) {
+ return glfs_discard(*(glfs_fd_t **)
+ VFS_FETCH_FSP_EXTENSION(handle, fsp),
+ offset, len);
+ }
+
+ return glfs_fallocate(*(glfs_fd_t **)
+ VFS_FETCH_FSP_EXTENSION(handle, fsp),
+ keep_size, offset, len);
+#else
errno = ENOTSUP;
return -1;
+#endif
}
-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) {
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,
}
static const char *vfs_gluster_connectpath(struct vfs_handle_struct *handle,
- const char *filename)
+ const struct smb_filename *smb_fname)
{
return handle->conn->connectpath;
}
.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 */
.open_fn = vfs_gluster_open,
.create_file_fn = NULL,
.close_fn = vfs_gluster_close,
- .read_fn = vfs_gluster_read,
.pread_fn = vfs_gluster_pread,
.pread_send_fn = vfs_gluster_pread_send,
.pread_recv_fn = vfs_gluster_recv,
- .write_fn = vfs_gluster_write,
.pwrite_fn = vfs_gluster_pwrite,
.pwrite_send_fn = vfs_gluster_pwrite_send,
.pwrite_recv_fn = vfs_gluster_recv,
.sendfile_fn = vfs_gluster_sendfile,
.recvfile_fn = vfs_gluster_recvfile,
.rename_fn = vfs_gluster_rename,
- .fsync_fn = vfs_gluster_fsync,
.fsync_send_fn = vfs_gluster_fsync_send,
.fsync_recv_fn = vfs_gluster_fsync_recv,
.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,
.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,
.audit_file_fn = NULL,
/* Posix ACL Operations */
- .chmod_acl_fn = NULL, /* passthrough to default */
- .fchmod_acl_fn = NULL, /* passthrough to default */
.sys_acl_get_file_fn = posixacl_xattr_acl_get_file,
.sys_acl_get_fd_fn = posixacl_xattr_acl_get_fd,
.sys_acl_blob_get_file_fn = posix_sys_acl_blob_get_file,
.durable_reconnect_fn = NULL,
};
-NTSTATUS vfs_glusterfs_init(TALLOC_CTX *);
+static_decl_vfs;
NTSTATUS vfs_glusterfs_init(TALLOC_CTX *ctx)
{
return smb_register_vfs(SMB_VFS_INTERFACE_VERSION,