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_open(vfs_handle_struct *handle,
618 struct smb_filename *smb_fname,
619 files_struct *fsp, int flags, mode_t mode)
621 struct smb_filename *smb_fname_stream = NULL;
622 struct smb_filename *smb_fname_base = NULL;
626 if (!is_named_stream(smb_fname)) {
627 return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
630 /* Ensure the base file still exists. */
631 smb_fname_base = synthetic_smb_fname(talloc_tos(),
632 smb_fname->base_name,
637 if (smb_fname_base == NULL) {
643 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
648 /* Determine the stream name, and then open it. */
649 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream, true);
650 if (!NT_STATUS_IS_OK(status)) {
652 errno = map_errno_from_nt_status(status);
656 ret = SMB_VFS_NEXT_OPEN(handle, smb_fname_stream, fsp, flags, mode);
659 TALLOC_FREE(smb_fname_stream);
660 TALLOC_FREE(smb_fname_base);
664 static int streams_depot_unlink_internal(vfs_handle_struct *handle,
665 struct files_struct *dirfsp,
666 const struct smb_filename *smb_fname,
669 struct smb_filename *smb_fname_base = NULL;
672 DEBUG(10, ("streams_depot_unlink called for %s\n",
673 smb_fname_str_dbg(smb_fname)));
675 /* If there is a valid stream, just unlink the stream and return. */
676 if (is_named_stream(smb_fname)) {
677 struct smb_filename *smb_fname_stream = NULL;
680 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream,
682 if (!NT_STATUS_IS_OK(status)) {
683 errno = map_errno_from_nt_status(status);
687 ret = SMB_VFS_NEXT_UNLINKAT(handle,
692 TALLOC_FREE(smb_fname_stream);
697 * We potentially need to delete the per-inode streams directory
700 smb_fname_base = synthetic_smb_fname(talloc_tos(),
701 smb_fname->base_name,
706 if (smb_fname_base == NULL) {
711 if (smb_fname_base->flags & SMB_FILENAME_POSIX_PATH) {
712 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_base);
714 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
718 TALLOC_FREE(smb_fname_base);
723 * We know the unlink should succeed as the ACL
724 * check is already done in the caller. Remove the
725 * file *after* the streams.
728 char *dirname = stream_dir(handle, smb_fname_base,
729 &smb_fname_base->st, false);
731 if (dirname != NULL) {
732 struct smb_filename *smb_fname_dir =
733 synthetic_smb_fname(talloc_tos(),
739 if (smb_fname_dir == NULL) {
740 TALLOC_FREE(smb_fname_base);
741 TALLOC_FREE(dirname);
745 SMB_VFS_NEXT_UNLINKAT(handle,
749 TALLOC_FREE(smb_fname_dir);
751 TALLOC_FREE(dirname);
754 ret = SMB_VFS_NEXT_UNLINKAT(handle,
758 TALLOC_FREE(smb_fname_base);
762 static int streams_depot_rmdir_internal(vfs_handle_struct *handle,
763 struct files_struct *dirfsp,
764 const struct smb_filename *smb_fname)
766 struct smb_filename *smb_fname_base = NULL;
769 DBG_DEBUG("called for %s\n", smb_fname->base_name);
772 * We potentially need to delete the per-inode streams directory
775 smb_fname_base = synthetic_smb_fname(talloc_tos(),
776 smb_fname->base_name,
781 if (smb_fname_base == NULL) {
786 if (smb_fname_base->flags & SMB_FILENAME_POSIX_PATH) {
787 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_base);
789 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
793 TALLOC_FREE(smb_fname_base);
798 * We know the rmdir should succeed as the ACL
799 * check is already done in the caller. Remove the
800 * directory *after* the streams.
803 char *dirname = stream_dir(handle, smb_fname_base,
804 &smb_fname_base->st, false);
806 if (dirname != NULL) {
807 struct smb_filename *smb_fname_dir =
808 synthetic_smb_fname(talloc_tos(),
814 if (smb_fname_dir == NULL) {
815 TALLOC_FREE(smb_fname_base);
816 TALLOC_FREE(dirname);
820 SMB_VFS_NEXT_UNLINKAT(handle,
824 TALLOC_FREE(smb_fname_dir);
826 TALLOC_FREE(dirname);
829 ret = SMB_VFS_NEXT_UNLINKAT(handle,
833 TALLOC_FREE(smb_fname_base);
837 static int streams_depot_unlinkat(vfs_handle_struct *handle,
838 struct files_struct *dirfsp,
839 const struct smb_filename *smb_fname,
843 SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp);
844 if (flags & AT_REMOVEDIR) {
845 ret = streams_depot_rmdir_internal(handle,
849 ret = streams_depot_unlink_internal(handle,
857 static int streams_depot_renameat(vfs_handle_struct *handle,
858 files_struct *srcfsp,
859 const struct smb_filename *smb_fname_src,
860 files_struct *dstfsp,
861 const struct smb_filename *smb_fname_dst)
863 struct smb_filename *smb_fname_src_stream = NULL;
864 struct smb_filename *smb_fname_dst_stream = NULL;
865 bool src_is_stream, dst_is_stream;
869 DEBUG(10, ("streams_depot_renameat called for %s => %s\n",
870 smb_fname_str_dbg(smb_fname_src),
871 smb_fname_str_dbg(smb_fname_dst)));
873 src_is_stream = is_ntfs_stream_smb_fname(smb_fname_src);
874 dst_is_stream = is_ntfs_stream_smb_fname(smb_fname_dst);
876 if (!src_is_stream && !dst_is_stream) {
877 return SMB_VFS_NEXT_RENAMEAT(handle,
884 /* for now don't allow renames from or to the default stream */
885 if (is_ntfs_default_stream_smb_fname(smb_fname_src) ||
886 is_ntfs_default_stream_smb_fname(smb_fname_dst)) {
891 status = stream_smb_fname(handle, smb_fname_src, &smb_fname_src_stream,
893 if (!NT_STATUS_IS_OK(status)) {
894 errno = map_errno_from_nt_status(status);
898 status = stream_smb_fname(handle, smb_fname_dst,
899 &smb_fname_dst_stream, false);
900 if (!NT_STATUS_IS_OK(status)) {
901 errno = map_errno_from_nt_status(status);
905 ret = SMB_VFS_NEXT_RENAMEAT(handle,
907 smb_fname_src_stream,
909 smb_fname_dst_stream);
912 TALLOC_FREE(smb_fname_src_stream);
913 TALLOC_FREE(smb_fname_dst_stream);
917 static bool add_one_stream(TALLOC_CTX *mem_ctx, unsigned int *num_streams,
918 struct stream_struct **streams,
919 const char *name, off_t size,
922 struct stream_struct *tmp;
924 tmp = talloc_realloc(mem_ctx, *streams, struct stream_struct,
930 tmp[*num_streams].name = talloc_strdup(tmp, name);
931 if (tmp[*num_streams].name == NULL) {
935 tmp[*num_streams].size = size;
936 tmp[*num_streams].alloc_size = alloc_size;
943 struct streaminfo_state {
945 vfs_handle_struct *handle;
946 unsigned int num_streams;
947 struct stream_struct *streams;
951 static bool collect_one_stream(const struct smb_filename *dirfname,
955 const char *dirname = dirfname->base_name;
956 struct streaminfo_state *state =
957 (struct streaminfo_state *)private_data;
958 struct smb_filename *smb_fname = NULL;
962 sname = talloc_asprintf(talloc_tos(), "%s/%s", dirname, dirent);
964 state->status = NT_STATUS_NO_MEMORY;
969 smb_fname = synthetic_smb_fname(talloc_tos(),
975 if (smb_fname == NULL) {
976 state->status = NT_STATUS_NO_MEMORY;
981 if (SMB_VFS_NEXT_STAT(state->handle, smb_fname) == -1) {
982 DEBUG(10, ("Could not stat %s: %s\n", sname,
988 if (!add_one_stream(state->mem_ctx,
989 &state->num_streams, &state->streams,
990 dirent, smb_fname->st.st_ex_size,
991 SMB_VFS_GET_ALLOC_SIZE(state->handle->conn, NULL,
993 state->status = NT_STATUS_NO_MEMORY;
1001 TALLOC_FREE(smb_fname);
1005 static NTSTATUS streams_depot_streaminfo(vfs_handle_struct *handle,
1006 struct files_struct *fsp,
1007 const struct smb_filename *smb_fname,
1008 TALLOC_CTX *mem_ctx,
1009 unsigned int *pnum_streams,
1010 struct stream_struct **pstreams)
1012 struct smb_filename *smb_fname_base = NULL;
1015 struct streaminfo_state state;
1017 smb_fname_base = synthetic_smb_fname(talloc_tos(),
1018 smb_fname->base_name,
1023 if (smb_fname_base == NULL) {
1024 return NT_STATUS_NO_MEMORY;
1027 if ((fsp != NULL) && (fsp->fh->fd != -1)) {
1028 ret = SMB_VFS_NEXT_FSTAT(handle, fsp, &smb_fname_base->st);
1031 if (smb_fname_base->flags & SMB_FILENAME_POSIX_PATH) {
1032 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_base);
1034 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
1039 status = map_nt_error_from_unix(errno);
1043 state.streams = *pstreams;
1044 state.num_streams = *pnum_streams;
1045 state.mem_ctx = mem_ctx;
1046 state.handle = handle;
1047 state.status = NT_STATUS_OK;
1049 if (S_ISLNK(smb_fname_base->st.st_ex_mode)) {
1051 * Currently we do't have SMB_VFS_LLISTXATTR
1052 * inside the VFS which means there's no way
1053 * to cope with a symlink when lp_posix_pathnames().
1054 * returns true. For now ignore links.
1055 * FIXME - by adding SMB_VFS_LLISTXATTR. JRA.
1057 status = NT_STATUS_OK;
1059 status = walk_streams(handle, smb_fname_base, NULL, collect_one_stream,
1063 if (!NT_STATUS_IS_OK(status)) {
1064 TALLOC_FREE(state.streams);
1068 if (!NT_STATUS_IS_OK(state.status)) {
1069 TALLOC_FREE(state.streams);
1070 status = state.status;
1074 *pnum_streams = state.num_streams;
1075 *pstreams = state.streams;
1076 status = SMB_VFS_NEXT_STREAMINFO(handle,
1084 TALLOC_FREE(smb_fname_base);
1088 static uint32_t streams_depot_fs_capabilities(struct vfs_handle_struct *handle,
1089 enum timestamp_set_resolution *p_ts_res)
1091 return SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res) | FILE_NAMED_STREAMS;
1094 static struct vfs_fn_pointers vfs_streams_depot_fns = {
1095 .fs_capabilities_fn = streams_depot_fs_capabilities,
1096 .open_fn = streams_depot_open,
1097 .stat_fn = streams_depot_stat,
1098 .lstat_fn = streams_depot_lstat,
1099 .unlinkat_fn = streams_depot_unlinkat,
1100 .renameat_fn = streams_depot_renameat,
1101 .streaminfo_fn = streams_depot_streaminfo,
1105 NTSTATUS vfs_streams_depot_init(TALLOC_CTX *ctx)
1107 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "streams_depot",
1108 &vfs_streams_depot_fns);