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_SETXATTR(handle->conn, smb_fname, 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;
135 check_valid = lp_parm_bool(SNUM(handle->conn),
136 "streams_depot", "check_valid", true);
138 tmp = talloc_asprintf(talloc_tos(), "%s/.streams",
139 handle->conn->connectpath);
146 rootdir = lp_parm_substituted_string(talloc_tos(), lp_sub,
147 SNUM(handle->conn), "streams_depot", "directory",
149 if (rootdir == NULL) {
154 rootdir_fname = synthetic_smb_fname(talloc_tos(),
160 if (rootdir_fname == NULL) {
165 /* Stat the base file if it hasn't already been done. */
166 if (base_sbuf == NULL) {
167 struct smb_filename *smb_fname_base;
169 smb_fname_base = synthetic_smb_fname(
171 smb_fname->base_name,
176 if (smb_fname_base == NULL) {
180 if (SMB_VFS_NEXT_STAT(handle, smb_fname_base) == -1) {
181 TALLOC_FREE(smb_fname_base);
184 base_sbuf_tmp = smb_fname_base->st;
185 TALLOC_FREE(smb_fname_base);
187 base_sbuf_tmp = *base_sbuf;
190 id = SMB_VFS_FILE_ID_CREATE(handle->conn, &base_sbuf_tmp);
192 push_file_id_16((char *)id_buf, &id);
194 hash = hash_fn(data_blob_const(id_buf, sizeof(id_buf)));
197 second = (hash >> 8) & 0xff;
199 id_hex = hex_encode_talloc(talloc_tos(), id_buf, sizeof(id_buf));
201 if (id_hex == NULL) {
206 result = talloc_asprintf(talloc_tos(), "%s/%2.2X/%2.2X/%s", rootdir,
207 first, second, id_hex);
211 if (result == NULL) {
216 smb_fname_hash = synthetic_smb_fname(talloc_tos(),
222 if (smb_fname_hash == NULL) {
227 if (SMB_VFS_NEXT_STAT(handle, smb_fname_hash) == 0) {
228 struct smb_filename *smb_fname_new = NULL;
232 if (!S_ISDIR(smb_fname_hash->st.st_ex_mode)) {
238 file_is_valid(handle, smb_fname)) {
243 * Someone has recreated a file under an existing inode
244 * without deleting the streams directory.
245 * Move it away or remove if streams_depot:delete_lost is set.
249 delete_lost = lp_parm_bool(SNUM(handle->conn), "streams_depot",
250 "delete_lost", false);
253 DEBUG(3, ("Someone has recreated a file under an "
254 "existing inode. Removing: %s\n",
255 smb_fname_hash->base_name));
256 recursive_rmdir(talloc_tos(), handle->conn,
258 SMB_VFS_NEXT_UNLINKAT(handle,
259 handle->conn->cwd_fsp,
263 newname = talloc_asprintf(talloc_tos(), "lost-%lu",
265 DEBUG(3, ("Someone has recreated a file under an "
266 "existing inode. Renaming: %s to: %s\n",
267 smb_fname_hash->base_name,
269 if (newname == NULL) {
274 smb_fname_new = synthetic_smb_fname(
281 TALLOC_FREE(newname);
282 if (smb_fname_new == NULL) {
287 if (SMB_VFS_NEXT_RENAMEAT(handle,
288 handle->conn->cwd_fsp,
290 handle->conn->cwd_fsp,
291 smb_fname_new) == -1) {
292 TALLOC_FREE(smb_fname_new);
293 if ((errno == EEXIST) || (errno == ENOTEMPTY)) {
299 TALLOC_FREE(smb_fname_new);
308 ret = SMB_VFS_NEXT_MKDIRAT(handle,
309 handle->conn->cwd_fsp,
312 if ((ret != 0) && (errno != EEXIST)) {
316 tmp = talloc_asprintf(result, "%s/%2.2X", rootdir, first);
322 tmp_fname = synthetic_smb_fname(talloc_tos(),
328 if (tmp_fname == NULL) {
333 ret = SMB_VFS_NEXT_MKDIRAT(handle,
334 handle->conn->cwd_fsp,
337 if ((ret != 0) && (errno != EEXIST)) {
342 TALLOC_FREE(tmp_fname);
344 tmp = talloc_asprintf(result, "%s/%2.2X/%2.2X", rootdir, first,
351 tmp_fname = synthetic_smb_fname(talloc_tos(),
357 if (tmp_fname == NULL) {
362 ret = SMB_VFS_NEXT_MKDIRAT(handle,
363 handle->conn->cwd_fsp,
366 if ((ret != 0) && (errno != EEXIST)) {
371 TALLOC_FREE(tmp_fname);
373 /* smb_fname_hash is the struct smb_filename version of 'result' */
374 ret = SMB_VFS_NEXT_MKDIRAT(handle,
375 handle->conn->cwd_fsp,
378 if ((ret != 0) && (errno != EEXIST)) {
382 if (check_valid && !mark_file_valid(handle, smb_fname)) {
386 TALLOC_FREE(rootdir_fname);
387 TALLOC_FREE(rootdir);
388 TALLOC_FREE(tmp_fname);
389 TALLOC_FREE(smb_fname_hash);
393 TALLOC_FREE(rootdir_fname);
394 TALLOC_FREE(rootdir);
395 TALLOC_FREE(tmp_fname);
396 TALLOC_FREE(smb_fname_hash);
401 * Given a stream name, populate smb_fname_out with the actual location of the
404 static NTSTATUS stream_smb_fname(vfs_handle_struct *handle,
405 const struct smb_filename *smb_fname,
406 struct smb_filename **smb_fname_out,
409 char *dirname, *stream_fname;
413 *smb_fname_out = NULL;
415 stype = strchr_m(smb_fname->stream_name + 1, ':');
418 if (strcasecmp_m(stype, ":$DATA") != 0) {
419 return NT_STATUS_INVALID_PARAMETER;
423 dirname = stream_dir(handle, smb_fname, NULL, create_dir);
425 if (dirname == NULL) {
426 status = map_nt_error_from_unix(errno);
430 stream_fname = talloc_asprintf(talloc_tos(), "%s/%s", dirname,
431 smb_fname->stream_name);
433 if (stream_fname == NULL) {
434 status = NT_STATUS_NO_MEMORY;
439 /* Append an explicit stream type if one wasn't specified. */
440 stream_fname = talloc_asprintf(talloc_tos(), "%s:$DATA",
442 if (stream_fname == NULL) {
443 status = NT_STATUS_NO_MEMORY;
447 /* Normalize the stream type to upercase. */
448 if (!strupper_m(strrchr_m(stream_fname, ':') + 1)) {
449 status = NT_STATUS_INVALID_PARAMETER;
454 DEBUG(10, ("stream filename = %s\n", stream_fname));
456 /* Create an smb_filename with stream_name == NULL. */
457 *smb_fname_out = synthetic_smb_fname(talloc_tos(),
463 if (*smb_fname_out == NULL) {
464 return NT_STATUS_NO_MEMORY;
470 DEBUG(5, ("stream_name failed: %s\n", strerror(errno)));
471 TALLOC_FREE(*smb_fname_out);
475 static NTSTATUS walk_streams(vfs_handle_struct *handle,
476 struct smb_filename *smb_fname_base,
478 bool (*fn)(const struct smb_filename *dirname,
484 struct smb_filename *dir_smb_fname = NULL;
485 struct smb_Dir *dir_hnd = NULL;
486 const char *dname = NULL;
488 char *talloced = NULL;
490 dirname = stream_dir(handle, smb_fname_base, &smb_fname_base->st,
493 if (dirname == NULL) {
494 if (errno == ENOENT) {
500 return map_nt_error_from_unix(errno);
503 DEBUG(10, ("walk_streams: dirname=%s\n", dirname));
505 dir_smb_fname = synthetic_smb_fname(talloc_tos(),
509 smb_fname_base->twrp,
510 smb_fname_base->flags);
511 if (dir_smb_fname == NULL) {
512 TALLOC_FREE(dirname);
513 return NT_STATUS_NO_MEMORY;
516 dir_hnd = OpenDir(talloc_tos(), handle->conn, dir_smb_fname, NULL, 0);
517 if (dir_hnd == NULL) {
518 TALLOC_FREE(dir_smb_fname);
519 TALLOC_FREE(dirname);
520 return map_nt_error_from_unix(errno);
523 while ((dname = ReadDirName(dir_hnd, &offset, NULL, &talloced))
526 if (ISDOT(dname) || ISDOTDOT(dname)) {
527 TALLOC_FREE(talloced);
531 DBG_DEBUG("dirent=%s\n", dname);
533 if (!fn(dir_smb_fname, dname, private_data)) {
534 TALLOC_FREE(talloced);
537 TALLOC_FREE(talloced);
540 TALLOC_FREE(dir_smb_fname);
541 TALLOC_FREE(dir_hnd);
543 if (pdirname != NULL) {
547 TALLOC_FREE(dirname);
553 static int streams_depot_stat(vfs_handle_struct *handle,
554 struct smb_filename *smb_fname)
556 struct smb_filename *smb_fname_stream = NULL;
560 DEBUG(10, ("streams_depot_stat called for [%s]\n",
561 smb_fname_str_dbg(smb_fname)));
563 if (!is_named_stream(smb_fname)) {
564 return SMB_VFS_NEXT_STAT(handle, smb_fname);
567 /* Stat the actual stream now. */
568 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream,
570 if (!NT_STATUS_IS_OK(status)) {
572 errno = map_errno_from_nt_status(status);
576 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_stream);
578 /* Update the original smb_fname with the stat info. */
579 smb_fname->st = smb_fname_stream->st;
581 TALLOC_FREE(smb_fname_stream);
587 static int streams_depot_lstat(vfs_handle_struct *handle,
588 struct smb_filename *smb_fname)
590 struct smb_filename *smb_fname_stream = NULL;
594 DEBUG(10, ("streams_depot_lstat called for [%s]\n",
595 smb_fname_str_dbg(smb_fname)));
597 if (!is_named_stream(smb_fname)) {
598 return SMB_VFS_NEXT_LSTAT(handle, smb_fname);
601 /* Stat the actual stream now. */
602 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream,
604 if (!NT_STATUS_IS_OK(status)) {
606 errno = map_errno_from_nt_status(status);
610 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_stream);
613 TALLOC_FREE(smb_fname_stream);
617 static int streams_depot_openat(struct vfs_handle_struct *handle,
618 const struct files_struct *dirfsp,
619 const struct smb_filename *smb_fname,
620 struct files_struct *fsp,
624 struct smb_filename *smb_fname_stream = NULL;
625 struct smb_filename *smb_fname_base = NULL;
626 struct files_struct *fspcwd = NULL;
630 if (!is_named_stream(smb_fname)) {
631 return SMB_VFS_NEXT_OPENAT(handle,
640 * For now assert this so the below SMB_VFS_STAT() is ok.
642 SMB_ASSERT(fsp_get_pathref_fd(dirfsp) == AT_FDCWD);
644 /* Ensure the base file still exists. */
645 smb_fname_base = synthetic_smb_fname(talloc_tos(),
646 smb_fname->base_name,
651 if (smb_fname_base == NULL) {
657 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
662 /* Determine the stream name, and then open it. */
663 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream, true);
664 if (!NT_STATUS_IS_OK(status)) {
666 errno = map_errno_from_nt_status(status);
670 status = vfs_at_fspcwd(talloc_tos(), handle->conn, &fspcwd);
671 if (!NT_STATUS_IS_OK(status)) {
673 errno = map_errno_from_nt_status(status);
677 ret = SMB_VFS_NEXT_OPENAT(handle,
685 TALLOC_FREE(smb_fname_stream);
686 TALLOC_FREE(smb_fname_base);
691 static int streams_depot_unlink_internal(vfs_handle_struct *handle,
692 struct files_struct *dirfsp,
693 const struct smb_filename *smb_fname,
696 struct smb_filename *smb_fname_base = NULL;
697 char *dirname = NULL;
700 DEBUG(10, ("streams_depot_unlink called for %s\n",
701 smb_fname_str_dbg(smb_fname)));
703 /* If there is a valid stream, just unlink the stream and return. */
704 if (is_named_stream(smb_fname)) {
705 struct smb_filename *smb_fname_stream = NULL;
708 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream,
710 if (!NT_STATUS_IS_OK(status)) {
711 errno = map_errno_from_nt_status(status);
715 ret = SMB_VFS_NEXT_UNLINKAT(handle,
720 TALLOC_FREE(smb_fname_stream);
725 * We potentially need to delete the per-inode streams directory
728 smb_fname_base = synthetic_smb_fname(talloc_tos(),
729 smb_fname->base_name,
734 if (smb_fname_base == NULL) {
739 if (smb_fname_base->flags & SMB_FILENAME_POSIX_PATH) {
740 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_base);
742 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
746 TALLOC_FREE(smb_fname_base);
751 * We know the unlink should succeed as the ACL
752 * check is already done in the caller. Remove the
753 * file *after* the streams.
755 dirname = stream_dir(handle,
759 if (dirname != NULL) {
760 struct smb_filename *smb_fname_dir = NULL;
762 smb_fname_dir = synthetic_smb_fname(talloc_tos(),
768 if (smb_fname_dir == NULL) {
769 TALLOC_FREE(smb_fname_base);
770 TALLOC_FREE(dirname);
775 SMB_VFS_NEXT_UNLINKAT(handle,
779 TALLOC_FREE(smb_fname_dir);
780 TALLOC_FREE(dirname);
783 ret = SMB_VFS_NEXT_UNLINKAT(handle,
787 TALLOC_FREE(smb_fname_base);
791 static int streams_depot_rmdir_internal(vfs_handle_struct *handle,
792 struct files_struct *dirfsp,
793 const struct smb_filename *smb_fname)
795 struct smb_filename *smb_fname_base = NULL;
798 DBG_DEBUG("called for %s\n", smb_fname->base_name);
801 * We potentially need to delete the per-inode streams directory
804 smb_fname_base = synthetic_smb_fname(talloc_tos(),
805 smb_fname->base_name,
810 if (smb_fname_base == NULL) {
815 if (smb_fname_base->flags & SMB_FILENAME_POSIX_PATH) {
816 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_base);
818 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
822 TALLOC_FREE(smb_fname_base);
827 * We know the rmdir should succeed as the ACL
828 * check is already done in the caller. Remove the
829 * directory *after* the streams.
832 char *dirname = stream_dir(handle, smb_fname_base,
833 &smb_fname_base->st, false);
835 if (dirname != NULL) {
836 struct smb_filename *smb_fname_dir =
837 synthetic_smb_fname(talloc_tos(),
843 if (smb_fname_dir == NULL) {
844 TALLOC_FREE(smb_fname_base);
845 TALLOC_FREE(dirname);
849 SMB_VFS_NEXT_UNLINKAT(handle,
853 TALLOC_FREE(smb_fname_dir);
855 TALLOC_FREE(dirname);
858 ret = SMB_VFS_NEXT_UNLINKAT(handle,
862 TALLOC_FREE(smb_fname_base);
866 static int streams_depot_unlinkat(vfs_handle_struct *handle,
867 struct files_struct *dirfsp,
868 const struct smb_filename *smb_fname,
872 SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp);
873 if (flags & AT_REMOVEDIR) {
874 ret = streams_depot_rmdir_internal(handle,
878 ret = streams_depot_unlink_internal(handle,
886 static int streams_depot_renameat(vfs_handle_struct *handle,
887 files_struct *srcfsp,
888 const struct smb_filename *smb_fname_src,
889 files_struct *dstfsp,
890 const struct smb_filename *smb_fname_dst)
892 struct smb_filename *smb_fname_src_stream = NULL;
893 struct smb_filename *smb_fname_dst_stream = NULL;
894 bool src_is_stream, dst_is_stream;
898 DEBUG(10, ("streams_depot_renameat called for %s => %s\n",
899 smb_fname_str_dbg(smb_fname_src),
900 smb_fname_str_dbg(smb_fname_dst)));
902 src_is_stream = is_ntfs_stream_smb_fname(smb_fname_src);
903 dst_is_stream = is_ntfs_stream_smb_fname(smb_fname_dst);
905 if (!src_is_stream && !dst_is_stream) {
906 return SMB_VFS_NEXT_RENAMEAT(handle,
913 /* for now don't allow renames from or to the default stream */
914 if (is_ntfs_default_stream_smb_fname(smb_fname_src) ||
915 is_ntfs_default_stream_smb_fname(smb_fname_dst)) {
920 status = stream_smb_fname(handle, smb_fname_src, &smb_fname_src_stream,
922 if (!NT_STATUS_IS_OK(status)) {
923 errno = map_errno_from_nt_status(status);
927 status = stream_smb_fname(handle, smb_fname_dst,
928 &smb_fname_dst_stream, false);
929 if (!NT_STATUS_IS_OK(status)) {
930 errno = map_errno_from_nt_status(status);
934 ret = SMB_VFS_NEXT_RENAMEAT(handle,
936 smb_fname_src_stream,
938 smb_fname_dst_stream);
941 TALLOC_FREE(smb_fname_src_stream);
942 TALLOC_FREE(smb_fname_dst_stream);
946 static bool add_one_stream(TALLOC_CTX *mem_ctx, unsigned int *num_streams,
947 struct stream_struct **streams,
948 const char *name, off_t size,
951 struct stream_struct *tmp;
953 tmp = talloc_realloc(mem_ctx, *streams, struct stream_struct,
959 tmp[*num_streams].name = talloc_strdup(tmp, name);
960 if (tmp[*num_streams].name == NULL) {
964 tmp[*num_streams].size = size;
965 tmp[*num_streams].alloc_size = alloc_size;
972 struct streaminfo_state {
974 vfs_handle_struct *handle;
975 unsigned int num_streams;
976 struct stream_struct *streams;
980 static bool collect_one_stream(const struct smb_filename *dirfname,
984 const char *dirname = dirfname->base_name;
985 struct streaminfo_state *state =
986 (struct streaminfo_state *)private_data;
987 struct smb_filename *smb_fname = NULL;
991 sname = talloc_asprintf(talloc_tos(), "%s/%s", dirname, dirent);
993 state->status = NT_STATUS_NO_MEMORY;
998 smb_fname = synthetic_smb_fname(talloc_tos(),
1004 if (smb_fname == NULL) {
1005 state->status = NT_STATUS_NO_MEMORY;
1010 if (SMB_VFS_NEXT_STAT(state->handle, smb_fname) == -1) {
1011 DEBUG(10, ("Could not stat %s: %s\n", sname,
1017 if (!add_one_stream(state->mem_ctx,
1018 &state->num_streams, &state->streams,
1019 dirent, smb_fname->st.st_ex_size,
1020 SMB_VFS_GET_ALLOC_SIZE(state->handle->conn, NULL,
1022 state->status = NT_STATUS_NO_MEMORY;
1030 TALLOC_FREE(smb_fname);
1034 static NTSTATUS streams_depot_streaminfo(vfs_handle_struct *handle,
1035 struct files_struct *fsp,
1036 const struct smb_filename *smb_fname,
1037 TALLOC_CTX *mem_ctx,
1038 unsigned int *pnum_streams,
1039 struct stream_struct **pstreams)
1041 struct smb_filename *smb_fname_base = NULL;
1044 struct streaminfo_state state;
1046 smb_fname_base = synthetic_smb_fname(talloc_tos(),
1047 smb_fname->base_name,
1052 if (smb_fname_base == NULL) {
1053 return NT_STATUS_NO_MEMORY;
1056 if ((fsp != NULL) && (fsp_get_pathref_fd(fsp) != -1)) {
1057 ret = SMB_VFS_NEXT_FSTAT(handle, fsp, &smb_fname_base->st);
1060 if (smb_fname_base->flags & SMB_FILENAME_POSIX_PATH) {
1061 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_base);
1063 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
1068 status = map_nt_error_from_unix(errno);
1072 state.streams = *pstreams;
1073 state.num_streams = *pnum_streams;
1074 state.mem_ctx = mem_ctx;
1075 state.handle = handle;
1076 state.status = NT_STATUS_OK;
1078 if (S_ISLNK(smb_fname_base->st.st_ex_mode)) {
1080 * Currently we do't have SMB_VFS_LLISTXATTR
1081 * inside the VFS which means there's no way
1082 * to cope with a symlink when lp_posix_pathnames().
1083 * returns true. For now ignore links.
1084 * FIXME - by adding SMB_VFS_LLISTXATTR. JRA.
1086 status = NT_STATUS_OK;
1088 status = walk_streams(handle, smb_fname_base, NULL, collect_one_stream,
1092 if (!NT_STATUS_IS_OK(status)) {
1093 TALLOC_FREE(state.streams);
1097 if (!NT_STATUS_IS_OK(state.status)) {
1098 TALLOC_FREE(state.streams);
1099 status = state.status;
1103 *pnum_streams = state.num_streams;
1104 *pstreams = state.streams;
1105 status = SMB_VFS_NEXT_STREAMINFO(handle,
1113 TALLOC_FREE(smb_fname_base);
1117 static uint32_t streams_depot_fs_capabilities(struct vfs_handle_struct *handle,
1118 enum timestamp_set_resolution *p_ts_res)
1120 return SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res) | FILE_NAMED_STREAMS;
1123 static struct vfs_fn_pointers vfs_streams_depot_fns = {
1124 .fs_capabilities_fn = streams_depot_fs_capabilities,
1125 .openat_fn = streams_depot_openat,
1126 .stat_fn = streams_depot_stat,
1127 .lstat_fn = streams_depot_lstat,
1128 .unlinkat_fn = streams_depot_unlinkat,
1129 .renameat_fn = streams_depot_renameat,
1130 .streaminfo_fn = streams_depot_streaminfo,
1134 NTSTATUS vfs_streams_depot_init(TALLOC_CTX *ctx)
1136 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "streams_depot",
1137 &vfs_streams_depot_fns);