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)
119 struct smb_filename *smb_fname_hash = NULL;
121 SMB_STRUCT_STAT base_sbuf_tmp;
122 uint8_t first, second;
128 char *rootdir = NULL;
129 struct smb_filename *rootdir_fname = NULL;
130 struct smb_filename *tmp_fname = NULL;
133 check_valid = lp_parm_bool(SNUM(handle->conn),
134 "streams_depot", "check_valid", true);
136 tmp = talloc_asprintf(talloc_tos(), "%s/.streams",
137 handle->conn->connectpath);
144 rootdir = lp_parm_talloc_string(talloc_tos(),
145 SNUM(handle->conn), "streams_depot", "directory",
147 if (rootdir == NULL) {
152 rootdir_fname = synthetic_smb_fname(talloc_tos(),
157 if (rootdir_fname == NULL) {
162 /* Stat the base file if it hasn't already been done. */
163 if (base_sbuf == NULL) {
164 struct smb_filename *smb_fname_base;
166 smb_fname_base = synthetic_smb_fname(
168 smb_fname->base_name,
172 if (smb_fname_base == NULL) {
176 if (SMB_VFS_NEXT_STAT(handle, smb_fname_base) == -1) {
177 TALLOC_FREE(smb_fname_base);
180 base_sbuf_tmp = smb_fname_base->st;
181 TALLOC_FREE(smb_fname_base);
183 base_sbuf_tmp = *base_sbuf;
186 id = SMB_VFS_FILE_ID_CREATE(handle->conn, &base_sbuf_tmp);
188 push_file_id_16((char *)id_buf, &id);
190 hash = hash_fn(data_blob_const(id_buf, sizeof(id_buf)));
193 second = (hash >> 8) & 0xff;
195 id_hex = hex_encode_talloc(talloc_tos(), id_buf, sizeof(id_buf));
197 if (id_hex == NULL) {
202 result = talloc_asprintf(talloc_tos(), "%s/%2.2X/%2.2X/%s", rootdir,
203 first, second, id_hex);
207 if (result == NULL) {
212 smb_fname_hash = synthetic_smb_fname(talloc_tos(),
217 if (smb_fname_hash == NULL) {
222 if (SMB_VFS_NEXT_STAT(handle, smb_fname_hash) == 0) {
223 struct smb_filename *smb_fname_new = NULL;
227 if (!S_ISDIR(smb_fname_hash->st.st_ex_mode)) {
233 file_is_valid(handle, smb_fname)) {
238 * Someone has recreated a file under an existing inode
239 * without deleting the streams directory.
240 * Move it away or remove if streams_depot:delete_lost is set.
244 delete_lost = lp_parm_bool(SNUM(handle->conn), "streams_depot",
245 "delete_lost", false);
248 DEBUG(3, ("Someone has recreated a file under an "
249 "existing inode. Removing: %s\n",
250 smb_fname_hash->base_name));
251 recursive_rmdir(talloc_tos(), handle->conn,
253 SMB_VFS_NEXT_UNLINKAT(handle,
254 handle->conn->cwd_fsp,
258 newname = talloc_asprintf(talloc_tos(), "lost-%lu",
260 DEBUG(3, ("Someone has recreated a file under an "
261 "existing inode. Renaming: %s to: %s\n",
262 smb_fname_hash->base_name,
264 if (newname == NULL) {
269 smb_fname_new = synthetic_smb_fname(
275 TALLOC_FREE(newname);
276 if (smb_fname_new == NULL) {
281 if (SMB_VFS_NEXT_RENAMEAT(handle,
282 handle->conn->cwd_fsp,
284 handle->conn->cwd_fsp,
285 smb_fname_new) == -1) {
286 TALLOC_FREE(smb_fname_new);
287 if ((errno == EEXIST) || (errno == ENOTEMPTY)) {
293 TALLOC_FREE(smb_fname_new);
302 ret = SMB_VFS_NEXT_MKDIRAT(handle,
303 handle->conn->cwd_fsp,
306 if ((ret != 0) && (errno != EEXIST)) {
310 tmp = talloc_asprintf(result, "%s/%2.2X", rootdir, first);
316 tmp_fname = synthetic_smb_fname(talloc_tos(),
321 if (tmp_fname == NULL) {
326 ret = SMB_VFS_NEXT_MKDIRAT(handle,
327 handle->conn->cwd_fsp,
330 if ((ret != 0) && (errno != EEXIST)) {
335 TALLOC_FREE(tmp_fname);
337 tmp = talloc_asprintf(result, "%s/%2.2X/%2.2X", rootdir, first,
344 tmp_fname = synthetic_smb_fname(talloc_tos(),
349 if (tmp_fname == NULL) {
354 ret = SMB_VFS_NEXT_MKDIRAT(handle,
355 handle->conn->cwd_fsp,
358 if ((ret != 0) && (errno != EEXIST)) {
363 TALLOC_FREE(tmp_fname);
365 /* smb_fname_hash is the struct smb_filename version of 'result' */
366 ret = SMB_VFS_NEXT_MKDIRAT(handle,
367 handle->conn->cwd_fsp,
370 if ((ret != 0) && (errno != EEXIST)) {
374 if (check_valid && !mark_file_valid(handle, smb_fname)) {
378 TALLOC_FREE(rootdir_fname);
379 TALLOC_FREE(rootdir);
380 TALLOC_FREE(tmp_fname);
381 TALLOC_FREE(smb_fname_hash);
385 TALLOC_FREE(rootdir_fname);
386 TALLOC_FREE(rootdir);
387 TALLOC_FREE(tmp_fname);
388 TALLOC_FREE(smb_fname_hash);
393 * Given a stream name, populate smb_fname_out with the actual location of the
396 static NTSTATUS stream_smb_fname(vfs_handle_struct *handle,
397 const struct smb_filename *smb_fname,
398 struct smb_filename **smb_fname_out,
401 char *dirname, *stream_fname;
405 *smb_fname_out = NULL;
407 stype = strchr_m(smb_fname->stream_name + 1, ':');
410 if (strcasecmp_m(stype, ":$DATA") != 0) {
411 return NT_STATUS_INVALID_PARAMETER;
415 dirname = stream_dir(handle, smb_fname, NULL, create_dir);
417 if (dirname == NULL) {
418 status = map_nt_error_from_unix(errno);
422 stream_fname = talloc_asprintf(talloc_tos(), "%s/%s", dirname,
423 smb_fname->stream_name);
425 if (stream_fname == NULL) {
426 status = NT_STATUS_NO_MEMORY;
431 /* Append an explicit stream type if one wasn't specified. */
432 stream_fname = talloc_asprintf(talloc_tos(), "%s:$DATA",
434 if (stream_fname == NULL) {
435 status = NT_STATUS_NO_MEMORY;
439 /* Normalize the stream type to upercase. */
440 if (!strupper_m(strrchr_m(stream_fname, ':') + 1)) {
441 status = NT_STATUS_INVALID_PARAMETER;
446 DEBUG(10, ("stream filename = %s\n", stream_fname));
448 /* Create an smb_filename with stream_name == NULL. */
449 *smb_fname_out = synthetic_smb_fname(talloc_tos(),
454 if (*smb_fname_out == NULL) {
455 return NT_STATUS_NO_MEMORY;
461 DEBUG(5, ("stream_name failed: %s\n", strerror(errno)));
462 TALLOC_FREE(*smb_fname_out);
466 static NTSTATUS walk_streams(vfs_handle_struct *handle,
467 struct smb_filename *smb_fname_base,
469 bool (*fn)(const char *dirname,
475 struct smb_filename *dir_smb_fname = NULL;
476 DIR *dirhandle = NULL;
477 const char *dirent = NULL;
478 char *talloced = NULL;
480 dirname = stream_dir(handle, smb_fname_base, &smb_fname_base->st,
483 if (dirname == NULL) {
484 if (errno == ENOENT) {
490 return map_nt_error_from_unix(errno);
493 DEBUG(10, ("walk_streams: dirname=%s\n", dirname));
495 dir_smb_fname = synthetic_smb_fname(talloc_tos(),
499 smb_fname_base->flags);
500 if (dir_smb_fname == NULL) {
501 TALLOC_FREE(dirname);
502 return NT_STATUS_NO_MEMORY;
505 dirhandle = SMB_VFS_NEXT_OPENDIR(handle, dir_smb_fname, NULL, 0);
507 TALLOC_FREE(dir_smb_fname);
509 if (dirhandle == NULL) {
510 TALLOC_FREE(dirname);
511 return map_nt_error_from_unix(errno);
514 while ((dirent = vfs_readdirname(handle->conn, dirhandle, NULL,
515 &talloced)) != NULL) {
517 if (ISDOT(dirent) || ISDOTDOT(dirent)) {
518 TALLOC_FREE(talloced);
522 DEBUG(10, ("walk_streams: dirent=%s\n", dirent));
524 if (!fn(dirname, dirent, private_data)) {
525 TALLOC_FREE(talloced);
528 TALLOC_FREE(talloced);
531 SMB_VFS_NEXT_CLOSEDIR(handle, dirhandle);
533 if (pdirname != NULL) {
537 TALLOC_FREE(dirname);
543 static int streams_depot_stat(vfs_handle_struct *handle,
544 struct smb_filename *smb_fname)
546 struct smb_filename *smb_fname_stream = NULL;
550 DEBUG(10, ("streams_depot_stat called for [%s]\n",
551 smb_fname_str_dbg(smb_fname)));
553 if (!is_named_stream(smb_fname)) {
554 return SMB_VFS_NEXT_STAT(handle, smb_fname);
557 /* Stat the actual stream now. */
558 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream,
560 if (!NT_STATUS_IS_OK(status)) {
562 errno = map_errno_from_nt_status(status);
566 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_stream);
568 /* Update the original smb_fname with the stat info. */
569 smb_fname->st = smb_fname_stream->st;
571 TALLOC_FREE(smb_fname_stream);
577 static int streams_depot_lstat(vfs_handle_struct *handle,
578 struct smb_filename *smb_fname)
580 struct smb_filename *smb_fname_stream = NULL;
584 DEBUG(10, ("streams_depot_lstat called for [%s]\n",
585 smb_fname_str_dbg(smb_fname)));
587 if (!is_named_stream(smb_fname)) {
588 return SMB_VFS_NEXT_LSTAT(handle, smb_fname);
591 /* Stat the actual stream now. */
592 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream,
594 if (!NT_STATUS_IS_OK(status)) {
596 errno = map_errno_from_nt_status(status);
600 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_stream);
603 TALLOC_FREE(smb_fname_stream);
607 static int streams_depot_open(vfs_handle_struct *handle,
608 struct smb_filename *smb_fname,
609 files_struct *fsp, int flags, mode_t mode)
611 struct smb_filename *smb_fname_stream = NULL;
612 struct smb_filename *smb_fname_base = NULL;
616 if (!is_named_stream(smb_fname)) {
617 return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
620 /* Ensure the base file still exists. */
621 smb_fname_base = synthetic_smb_fname(talloc_tos(),
622 smb_fname->base_name,
626 if (smb_fname_base == NULL) {
632 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
637 /* Determine the stream name, and then open it. */
638 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream, true);
639 if (!NT_STATUS_IS_OK(status)) {
641 errno = map_errno_from_nt_status(status);
645 ret = SMB_VFS_NEXT_OPEN(handle, smb_fname_stream, fsp, flags, mode);
648 TALLOC_FREE(smb_fname_stream);
649 TALLOC_FREE(smb_fname_base);
653 static int streams_depot_unlink_internal(vfs_handle_struct *handle,
654 struct files_struct *dirfsp,
655 const struct smb_filename *smb_fname,
658 struct smb_filename *smb_fname_base = NULL;
661 DEBUG(10, ("streams_depot_unlink called for %s\n",
662 smb_fname_str_dbg(smb_fname)));
664 /* If there is a valid stream, just unlink the stream and return. */
665 if (is_named_stream(smb_fname)) {
666 struct smb_filename *smb_fname_stream = NULL;
669 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream,
671 if (!NT_STATUS_IS_OK(status)) {
672 errno = map_errno_from_nt_status(status);
676 ret = SMB_VFS_NEXT_UNLINKAT(handle,
681 TALLOC_FREE(smb_fname_stream);
686 * We potentially need to delete the per-inode streams directory
689 smb_fname_base = synthetic_smb_fname(talloc_tos(),
690 smb_fname->base_name,
694 if (smb_fname_base == NULL) {
699 if (smb_fname_base->flags & SMB_FILENAME_POSIX_PATH) {
700 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_base);
702 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
706 TALLOC_FREE(smb_fname_base);
711 * We know the unlink should succeed as the ACL
712 * check is already done in the caller. Remove the
713 * file *after* the streams.
716 char *dirname = stream_dir(handle, smb_fname_base,
717 &smb_fname_base->st, false);
719 if (dirname != NULL) {
720 struct smb_filename *smb_fname_dir =
721 synthetic_smb_fname(talloc_tos(),
726 if (smb_fname_dir == NULL) {
727 TALLOC_FREE(smb_fname_base);
728 TALLOC_FREE(dirname);
732 SMB_VFS_NEXT_RMDIR(handle, smb_fname_dir);
733 TALLOC_FREE(smb_fname_dir);
735 TALLOC_FREE(dirname);
738 ret = SMB_VFS_NEXT_UNLINKAT(handle,
742 TALLOC_FREE(smb_fname_base);
746 static int streams_depot_rmdir_internal(vfs_handle_struct *handle,
747 struct files_struct *dirfsp,
748 const struct smb_filename *smb_fname)
750 struct smb_filename *smb_fname_base = NULL;
753 DBG_DEBUG("called for %s\n", smb_fname->base_name);
756 * We potentially need to delete the per-inode streams directory
759 smb_fname_base = synthetic_smb_fname(talloc_tos(),
760 smb_fname->base_name,
764 if (smb_fname_base == NULL) {
769 if (smb_fname_base->flags & SMB_FILENAME_POSIX_PATH) {
770 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_base);
772 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
776 TALLOC_FREE(smb_fname_base);
781 * We know the rmdir should succeed as the ACL
782 * check is already done in the caller. Remove the
783 * directory *after* the streams.
786 char *dirname = stream_dir(handle, smb_fname_base,
787 &smb_fname_base->st, false);
789 if (dirname != NULL) {
790 struct smb_filename *smb_fname_dir =
791 synthetic_smb_fname(talloc_tos(),
796 if (smb_fname_dir == NULL) {
797 TALLOC_FREE(smb_fname_base);
798 TALLOC_FREE(dirname);
802 SMB_VFS_NEXT_UNLINKAT(handle,
806 TALLOC_FREE(smb_fname_dir);
808 TALLOC_FREE(dirname);
811 ret = SMB_VFS_NEXT_UNLINKAT(handle,
815 TALLOC_FREE(smb_fname_base);
819 static int streams_depot_unlinkat(vfs_handle_struct *handle,
820 struct files_struct *dirfsp,
821 const struct smb_filename *smb_fname,
825 SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp);
826 if (flags & AT_REMOVEDIR) {
827 ret = streams_depot_rmdir_internal(handle,
831 ret = streams_depot_unlink_internal(handle,
839 static int streams_depot_rmdir(vfs_handle_struct *handle,
840 const struct smb_filename *smb_fname)
842 return streams_depot_rmdir_internal(handle,
843 handle->conn->cwd_fsp,
847 static int streams_depot_renameat(vfs_handle_struct *handle,
848 files_struct *srcfsp,
849 const struct smb_filename *smb_fname_src,
850 files_struct *dstfsp,
851 const struct smb_filename *smb_fname_dst)
853 struct smb_filename *smb_fname_src_stream = NULL;
854 struct smb_filename *smb_fname_dst_stream = NULL;
855 bool src_is_stream, dst_is_stream;
859 DEBUG(10, ("streams_depot_renameat called for %s => %s\n",
860 smb_fname_str_dbg(smb_fname_src),
861 smb_fname_str_dbg(smb_fname_dst)));
863 src_is_stream = is_ntfs_stream_smb_fname(smb_fname_src);
864 dst_is_stream = is_ntfs_stream_smb_fname(smb_fname_dst);
866 if (!src_is_stream && !dst_is_stream) {
867 return SMB_VFS_NEXT_RENAMEAT(handle,
874 /* for now don't allow renames from or to the default stream */
875 if (is_ntfs_default_stream_smb_fname(smb_fname_src) ||
876 is_ntfs_default_stream_smb_fname(smb_fname_dst)) {
881 status = stream_smb_fname(handle, smb_fname_src, &smb_fname_src_stream,
883 if (!NT_STATUS_IS_OK(status)) {
884 errno = map_errno_from_nt_status(status);
888 status = stream_smb_fname(handle, smb_fname_dst,
889 &smb_fname_dst_stream, false);
890 if (!NT_STATUS_IS_OK(status)) {
891 errno = map_errno_from_nt_status(status);
895 ret = SMB_VFS_NEXT_RENAMEAT(handle,
897 smb_fname_src_stream,
899 smb_fname_dst_stream);
902 TALLOC_FREE(smb_fname_src_stream);
903 TALLOC_FREE(smb_fname_dst_stream);
907 static bool add_one_stream(TALLOC_CTX *mem_ctx, unsigned int *num_streams,
908 struct stream_struct **streams,
909 const char *name, off_t size,
912 struct stream_struct *tmp;
914 tmp = talloc_realloc(mem_ctx, *streams, struct stream_struct,
920 tmp[*num_streams].name = talloc_strdup(tmp, name);
921 if (tmp[*num_streams].name == NULL) {
925 tmp[*num_streams].size = size;
926 tmp[*num_streams].alloc_size = alloc_size;
933 struct streaminfo_state {
935 vfs_handle_struct *handle;
936 unsigned int num_streams;
937 struct stream_struct *streams;
941 static bool collect_one_stream(const char *dirname,
945 struct streaminfo_state *state =
946 (struct streaminfo_state *)private_data;
947 struct smb_filename *smb_fname = NULL;
951 sname = talloc_asprintf(talloc_tos(), "%s/%s", dirname, dirent);
953 state->status = NT_STATUS_NO_MEMORY;
958 smb_fname = synthetic_smb_fname(talloc_tos(), sname, NULL, NULL, 0);
959 if (smb_fname == NULL) {
960 state->status = NT_STATUS_NO_MEMORY;
965 if (SMB_VFS_NEXT_STAT(state->handle, smb_fname) == -1) {
966 DEBUG(10, ("Could not stat %s: %s\n", sname,
972 if (!add_one_stream(state->mem_ctx,
973 &state->num_streams, &state->streams,
974 dirent, smb_fname->st.st_ex_size,
975 SMB_VFS_GET_ALLOC_SIZE(state->handle->conn, NULL,
977 state->status = NT_STATUS_NO_MEMORY;
985 TALLOC_FREE(smb_fname);
989 static NTSTATUS streams_depot_streaminfo(vfs_handle_struct *handle,
990 struct files_struct *fsp,
991 const struct smb_filename *smb_fname,
993 unsigned int *pnum_streams,
994 struct stream_struct **pstreams)
996 struct smb_filename *smb_fname_base = NULL;
999 struct streaminfo_state state;
1001 smb_fname_base = synthetic_smb_fname(talloc_tos(),
1002 smb_fname->base_name,
1006 if (smb_fname_base == NULL) {
1007 return NT_STATUS_NO_MEMORY;
1010 if ((fsp != NULL) && (fsp->fh->fd != -1)) {
1011 ret = SMB_VFS_NEXT_FSTAT(handle, fsp, &smb_fname_base->st);
1014 if (smb_fname_base->flags & SMB_FILENAME_POSIX_PATH) {
1015 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_base);
1017 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
1022 status = map_nt_error_from_unix(errno);
1026 state.streams = *pstreams;
1027 state.num_streams = *pnum_streams;
1028 state.mem_ctx = mem_ctx;
1029 state.handle = handle;
1030 state.status = NT_STATUS_OK;
1032 if (S_ISLNK(smb_fname_base->st.st_ex_mode)) {
1034 * Currently we do't have SMB_VFS_LLISTXATTR
1035 * inside the VFS which means there's no way
1036 * to cope with a symlink when lp_posix_pathnames().
1037 * returns true. For now ignore links.
1038 * FIXME - by adding SMB_VFS_LLISTXATTR. JRA.
1040 status = NT_STATUS_OK;
1042 status = walk_streams(handle, smb_fname_base, NULL, collect_one_stream,
1046 if (!NT_STATUS_IS_OK(status)) {
1047 TALLOC_FREE(state.streams);
1051 if (!NT_STATUS_IS_OK(state.status)) {
1052 TALLOC_FREE(state.streams);
1053 status = state.status;
1057 *pnum_streams = state.num_streams;
1058 *pstreams = state.streams;
1059 status = SMB_VFS_NEXT_STREAMINFO(handle,
1067 TALLOC_FREE(smb_fname_base);
1071 static uint32_t streams_depot_fs_capabilities(struct vfs_handle_struct *handle,
1072 enum timestamp_set_resolution *p_ts_res)
1074 return SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res) | FILE_NAMED_STREAMS;
1077 static struct vfs_fn_pointers vfs_streams_depot_fns = {
1078 .fs_capabilities_fn = streams_depot_fs_capabilities,
1079 .open_fn = streams_depot_open,
1080 .stat_fn = streams_depot_stat,
1081 .lstat_fn = streams_depot_lstat,
1082 .unlinkat_fn = streams_depot_unlinkat,
1083 .rmdir_fn = streams_depot_rmdir,
1084 .renameat_fn = streams_depot_renameat,
1085 .streaminfo_fn = streams_depot_streaminfo,
1089 NTSTATUS vfs_streams_depot_init(TALLOC_CTX *ctx)
1091 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "streams_depot",
1092 &vfs_streams_depot_fns);