vfs: remove SMB_VFS_INIT_SEARCH_OP
[nivanova/samba-autobuild/.git] / source3 / smbd / vfs.c
index 581a02567ec09342b7c0056b197ebe39afe1b57e..59702203612e4ec5d61d3c828204b3ad63455b40 100644 (file)
@@ -27,7 +27,7 @@
 #include "system/filesys.h"
 #include "smbd/smbd.h"
 #include "smbd/globals.h"
-#include "memcache.h"
+#include "../lib/util/memcache.h"
 #include "transfer_file.h"
 #include "ntioctl.h"
 #include "lib/util/tevent_unix.h"
@@ -133,7 +133,7 @@ bool vfs_init_custom(connection_struct *conn, const char *vfs_object)
        }
 
        if(!backends) {
-               static_init_vfs;
+               static_init_vfs(NULL);
        }
 
        DEBUG(3, ("Initialising custom vfs hooks from [%s]\n", vfs_object));
@@ -222,7 +222,7 @@ bool vfs_init_custom(connection_struct *conn, const char *vfs_object)
  be refactored if it becomes more widely used.
 ******************************************************************/
 
-#define EXT_DATA_AREA(e) ((uint8 *)(e) + sizeof(struct vfs_fsp_data))
+#define EXT_DATA_AREA(e) ((uint8_t *)(e) + sizeof(struct vfs_fsp_data))
 
 void *vfs_add_fsp_extension_notype(vfs_handle_struct *handle,
                                   files_struct *fsp, size_t ext_size,
@@ -316,6 +316,36 @@ void *vfs_fetch_fsp_extension(vfs_handle_struct *handle, files_struct *fsp)
 
 #undef EXT_DATA_AREA
 
+/*
+ * Ensure this module catches all VFS functions.
+ */
+#ifdef DEVELOPER
+void smb_vfs_assert_all_fns(const struct vfs_fn_pointers* fns,
+                           const char *module)
+{
+       bool missing_fn = false;
+       unsigned int idx;
+       const uintptr_t *end = (const uintptr_t *)(fns + 1);
+
+       for (idx = 0; ((const uintptr_t *)fns + idx) < end; idx++) {
+               if (*((const uintptr_t *)fns + idx) == 0) {
+                       DBG_ERR("VFS function at index %d not implemented "
+                               "in module %s\n", idx, module);
+                       missing_fn = true;
+               }
+       }
+
+       if (missing_fn) {
+               smb_panic("Required VFS function not implemented in module.\n");
+       }
+}
+#else
+void smb_vfs_assert_all_fns(const struct vfs_fn_pointers* fns,
+                           const char *module)
+{
+}
+#endif
+
 /*****************************************************************
  Generic VFS init.
 ******************************************************************/
@@ -393,28 +423,6 @@ ssize_t vfs_read_data(files_struct *fsp, char *buf, size_t byte_count)
        return (ssize_t)total;
 }
 
-ssize_t vfs_pread_data(files_struct *fsp, char *buf,
-                size_t byte_count, off_t offset)
-{
-       size_t total=0;
-
-       while (total < byte_count)
-       {
-               ssize_t ret = SMB_VFS_PREAD(fsp, buf + total,
-                                       byte_count - total, offset + total);
-
-               if (ret == 0) return total;
-               if (ret == -1) {
-                       if (errno == EINTR)
-                               continue;
-                       else
-                               return -1;
-               }
-               total += ret;
-       }
-       return (ssize_t)total;
-}
-
 /****************************************************************************
  Write data to a fd on the vfs.
 ****************************************************************************/
@@ -428,14 +436,25 @@ ssize_t vfs_write_data(struct smb_request *req,
        ssize_t ret;
 
        if (req && req->unread_bytes) {
+               int sockfd = req->xconn->transport.sock;
+               int old_flags;
                SMB_ASSERT(req->unread_bytes == N);
                /* VFS_RECVFILE must drain the socket
                 * before returning. */
                req->unread_bytes = 0;
-               return SMB_VFS_RECVFILE(req->sconn->sock,
+               /* Ensure the socket is blocking. */
+               old_flags = fcntl(sockfd, F_GETFL, 0);
+               if (set_blocking(sockfd, true) == -1) {
+                       return (ssize_t)-1;
+               }
+               ret = SMB_VFS_RECVFILE(sockfd,
                                        fsp,
                                        (off_t)-1,
                                        N);
+               if (fcntl(sockfd, F_SETFL, old_flags) == -1) {
+                       return (ssize_t)-1;
+               }
+               return ret;
        }
 
        while (total < N) {
@@ -461,14 +480,52 @@ ssize_t vfs_pwrite_data(struct smb_request *req,
        ssize_t ret;
 
        if (req && req->unread_bytes) {
+               int sockfd = req->xconn->transport.sock;
                SMB_ASSERT(req->unread_bytes == N);
                /* VFS_RECVFILE must drain the socket
                 * before returning. */
                req->unread_bytes = 0;
-               return SMB_VFS_RECVFILE(req->sconn->sock,
-                                       fsp,
-                                       offset,
-                                       N);
+               /*
+                * Leave the socket non-blocking and
+                * use SMB_VFS_RECVFILE. If it returns
+                * EAGAIN || EWOULDBLOCK temporarily set
+                * the socket blocking and retry
+                * the RECVFILE.
+                */
+               while (total < N) {
+                       ret = SMB_VFS_RECVFILE(sockfd,
+                                               fsp,
+                                               offset + total,
+                                               N - total);
+                       if (ret == 0 || (ret == -1 &&
+                                        (errno == EAGAIN ||
+                                         errno == EWOULDBLOCK))) {
+                               int old_flags;
+                               /* Ensure the socket is blocking. */
+                               old_flags = fcntl(sockfd, F_GETFL, 0);
+                               if (set_blocking(sockfd, true) == -1) {
+                                       return (ssize_t)-1;
+                               }
+                               ret = SMB_VFS_RECVFILE(sockfd,
+                                                       fsp,
+                                                       offset + total,
+                                                       N - total);
+                               if (fcntl(sockfd, F_SETFL, old_flags) == -1) {
+                                       return (ssize_t)-1;
+                               }
+                               if (ret == -1) {
+                                       return (ssize_t)-1;
+                               }
+                               total += ret;
+                               return (ssize_t)total;
+                       }
+                       /* Any other error case. */
+                       if (ret == -1) {
+                               return ret;
+                       }
+                       total += ret;
+               }
+               return (ssize_t)total;
        }
 
        while (total < N) {
@@ -529,7 +586,7 @@ int vfs_allocate_file_space(files_struct *fsp, uint64_t len)
 
                contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_ALLOC_SHRINK);
 
-               flush_write_cache(fsp, SIZECHANGE_FLUSH);
+               flush_write_cache(fsp, SAMBA_SIZECHANGE_FLUSH);
                if ((ret = SMB_VFS_FTRUNCATE(fsp, (off_t)len)) != -1) {
                        set_filelen_write_cache(fsp, len);
                }
@@ -539,16 +596,18 @@ int vfs_allocate_file_space(files_struct *fsp, uint64_t len)
                return ret;
        }
 
-       if (!lp_strict_allocate(SNUM(fsp->conn)))
-               return 0;
-
        /* Grow - we need to test if we have enough space. */
 
        contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_ALLOC_GROW);
 
-       /* See if we have a syscall that will allocate beyond end-of-file
-          without changing EOF. */
-       ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_KEEP_SIZE, 0, len);
+       if (lp_strict_allocate(SNUM(fsp->conn))) {
+               /* See if we have a syscall that will allocate beyond
+                  end-of-file without changing EOF. */
+               ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_FL_KEEP_SIZE,
+                                       0, len);
+       } else {
+               ret = 0;
+       }
 
        contend_level2_oplocks_end(fsp, LEVEL2_CONTEND_ALLOC_GROW);
 
@@ -558,10 +617,14 @@ int vfs_allocate_file_space(files_struct *fsp, uint64_t len)
                return 0;
        }
 
+       if (ret == -1 && errno == ENOSPC) {
+               return -1;
+       }
+
        len -= fsp->fsp_name->st.st_ex_size;
        len /= 1024; /* Len is now number of 1k blocks needed. */
-       space_avail = get_dfree_info(conn, fsp->fsp_name->base_name, false,
-                                    &bsize, &dfree, &dsize);
+       space_avail =
+           get_dfree_info(conn, fsp->fsp_name, &bsize, &dfree, &dsize);
        if (space_avail == (uint64_t)-1) {
                return -1;
        }
@@ -593,7 +656,7 @@ int vfs_set_filelen(files_struct *fsp, off_t len)
 
        DEBUG(10,("vfs_set_filelen: ftruncate %s to len %.0f\n",
                  fsp_str_dbg(fsp), (double)len));
-       flush_write_cache(fsp, SIZECHANGE_FLUSH);
+       flush_write_cache(fsp, SAMBA_SIZECHANGE_FLUSH);
        if ((ret = SMB_VFS_FTRUNCATE(fsp, len)) != -1) {
                set_filelen_write_cache(fsp, len);
                notify_fname(fsp->conn, NOTIFY_ACTION_MODIFIED,
@@ -612,7 +675,7 @@ int vfs_set_filelen(files_struct *fsp, off_t len)
  fails. Needs to be outside of the default version of SMB_VFS_FALLOCATE
  as this is also called from the default SMB_VFS_FTRUNCATE code.
  Always extends the file size.
- Returns 0 on success, errno on failure.
+ Returns 0 on success, -1 on failure.
 ****************************************************************************/
 
 #define SPARSE_BUF_WRITE_SIZE (32*1024)
@@ -626,7 +689,7 @@ int vfs_slow_fallocate(files_struct *fsp, off_t offset, off_t len)
                sparse_buf = SMB_CALLOC_ARRAY(char, SPARSE_BUF_WRITE_SIZE);
                if (!sparse_buf) {
                        errno = ENOMEM;
-                       return ENOMEM;
+                       return -1;
                }
        }
 
@@ -635,10 +698,12 @@ int vfs_slow_fallocate(files_struct *fsp, off_t offset, off_t len)
 
                pwrite_ret = SMB_VFS_PWRITE(fsp, sparse_buf, curr_write_size, offset + total);
                if (pwrite_ret == -1) {
+                       int saved_errno = errno;
                        DEBUG(10,("vfs_slow_fallocate: SMB_VFS_PWRITE for file "
                                  "%s failed with error %s\n",
-                                 fsp_str_dbg(fsp), strerror(errno)));
-                       return errno;
+                                 fsp_str_dbg(fsp), strerror(saved_errno)));
+                       errno = saved_errno;
+                       return -1;
                }
                total += pwrite_ret;
        }
@@ -682,7 +747,7 @@ int vfs_fill_sparse(files_struct *fsp, off_t len)
 
        contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_FILL_SPARSE);
 
-       flush_write_cache(fsp, SIZECHANGE_FLUSH);
+       flush_write_cache(fsp, SAMBA_SIZECHANGE_FLUSH);
 
        offset = fsp->fsp_name->st.st_ex_size;
        num_to_write = len - fsp->fsp_name->st.st_ex_size;
@@ -694,11 +759,8 @@ int vfs_fill_sparse(files_struct *fsp, off_t len)
                 * emulation is being done by the libc (like on AIX with JFS1). In that
                 * case we do our own emulation. fallocate implementations can
                 * return ENOTSUP or EINVAL in cases like that. */
-               ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_EXTEND_SIZE,
-                               offset, num_to_write);
-               if (ret == ENOSPC) {
-                       errno = ENOSPC;
-                       ret = -1;
+               ret = SMB_VFS_FALLOCATE(fsp, 0, offset, num_to_write);
+               if (ret == -1 && errno == ENOSPC) {
                        goto out;
                }
                if (ret == 0) {
@@ -709,10 +771,6 @@ int vfs_fill_sparse(files_struct *fsp, off_t len)
        }
 
        ret = vfs_slow_fallocate(fsp, offset, num_to_write);
-       if (ret != 0) {
-               errno = ret;
-               ret = -1;
-       }
 
  out:
 
@@ -728,24 +786,24 @@ int vfs_fill_sparse(files_struct *fsp, off_t len)
  Transfer some data (n bytes) between two file_struct's.
 ****************************************************************************/
 
-static ssize_t vfs_read_fn(void *file, void *buf, size_t len)
+static ssize_t vfs_pread_fn(void *file, void *buf, size_t len, off_t offset)
 {
        struct files_struct *fsp = (struct files_struct *)file;
 
-       return SMB_VFS_READ(fsp, buf, len);
+       return SMB_VFS_PREAD(fsp, buf, len, offset);
 }
 
-static ssize_t vfs_write_fn(void *file, const void *buf, size_t len)
+static ssize_t vfs_pwrite_fn(void *file, const void *buf, size_t len, off_t offset)
 {
        struct files_struct *fsp = (struct files_struct *)file;
 
-       return SMB_VFS_WRITE(fsp, buf, len);
+       return SMB_VFS_PWRITE(fsp, buf, len, offset);
 }
 
 off_t vfs_transfer_file(files_struct *in, files_struct *out, off_t n)
 {
        return transfer_file_internal((void *)in, (void *)out, n,
-                                     vfs_read_fn, vfs_write_fn);
+                                     vfs_pread_fn, vfs_pwrite_fn);
 }
 
 /*******************************************************************
@@ -797,34 +855,99 @@ const char *vfs_readdirname(connection_struct *conn, void *p,
  A wrapper for vfs_chdir().
 ********************************************************************/
 
-int vfs_ChDir(connection_struct *conn, const char *path)
+int vfs_ChDir(connection_struct *conn, const struct smb_filename *smb_fname)
 {
        int ret;
+       int saved_errno = 0;
+       struct smb_filename *saved_cwd = NULL;
 
        if (!LastDir) {
                LastDir = SMB_STRDUP("");
        }
 
-       if (strcsequal(path,".")) {
+       if (ISDOT(smb_fname->base_name)) {
                return 0;
        }
 
-       if (*path == '/' && strcsequal(LastDir,path)) {
+       if (*smb_fname->base_name == '/' &&
+                       strcsequal(LastDir,smb_fname->base_name)) {
                return 0;
        }
 
-       DEBUG(4,("vfs_ChDir to %s\n",path));
+       if (conn->cwd_fname != NULL) {
+               /*
+                * Save off where we are in case we need to return
+                * on vfs_GetWd() failure after successful SMB_VFS_CHDIR().
+                */
+               saved_cwd = cp_smb_filename(conn, conn->cwd_fname);
+               if (saved_cwd == NULL) {
+                       return -1;
+               }
+       }
 
-       ret = SMB_VFS_CHDIR(conn,path);
-       if (ret == 0) {
-               /* Global cache. */
-               SAFE_FREE(LastDir);
-               LastDir = SMB_STRDUP(path);
+       DEBUG(4,("vfs_ChDir to %s\n", smb_fname->base_name));
+
+       ret = SMB_VFS_CHDIR(conn, smb_fname);
+       if (ret != 0) {
+               saved_errno = errno;
+               TALLOC_FREE(saved_cwd);
+               errno = saved_errno;
+               return -1;
+       }
+
+       /*
+        * Always replace conn->cwd_fname. We
+        * don't know if it's been modified by
+        * VFS modules in the stack.
+        */
 
-               /* conn cache. */
-               TALLOC_FREE(conn->cwd);
-               conn->cwd = vfs_GetWd(conn, conn);
-               DEBUG(4,("vfs_ChDir got %s\n",conn->cwd));
+       /* conn cache. */
+       TALLOC_FREE(conn->cwd_fname);
+       conn->cwd_fname = vfs_GetWd(conn, conn);
+       if (conn->cwd_fname == NULL) {
+               /*
+                * vfs_GetWd() failed.
+                * We must be able to read cwd.
+                * Return to original directory
+                * and return -1.
+                */
+               saved_errno = errno;
+
+               if (saved_cwd == NULL) {
+                       /*
+                        * Failed on the very first chdir()+getwd()
+                        * for this connection. We can't
+                        * continue.
+                        */
+                       smb_panic("conn->cwd getwd failed\n");
+                       /* NOTREACHED */
+                       return -1;
+               }
+
+               /* Return to the previous $cwd. */
+               ret = SMB_VFS_CHDIR(conn, saved_cwd);
+               if (ret != 0) {
+                       smb_panic("conn->cwd getwd failed\n");
+                       /* NOTREACHED */
+                       return -1;
+               }
+               /* Restore original conn->cwd_fname. */
+               conn->cwd_fname = saved_cwd;
+               errno = saved_errno;
+               /* And fail the chdir(). */
+               return -1;
+       }
+
+       /* vfs_GetWd() succeeded. */
+       /* Replace global cache. */
+       SAFE_FREE(LastDir);
+       LastDir = SMB_STRDUP(smb_fname->base_name);
+
+       DEBUG(4,("vfs_ChDir got %s\n", conn->cwd_fname->base_name));
+
+       TALLOC_FREE(saved_cwd);
+       if (saved_errno != 0) {
+               errno = saved_errno;
        }
        return ret;
 }
@@ -835,24 +958,21 @@ int vfs_ChDir(connection_struct *conn, const char *path)
  format. Note this can be called with conn == NULL.
 ********************************************************************/
 
-char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
+struct smb_filename *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
 {
-        char *current_dir = NULL;
-       char *result = NULL;
-       DATA_BLOB cache_value;
+        struct smb_filename *current_dir_fname = NULL;
        struct file_id key;
        struct smb_filename *smb_fname_dot = NULL;
        struct smb_filename *smb_fname_full = NULL;
-       NTSTATUS status;
+       struct smb_filename *result = NULL;
 
        if (!lp_getwd_cache()) {
                goto nocache;
        }
 
-       status = create_synthetic_smb_fname(ctx, ".", NULL, NULL,
-                                           &smb_fname_dot);
-       if (!NT_STATUS_IS_OK(status)) {
-               errno = map_errno_from_nt_status(status);
+       smb_fname_dot = synthetic_smb_fname(ctx, ".", NULL, NULL, 0);
+       if (smb_fname_dot == NULL) {
+               errno = ENOMEM;
                goto out;
        }
 
@@ -868,20 +988,13 @@ char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
 
        key = vfs_file_id_from_sbuf(conn, &smb_fname_dot->st);
 
-       if (!memcache_lookup(smbd_memcache(), GETWD_CACHE,
-                            data_blob_const(&key, sizeof(key)),
-                            &cache_value)) {
-               goto nocache;
-       }
-
-       SMB_ASSERT((cache_value.length > 0)
-                  && (cache_value.data[cache_value.length-1] == '\0'));
+       smb_fname_full = (struct smb_filename *)memcache_lookup_talloc(
+                                       smbd_memcache(),
+                                       GETWD_CACHE,
+                                       data_blob_const(&key, sizeof(key)));
 
-       status = create_synthetic_smb_fname(ctx, (char *)cache_value.data,
-                                           NULL, NULL, &smb_fname_full);
-       if (!NT_STATUS_IS_OK(status)) {
-               errno = map_errno_from_nt_status(status);
-               goto out;
+       if (smb_fname_full == NULL) {
+               goto nocache;
        }
 
        if ((SMB_VFS_STAT(conn, smb_fname_full) == 0) &&
@@ -890,8 +1003,10 @@ char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
            (S_ISDIR(smb_fname_dot->st.st_ex_mode))) {
                /*
                 * Ok, we're done
+                * Note: smb_fname_full is owned by smbd_memcache()
+                * so we must make a copy to return.
                 */
-               result = talloc_strdup(ctx, smb_fname_full->base_name);
+               result = cp_smb_filename(ctx, smb_fname_full);
                if (result == NULL) {
                        errno = ENOMEM;
                }
@@ -906,8 +1021,8 @@ char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
         * systems, or the not quite so bad getwd.
         */
 
-       current_dir = SMB_VFS_GETWD(conn);
-       if (current_dir == NULL) {
+       current_dir_fname = SMB_VFS_GETWD(conn, ctx);
+       if (current_dir_fname == NULL) {
                DEBUG(0, ("vfs_GetWd: SMB_VFS_GETWD call failed: %s\n",
                          strerror(errno)));
                goto out;
@@ -916,21 +1031,39 @@ char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
        if (lp_getwd_cache() && VALID_STAT(smb_fname_dot->st)) {
                key = vfs_file_id_from_sbuf(conn, &smb_fname_dot->st);
 
-               memcache_add(smbd_memcache(), GETWD_CACHE,
-                            data_blob_const(&key, sizeof(key)),
-                            data_blob_const(current_dir,
-                                               strlen(current_dir)+1));
-       }
+               /*
+                * smbd_memcache() will own current_dir_fname after the
+                * memcache_add_talloc call, so we must make
+                * a copy on ctx to return.
+                */
+               result = cp_smb_filename(ctx, current_dir_fname);
+               if (result == NULL) {
+                       errno = ENOMEM;
+               }
 
-       result = talloc_strdup(ctx, current_dir);
-       if (result == NULL) {
-               errno = ENOMEM;
+               /*
+                * Ensure the memory going into the cache
+                * doesn't have a destructor so it can be
+                * cleanly freed.
+                */
+               talloc_set_destructor(current_dir_fname, NULL);
+
+               memcache_add_talloc(smbd_memcache(),
+                               GETWD_CACHE,
+                               data_blob_const(&key, sizeof(key)),
+                               &current_dir_fname);
+               /* current_dir_fname is now == NULL here. */
+       } else {
+               /* current_dir_fname is already allocated on ctx. */
+               result = current_dir_fname;
        }
 
  out:
        TALLOC_FREE(smb_fname_dot);
-       TALLOC_FREE(smb_fname_full);
-       SAFE_FREE(current_dir);
+       /*
+        * Don't free current_dir_fname here. It's either been moved
+        * to the memcache or is being returned in result.
+        */
        return result;
 }
 
@@ -942,7 +1075,7 @@ char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
 ********************************************************************/
 
 NTSTATUS check_reduced_name_with_privilege(connection_struct *conn,
-                       const char *fname,
+                       const struct smb_filename *smb_fname,
                        struct smb_request *smbreq)
 {
        NTSTATUS status;
@@ -950,15 +1083,16 @@ NTSTATUS check_reduced_name_with_privilege(connection_struct *conn,
        const char *conn_rootdir;
        size_t rootdir_len;
        char *dir_name = NULL;
-       const char *last_component = NULL;
        char *resolved_name = NULL;
-       char *saved_dir = NULL;
+       const char *last_component = NULL;
+       struct smb_filename *resolved_fname = NULL;
+       struct smb_filename *saved_dir_fname = NULL;
        struct smb_filename *smb_fname_cwd = NULL;
        struct privilege_paths *priv_paths = NULL;
        int ret;
 
        DEBUG(3,("check_reduced_name_with_privilege [%s] [%s]\n",
-                       fname,
+                       smb_fname->base_name,
                        conn->connectpath));
 
 
@@ -968,7 +1102,8 @@ NTSTATUS check_reduced_name_with_privilege(connection_struct *conn,
                goto err;
        }
 
-       if (!parent_dirname(ctx, fname, &dir_name, &last_component)) {
+       if (!parent_dirname(ctx, smb_fname->base_name,
+                       &dir_name, &last_component)) {
                status = NT_STATUS_NO_MEMORY;
                goto err;
        }
@@ -987,24 +1122,30 @@ NTSTATUS check_reduced_name_with_privilege(connection_struct *conn,
                goto err;
        }
        /* Remember where we were. */
-       saved_dir = vfs_GetWd(ctx, conn);
-       if (!saved_dir) {
+       saved_dir_fname = vfs_GetWd(ctx, conn);
+       if (!saved_dir_fname) {
                status = map_nt_error_from_unix(errno);
                goto err;
        }
 
-       /* Go to the parent directory to lock in memory. */
-       if (vfs_ChDir(conn, priv_paths->parent_name.base_name) == -1) {
+       if (vfs_ChDir(conn, &priv_paths->parent_name) == -1) {
                status = map_nt_error_from_unix(errno);
                goto err;
        }
 
+       smb_fname_cwd = synthetic_smb_fname(talloc_tos(), ".", NULL, NULL, 0);
+       if (smb_fname_cwd == NULL) {
+               status = NT_STATUS_NO_MEMORY;
+               goto err;
+       }
+
        /* Get the absolute path of the parent directory. */
-       resolved_name = SMB_VFS_REALPATH(conn,".");
-       if (!resolved_name) {
+       resolved_fname = SMB_VFS_REALPATH(conn, ctx, smb_fname_cwd);
+       if (resolved_fname == NULL) {
                status = map_nt_error_from_unix(errno);
                goto err;
        }
+       resolved_name = resolved_fname->base_name;
 
        if (*resolved_name != '/') {
                DEBUG(0,("check_reduced_name_with_privilege: realpath "
@@ -1018,13 +1159,6 @@ NTSTATUS check_reduced_name_with_privilege(connection_struct *conn,
                resolved_name));
 
        /* Now check the stat value is the same. */
-       status = create_synthetic_smb_fname(talloc_tos(), ".",
-                                       NULL, NULL,
-                                       &smb_fname_cwd);
-       if (!NT_STATUS_IS_OK(status)) {
-               goto err;
-       }
-
        if (SMB_VFS_LSTAT(conn, smb_fname_cwd) != 0) {
                status = map_nt_error_from_unix(errno);
                goto err;
@@ -1042,7 +1176,7 @@ NTSTATUS check_reduced_name_with_privilege(connection_struct *conn,
 
        /* Ensure we're below the connect path. */
 
-       conn_rootdir = SMB_VFS_CONNECTPATH(conn, fname);
+       conn_rootdir = SMB_VFS_CONNECTPATH(conn, smb_fname);
        if (conn_rootdir == NULL) {
                DEBUG(2, ("check_reduced_name_with_privilege: Could not get "
                        "conn_rootdir\n"));
@@ -1051,15 +1185,32 @@ NTSTATUS check_reduced_name_with_privilege(connection_struct *conn,
        }
 
        rootdir_len = strlen(conn_rootdir);
-       if (strncmp(conn_rootdir, resolved_name, rootdir_len) != 0) {
-               DEBUG(2, ("check_reduced_name_with_privilege: Bad access "
-                       "attempt: %s is a symlink outside the "
-                       "share path\n",
-                       dir_name));
-               DEBUGADD(2, ("conn_rootdir =%s\n", conn_rootdir));
-               DEBUGADD(2, ("resolved_name=%s\n", resolved_name));
-               status = NT_STATUS_ACCESS_DENIED;
-               goto err;
+
+       /*
+        * In the case of rootdir_len == 1, we know that conn_rootdir is
+        * "/", and we also know that resolved_name starts with a slash.
+        * So, in this corner case, resolved_name is automatically a
+        * sub-directory of the conn_rootdir. Thus we can skip the string
+        * comparison and the next character checks (which are even
+        * wrong in this case).
+        */
+       if (rootdir_len != 1) {
+               bool matched;
+
+               matched = (strncmp(conn_rootdir, resolved_name,
+                               rootdir_len) == 0);
+
+               if (!matched || (resolved_name[rootdir_len] != '/' &&
+                                resolved_name[rootdir_len] != '\0')) {
+                       DEBUG(2, ("check_reduced_name_with_privilege: Bad "
+                               "access attempt: %s is a symlink outside the "
+                               "share path\n",
+                               dir_name));
+                       DEBUGADD(2, ("conn_rootdir =%s\n", conn_rootdir));
+                       DEBUGADD(2, ("resolved_name=%s\n", resolved_name));
+                       status = NT_STATUS_ACCESS_DENIED;
+                       goto err;
+               }
        }
 
        /* Now ensure that the last component either doesn't
@@ -1093,10 +1244,11 @@ NTSTATUS check_reduced_name_with_privilege(connection_struct *conn,
 
   err:
 
-       if (saved_dir) {
-               vfs_ChDir(conn, saved_dir);
+       if (saved_dir_fname != NULL) {
+               vfs_ChDir(conn, saved_dir_fname);
+               TALLOC_FREE(saved_dir_fname);
        }
-       SAFE_FREE(resolved_name);
+       TALLOC_FREE(resolved_fname);
        if (!NT_STATUS_IS_OK(status)) {
                TALLOC_FREE(priv_paths);
        }
@@ -1107,19 +1259,32 @@ NTSTATUS check_reduced_name_with_privilege(connection_struct *conn,
 /*******************************************************************
  Reduce a file name, removing .. elements and checking that
  it is below dir in the heirachy. This uses realpath.
+
+ If cwd_name == NULL then fname is a client given path relative
+ to the root path of the share.
+
+ If cwd_name != NULL then fname is a client given path relative
+ to cwd_name. cwd_name is relative to the root path of the share.
 ********************************************************************/
 
-NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
+NTSTATUS check_reduced_name(connection_struct *conn,
+                               const struct smb_filename *cwd_fname,
+                               const struct smb_filename *smb_fname)
 {
+       TALLOC_CTX *ctx = talloc_tos();
+       const char *cwd_name = cwd_fname ? cwd_fname->base_name : NULL;
+       const char *fname = smb_fname->base_name;
+       struct smb_filename *resolved_fname;
        char *resolved_name = NULL;
+       char *new_fname = NULL;
        bool allow_symlinks = true;
        bool allow_widelinks = false;
 
-       DEBUG(3,("check_reduced_name [%s] [%s]\n", fname, conn->connectpath));
+       DBG_DEBUG("check_reduced_name [%s] [%s]\n", fname, conn->connectpath);
 
-       resolved_name = SMB_VFS_REALPATH(conn,fname);
+       resolved_fname = SMB_VFS_REALPATH(conn, ctx, smb_fname);
 
-       if (!resolved_name) {
+       if (resolved_fname == NULL) {
                switch (errno) {
                        case ENOTDIR:
                                DEBUG(3,("check_reduced_name: Component not a "
@@ -1128,11 +1293,9 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
                                return NT_STATUS_OBJECT_PATH_NOT_FOUND;
                        case ENOENT:
                        {
-                               TALLOC_CTX *ctx = talloc_tos();
                                char *dir_name = NULL;
+                               struct smb_filename dir_fname = {0};
                                const char *last_component = NULL;
-                               char *new_name = NULL;
-                               int ret;
 
                                /* Last component didn't exist.
                                   Remove it and try and canonicalise
@@ -1143,8 +1306,12 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
                                        return NT_STATUS_NO_MEMORY;
                                }
 
-                               resolved_name = SMB_VFS_REALPATH(conn,dir_name);
-                               if (!resolved_name) {
+                               dir_fname = (struct smb_filename)
+                                       { .base_name = dir_name };
+                               resolved_fname = SMB_VFS_REALPATH(conn,
+                                                       ctx,
+                                                       &dir_fname);
+                               if (resolved_fname == NULL) {
                                        NTSTATUS status = map_nt_error_from_unix(errno);
 
                                        if (errno == ENOENT || errno == ENOTDIR) {
@@ -1158,13 +1325,13 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
                                                nt_errstr(status)));
                                        return status;
                                }
-                               ret = asprintf(&new_name, "%s/%s",
-                                              resolved_name, last_component);
-                               SAFE_FREE(resolved_name);
-                               if (ret == -1) {
+                               resolved_name = talloc_asprintf(ctx,
+                                               "%s/%s",
+                                               resolved_fname->base_name,
+                                               last_component);
+                               if (resolved_name == NULL) {
                                        return NT_STATUS_NO_MEMORY;
                                }
-                               resolved_name = new_name;
                                break;
                        }
                        default:
@@ -1172,6 +1339,8 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
                                         "realpath for %s\n", fname));
                                return map_nt_error_from_unix(errno);
                }
+       } else {
+               resolved_name = resolved_fname->base_name;
        }
 
        DEBUG(10,("check_reduced_name realpath [%s] -> [%s]\n", fname,
@@ -1180,36 +1349,54 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
        if (*resolved_name != '/') {
                DEBUG(0,("check_reduced_name: realpath doesn't return "
                         "absolute paths !\n"));
-               SAFE_FREE(resolved_name);
+               TALLOC_FREE(resolved_fname);
                return NT_STATUS_OBJECT_NAME_INVALID;
        }
 
        allow_widelinks = lp_widelinks(SNUM(conn));
-       allow_symlinks = lp_symlinks(SNUM(conn));
+       allow_symlinks = lp_follow_symlinks(SNUM(conn));
 
        /* Common widelinks and symlinks checks. */
        if (!allow_widelinks || !allow_symlinks) {
                const char *conn_rootdir;
                size_t rootdir_len;
 
-               conn_rootdir = SMB_VFS_CONNECTPATH(conn, fname);
+               conn_rootdir = SMB_VFS_CONNECTPATH(conn, smb_fname);
                if (conn_rootdir == NULL) {
                        DEBUG(2, ("check_reduced_name: Could not get "
                                "conn_rootdir\n"));
-                       SAFE_FREE(resolved_name);
+                       TALLOC_FREE(resolved_fname);
                        return NT_STATUS_ACCESS_DENIED;
                }
 
                rootdir_len = strlen(conn_rootdir);
-               if (strncmp(conn_rootdir, resolved_name,
-                               rootdir_len) != 0) {
-                       DEBUG(2, ("check_reduced_name: Bad access "
-                               "attempt: %s is a symlink outside the "
-                               "share path\n", fname));
-                       DEBUGADD(2, ("conn_rootdir =%s\n", conn_rootdir));
-                       DEBUGADD(2, ("resolved_name=%s\n", resolved_name));
-                       SAFE_FREE(resolved_name);
-                       return NT_STATUS_ACCESS_DENIED;
+
+               /*
+                * In the case of rootdir_len == 1, we know that
+                * conn_rootdir is "/", and we also know that
+                * resolved_name starts with a slash.  So, in this
+                * corner case, resolved_name is automatically a
+                * sub-directory of the conn_rootdir. Thus we can skip
+                * the string comparison and the next character checks
+                * (which are even wrong in this case).
+                */
+               if (rootdir_len != 1) {
+                       bool matched;
+
+                       matched = (strncmp(conn_rootdir, resolved_name,
+                                       rootdir_len) == 0);
+                       if (!matched || (resolved_name[rootdir_len] != '/' &&
+                                        resolved_name[rootdir_len] != '\0')) {
+                               DEBUG(2, ("check_reduced_name: Bad access "
+                                       "attempt: %s is a symlink outside the "
+                                       "share path\n", fname));
+                               DEBUGADD(2, ("conn_rootdir =%s\n",
+                                            conn_rootdir));
+                               DEBUGADD(2, ("resolved_name=%s\n",
+                                            resolved_name));
+                               TALLOC_FREE(resolved_fname);
+                               return NT_STATUS_ACCESS_DENIED;
+                       }
                }
 
                /* Extra checks if all symlinks are disallowed. */
@@ -1217,8 +1404,11 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
                        /* fname can't have changed in resolved_path. */
                        const char *p = &resolved_name[rootdir_len];
 
-                       /* *p can be '\0' if fname was "." */
-                       if (*p == '\0' && ISDOT(fname)) {
+                       /*
+                        * UNIX filesystem semantics, names consisting
+                        * only of "." or ".." CANNOT be symlinks.
+                        */
+                       if (ISDOT(fname) || ISDOTDOT(fname)) {
                                goto out;
                        }
 
@@ -1227,16 +1417,37 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
                                        "in resolved_name: %s\n",
                                        *p,
                                        fname));
-                               SAFE_FREE(resolved_name);
+                               TALLOC_FREE(resolved_fname);
                                return NT_STATUS_ACCESS_DENIED;
                        }
 
                        p++;
+
+                       /*
+                        * If cwd_name is present and not ".",
+                        * then fname is relative to that, not
+                        * the root of the share. Make sure the
+                        * path we check is the one the client
+                        * sent (cwd_name+fname).
+                        */
+                       if (cwd_name != NULL && !ISDOT(cwd_name)) {
+                               new_fname = talloc_asprintf(ctx,
+                                                       "%s/%s",
+                                                       cwd_name,
+                                                       fname);
+                               if (new_fname == NULL) {
+                                       TALLOC_FREE(resolved_fname);
+                                       return NT_STATUS_NO_MEMORY;
+                               }
+                               fname = new_fname;
+                       }
+
                        if (strcmp(fname, p)!=0) {
                                DEBUG(2, ("check_reduced_name: Bad access "
                                        "attempt: %s is a symlink to %s\n",
                                          fname, p));
-                               SAFE_FREE(resolved_name);
+                               TALLOC_FREE(resolved_fname);
+                               TALLOC_FREE(new_fname);
                                return NT_STATUS_ACCESS_DENIED;
                        }
                }
@@ -1244,68 +1455,37 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
 
   out:
 
-       DEBUG(3,("check_reduced_name: %s reduced to %s\n", fname,
-                resolved_name));
-       SAFE_FREE(resolved_name);
+       DBG_INFO("%s reduced to %s\n", fname, resolved_name);
+       TALLOC_FREE(resolved_fname);
+       TALLOC_FREE(new_fname);
        return NT_STATUS_OK;
 }
 
 /**
  * XXX: This is temporary and there should be no callers of this once
  * smb_filename is plumbed through all path based operations.
+ *
+ * Called when we know stream name parsing has already been done.
  */
-int vfs_stat_smb_fname(struct connection_struct *conn, const char *fname,
-                      SMB_STRUCT_STAT *psbuf)
-{
-       struct smb_filename *smb_fname = NULL;
-       NTSTATUS status;
-       int ret;
-
-       status = create_synthetic_smb_fname_split(talloc_tos(), fname, NULL,
-                                                 &smb_fname);
-       if (!NT_STATUS_IS_OK(status)) {
-               errno = map_errno_from_nt_status(status);
-               return -1;
-       }
-
-       if (lp_posix_pathnames()) {
-               ret = SMB_VFS_LSTAT(conn, smb_fname);
-       } else {
-               ret = SMB_VFS_STAT(conn, smb_fname);
-       }
-
-       if (ret != -1) {
-               *psbuf = smb_fname->st;
-       }
-
-       TALLOC_FREE(smb_fname);
-       return ret;
-}
-
-/**
- * XXX: This is temporary and there should be no callers of this once
- * smb_filename is plumbed through all path based operations.
- */
-int vfs_lstat_smb_fname(struct connection_struct *conn, const char *fname,
+int vfs_stat_smb_basename(struct connection_struct *conn,
+                       const struct smb_filename *smb_fname_in,
                        SMB_STRUCT_STAT *psbuf)
 {
-       struct smb_filename *smb_fname = NULL;
-       NTSTATUS status;
+       struct smb_filename smb_fname = {
+               .base_name = discard_const_p(char, smb_fname_in->base_name),
+               .flags = smb_fname_in->flags
+       };
        int ret;
 
-       status = create_synthetic_smb_fname_split(talloc_tos(), fname, NULL,
-                                                 &smb_fname);
-       if (!NT_STATUS_IS_OK(status)) {
-               errno = map_errno_from_nt_status(status);
-               return -1;
+       if (smb_fname.flags & SMB_FILENAME_POSIX_PATH) {
+               ret = SMB_VFS_LSTAT(conn, &smb_fname);
+       } else {
+               ret = SMB_VFS_STAT(conn, &smb_fname);
        }
 
-       ret = SMB_VFS_LSTAT(conn, smb_fname);
        if (ret != -1) {
-               *psbuf = smb_fname->st;
+               *psbuf = smb_fname.st;
        }
-
-       TALLOC_FREE(smb_fname);
        return ret;
 }
 
@@ -1318,7 +1498,7 @@ NTSTATUS vfs_stat_fsp(files_struct *fsp)
        int ret;
 
        if(fsp->fh->fd == -1) {
-               if (fsp->posix_open) {
+               if (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) {
                        ret = SMB_VFS_LSTAT(fsp->conn, fsp->fsp_name);
                } else {
                        ret = SMB_VFS_STAT(fsp->conn, fsp->fsp_name);
@@ -1339,14 +1519,19 @@ NTSTATUS vfs_stat_fsp(files_struct *fsp)
  */
 NTSTATUS vfs_streaminfo(connection_struct *conn,
                        struct files_struct *fsp,
-                       const char *fname,
+                       const struct smb_filename *smb_fname,
                        TALLOC_CTX *mem_ctx,
                        unsigned int *num_streams,
                        struct stream_struct **streams)
 {
        *num_streams = 0;
        *streams = NULL;
-       return SMB_VFS_STREAMINFO(conn, fsp, fname, mem_ctx, num_streams, streams);
+       return SMB_VFS_STREAMINFO(conn,
+                       fsp,
+                       smb_fname,
+                       mem_ctx,
+                       num_streams,
+                       streams);
 }
 
 /*
@@ -1371,21 +1556,24 @@ void smb_vfs_call_disconnect(struct vfs_handle_struct *handle)
 }
 
 uint64_t smb_vfs_call_disk_free(struct vfs_handle_struct *handle,
-                               const char *path, bool small_query,
-                               uint64_t *bsize, uint64_t *dfree,
+                               const struct smb_filename *smb_fname,
+                               uint64_t *bsize,
+                               uint64_t *dfree,
                                uint64_t *dsize)
 {
        VFS_FIND(disk_free);
-       return handle->fns->disk_free_fn(handle, path, small_query, bsize, 
-                                        dfree, dsize);
+       return handle->fns->disk_free_fn(handle, smb_fname,
+                       bsize, dfree, dsize);
 }
 
 int smb_vfs_call_get_quota(struct vfs_handle_struct *handle,
-                          enum SMB_QUOTA_TYPE qtype, unid_t id,
-                          SMB_DISK_QUOTA *qt)
+                               const struct smb_filename *smb_fname,
+                               enum SMB_QUOTA_TYPE qtype,
+                               unid_t id,
+                               SMB_DISK_QUOTA *qt)
 {
        VFS_FIND(get_quota);
-       return handle->fns->get_quota_fn(handle, qtype, id, qt);
+       return handle->fns->get_quota_fn(handle, smb_fname, qtype, id, qt);
 }
 
 int smb_vfs_call_set_quota(struct vfs_handle_struct *handle,
@@ -1406,11 +1594,12 @@ int smb_vfs_call_get_shadow_copy_data(struct vfs_handle_struct *handle,
                                                    shadow_copy_data,
                                                    labels);
 }
-int smb_vfs_call_statvfs(struct vfs_handle_struct *handle, const char *path,
-                        struct vfs_statvfs_struct *statbuf)
+int smb_vfs_call_statvfs(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       struct vfs_statvfs_struct *statbuf)
 {
        VFS_FIND(statvfs);
-       return handle->fns->statvfs_fn(handle, path, statbuf);
+       return handle->fns->statvfs_fn(handle, smb_fname, statbuf);
 }
 
 uint32_t smb_vfs_call_fs_capabilities(struct vfs_handle_struct *handle,
@@ -1428,17 +1617,18 @@ NTSTATUS smb_vfs_call_get_dfs_referrals(struct vfs_handle_struct *handle,
 }
 
 DIR *smb_vfs_call_opendir(struct vfs_handle_struct *handle,
-                                    const char *fname, const char *mask,
-                                    uint32 attributes)
+                                       const struct smb_filename *smb_fname,
+                                       const char *mask,
+                                       uint32_t attributes)
 {
        VFS_FIND(opendir);
-       return handle->fns->opendir_fn(handle, fname, mask, attributes);
+       return handle->fns->opendir_fn(handle, smb_fname, mask, attributes);
 }
 
 DIR *smb_vfs_call_fdopendir(struct vfs_handle_struct *handle,
                                        struct files_struct *fsp,
                                        const char *mask,
-                                       uint32 attributes)
+                                       uint32_t attributes)
 {
        VFS_FIND(fdopendir);
        return handle->fns->fdopendir_fn(handle, fsp, mask, attributes);
@@ -1473,17 +1663,19 @@ void smb_vfs_call_rewind_dir(struct vfs_handle_struct *handle,
        handle->fns->rewind_dir_fn(handle, dirp);
 }
 
-int smb_vfs_call_mkdir(struct vfs_handle_struct *handle, const char *path,
-                      mode_t mode)
+int smb_vfs_call_mkdir(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       mode_t mode)
 {
        VFS_FIND(mkdir);
-       return handle->fns->mkdir_fn(handle, path, mode);
+       return handle->fns->mkdir_fn(handle, smb_fname, mode);
 }
 
-int smb_vfs_call_rmdir(struct vfs_handle_struct *handle, const char *path)
+int smb_vfs_call_rmdir(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname)
 {
        VFS_FIND(rmdir);
-       return handle->fns->rmdir_fn(handle, path);
+       return handle->fns->rmdir_fn(handle, smb_fname);
 }
 
 int smb_vfs_call_closedir(struct vfs_handle_struct *handle,
@@ -1493,13 +1685,6 @@ int smb_vfs_call_closedir(struct vfs_handle_struct *handle,
        return handle->fns->closedir_fn(handle, dir);
 }
 
-void smb_vfs_call_init_search_op(struct vfs_handle_struct *handle,
-                                DIR *dirp)
-{
-       VFS_FIND(init_search_op);
-       handle->fns->init_search_op_fn(handle, dirp);
-}
-
 int smb_vfs_call_open(struct vfs_handle_struct *handle,
                      struct smb_filename *smb_fname, struct files_struct *fsp,
                      int flags, mode_t mode)
@@ -1518,20 +1703,23 @@ NTSTATUS smb_vfs_call_create_file(struct vfs_handle_struct *handle,
                                  uint32_t create_options,
                                  uint32_t file_attributes,
                                  uint32_t oplock_request,
+                                 struct smb2_lease *lease,
                                  uint64_t allocation_size,
                                  uint32_t private_flags,
                                  struct security_descriptor *sd,
                                  struct ea_list *ea_list,
                                  files_struct **result,
-                                 int *pinfo)
+                                 int *pinfo,
+                                 const struct smb2_create_blobs *in_context_blobs,
+                                 struct smb2_create_blobs *out_context_blobs)
 {
        VFS_FIND(create_file);
        return handle->fns->create_file_fn(
                handle, req, root_dir_fid, smb_fname, access_mask,
                share_access, create_disposition, create_options,
-               file_attributes, oplock_request, allocation_size,
+               file_attributes, oplock_request, lease, allocation_size,
                private_flags, sd, ea_list,
-               result, pinfo);
+               result, pinfo, in_context_blobs, out_context_blobs);
 }
 
 int smb_vfs_call_close(struct vfs_handle_struct *handle,
@@ -1557,8 +1745,9 @@ ssize_t smb_vfs_call_pread(struct vfs_handle_struct *handle,
 }
 
 struct smb_vfs_call_pread_state {
-       ssize_t (*recv_fn)(struct tevent_req *req, int *err);
+       ssize_t (*recv_fn)(struct tevent_req *req, struct vfs_aio_state *vfs_aio_state);
        ssize_t retval;
+       struct vfs_aio_state vfs_aio_state;
 };
 
 static void smb_vfs_call_pread_done(struct tevent_req *subreq);
@@ -1596,27 +1785,26 @@ static void smb_vfs_call_pread_done(struct tevent_req *subreq)
                subreq, struct tevent_req);
        struct smb_vfs_call_pread_state *state = tevent_req_data(
                req, struct smb_vfs_call_pread_state);
-       int err;
 
-       state->retval = state->recv_fn(subreq, &err);
+       state->retval = state->recv_fn(subreq, &state->vfs_aio_state);
        TALLOC_FREE(subreq);
        if (state->retval == -1) {
-               tevent_req_error(req, err);
+               tevent_req_error(req, state->vfs_aio_state.error);
                return;
        }
        tevent_req_done(req);
 }
 
-ssize_t SMB_VFS_PREAD_RECV(struct tevent_req *req, int *perrno)
+ssize_t SMB_VFS_PREAD_RECV(struct tevent_req *req,
+                          struct vfs_aio_state *vfs_aio_state)
 {
        struct smb_vfs_call_pread_state *state = tevent_req_data(
                req, struct smb_vfs_call_pread_state);
-       int err;
 
-       if (tevent_req_is_unix_error(req, &err)) {
-               *perrno = err;
+       if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
                return -1;
        }
+       *vfs_aio_state = state->vfs_aio_state;
        return state->retval;
 }
 
@@ -1637,8 +1825,9 @@ ssize_t smb_vfs_call_pwrite(struct vfs_handle_struct *handle,
 }
 
 struct smb_vfs_call_pwrite_state {
-       ssize_t (*recv_fn)(struct tevent_req *req, int *err);
+       ssize_t (*recv_fn)(struct tevent_req *req, struct vfs_aio_state *vfs_aio_state);
        ssize_t retval;
+       struct vfs_aio_state vfs_aio_state;
 };
 
 static void smb_vfs_call_pwrite_done(struct tevent_req *subreq);
@@ -1676,27 +1865,26 @@ static void smb_vfs_call_pwrite_done(struct tevent_req *subreq)
                subreq, struct tevent_req);
        struct smb_vfs_call_pwrite_state *state = tevent_req_data(
                req, struct smb_vfs_call_pwrite_state);
-       int err;
 
-       state->retval = state->recv_fn(subreq, &err);
+       state->retval = state->recv_fn(subreq, &state->vfs_aio_state);
        TALLOC_FREE(subreq);
        if (state->retval == -1) {
-               tevent_req_error(req, err);
+               tevent_req_error(req, state->vfs_aio_state.error);
                return;
        }
        tevent_req_done(req);
 }
 
-ssize_t SMB_VFS_PWRITE_RECV(struct tevent_req *req, int *perrno)
+ssize_t SMB_VFS_PWRITE_RECV(struct tevent_req *req,
+                           struct vfs_aio_state *vfs_aio_state)
 {
        struct smb_vfs_call_pwrite_state *state = tevent_req_data(
                req, struct smb_vfs_call_pwrite_state);
-       int err;
 
-       if (tevent_req_is_unix_error(req, &err)) {
-               *perrno = err;
+       if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
                return -1;
        }
+       *vfs_aio_state = state->vfs_aio_state;
        return state->retval;
 }
 
@@ -1741,8 +1929,9 @@ int smb_vfs_call_fsync(struct vfs_handle_struct *handle,
 }
 
 struct smb_vfs_call_fsync_state {
-       int (*recv_fn)(struct tevent_req *req, int *err);
+       int (*recv_fn)(struct tevent_req *req, struct vfs_aio_state *vfs_aio_state);
        int retval;
+       struct vfs_aio_state vfs_aio_state;
 };
 
 static void smb_vfs_call_fsync_done(struct tevent_req *subreq);
@@ -1777,27 +1966,25 @@ static void smb_vfs_call_fsync_done(struct tevent_req *subreq)
                subreq, struct tevent_req);
        struct smb_vfs_call_fsync_state *state = tevent_req_data(
                req, struct smb_vfs_call_fsync_state);
-       int err;
 
-       state->retval = state->recv_fn(subreq, &err);
+       state->retval = state->recv_fn(subreq, &state->vfs_aio_state);
        TALLOC_FREE(subreq);
        if (state->retval == -1) {
-               tevent_req_error(req, err);
+               tevent_req_error(req, state->vfs_aio_state.error);
                return;
        }
        tevent_req_done(req);
 }
 
-int SMB_VFS_FSYNC_RECV(struct tevent_req *req, int *perrno)
+int SMB_VFS_FSYNC_RECV(struct tevent_req *req, struct vfs_aio_state *vfs_aio_state)
 {
        struct smb_vfs_call_fsync_state *state = tevent_req_data(
                req, struct smb_vfs_call_fsync_state);
-       int err;
 
-       if (tevent_req_is_unix_error(req, &err)) {
-               *perrno = err;
+       if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
                return -1;
        }
+       *vfs_aio_state = state->vfs_aio_state;
        return state->retval;
 }
 
@@ -1838,11 +2025,12 @@ int smb_vfs_call_unlink(struct vfs_handle_struct *handle,
        return handle->fns->unlink_fn(handle, smb_fname);
 }
 
-int smb_vfs_call_chmod(struct vfs_handle_struct *handle, const char *path,
-                      mode_t mode)
+int smb_vfs_call_chmod(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       mode_t mode)
 {
        VFS_FIND(chmod);
-       return handle->fns->chmod_fn(handle, path, mode);
+       return handle->fns->chmod_fn(handle, smb_fname, mode);
 }
 
 int smb_vfs_call_fchmod(struct vfs_handle_struct *handle,
@@ -1852,11 +2040,13 @@ int smb_vfs_call_fchmod(struct vfs_handle_struct *handle,
        return handle->fns->fchmod_fn(handle, fsp, mode);
 }
 
-int smb_vfs_call_chown(struct vfs_handle_struct *handle, const char *path,
-                      uid_t uid, gid_t gid)
+int smb_vfs_call_chown(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       uid_t uid,
+                       gid_t gid)
 {
        VFS_FIND(chown);
-       return handle->fns->chown_fn(handle, path, uid, gid);
+       return handle->fns->chown_fn(handle, smb_fname, uid, gid);
 }
 
 int smb_vfs_call_fchown(struct vfs_handle_struct *handle,
@@ -1866,20 +2056,19 @@ int smb_vfs_call_fchown(struct vfs_handle_struct *handle,
        return handle->fns->fchown_fn(handle, fsp, uid, gid);
 }
 
-int smb_vfs_call_lchown(struct vfs_handle_struct *handle, const char *path,
-                       uid_t uid, gid_t gid)
+int smb_vfs_call_lchown(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       uid_t uid,
+                       gid_t gid)
 {
        VFS_FIND(lchown);
-       return handle->fns->lchown_fn(handle, path, uid, gid);
+       return handle->fns->lchown_fn(handle, smb_fname, uid, gid);
 }
 
 NTSTATUS vfs_chown_fsp(files_struct *fsp, uid_t uid, gid_t gid)
 {
        int ret;
        bool as_root = false;
-       const char *path;
-       char *saved_dir = NULL;
-       char *parent_dir = NULL;
        NTSTATUS status;
 
        if (fsp->fh->fd != -1) {
@@ -1902,11 +2091,14 @@ NTSTATUS vfs_chown_fsp(files_struct *fsp, uid_t uid, gid_t gid)
                 * and always act using lchown to ensure we
                 * don't deref any symbolic links.
                 */
+               char *parent_dir = NULL;
                const char *final_component = NULL;
-               struct smb_filename local_fname;
+               struct smb_filename *local_smb_fname = NULL;
+               struct smb_filename parent_dir_fname = {0};
+               struct smb_filename *saved_dir_fname = NULL;
 
-               saved_dir = vfs_GetWd(talloc_tos(),fsp->conn);
-               if (!saved_dir) {
+               saved_dir_fname = vfs_GetWd(talloc_tos(),fsp->conn);
+               if (!saved_dir_fname) {
                        status = map_nt_error_from_unix(errno);
                        DEBUG(0,("vfs_chown_fsp: failed to get "
                                "current working directory. Error was %s\n",
@@ -1921,39 +2113,68 @@ NTSTATUS vfs_chown_fsp(files_struct *fsp, uid_t uid, gid_t gid)
                        return NT_STATUS_NO_MEMORY;
                }
 
+               parent_dir_fname = (struct smb_filename) {
+                       .base_name = parent_dir,
+                       .flags = fsp->fsp_name->flags
+               };
+
                /* cd into the parent dir to pin it. */
-               ret = vfs_ChDir(fsp->conn, parent_dir);
+               ret = vfs_ChDir(fsp->conn, &parent_dir_fname);
                if (ret == -1) {
                        return map_nt_error_from_unix(errno);
                }
 
-               ZERO_STRUCT(local_fname);
-               local_fname.base_name = discard_const_p(char, final_component);
+               local_smb_fname = synthetic_smb_fname(talloc_tos(),
+                                       final_component,
+                                       NULL,
+                                       NULL,
+                                       fsp->fsp_name->flags);
+               if (local_smb_fname == NULL) {
+                       status = NT_STATUS_NO_MEMORY;
+                       goto out;
+               }
 
                /* Must use lstat here. */
-               ret = SMB_VFS_LSTAT(fsp->conn, &local_fname);
+               ret = SMB_VFS_LSTAT(fsp->conn, local_smb_fname);
                if (ret == -1) {
                        status = map_nt_error_from_unix(errno);
                        goto out;
                }
 
                /* Ensure it matches the fsp stat. */
-               if (!check_same_stat(&local_fname.st, &fsp->fsp_name->st)) {
+               if (!check_same_stat(&local_smb_fname->st,
+                               &fsp->fsp_name->st)) {
                         status = NT_STATUS_ACCESS_DENIED;
                        goto out;
                 }
-                path = final_component;
-        } else {
-                path = fsp->fsp_name->base_name;
-        }
 
-       if (fsp->posix_open || as_root) {
                ret = SMB_VFS_LCHOWN(fsp->conn,
-                       path,
+                       local_smb_fname,
+                       uid, gid);
+
+               if (ret == 0) {
+                       status = NT_STATUS_OK;
+               } else {
+                       status = map_nt_error_from_unix(errno);
+               }
+
+  out:
+
+               vfs_ChDir(fsp->conn, saved_dir_fname);
+               TALLOC_FREE(local_smb_fname);
+               TALLOC_FREE(saved_dir_fname);
+               TALLOC_FREE(parent_dir);
+
+               return status;
+       }
+
+       if (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) {
+               ret = SMB_VFS_LCHOWN(fsp->conn,
+                       fsp->fsp_name,
                        uid, gid);
        } else {
                ret = SMB_VFS_CHOWN(fsp->conn,
-                       path,
+                       fsp->fsp_name,
                        uid, gid);
        }
 
@@ -1962,27 +2183,21 @@ NTSTATUS vfs_chown_fsp(files_struct *fsp, uid_t uid, gid_t gid)
        } else {
                status = map_nt_error_from_unix(errno);
        }
-
-  out:
-
-       if (as_root) {
-               vfs_ChDir(fsp->conn,saved_dir);
-               TALLOC_FREE(saved_dir);
-               TALLOC_FREE(parent_dir);
-       }
        return status;
 }
 
-int smb_vfs_call_chdir(struct vfs_handle_struct *handle, const char *path)
+int smb_vfs_call_chdir(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname)
 {
        VFS_FIND(chdir);
-       return handle->fns->chdir_fn(handle, path);
+       return handle->fns->chdir_fn(handle, smb_fname);
 }
 
-char *smb_vfs_call_getwd(struct vfs_handle_struct *handle)
+struct smb_filename *smb_vfs_call_getwd(struct vfs_handle_struct *handle,
+                               TALLOC_CTX *ctx)
 {
        VFS_FIND(getwd);
-       return handle->fns->getwd_fn(handle);
+       return handle->fns->getwd_fn(handle, ctx);
 }
 
 int smb_vfs_call_ntimes(struct vfs_handle_struct *handle,
@@ -2001,17 +2216,17 @@ int smb_vfs_call_ftruncate(struct vfs_handle_struct *handle,
 }
 
 int smb_vfs_call_fallocate(struct vfs_handle_struct *handle,
-                               struct files_struct *fsp,
-                               enum vfs_fallocate_mode mode,
-                               off_t offset,
-                               off_t len)
+                          struct files_struct *fsp,
+                          uint32_t mode,
+                          off_t offset,
+                          off_t len)
 {
        VFS_FIND(fallocate);
        return handle->fns->fallocate_fn(handle, fsp, mode, offset, len);
 }
 
 int smb_vfs_call_kernel_flock(struct vfs_handle_struct *handle,
-                             struct files_struct *fsp, uint32 share_mode,
+                             struct files_struct *fsp, uint32_t share_mode,
                              uint32_t access_mask)
 {
        VFS_FIND(kernel_flock);
@@ -2026,61 +2241,54 @@ int smb_vfs_call_linux_setlease(struct vfs_handle_struct *handle,
        return handle->fns->linux_setlease_fn(handle, fsp, leasetype);
 }
 
-int smb_vfs_call_symlink(struct vfs_handle_struct *handle, const char *oldpath,
-                        const char *newpath)
+int smb_vfs_call_symlink(struct vfs_handle_struct *handle,
+                       const char *link_target,
+                       const struct smb_filename *new_smb_fname)
 {
        VFS_FIND(symlink);
-       return handle->fns->symlink_fn(handle, oldpath, newpath);
+       return handle->fns->symlink_fn(handle, link_target, new_smb_fname);
 }
 
 int smb_vfs_call_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)
 {
        VFS_FIND(readlink);
-       return handle->fns->readlink_fn(handle, path, buf, bufsiz);
+       return handle->fns->readlink_fn(handle, smb_fname, buf, bufsiz);
 }
 
-int smb_vfs_call_link(struct vfs_handle_struct *handle, const char *oldpath,
-                     const char *newpath)
+int smb_vfs_call_link(struct vfs_handle_struct *handle,
+                       const struct smb_filename *old_smb_fname,
+                       const struct smb_filename *new_smb_fname)
 {
        VFS_FIND(link);
-       return handle->fns->link_fn(handle, oldpath, newpath);
+       return handle->fns->link_fn(handle, old_smb_fname, new_smb_fname);
 }
 
-int smb_vfs_call_mknod(struct vfs_handle_struct *handle, const char *path,
-                      mode_t mode, SMB_DEV_T dev)
+int smb_vfs_call_mknod(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       mode_t mode,
+                       SMB_DEV_T dev)
 {
        VFS_FIND(mknod);
-       return handle->fns->mknod_fn(handle, path, mode, dev);
+       return handle->fns->mknod_fn(handle, smb_fname, mode, dev);
 }
 
-char *smb_vfs_call_realpath(struct vfs_handle_struct *handle, const char *path)
+struct smb_filename *smb_vfs_call_realpath(struct vfs_handle_struct *handle,
+                       TALLOC_CTX *ctx,
+                       const struct smb_filename *smb_fname)
 {
        VFS_FIND(realpath);
-       return handle->fns->realpath_fn(handle, path);
+       return handle->fns->realpath_fn(handle, ctx, smb_fname);
 }
 
-NTSTATUS smb_vfs_call_notify_watch(struct vfs_handle_struct *handle,
-                                  struct sys_notify_context *ctx,
-                                  const char *path,
-                                  uint32_t *filter,
-                                  uint32_t *subdir_filter,
-                                  void (*callback)(struct sys_notify_context *ctx,
-                                                   void *private_data,
-                                                   struct notify_event *ev),
-                                  void *private_data, void *handle_p)
-{
-       VFS_FIND(notify_watch);
-       return handle->fns->notify_watch_fn(handle, ctx, path,
-                                           filter, subdir_filter, callback,
-                                           private_data, handle_p);
-}
-
-int smb_vfs_call_chflags(struct vfs_handle_struct *handle, const char *path,
-                        unsigned int flags)
+int smb_vfs_call_chflags(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       unsigned int flags)
 {
        VFS_FIND(chflags);
-       return handle->fns->chflags_fn(handle, path, flags);
+       return handle->fns->chflags_fn(handle, smb_fname, flags);
 }
 
 struct file_id smb_vfs_call_file_id_create(struct vfs_handle_struct *handle,
@@ -2092,13 +2300,13 @@ struct file_id smb_vfs_call_file_id_create(struct vfs_handle_struct *handle,
 
 NTSTATUS smb_vfs_call_streaminfo(struct vfs_handle_struct *handle,
                                 struct files_struct *fsp,
-                                const char *fname,
+                                const struct smb_filename *smb_fname,
                                 TALLOC_CTX *mem_ctx,
                                 unsigned int *num_streams,
                                 struct stream_struct **streams)
 {
        VFS_FIND(streaminfo);
-       return handle->fns->streaminfo_fn(handle, fsp, fname, mem_ctx,
+       return handle->fns->streaminfo_fn(handle, fsp, smb_fname, mem_ctx,
                                          num_streams, streams);
 }
 
@@ -2112,26 +2320,18 @@ int smb_vfs_call_get_real_filename(struct vfs_handle_struct *handle,
 }
 
 const char *smb_vfs_call_connectpath(struct vfs_handle_struct *handle,
-                                    const char *filename)
+                                const struct smb_filename *smb_fname)
 {
        VFS_FIND(connectpath);
-       return handle->fns->connectpath_fn(handle, filename);
+       return handle->fns->connectpath_fn(handle, smb_fname);
 }
 
-bool smb_vfs_call_strict_lock(struct vfs_handle_struct *handle,
-                             struct files_struct *fsp,
-                             struct lock_struct *plock)
+bool smb_vfs_call_strict_lock_check(struct vfs_handle_struct *handle,
+                                   struct files_struct *fsp,
+                                   struct lock_struct *plock)
 {
-       VFS_FIND(strict_lock);
-       return handle->fns->strict_lock_fn(handle, fsp, plock);
-}
-
-void smb_vfs_call_strict_unlock(struct vfs_handle_struct *handle,
-                               struct files_struct *fsp,
-                               struct lock_struct *plock)
-{
-       VFS_FIND(strict_unlock);
-       handle->fns->strict_unlock_fn(handle, fsp, plock);
+       VFS_FIND(strict_lock_check);
+       return handle->fns->strict_lock_check_fn(handle, fsp, plock);
 }
 
 NTSTATUS smb_vfs_call_translate_name(struct vfs_handle_struct *handle,
@@ -2157,14 +2357,148 @@ NTSTATUS smb_vfs_call_fsctl(struct vfs_handle_struct *handle,
                            uint32_t *out_len)
 {
        VFS_FIND(fsctl);
-       return handle->fns->fsctl_fn(handle, fsp, ctx, function, req_flags, 
-                                    in_data, in_len, out_data, max_out_len, 
+       return handle->fns->fsctl_fn(handle, fsp, ctx, function, req_flags,
+                                    in_data, in_len, out_data, max_out_len,
                                     out_len);
 }
 
+NTSTATUS smb_vfs_call_get_dos_attributes(struct vfs_handle_struct *handle,
+                                        struct smb_filename *smb_fname,
+                                        uint32_t *dosmode)
+{
+       VFS_FIND(get_dos_attributes);
+       return handle->fns->get_dos_attributes_fn(handle, smb_fname, dosmode);
+}
+
+NTSTATUS smb_vfs_call_fget_dos_attributes(struct vfs_handle_struct *handle,
+                                         struct files_struct *fsp,
+                                         uint32_t *dosmode)
+{
+       VFS_FIND(fget_dos_attributes);
+       return handle->fns->fget_dos_attributes_fn(handle, fsp, dosmode);
+}
+
+NTSTATUS smb_vfs_call_set_dos_attributes(struct vfs_handle_struct *handle,
+                                        const struct smb_filename *smb_fname,
+                                        uint32_t dosmode)
+{
+       VFS_FIND(set_dos_attributes);
+       return handle->fns->set_dos_attributes_fn(handle, smb_fname, dosmode);
+}
+
+NTSTATUS smb_vfs_call_fset_dos_attributes(struct vfs_handle_struct *handle,
+                                         struct files_struct *fsp,
+                                         uint32_t dosmode)
+{
+       VFS_FIND(set_dos_attributes);
+       return handle->fns->fset_dos_attributes_fn(handle, fsp, dosmode);
+}
+
+struct tevent_req *smb_vfs_call_offload_read_send(TALLOC_CTX *mem_ctx,
+                                                 struct tevent_context *ev,
+                                                 struct vfs_handle_struct *handle,
+                                                 struct files_struct *fsp,
+                                                 uint32_t fsctl,
+                                                 uint32_t ttl,
+                                                 off_t offset,
+                                                 size_t to_copy)
+{
+       VFS_FIND(offload_read_send);
+       return handle->fns->offload_read_send_fn(mem_ctx, ev, handle,
+                                                fsp, fsctl,
+                                                ttl, offset, to_copy);
+}
+
+NTSTATUS smb_vfs_call_offload_read_recv(struct tevent_req *req,
+                                       struct vfs_handle_struct *handle,
+                                       TALLOC_CTX *mem_ctx,
+                                       DATA_BLOB *token_blob)
+{
+       VFS_FIND(offload_read_recv);
+       return handle->fns->offload_read_recv_fn(req, handle, mem_ctx, token_blob);
+}
+
+struct tevent_req *smb_vfs_call_offload_write_send(struct vfs_handle_struct *handle,
+                                                  TALLOC_CTX *mem_ctx,
+                                                  struct tevent_context *ev,
+                                                  uint32_t fsctl,
+                                                  DATA_BLOB *token,
+                                                  off_t transfer_offset,
+                                                  struct files_struct *dest_fsp,
+                                                  off_t dest_off,
+                                                  off_t num)
+{
+       VFS_FIND(offload_write_send);
+       return handle->fns->offload_write_send_fn(handle, mem_ctx, ev, fsctl,
+                                              token, transfer_offset,
+                                              dest_fsp, dest_off, num);
+}
+
+NTSTATUS smb_vfs_call_offload_write_recv(struct vfs_handle_struct *handle,
+                                        struct tevent_req *req,
+                                        off_t *copied)
+{
+       VFS_FIND(offload_write_recv);
+       return handle->fns->offload_write_recv_fn(handle, req, copied);
+}
+
+NTSTATUS smb_vfs_call_get_compression(vfs_handle_struct *handle,
+                                     TALLOC_CTX *mem_ctx,
+                                     struct files_struct *fsp,
+                                     struct smb_filename *smb_fname,
+                                     uint16_t *_compression_fmt)
+{
+       VFS_FIND(get_compression);
+       return handle->fns->get_compression_fn(handle, mem_ctx, fsp, smb_fname,
+                                              _compression_fmt);
+}
+
+NTSTATUS smb_vfs_call_set_compression(vfs_handle_struct *handle,
+                                     TALLOC_CTX *mem_ctx,
+                                     struct files_struct *fsp,
+                                     uint16_t compression_fmt)
+{
+       VFS_FIND(set_compression);
+       return handle->fns->set_compression_fn(handle, mem_ctx, fsp,
+                                              compression_fmt);
+}
+
+NTSTATUS smb_vfs_call_snap_check_path(vfs_handle_struct *handle,
+                                     TALLOC_CTX *mem_ctx,
+                                     const char *service_path,
+                                     char **base_volume)
+{
+       VFS_FIND(snap_check_path);
+       return handle->fns->snap_check_path_fn(handle, mem_ctx, service_path,
+                                              base_volume);
+}
+
+NTSTATUS smb_vfs_call_snap_create(struct vfs_handle_struct *handle,
+                                 TALLOC_CTX *mem_ctx,
+                                 const char *base_volume,
+                                 time_t *tstamp,
+                                 bool rw,
+                                 char **base_path,
+                                 char **snap_path)
+{
+       VFS_FIND(snap_create);
+       return handle->fns->snap_create_fn(handle, mem_ctx, base_volume, tstamp,
+                                          rw, base_path, snap_path);
+}
+
+NTSTATUS smb_vfs_call_snap_delete(struct vfs_handle_struct *handle,
+                                 TALLOC_CTX *mem_ctx,
+                                 char *base_path,
+                                 char *snap_path)
+{
+       VFS_FIND(snap_delete);
+       return handle->fns->snap_delete_fn(handle, mem_ctx, base_path,
+                                          snap_path);
+}
+
 NTSTATUS smb_vfs_call_fget_nt_acl(struct vfs_handle_struct *handle,
                                  struct files_struct *fsp,
-                                 uint32 security_info,
+                                 uint32_t security_info,
                                  TALLOC_CTX *mem_ctx,
                                  struct security_descriptor **ppdesc)
 {
@@ -2174,18 +2508,22 @@ NTSTATUS smb_vfs_call_fget_nt_acl(struct vfs_handle_struct *handle,
 }
 
 NTSTATUS smb_vfs_call_get_nt_acl(struct vfs_handle_struct *handle,
-                                const char *name,
-                                uint32 security_info,
+                                const struct smb_filename *smb_fname,
+                                uint32_t security_info,
                                 TALLOC_CTX *mem_ctx,
                                 struct security_descriptor **ppdesc)
 {
        VFS_FIND(get_nt_acl);
-       return handle->fns->get_nt_acl_fn(handle, name, security_info, mem_ctx, ppdesc);
+       return handle->fns->get_nt_acl_fn(handle,
+                               smb_fname,
+                               security_info,
+                               mem_ctx,
+                               ppdesc);
 }
 
 NTSTATUS smb_vfs_call_fset_nt_acl(struct vfs_handle_struct *handle,
                                  struct files_struct *fsp,
-                                 uint32 security_info_sent,
+                                 uint32_t security_info_sent,
                                  const struct security_descriptor *psd)
 {
        VFS_FIND(fset_nt_acl);
@@ -2207,11 +2545,12 @@ NTSTATUS smb_vfs_call_audit_file(struct vfs_handle_struct *handle,
                                          access_denied);
 }
 
-int smb_vfs_call_chmod_acl(struct vfs_handle_struct *handle, const char *name,
-                          mode_t mode)
+int smb_vfs_call_chmod_acl(struct vfs_handle_struct *handle,
+               const struct smb_filename *smb_fname,
+               mode_t mode)
 {
        VFS_FIND(chmod_acl);
-       return handle->fns->chmod_acl_fn(handle, name, mode);
+       return handle->fns->chmod_acl_fn(handle, smb_fname, mode);
 }
 
 int smb_vfs_call_fchmod_acl(struct vfs_handle_struct *handle,
@@ -2222,12 +2561,12 @@ int smb_vfs_call_fchmod_acl(struct vfs_handle_struct *handle,
 }
 
 SMB_ACL_T smb_vfs_call_sys_acl_get_file(struct vfs_handle_struct *handle,
-                                       const char *path_p,
+                                       const struct smb_filename *smb_fname,
                                        SMB_ACL_TYPE_T type,
                                        TALLOC_CTX *mem_ctx)
 {
        VFS_FIND(sys_acl_get_file);
-       return handle->fns->sys_acl_get_file_fn(handle, path_p, type, mem_ctx);
+       return handle->fns->sys_acl_get_file_fn(handle, smb_fname, type, mem_ctx);
 }
 
 SMB_ACL_T smb_vfs_call_sys_acl_get_fd(struct vfs_handle_struct *handle,
@@ -2239,13 +2578,14 @@ SMB_ACL_T smb_vfs_call_sys_acl_get_fd(struct vfs_handle_struct *handle,
 }
 
 int smb_vfs_call_sys_acl_blob_get_file(struct vfs_handle_struct *handle,
-                                      const char *path_p,
-                                      TALLOC_CTX *mem_ctx, 
-                                      char **blob_description,
-                                      DATA_BLOB *blob)
+                               const struct smb_filename *smb_fname,
+                               TALLOC_CTX *mem_ctx,
+                               char **blob_description,
+                               DATA_BLOB *blob)
 {
        VFS_FIND(sys_acl_blob_get_file);
-       return handle->fns->sys_acl_blob_get_file_fn(handle, path_p, mem_ctx, blob_description, blob);
+       return handle->fns->sys_acl_blob_get_file_fn(handle, smb_fname,
+                       mem_ctx, blob_description, blob);
 }
 
 int smb_vfs_call_sys_acl_blob_get_fd(struct vfs_handle_struct *handle,
@@ -2259,11 +2599,13 @@ int smb_vfs_call_sys_acl_blob_get_fd(struct vfs_handle_struct *handle,
 }
 
 int smb_vfs_call_sys_acl_set_file(struct vfs_handle_struct *handle,
-                                 const char *name, SMB_ACL_TYPE_T acltype,
-                                 SMB_ACL_T theacl)
+                               const struct smb_filename *smb_fname,
+                               SMB_ACL_TYPE_T acltype,
+                               SMB_ACL_T theacl)
 {
        VFS_FIND(sys_acl_set_file);
-       return handle->fns->sys_acl_set_file_fn(handle, name, acltype, theacl);
+       return handle->fns->sys_acl_set_file_fn(handle, smb_fname,
+                               acltype, theacl);
 }
 
 int smb_vfs_call_sys_acl_set_fd(struct vfs_handle_struct *handle,
@@ -2274,18 +2616,20 @@ int smb_vfs_call_sys_acl_set_fd(struct vfs_handle_struct *handle,
 }
 
 int smb_vfs_call_sys_acl_delete_def_file(struct vfs_handle_struct *handle,
-                                        const char *path)
+                               const struct smb_filename *smb_fname)
 {
        VFS_FIND(sys_acl_delete_def_file);
-       return handle->fns->sys_acl_delete_def_file_fn(handle, path);
+       return handle->fns->sys_acl_delete_def_file_fn(handle, smb_fname);
 }
 
 ssize_t smb_vfs_call_getxattr(struct vfs_handle_struct *handle,
-                             const char *path, const char *name, void *value,
-                             size_t size)
+                               const struct smb_filename *smb_fname,
+                               const char *name,
+                               void *value,
+                               size_t size)
 {
        VFS_FIND(getxattr);
-       return handle->fns->getxattr_fn(handle, path, name, value, size);
+       return handle->fns->getxattr_fn(handle, smb_fname, name, value, size);
 }
 
 ssize_t smb_vfs_call_fgetxattr(struct vfs_handle_struct *handle,
@@ -2297,10 +2641,12 @@ ssize_t smb_vfs_call_fgetxattr(struct vfs_handle_struct *handle,
 }
 
 ssize_t smb_vfs_call_listxattr(struct vfs_handle_struct *handle,
-                              const char *path, char *list, size_t size)
+                               const struct smb_filename *smb_fname,
+                               char *list,
+                               size_t size)
 {
        VFS_FIND(listxattr);
-       return handle->fns->listxattr_fn(handle, path, list, size);
+       return handle->fns->listxattr_fn(handle, smb_fname, list, size);
 }
 
 ssize_t smb_vfs_call_flistxattr(struct vfs_handle_struct *handle,
@@ -2312,10 +2658,11 @@ ssize_t smb_vfs_call_flistxattr(struct vfs_handle_struct *handle,
 }
 
 int smb_vfs_call_removexattr(struct vfs_handle_struct *handle,
-                            const char *path, const char *name)
+                               const struct smb_filename *smb_fname,
+                               const char *name)
 {
        VFS_FIND(removexattr);
-       return handle->fns->removexattr_fn(handle, path, name);
+       return handle->fns->removexattr_fn(handle, smb_fname, name);
 }
 
 int smb_vfs_call_fremovexattr(struct vfs_handle_struct *handle,
@@ -2325,12 +2672,16 @@ int smb_vfs_call_fremovexattr(struct vfs_handle_struct *handle,
        return handle->fns->fremovexattr_fn(handle, fsp, name);
 }
 
-int smb_vfs_call_setxattr(struct vfs_handle_struct *handle, const char *path,
-                         const char *name, const void *value, size_t size,
-                         int flags)
+int smb_vfs_call_setxattr(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       const char *name,
+                       const void *value,
+                       size_t size,
+                       int flags)
 {
        VFS_FIND(setxattr);
-       return handle->fns->setxattr_fn(handle, path, name, value, size, flags);
+       return handle->fns->setxattr_fn(handle, smb_fname,
+                       name, value, size, flags);
 }
 
 int smb_vfs_call_fsetxattr(struct vfs_handle_struct *handle,
@@ -2348,21 +2699,6 @@ bool smb_vfs_call_aio_force(struct vfs_handle_struct *handle,
        return handle->fns->aio_force_fn(handle, fsp);
 }
 
-bool smb_vfs_call_is_offline(struct vfs_handle_struct *handle,
-                            const struct smb_filename *fname,
-                            SMB_STRUCT_STAT *sbuf)
-{
-       VFS_FIND(is_offline);
-       return handle->fns->is_offline_fn(handle, fname, sbuf);
-}
-
-int smb_vfs_call_set_offline(struct vfs_handle_struct *handle,
-                             const struct smb_filename *fname)
-{
-       VFS_FIND(set_offline);
-       return handle->fns->set_offline_fn(handle, fname);
-}
-
 NTSTATUS smb_vfs_call_durable_cookie(struct vfs_handle_struct *handle,
                                     struct files_struct *fsp,
                                     TALLOC_CTX *mem_ctx,
@@ -2396,3 +2732,12 @@ NTSTATUS smb_vfs_call_durable_reconnect(struct vfs_handle_struct *handle,
                                                 old_cookie, mem_ctx, fsp,
                                                 new_cookie);
 }
+
+NTSTATUS smb_vfs_call_readdir_attr(struct vfs_handle_struct *handle,
+                                  const struct smb_filename *fname,
+                                  TALLOC_CTX *mem_ctx,
+                                  struct readdir_attr_data **attr_data)
+{
+       VFS_FIND(readdir_attr);
+       return handle->fns->readdir_attr_fn(handle, fname, mem_ctx, attr_data);
+}