2 * Store streams in a separate subdirectory
4 * Copyright (C) Volker Lendecke, 2007
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "smbd/smbd.h"
22 #include "system/filesys.h"
25 #define DBGC_CLASS DBGC_VFS
28 * Excerpt from a mail from tridge:
30 * Volker, what I'm thinking of is this:
31 * /mount-point/.streams/XX/YY/aaaa.bbbb/namedstream1
32 * /mount-point/.streams/XX/YY/aaaa.bbbb/namedstream2
34 * where XX/YY is a 2 level hash based on the fsid/inode. "aaaa.bbbb"
35 * is the fsid/inode. "namedstreamX" is a file named after the stream
39 static uint32_t hash_fn(DATA_BLOB key)
41 uint32_t value; /* Used to compute the hash value. */
42 uint32_t i; /* Used to cycle through random values. */
44 /* Set the initial value from the key size. */
45 for (value = 0x238F13AF * key.length, i=0; i < key.length; i++)
46 value = (value + (key.data[i] << (i*5 % 24)));
48 return (1103515243 * value + 12345);
52 * With the hashing scheme based on the inode we need to protect against
53 * streams showing up on files with re-used inodes. This can happen if we
54 * create a stream directory from within Samba, and a local process or NFS
55 * client deletes the file without deleting the streams directory. When the
56 * inode is re-used and the stream directory is still around, the streams in
57 * there would be show up as belonging to the new file.
59 * There are several workarounds for this, probably the easiest one is on
60 * systems which have a true birthtime stat element: When the file has a later
61 * birthtime than the streams directory, then we have to recreate the
64 * The other workaround is to somehow mark the file as generated by Samba with
65 * something that a NFS client would not do. The closest one is a special
66 * xattr value being set. On systems which do not support xattrs, it might be
67 * an option to put in a special ACL entry for a non-existing group.
70 static bool file_is_valid(vfs_handle_struct *handle,
71 const struct smb_filename *smb_fname)
75 DEBUG(10, ("file_is_valid (%s) called\n", smb_fname->base_name));
77 if (SMB_VFS_GETXATTR(handle->conn, smb_fname, SAMBA_XATTR_MARKER,
78 &buf, sizeof(buf)) != sizeof(buf)) {
79 DEBUG(10, ("GETXATTR failed: %s\n", strerror(errno)));
84 DEBUG(10, ("got wrong buffer content: '%c'\n", buf));
91 static bool mark_file_valid(vfs_handle_struct *handle,
92 const struct smb_filename *smb_fname)
97 DEBUG(10, ("marking file %s as valid\n", smb_fname->base_name));
99 ret = SMB_VFS_FSETXATTR(smb_fname->fsp, SAMBA_XATTR_MARKER,
100 &buf, sizeof(buf), 0);
103 DEBUG(10, ("SETXATTR failed: %s\n", strerror(errno)));
111 * Given an smb_filename, determine the stream directory using the file's
114 static char *stream_dir(vfs_handle_struct *handle,
115 const struct smb_filename *smb_fname,
116 const SMB_STRUCT_STAT *base_sbuf, bool create_it)
118 const struct loadparm_substitution *lp_sub =
119 loadparm_s3_global_substitution();
121 struct smb_filename *smb_fname_hash = NULL;
123 SMB_STRUCT_STAT base_sbuf_tmp;
124 uint8_t first, second;
130 char *rootdir = NULL;
131 struct smb_filename *rootdir_fname = NULL;
132 struct smb_filename *tmp_fname = NULL;
133 struct smb_filename *tmpref = NULL;
134 const struct smb_filename *pathref = NULL;
137 check_valid = lp_parm_bool(SNUM(handle->conn),
138 "streams_depot", "check_valid", true);
140 tmp = talloc_asprintf(talloc_tos(), "%s/.streams",
141 handle->conn->connectpath);
148 rootdir = lp_parm_substituted_string(talloc_tos(), lp_sub,
149 SNUM(handle->conn), "streams_depot", "directory",
151 if (rootdir == NULL) {
156 rootdir_fname = synthetic_smb_fname(talloc_tos(),
162 if (rootdir_fname == NULL) {
167 /* Stat the base file if it hasn't already been done. */
168 if (base_sbuf == NULL) {
169 struct smb_filename *smb_fname_base;
171 smb_fname_base = synthetic_smb_fname(
173 smb_fname->base_name,
178 if (smb_fname_base == NULL) {
182 if (SMB_VFS_NEXT_STAT(handle, smb_fname_base) == -1) {
183 TALLOC_FREE(smb_fname_base);
186 base_sbuf_tmp = smb_fname_base->st;
187 TALLOC_FREE(smb_fname_base);
189 base_sbuf_tmp = *base_sbuf;
192 id = SMB_VFS_FILE_ID_CREATE(handle->conn, &base_sbuf_tmp);
194 push_file_id_16((char *)id_buf, &id);
196 hash = hash_fn(data_blob_const(id_buf, sizeof(id_buf)));
199 second = (hash >> 8) & 0xff;
201 id_hex = hex_encode_talloc(talloc_tos(), id_buf, sizeof(id_buf));
203 if (id_hex == NULL) {
208 result = talloc_asprintf(talloc_tos(), "%s/%2.2X/%2.2X/%s", rootdir,
209 first, second, id_hex);
213 if (result == NULL) {
218 smb_fname_hash = synthetic_smb_fname(talloc_tos(),
224 if (smb_fname_hash == NULL) {
229 if (SMB_VFS_NEXT_STAT(handle, smb_fname_hash) == 0) {
230 struct smb_filename *smb_fname_new = NULL;
234 if (!S_ISDIR(smb_fname_hash->st.st_ex_mode)) {
240 file_is_valid(handle, smb_fname)) {
245 * Someone has recreated a file under an existing inode
246 * without deleting the streams directory.
247 * Move it away or remove if streams_depot:delete_lost is set.
251 delete_lost = lp_parm_bool(SNUM(handle->conn), "streams_depot",
252 "delete_lost", false);
255 DEBUG(3, ("Someone has recreated a file under an "
256 "existing inode. Removing: %s\n",
257 smb_fname_hash->base_name));
258 recursive_rmdir(talloc_tos(), handle->conn,
260 SMB_VFS_NEXT_UNLINKAT(handle,
261 handle->conn->cwd_fsp,
265 newname = talloc_asprintf(talloc_tos(), "lost-%lu",
267 DEBUG(3, ("Someone has recreated a file under an "
268 "existing inode. Renaming: %s to: %s\n",
269 smb_fname_hash->base_name,
271 if (newname == NULL) {
276 smb_fname_new = synthetic_smb_fname(
283 TALLOC_FREE(newname);
284 if (smb_fname_new == NULL) {
289 if (SMB_VFS_NEXT_RENAMEAT(handle,
290 handle->conn->cwd_fsp,
292 handle->conn->cwd_fsp,
293 smb_fname_new) == -1) {
294 TALLOC_FREE(smb_fname_new);
295 if ((errno == EEXIST) || (errno == ENOTEMPTY)) {
301 TALLOC_FREE(smb_fname_new);
310 ret = SMB_VFS_NEXT_MKDIRAT(handle,
311 handle->conn->cwd_fsp,
314 if ((ret != 0) && (errno != EEXIST)) {
318 tmp = talloc_asprintf(result, "%s/%2.2X", rootdir, first);
324 tmp_fname = synthetic_smb_fname(talloc_tos(),
330 if (tmp_fname == NULL) {
335 ret = SMB_VFS_NEXT_MKDIRAT(handle,
336 handle->conn->cwd_fsp,
339 if ((ret != 0) && (errno != EEXIST)) {
344 TALLOC_FREE(tmp_fname);
346 tmp = talloc_asprintf(result, "%s/%2.2X/%2.2X", rootdir, first,
353 tmp_fname = synthetic_smb_fname(talloc_tos(),
359 if (tmp_fname == NULL) {
364 ret = SMB_VFS_NEXT_MKDIRAT(handle,
365 handle->conn->cwd_fsp,
368 if ((ret != 0) && (errno != EEXIST)) {
373 TALLOC_FREE(tmp_fname);
375 /* smb_fname_hash is the struct smb_filename version of 'result' */
376 ret = SMB_VFS_NEXT_MKDIRAT(handle,
377 handle->conn->cwd_fsp,
380 if ((ret != 0) && (errno != EEXIST)) {
384 if (smb_fname->fsp == NULL) {
386 status = synthetic_pathref(talloc_tos(),
387 handle->conn->cwd_fsp,
388 smb_fname->base_name,
394 if (!NT_STATUS_IS_OK(status)) {
399 if (check_valid && !mark_file_valid(handle, pathref)) {
404 TALLOC_FREE(rootdir_fname);
405 TALLOC_FREE(rootdir);
406 TALLOC_FREE(tmp_fname);
407 TALLOC_FREE(smb_fname_hash);
412 TALLOC_FREE(rootdir_fname);
413 TALLOC_FREE(rootdir);
414 TALLOC_FREE(tmp_fname);
415 TALLOC_FREE(smb_fname_hash);
420 * Given a stream name, populate smb_fname_out with the actual location of the
423 static NTSTATUS stream_smb_fname(vfs_handle_struct *handle,
424 const struct smb_filename *smb_fname,
425 struct smb_filename **smb_fname_out,
428 char *dirname, *stream_fname;
432 *smb_fname_out = NULL;
434 stype = strchr_m(smb_fname->stream_name + 1, ':');
437 if (strcasecmp_m(stype, ":$DATA") != 0) {
438 return NT_STATUS_INVALID_PARAMETER;
442 dirname = stream_dir(handle, smb_fname, NULL, create_dir);
444 if (dirname == NULL) {
445 status = map_nt_error_from_unix(errno);
449 stream_fname = talloc_asprintf(talloc_tos(), "%s/%s", dirname,
450 smb_fname->stream_name);
452 if (stream_fname == NULL) {
453 status = NT_STATUS_NO_MEMORY;
458 /* Append an explicit stream type if one wasn't specified. */
459 stream_fname = talloc_asprintf(talloc_tos(), "%s:$DATA",
461 if (stream_fname == NULL) {
462 status = NT_STATUS_NO_MEMORY;
466 /* Normalize the stream type to upercase. */
467 if (!strupper_m(strrchr_m(stream_fname, ':') + 1)) {
468 status = NT_STATUS_INVALID_PARAMETER;
473 DEBUG(10, ("stream filename = %s\n", stream_fname));
475 /* Create an smb_filename with stream_name == NULL. */
476 *smb_fname_out = synthetic_smb_fname(talloc_tos(),
482 if (*smb_fname_out == NULL) {
483 return NT_STATUS_NO_MEMORY;
489 DEBUG(5, ("stream_name failed: %s\n", strerror(errno)));
490 TALLOC_FREE(*smb_fname_out);
494 static NTSTATUS walk_streams(vfs_handle_struct *handle,
495 struct smb_filename *smb_fname_base,
497 bool (*fn)(const struct smb_filename *dirname,
503 struct smb_filename *dir_smb_fname = NULL;
504 struct smb_Dir *dir_hnd = NULL;
505 const char *dname = NULL;
507 char *talloced = NULL;
509 dirname = stream_dir(handle, smb_fname_base, &smb_fname_base->st,
512 if (dirname == NULL) {
513 if (errno == ENOENT) {
519 return map_nt_error_from_unix(errno);
522 DEBUG(10, ("walk_streams: dirname=%s\n", dirname));
524 dir_smb_fname = synthetic_smb_fname(talloc_tos(),
528 smb_fname_base->twrp,
529 smb_fname_base->flags);
530 if (dir_smb_fname == NULL) {
531 TALLOC_FREE(dirname);
532 return NT_STATUS_NO_MEMORY;
535 dir_hnd = OpenDir(talloc_tos(), handle->conn, dir_smb_fname, NULL, 0);
536 if (dir_hnd == NULL) {
537 TALLOC_FREE(dir_smb_fname);
538 TALLOC_FREE(dirname);
539 return map_nt_error_from_unix(errno);
542 while ((dname = ReadDirName(dir_hnd, &offset, NULL, &talloced))
545 if (ISDOT(dname) || ISDOTDOT(dname)) {
546 TALLOC_FREE(talloced);
550 DBG_DEBUG("dirent=%s\n", dname);
552 if (!fn(dir_smb_fname, dname, private_data)) {
553 TALLOC_FREE(talloced);
556 TALLOC_FREE(talloced);
559 TALLOC_FREE(dir_smb_fname);
560 TALLOC_FREE(dir_hnd);
562 if (pdirname != NULL) {
566 TALLOC_FREE(dirname);
572 static int streams_depot_stat(vfs_handle_struct *handle,
573 struct smb_filename *smb_fname)
575 struct smb_filename *smb_fname_stream = NULL;
579 DEBUG(10, ("streams_depot_stat called for [%s]\n",
580 smb_fname_str_dbg(smb_fname)));
582 if (!is_named_stream(smb_fname)) {
583 return SMB_VFS_NEXT_STAT(handle, smb_fname);
586 /* Stat the actual stream now. */
587 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream,
589 if (!NT_STATUS_IS_OK(status)) {
591 errno = map_errno_from_nt_status(status);
595 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_stream);
597 /* Update the original smb_fname with the stat info. */
598 smb_fname->st = smb_fname_stream->st;
600 TALLOC_FREE(smb_fname_stream);
606 static int streams_depot_lstat(vfs_handle_struct *handle,
607 struct smb_filename *smb_fname)
609 struct smb_filename *smb_fname_stream = NULL;
613 DEBUG(10, ("streams_depot_lstat called for [%s]\n",
614 smb_fname_str_dbg(smb_fname)));
616 if (!is_named_stream(smb_fname)) {
617 return SMB_VFS_NEXT_LSTAT(handle, smb_fname);
620 /* Stat the actual stream now. */
621 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream,
623 if (!NT_STATUS_IS_OK(status)) {
625 errno = map_errno_from_nt_status(status);
629 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_stream);
632 TALLOC_FREE(smb_fname_stream);
636 static int streams_depot_openat(struct vfs_handle_struct *handle,
637 const struct files_struct *dirfsp,
638 const struct smb_filename *smb_fname,
639 struct files_struct *fsp,
643 struct smb_filename *smb_fname_stream = NULL;
644 struct smb_filename *smb_fname_base = NULL;
645 struct files_struct *fspcwd = NULL;
649 if (!is_named_stream(smb_fname)) {
650 return SMB_VFS_NEXT_OPENAT(handle,
659 * For now assert this so the below SMB_VFS_STAT() is ok.
661 SMB_ASSERT(fsp_get_pathref_fd(dirfsp) == AT_FDCWD);
663 /* Ensure the base file still exists. */
664 smb_fname_base = synthetic_smb_fname(talloc_tos(),
665 smb_fname->base_name,
670 if (smb_fname_base == NULL) {
676 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
681 /* Determine the stream name, and then open it. */
682 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream, true);
683 if (!NT_STATUS_IS_OK(status)) {
685 errno = map_errno_from_nt_status(status);
689 status = vfs_at_fspcwd(talloc_tos(), handle->conn, &fspcwd);
690 if (!NT_STATUS_IS_OK(status)) {
692 errno = map_errno_from_nt_status(status);
696 ret = SMB_VFS_NEXT_OPENAT(handle,
704 TALLOC_FREE(smb_fname_stream);
705 TALLOC_FREE(smb_fname_base);
710 static int streams_depot_unlink_internal(vfs_handle_struct *handle,
711 struct files_struct *dirfsp,
712 const struct smb_filename *smb_fname,
715 struct smb_filename *full_fname = NULL;
716 char *dirname = NULL;
719 full_fname = full_path_from_dirfsp_atname(talloc_tos(),
722 if (full_fname == NULL) {
726 DEBUG(10, ("streams_depot_unlink called for %s\n",
727 smb_fname_str_dbg(full_fname)));
729 /* If there is a valid stream, just unlink the stream and return. */
730 if (is_named_stream(full_fname)) {
731 struct smb_filename *smb_fname_stream = NULL;
734 status = stream_smb_fname(handle, full_fname, &smb_fname_stream,
736 TALLOC_FREE(full_fname);
737 if (!NT_STATUS_IS_OK(status)) {
738 errno = map_errno_from_nt_status(status);
742 ret = SMB_VFS_NEXT_UNLINKAT(handle,
743 dirfsp->conn->cwd_fsp,
747 TALLOC_FREE(smb_fname_stream);
752 * We potentially need to delete the per-inode streams directory
755 if (full_fname->flags & SMB_FILENAME_POSIX_PATH) {
756 ret = SMB_VFS_NEXT_LSTAT(handle, full_fname);
758 ret = SMB_VFS_NEXT_STAT(handle, full_fname);
761 TALLOC_FREE(full_fname);
766 * We know the unlink should succeed as the ACL
767 * check is already done in the caller. Remove the
768 * file *after* the streams.
770 dirname = stream_dir(handle,
774 TALLOC_FREE(full_fname);
775 if (dirname != NULL) {
776 struct smb_filename *smb_fname_dir = NULL;
778 smb_fname_dir = synthetic_smb_fname(talloc_tos(),
784 if (smb_fname_dir == NULL) {
785 TALLOC_FREE(dirname);
790 SMB_VFS_NEXT_UNLINKAT(handle,
791 dirfsp->conn->cwd_fsp,
794 TALLOC_FREE(smb_fname_dir);
795 TALLOC_FREE(dirname);
798 ret = SMB_VFS_NEXT_UNLINKAT(handle,
805 static int streams_depot_rmdir_internal(vfs_handle_struct *handle,
806 struct files_struct *dirfsp,
807 const struct smb_filename *smb_fname)
809 struct smb_filename *full_fname = NULL;
810 struct smb_filename *smb_fname_base = NULL;
813 full_fname = full_path_from_dirfsp_atname(talloc_tos(),
816 if (full_fname == NULL) {
820 DBG_DEBUG("called for %s\n", full_fname->base_name);
823 * We potentially need to delete the per-inode streams directory
826 smb_fname_base = synthetic_smb_fname(talloc_tos(),
827 full_fname->base_name,
832 TALLOC_FREE(full_fname);
833 if (smb_fname_base == NULL) {
838 if (smb_fname_base->flags & SMB_FILENAME_POSIX_PATH) {
839 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_base);
841 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
845 TALLOC_FREE(smb_fname_base);
850 * We know the rmdir should succeed as the ACL
851 * check is already done in the caller. Remove the
852 * directory *after* the streams.
855 char *dirname = stream_dir(handle, smb_fname_base,
856 &smb_fname_base->st, false);
858 if (dirname != NULL) {
859 struct smb_filename *smb_fname_dir =
860 synthetic_smb_fname(talloc_tos(),
866 if (smb_fname_dir == NULL) {
867 TALLOC_FREE(smb_fname_base);
868 TALLOC_FREE(dirname);
872 SMB_VFS_NEXT_UNLINKAT(handle,
873 dirfsp->conn->cwd_fsp,
876 TALLOC_FREE(smb_fname_dir);
878 TALLOC_FREE(dirname);
881 ret = SMB_VFS_NEXT_UNLINKAT(handle,
885 TALLOC_FREE(smb_fname_base);
889 static int streams_depot_unlinkat(vfs_handle_struct *handle,
890 struct files_struct *dirfsp,
891 const struct smb_filename *smb_fname,
895 if (flags & AT_REMOVEDIR) {
896 ret = streams_depot_rmdir_internal(handle,
900 ret = streams_depot_unlink_internal(handle,
908 static int streams_depot_renameat(vfs_handle_struct *handle,
909 files_struct *srcfsp,
910 const struct smb_filename *smb_fname_src,
911 files_struct *dstfsp,
912 const struct smb_filename *smb_fname_dst)
914 struct smb_filename *smb_fname_src_stream = NULL;
915 struct smb_filename *smb_fname_dst_stream = NULL;
916 bool src_is_stream, dst_is_stream;
920 DEBUG(10, ("streams_depot_renameat called for %s => %s\n",
921 smb_fname_str_dbg(smb_fname_src),
922 smb_fname_str_dbg(smb_fname_dst)));
924 src_is_stream = is_ntfs_stream_smb_fname(smb_fname_src);
925 dst_is_stream = is_ntfs_stream_smb_fname(smb_fname_dst);
927 if (!src_is_stream && !dst_is_stream) {
928 return SMB_VFS_NEXT_RENAMEAT(handle,
935 /* for now don't allow renames from or to the default stream */
936 if (is_ntfs_default_stream_smb_fname(smb_fname_src) ||
937 is_ntfs_default_stream_smb_fname(smb_fname_dst)) {
942 status = stream_smb_fname(handle, smb_fname_src, &smb_fname_src_stream,
944 if (!NT_STATUS_IS_OK(status)) {
945 errno = map_errno_from_nt_status(status);
949 status = stream_smb_fname(handle, smb_fname_dst,
950 &smb_fname_dst_stream, false);
951 if (!NT_STATUS_IS_OK(status)) {
952 errno = map_errno_from_nt_status(status);
956 ret = SMB_VFS_NEXT_RENAMEAT(handle,
958 smb_fname_src_stream,
960 smb_fname_dst_stream);
963 TALLOC_FREE(smb_fname_src_stream);
964 TALLOC_FREE(smb_fname_dst_stream);
968 static bool add_one_stream(TALLOC_CTX *mem_ctx, unsigned int *num_streams,
969 struct stream_struct **streams,
970 const char *name, off_t size,
973 struct stream_struct *tmp;
975 tmp = talloc_realloc(mem_ctx, *streams, struct stream_struct,
981 tmp[*num_streams].name = talloc_strdup(tmp, name);
982 if (tmp[*num_streams].name == NULL) {
986 tmp[*num_streams].size = size;
987 tmp[*num_streams].alloc_size = alloc_size;
994 struct streaminfo_state {
996 vfs_handle_struct *handle;
997 unsigned int num_streams;
998 struct stream_struct *streams;
1002 static bool collect_one_stream(const struct smb_filename *dirfname,
1006 const char *dirname = dirfname->base_name;
1007 struct streaminfo_state *state =
1008 (struct streaminfo_state *)private_data;
1009 struct smb_filename *smb_fname = NULL;
1013 sname = talloc_asprintf(talloc_tos(), "%s/%s", dirname, dirent);
1014 if (sname == NULL) {
1015 state->status = NT_STATUS_NO_MEMORY;
1020 smb_fname = synthetic_smb_fname(talloc_tos(),
1026 if (smb_fname == NULL) {
1027 state->status = NT_STATUS_NO_MEMORY;
1032 if (SMB_VFS_NEXT_STAT(state->handle, smb_fname) == -1) {
1033 DEBUG(10, ("Could not stat %s: %s\n", sname,
1039 if (!add_one_stream(state->mem_ctx,
1040 &state->num_streams, &state->streams,
1041 dirent, smb_fname->st.st_ex_size,
1042 SMB_VFS_GET_ALLOC_SIZE(state->handle->conn, NULL,
1044 state->status = NT_STATUS_NO_MEMORY;
1052 TALLOC_FREE(smb_fname);
1056 static NTSTATUS streams_depot_streaminfo(vfs_handle_struct *handle,
1057 struct files_struct *fsp,
1058 const struct smb_filename *smb_fname,
1059 TALLOC_CTX *mem_ctx,
1060 unsigned int *pnum_streams,
1061 struct stream_struct **pstreams)
1063 struct smb_filename *smb_fname_base = NULL;
1066 struct streaminfo_state state;
1068 smb_fname_base = synthetic_smb_fname(talloc_tos(),
1069 smb_fname->base_name,
1074 if (smb_fname_base == NULL) {
1075 return NT_STATUS_NO_MEMORY;
1078 if ((fsp != NULL) && (fsp_get_pathref_fd(fsp) != -1)) {
1079 ret = SMB_VFS_NEXT_FSTAT(handle, fsp, &smb_fname_base->st);
1082 if (smb_fname_base->flags & SMB_FILENAME_POSIX_PATH) {
1083 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_base);
1085 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
1090 status = map_nt_error_from_unix(errno);
1094 state.streams = *pstreams;
1095 state.num_streams = *pnum_streams;
1096 state.mem_ctx = mem_ctx;
1097 state.handle = handle;
1098 state.status = NT_STATUS_OK;
1100 if (S_ISLNK(smb_fname_base->st.st_ex_mode)) {
1102 * Currently we do't have SMB_VFS_LLISTXATTR
1103 * inside the VFS which means there's no way
1104 * to cope with a symlink when lp_posix_pathnames().
1105 * returns true. For now ignore links.
1106 * FIXME - by adding SMB_VFS_LLISTXATTR. JRA.
1108 status = NT_STATUS_OK;
1110 status = walk_streams(handle, smb_fname_base, NULL, collect_one_stream,
1114 if (!NT_STATUS_IS_OK(status)) {
1115 TALLOC_FREE(state.streams);
1119 if (!NT_STATUS_IS_OK(state.status)) {
1120 TALLOC_FREE(state.streams);
1121 status = state.status;
1125 *pnum_streams = state.num_streams;
1126 *pstreams = state.streams;
1127 status = SMB_VFS_NEXT_STREAMINFO(handle,
1135 TALLOC_FREE(smb_fname_base);
1139 static uint32_t streams_depot_fs_capabilities(struct vfs_handle_struct *handle,
1140 enum timestamp_set_resolution *p_ts_res)
1142 return SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res) | FILE_NAMED_STREAMS;
1145 static struct vfs_fn_pointers vfs_streams_depot_fns = {
1146 .fs_capabilities_fn = streams_depot_fs_capabilities,
1147 .openat_fn = streams_depot_openat,
1148 .stat_fn = streams_depot_stat,
1149 .lstat_fn = streams_depot_lstat,
1150 .unlinkat_fn = streams_depot_unlinkat,
1151 .renameat_fn = streams_depot_renameat,
1152 .streaminfo_fn = streams_depot_streaminfo,
1156 NTSTATUS vfs_streams_depot_init(TALLOC_CTX *ctx)
1158 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "streams_depot",
1159 &vfs_streams_depot_fns);