VFS: Modify chmod to take a const struct smb_filename * instead of const char *
[kai/samba-autobuild/.git] / source3 / modules / vfs_streams_depot.c
index ba3b180244082753f5c058b67b1c089044dfd68d..d998dc51a347e60b151a86d1169c52b53c2762ed 100644 (file)
@@ -18,6 +18,8 @@
  */
 
 #include "includes.h"
+#include "smbd/smbd.h"
+#include "system/filesys.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_VFS
@@ -65,17 +67,10 @@ static uint32_t hash_fn(DATA_BLOB key)
  * an option to put in a special ACL entry for a non-existing group.
  */
 
-#define SAMBA_XATTR_MARKER "user.SAMBA_STREAMS"
-
-static bool file_is_valid(vfs_handle_struct *handle, const char *path,
-                         bool check_valid)
+static bool file_is_valid(vfs_handle_struct *handle, const char *path)
 {
        char buf;
 
-       if (!check_valid) {
-               return true;
-       }
-
        DEBUG(10, ("file_is_valid (%s) called\n", path));
 
        if (SMB_VFS_GETXATTR(handle->conn, path, SAMBA_XATTR_MARKER,
@@ -92,16 +87,11 @@ static bool file_is_valid(vfs_handle_struct *handle, const char *path,
        return true;
 }
 
-static bool mark_file_valid(vfs_handle_struct *handle, const char *path,
-                           bool check_valid)
+static bool mark_file_valid(vfs_handle_struct *handle, const char *path)
 {
        char buf = '1';
        int ret;
 
-       if (!check_valid) {
-               return true;
-       }
-
        DEBUG(10, ("marking file %s as valid\n", path));
 
        ret = SMB_VFS_SETXATTR(handle->conn, path, SAMBA_XATTR_MARKER,
@@ -131,15 +121,16 @@ static char *stream_dir(vfs_handle_struct *handle,
        char *tmp;
        char *id_hex;
        struct file_id id;
-       uint8 id_buf[16];
+       uint8_t id_buf[16];
        bool check_valid;
        const char *rootdir;
-       NTSTATUS status;
+       struct smb_filename *rootdir_fname = NULL;
+       struct smb_filename *tmp_fname = NULL;
 
        check_valid = lp_parm_bool(SNUM(handle->conn),
                      "streams_depot", "check_valid", true);
 
-       tmp = talloc_asprintf(talloc_tos(), "%s/.streams", handle->conn->connectpath);
+       tmp = talloc_asprintf(talloc_tos(), "%s/.streams", handle->conn->cwd);
 
        if (tmp == NULL) {
                errno = ENOMEM;
@@ -150,16 +141,23 @@ static char *stream_dir(vfs_handle_struct *handle,
                SNUM(handle->conn), "streams_depot", "directory",
                tmp);
 
+       rootdir_fname = synthetic_smb_fname(talloc_tos(),
+                                       rootdir,
+                                       NULL,
+                                       NULL);
+       if (rootdir_fname == NULL) {
+               errno = ENOMEM;
+               goto fail;
+       }
+
        /* Stat the base file if it hasn't already been done. */
        if (base_sbuf == NULL) {
-               struct smb_filename *smb_fname_base = NULL;
+               struct smb_filename *smb_fname_base;
 
-               status = create_synthetic_smb_fname(talloc_tos(),
-                                                   smb_fname->base_name,
-                                                   NULL, NULL,
-                                                   &smb_fname_base);
-               if (!NT_STATUS_IS_OK(status)) {
-                       errno = map_errno_from_nt_status(status);
+               smb_fname_base = synthetic_smb_fname(
+                       talloc_tos(), smb_fname->base_name, NULL, NULL);
+               if (smb_fname_base == NULL) {
+                       errno = ENOMEM;
                        goto fail;
                }
                if (SMB_VFS_NEXT_STAT(handle, smb_fname_base) == -1) {
@@ -198,58 +196,75 @@ static char *stream_dir(vfs_handle_struct *handle,
                return NULL;
        }
 
-       status = create_synthetic_smb_fname(talloc_tos(), result, NULL, NULL,
-                                           &smb_fname_hash);
-       if (!NT_STATUS_IS_OK(status)) {
-               errno = map_errno_from_nt_status(status);
+       smb_fname_hash = synthetic_smb_fname(talloc_tos(), result, NULL, NULL);
+       if (smb_fname_hash == NULL) {
+               errno = ENOMEM;
                goto fail;
        }
 
        if (SMB_VFS_NEXT_STAT(handle, smb_fname_hash) == 0) {
                struct smb_filename *smb_fname_new = NULL;
                char *newname;
+               bool delete_lost;
 
                if (!S_ISDIR(smb_fname_hash->st.st_ex_mode)) {
                        errno = EINVAL;
                        goto fail;
                }
 
-               if (file_is_valid(handle, smb_fname->base_name, check_valid)) {
+               if (!check_valid ||
+                   file_is_valid(handle, smb_fname->base_name)) {
                        return result;
                }
 
                /*
                 * Someone has recreated a file under an existing inode
-                * without deleting the streams directory. For now, just move
-                * it away.
+                * without deleting the streams directory.
+                * Move it away or remove if streams_depot:delete_lost is set.
                 */
 
        again:
-               newname = talloc_asprintf(talloc_tos(), "lost-%lu", random());
-               if (newname == NULL) {
-                       errno = ENOMEM;
-                       goto fail;
-               }
+               delete_lost = lp_parm_bool(SNUM(handle->conn), "streams_depot",
+                                          "delete_lost", false);
+
+               if (delete_lost) {
+                       DEBUG(3, ("Someone has recreated a file under an "
+                             "existing inode. Removing: %s\n",
+                             smb_fname_hash->base_name));
+                       recursive_rmdir(talloc_tos(), handle->conn,
+                                       smb_fname_hash);
+                       SMB_VFS_NEXT_RMDIR(handle, smb_fname_hash);
+               } else {
+                       newname = talloc_asprintf(talloc_tos(), "lost-%lu",
+                                                 random());
+                       DEBUG(3, ("Someone has recreated a file under an "
+                             "existing inode. Renaming: %s to: %s\n",
+                             smb_fname_hash->base_name,
+                             newname));
+                       if (newname == NULL) {
+                               errno = ENOMEM;
+                               goto fail;
+                       }
 
-               status = create_synthetic_smb_fname(talloc_tos(), newname,
-                                                   NULL, NULL,
-                                                   &smb_fname_new);
-               TALLOC_FREE(newname);
-               if (!NT_STATUS_IS_OK(status)) {
-                       errno = map_errno_from_nt_status(status);
-                       goto fail;
-               }
+                       smb_fname_new = synthetic_smb_fname(
+                               talloc_tos(), newname, NULL, NULL);
+                       TALLOC_FREE(newname);
+                       if (smb_fname_new == NULL) {
+                               errno = ENOMEM;
+                               goto fail;
+                       }
 
-               if (SMB_VFS_NEXT_RENAME(handle, smb_fname_hash,
-                                       smb_fname_new) == -1) {
-                       TALLOC_FREE(smb_fname_new);
-                       if ((errno == EEXIST) || (errno == ENOTEMPTY)) {
-                               goto again;
+                       if (SMB_VFS_NEXT_RENAME(handle, smb_fname_hash,
+                                               smb_fname_new) == -1) {
+                               TALLOC_FREE(smb_fname_new);
+                               if ((errno == EEXIST) || (errno == ENOTEMPTY)) {
+                                       goto again;
+                               }
+                               goto fail;
                        }
-                       goto fail;
-               }
 
-               TALLOC_FREE(smb_fname_new);
+                       TALLOC_FREE(smb_fname_new);
+               }
        }
 
        if (!create_it) {
@@ -257,7 +272,7 @@ static char *stream_dir(vfs_handle_struct *handle,
                goto fail;
        }
 
-       if ((SMB_VFS_NEXT_MKDIR(handle, rootdir, 0755) != 0)
+       if ((SMB_VFS_NEXT_MKDIR(handle, rootdir_fname, 0755) != 0)
            && (errno != EEXIST)) {
                goto fail;
        }
@@ -268,12 +283,19 @@ static char *stream_dir(vfs_handle_struct *handle,
                goto fail;
        }
 
-       if ((SMB_VFS_NEXT_MKDIR(handle, tmp, 0755) != 0)
+       tmp_fname = synthetic_smb_fname(talloc_tos(), tmp, NULL, NULL);
+       if (tmp_fname == NULL) {
+               errno = ENOMEM;
+               goto fail;
+       }
+
+       if ((SMB_VFS_NEXT_MKDIR(handle, tmp_fname, 0755) != 0)
            && (errno != EEXIST)) {
                goto fail;
        }
 
        TALLOC_FREE(tmp);
+       TALLOC_FREE(tmp_fname);
 
        tmp = talloc_asprintf(result, "%s/%2.2X/%2.2X", rootdir, first,
                              second);
@@ -282,26 +304,38 @@ static char *stream_dir(vfs_handle_struct *handle,
                goto fail;
        }
 
-       if ((SMB_VFS_NEXT_MKDIR(handle, tmp, 0755) != 0)
+       tmp_fname = synthetic_smb_fname(talloc_tos(), tmp, NULL, NULL);
+       if (tmp_fname == NULL) {
+               errno = ENOMEM;
+               goto fail;
+       }
+
+       if ((SMB_VFS_NEXT_MKDIR(handle, tmp_fname, 0755) != 0)
            && (errno != EEXIST)) {
                goto fail;
        }
 
        TALLOC_FREE(tmp);
+       TALLOC_FREE(tmp_fname);
 
-       if ((SMB_VFS_NEXT_MKDIR(handle, result, 0755) != 0)
+       /* smb_fname_hash is the struct smb_filename version of 'result' */
+       if ((SMB_VFS_NEXT_MKDIR(handle, smb_fname_hash, 0755) != 0)
            && (errno != EEXIST)) {
                goto fail;
        }
 
-       if (!mark_file_valid(handle, smb_fname->base_name, check_valid)) {
+       if (check_valid && !mark_file_valid(handle, smb_fname->base_name)) {
                goto fail;
        }
 
+       TALLOC_FREE(rootdir_fname);
+       TALLOC_FREE(tmp_fname);
        TALLOC_FREE(smb_fname_hash);
        return result;
 
  fail:
+       TALLOC_FREE(rootdir_fname);
+       TALLOC_FREE(tmp_fname);
        TALLOC_FREE(smb_fname_hash);
        TALLOC_FREE(result);
        return NULL;
@@ -321,6 +355,14 @@ static NTSTATUS stream_smb_fname(vfs_handle_struct *handle,
 
        *smb_fname_out = NULL;
 
+       stype = strchr_m(smb_fname->stream_name + 1, ':');
+
+       if (stype) {
+               if (strcasecmp_m(stype, ":$DATA") != 0) {
+                       return NT_STATUS_INVALID_PARAMETER;
+               }
+       }
+
        dirname = stream_dir(handle, smb_fname, NULL, create_dir);
 
        if (dirname == NULL) {
@@ -328,8 +370,6 @@ static NTSTATUS stream_smb_fname(vfs_handle_struct *handle,
                goto fail;
        }
 
-       stype = strchr_m(smb_fname->stream_name + 1, ':');
-
        stream_fname = talloc_asprintf(talloc_tos(), "%s/%s", dirname,
                                       smb_fname->stream_name);
 
@@ -348,16 +388,19 @@ static NTSTATUS stream_smb_fname(vfs_handle_struct *handle,
                }
        } else {
                /* Normalize the stream type to upercase. */
-               strupper_m(strrchr_m(stream_fname, ':') + 1);
+               if (!strupper_m(strrchr_m(stream_fname, ':') + 1)) {
+                       status = NT_STATUS_INVALID_PARAMETER;
+                       goto fail;
+               }
        }
 
        DEBUG(10, ("stream filename = %s\n", stream_fname));
 
        /* Create an smb_filename with stream_name == NULL. */
-       status = create_synthetic_smb_fname(talloc_tos(), stream_fname, NULL,
-                                           NULL, smb_fname_out);
-       if (!NT_STATUS_IS_OK(status)) {
-               return status;
+       *smb_fname_out = synthetic_smb_fname(
+               talloc_tos(), stream_fname, NULL, NULL);
+       if (*smb_fname_out == NULL) {
+               return NT_STATUS_NO_MEMORY;
        }
 
        return NT_STATUS_OK;
@@ -377,8 +420,10 @@ static NTSTATUS walk_streams(vfs_handle_struct *handle,
                             void *private_data)
 {
        char *dirname;
-       SMB_STRUCT_DIR *dirhandle = NULL;
-       char *dirent;
+       struct smb_filename *dir_smb_fname = NULL;
+       DIR *dirhandle = NULL;
+       const char *dirent = NULL;
+       char *talloced = NULL;
 
        dirname = stream_dir(handle, smb_fname_base, &smb_fname_base->st,
                             false);
@@ -395,24 +440,39 @@ static NTSTATUS walk_streams(vfs_handle_struct *handle,
 
        DEBUG(10, ("walk_streams: dirname=%s\n", dirname));
 
-       dirhandle = SMB_VFS_NEXT_OPENDIR(handle, dirname, NULL, 0);
+       dir_smb_fname = synthetic_smb_fname(talloc_tos(),
+                                       dirname,
+                                       NULL,
+                                       NULL);
+       if (dir_smb_fname == NULL) {
+               TALLOC_FREE(dirname);
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       dirhandle = SMB_VFS_NEXT_OPENDIR(handle, dir_smb_fname, NULL, 0);
+
+       TALLOC_FREE(dir_smb_fname);
 
        if (dirhandle == NULL) {
                TALLOC_FREE(dirname);
                return map_nt_error_from_unix(errno);
        }
 
-       while ((dirent = vfs_readdirname(handle->conn, dirhandle, NULL)) != NULL) {
+       while ((dirent = vfs_readdirname(handle->conn, dirhandle, NULL,
+                                        &talloced)) != NULL) {
 
                if (ISDOT(dirent) || ISDOTDOT(dirent)) {
+                       TALLOC_FREE(talloced);
                        continue;
                }
 
                DEBUG(10, ("walk_streams: dirent=%s\n", dirent));
 
                if (!fn(dirname, dirent, private_data)) {
+                       TALLOC_FREE(talloced);
                        break;
                }
+               TALLOC_FREE(talloced);
        }
 
        SMB_VFS_NEXT_CLOSEDIR(handle, dirhandle);
@@ -549,13 +609,11 @@ static int streams_depot_open(vfs_handle_struct *handle,
        }
 
        /* Ensure the base file still exists. */
-       status = create_synthetic_smb_fname(talloc_tos(),
-                                           smb_fname->base_name,
-                                           NULL, NULL,
-                                           &smb_fname_base);
-       if (!NT_STATUS_IS_OK(status)) {
+       smb_fname_base = synthetic_smb_fname(
+               talloc_tos(), smb_fname->base_name, NULL, NULL);
+       if (smb_fname_base == NULL) {
                ret = -1;
-               errno = map_errno_from_nt_status(status);
+               errno = ENOMEM;
                goto done;
        }
 
@@ -584,7 +642,6 @@ static int streams_depot_unlink(vfs_handle_struct *handle,
                                const struct smb_filename *smb_fname)
 {
        struct smb_filename *smb_fname_base = NULL;
-       NTSTATUS status;
        int ret = -1;
 
        DEBUG(10, ("streams_depot_unlink called for %s\n",
@@ -594,6 +651,7 @@ static int streams_depot_unlink(vfs_handle_struct *handle,
        if (is_ntfs_stream_smb_fname(smb_fname) &&
            !is_ntfs_default_stream_smb_fname(smb_fname)) {
                struct smb_filename *smb_fname_stream = NULL;
+               NTSTATUS status;
 
                status = stream_smb_fname(handle, smb_fname, &smb_fname_stream,
                                          false);
@@ -612,10 +670,10 @@ static int streams_depot_unlink(vfs_handle_struct *handle,
         * We potentially need to delete the per-inode streams directory
         */
 
-       status = create_synthetic_smb_fname(talloc_tos(), smb_fname->base_name,
-                                           NULL, NULL, &smb_fname_base);
-       if (!NT_STATUS_IS_OK(status)) {
-               errno = map_errno_from_nt_status(status);
+       smb_fname_base = synthetic_smb_fname(
+               talloc_tos(), smb_fname->base_name, NULL, NULL);
+       if (smb_fname_base == NULL) {
+               errno = ENOMEM;
                return -1;
        }
 
@@ -630,17 +688,88 @@ static int streams_depot_unlink(vfs_handle_struct *handle,
                return -1;
        }
 
-       if (smb_fname_base->st.st_ex_nlink == 1) {
+       ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
+       if (ret == 0) {
                char *dirname = stream_dir(handle, smb_fname_base,
                                           &smb_fname_base->st, false);
 
                if (dirname != NULL) {
-                       SMB_VFS_NEXT_RMDIR(handle, dirname);
+                       struct smb_filename *smb_fname_dir =
+                               synthetic_smb_fname(talloc_tos(),
+                                               dirname,
+                                               NULL,
+                                               NULL);
+                       if (smb_fname_dir == NULL) {
+                               TALLOC_FREE(smb_fname_base);
+                               TALLOC_FREE(dirname);
+                               errno = ENOMEM;
+                               return -1;
+                       }
+                       SMB_VFS_NEXT_RMDIR(handle, smb_fname_dir);
+                       TALLOC_FREE(smb_fname_dir);
                }
                TALLOC_FREE(dirname);
        }
 
-       ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
+       TALLOC_FREE(smb_fname_base);
+       return ret;
+}
+
+static int streams_depot_rmdir(vfs_handle_struct *handle,
+                               const struct smb_filename *smb_fname)
+{
+       struct smb_filename *smb_fname_base = NULL;
+       int ret = -1;
+
+       DEBUG(10, ("streams_depot_rmdir called for %s\n",
+               smb_fname->base_name));
+
+       /*
+        * We potentially need to delete the per-inode streams directory
+        */
+
+       smb_fname_base = synthetic_smb_fname(talloc_tos(),
+                               smb_fname->base_name,
+                               NULL,
+                               NULL);
+       if (smb_fname_base == NULL) {
+               errno = ENOMEM;
+               return -1;
+       }
+
+       if (lp_posix_pathnames()) {
+               ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_base);
+       } else {
+               ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
+       }
+
+       if (ret == -1) {
+               TALLOC_FREE(smb_fname_base);
+               return -1;
+       }
+
+       ret = SMB_VFS_NEXT_RMDIR(handle, smb_fname_base);
+       if (ret == 0) {
+               char *dirname = stream_dir(handle, smb_fname_base,
+                                          &smb_fname_base->st, false);
+
+               if (dirname != NULL) {
+                       struct smb_filename *smb_fname_dir =
+                               synthetic_smb_fname(talloc_tos(),
+                                               dirname,
+                                               NULL,
+                                               NULL);
+                       if (smb_fname_dir == NULL) {
+                               TALLOC_FREE(smb_fname_base);
+                               TALLOC_FREE(dirname);
+                               errno = ENOMEM;
+                               return -1;
+                       }
+                       SMB_VFS_NEXT_RMDIR(handle, smb_fname_dir);
+                       TALLOC_FREE(smb_fname_dir);
+               }
+               TALLOC_FREE(dirname);
+       }
 
        TALLOC_FREE(smb_fname_base);
        return ret;
@@ -652,7 +781,6 @@ static int streams_depot_rename(vfs_handle_struct *handle,
 {
        struct smb_filename *smb_fname_src_stream = NULL;
        struct smb_filename *smb_fname_dst_stream = NULL;
-       struct smb_filename *smb_fname_dst_mod = NULL;
        bool src_is_stream, dst_is_stream;
        NTSTATUS status;
        int ret = -1;
@@ -683,23 +811,7 @@ static int streams_depot_rename(vfs_handle_struct *handle,
                goto done;
        }
 
-       /*
-        * Handle passing in a stream name without the base file.  This is
-        * exercised by the NTRENAME streams rename path.
-        */
-       if (StrCaseCmp(smb_fname_dst->base_name, "./") == 0) {
-               status = create_synthetic_smb_fname(talloc_tos(),
-                                                   smb_fname_src->base_name,
-                                                   smb_fname_dst->stream_name,
-                                                   NULL, &smb_fname_dst_mod);
-               if (!NT_STATUS_IS_OK(status)) {
-                       errno = map_errno_from_nt_status(status);
-                       goto done;
-               }
-       }
-
-       status = stream_smb_fname(handle, (smb_fname_dst_mod ?
-                                          smb_fname_dst_mod : smb_fname_dst),
+       status = stream_smb_fname(handle, smb_fname_dst,
                                  &smb_fname_dst_stream, false);
        if (!NT_STATUS_IS_OK(status)) {
                errno = map_errno_from_nt_status(status);
@@ -712,18 +824,17 @@ static int streams_depot_rename(vfs_handle_struct *handle,
 done:
        TALLOC_FREE(smb_fname_src_stream);
        TALLOC_FREE(smb_fname_dst_stream);
-       TALLOC_FREE(smb_fname_dst_mod);
        return ret;
 }
 
 static bool add_one_stream(TALLOC_CTX *mem_ctx, unsigned int *num_streams,
                           struct stream_struct **streams,
-                          const char *name, SMB_OFF_T size,
-                          SMB_OFF_T alloc_size)
+                          const char *name, off_t size,
+                          off_t alloc_size)
 {
        struct stream_struct *tmp;
 
-       tmp = TALLOC_REALLOC_ARRAY(mem_ctx, *streams, struct stream_struct,
+       tmp = talloc_realloc(mem_ctx, *streams, struct stream_struct,
                                   (*num_streams)+1);
        if (tmp == NULL) {
                return false;
@@ -758,7 +869,6 @@ static bool collect_one_stream(const char *dirname,
                (struct streaminfo_state *)private_data;
        struct smb_filename *smb_fname = NULL;
        char *sname = NULL;
-       NTSTATUS status;
        bool ret;
 
        sname = talloc_asprintf(talloc_tos(), "%s/%s", dirname, dirent);
@@ -768,10 +878,9 @@ static bool collect_one_stream(const char *dirname,
                goto out;
        }
 
-       status = create_synthetic_smb_fname(talloc_tos(), sname, NULL,
-                                           NULL, &smb_fname);
-       if (!NT_STATUS_IS_OK(status)) {
-               state->status = status;
+       smb_fname = synthetic_smb_fname(talloc_tos(), sname, NULL, NULL);
+       if (smb_fname == NULL) {
+               state->status = NT_STATUS_NO_MEMORY;
                ret = false;
                goto out;
        }
@@ -807,15 +916,14 @@ static NTSTATUS streams_depot_streaminfo(vfs_handle_struct *handle,
                                         unsigned int *pnum_streams,
                                         struct stream_struct **pstreams)
 {
-       struct smb_filename *smb_fname_base = NULL;
+       struct smb_filename *smb_fname_base;
        int ret;
        NTSTATUS status;
        struct streaminfo_state state;
 
-       status = create_synthetic_smb_fname(talloc_tos(), fname, NULL, NULL,
-                                           &smb_fname_base);
-       if (!NT_STATUS_IS_OK(status)) {
-               return status;
+       smb_fname_base = synthetic_smb_fname(talloc_tos(), fname, NULL, NULL);
+       if (smb_fname_base == NULL) {
+               return NT_STATUS_NO_MEMORY;
        }
 
        if ((fsp != NULL) && (fsp->fh->fd != -1)) {
@@ -834,26 +942,25 @@ static NTSTATUS streams_depot_streaminfo(vfs_handle_struct *handle,
                goto out;
        }
 
-       state.streams = NULL;
-       state.num_streams = 0;
-
-       if (!S_ISDIR(smb_fname_base->st.st_ex_mode)) {
-               if (!add_one_stream(mem_ctx,
-                                   &state.num_streams, &state.streams,
-                                   "::$DATA", smb_fname_base->st.st_ex_size,
-                                   SMB_VFS_GET_ALLOC_SIZE(handle->conn, fsp,
-                                                      &smb_fname_base->st))) {
-                       status = NT_STATUS_NO_MEMORY;
-                       goto out;
-               }
-       }
-
+       state.streams = *pstreams;
+       state.num_streams = *pnum_streams;
        state.mem_ctx = mem_ctx;
        state.handle = handle;
        state.status = NT_STATUS_OK;
 
-       status = walk_streams(handle, smb_fname_base, NULL, collect_one_stream,
+       if (S_ISLNK(smb_fname_base->st.st_ex_mode)) {
+               /*
+                * Currently we do't have SMB_VFS_LLISTXATTR
+                * inside the VFS which means there's no way
+                * to cope with a symlink when lp_posix_pathnames().
+                * returns true. For now ignore links.
+                * FIXME - by adding SMB_VFS_LLISTXATTR. JRA.
+                */
+               status = NT_STATUS_OK;
+       } else {
+               status = walk_streams(handle, smb_fname_base, NULL, collect_one_stream,
                              &state);
+       }
 
        if (!NT_STATUS_IS_OK(status)) {
                TALLOC_FREE(state.streams);
@@ -868,41 +975,33 @@ static NTSTATUS streams_depot_streaminfo(vfs_handle_struct *handle,
 
        *pnum_streams = state.num_streams;
        *pstreams = state.streams;
-       status = NT_STATUS_OK;
+       status = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx, pnum_streams, pstreams);
 
  out:
        TALLOC_FREE(smb_fname_base);
        return status;
 }
 
-static uint32_t streams_depot_fs_capabilities(struct vfs_handle_struct *handle)
+static uint32_t streams_depot_fs_capabilities(struct vfs_handle_struct *handle,
+                       enum timestamp_set_resolution *p_ts_res)
 {
-       return SMB_VFS_NEXT_FS_CAPABILITIES(handle) | FILE_NAMED_STREAMS;
+       return SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res) | FILE_NAMED_STREAMS;
 }
 
-/* VFS operations structure */
-
-static vfs_op_tuple streams_depot_ops[] = {
-       {SMB_VFS_OP(streams_depot_fs_capabilities), SMB_VFS_OP_FS_CAPABILITIES,
-        SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(streams_depot_open), SMB_VFS_OP_OPEN,
-        SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(streams_depot_stat), SMB_VFS_OP_STAT,
-        SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(streams_depot_lstat), SMB_VFS_OP_LSTAT,
-        SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(streams_depot_unlink), SMB_VFS_OP_UNLINK,
-        SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(streams_depot_rename), SMB_VFS_OP_RENAME,
-        SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(streams_depot_streaminfo), SMB_VFS_OP_STREAMINFO,
-        SMB_VFS_LAYER_OPAQUE},
-       {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP}
+static struct vfs_fn_pointers vfs_streams_depot_fns = {
+       .fs_capabilities_fn = streams_depot_fs_capabilities,
+       .open_fn = streams_depot_open,
+       .stat_fn = streams_depot_stat,
+       .lstat_fn = streams_depot_lstat,
+       .unlink_fn = streams_depot_unlink,
+       .rmdir_fn = streams_depot_rmdir,
+       .rename_fn = streams_depot_rename,
+       .streaminfo_fn = streams_depot_streaminfo,
 };
 
 NTSTATUS vfs_streams_depot_init(void);
 NTSTATUS vfs_streams_depot_init(void)
 {
        return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "streams_depot",
-                               streams_depot_ops);
+                               &vfs_streams_depot_fns);
 }