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, const char *path)
74 DEBUG(10, ("file_is_valid (%s) called\n", path));
76 if (SMB_VFS_GETXATTR(handle->conn, path, SAMBA_XATTR_MARKER,
77 &buf, sizeof(buf)) != sizeof(buf)) {
78 DEBUG(10, ("GETXATTR failed: %s\n", strerror(errno)));
83 DEBUG(10, ("got wrong buffer content: '%c'\n", buf));
90 static bool mark_file_valid(vfs_handle_struct *handle, const char *path)
95 DEBUG(10, ("marking file %s as valid\n", path));
97 ret = SMB_VFS_SETXATTR(handle->conn, path, SAMBA_XATTR_MARKER,
98 &buf, sizeof(buf), 0);
101 DEBUG(10, ("SETXATTR failed: %s\n", strerror(errno)));
109 * Given an smb_filename, determine the stream directory using the file's
112 static char *stream_dir(vfs_handle_struct *handle,
113 const struct smb_filename *smb_fname,
114 const SMB_STRUCT_STAT *base_sbuf, bool create_it)
117 struct smb_filename *smb_fname_hash = NULL;
119 SMB_STRUCT_STAT base_sbuf_tmp;
120 uint8_t first, second;
126 char *rootdir = NULL;
127 struct smb_filename *rootdir_fname = NULL;
128 struct smb_filename *tmp_fname = NULL;
130 check_valid = lp_parm_bool(SNUM(handle->conn),
131 "streams_depot", "check_valid", true);
133 tmp = talloc_asprintf(talloc_tos(), "%s/.streams",
134 handle->conn->connectpath);
141 rootdir = lp_parm_talloc_string(talloc_tos(),
142 SNUM(handle->conn), "streams_depot", "directory",
144 if (rootdir == NULL) {
149 rootdir_fname = synthetic_smb_fname(talloc_tos(),
154 if (rootdir_fname == NULL) {
159 /* Stat the base file if it hasn't already been done. */
160 if (base_sbuf == NULL) {
161 struct smb_filename *smb_fname_base;
163 smb_fname_base = synthetic_smb_fname(
165 smb_fname->base_name,
169 if (smb_fname_base == NULL) {
173 if (SMB_VFS_NEXT_STAT(handle, smb_fname_base) == -1) {
174 TALLOC_FREE(smb_fname_base);
177 base_sbuf_tmp = smb_fname_base->st;
178 TALLOC_FREE(smb_fname_base);
180 base_sbuf_tmp = *base_sbuf;
183 id = SMB_VFS_FILE_ID_CREATE(handle->conn, &base_sbuf_tmp);
185 push_file_id_16((char *)id_buf, &id);
187 hash = hash_fn(data_blob_const(id_buf, sizeof(id_buf)));
190 second = (hash >> 8) & 0xff;
192 id_hex = hex_encode_talloc(talloc_tos(), id_buf, sizeof(id_buf));
194 if (id_hex == NULL) {
199 result = talloc_asprintf(talloc_tos(), "%s/%2.2X/%2.2X/%s", rootdir,
200 first, second, id_hex);
204 if (result == NULL) {
209 smb_fname_hash = synthetic_smb_fname(talloc_tos(),
214 if (smb_fname_hash == NULL) {
219 if (SMB_VFS_NEXT_STAT(handle, smb_fname_hash) == 0) {
220 struct smb_filename *smb_fname_new = NULL;
224 if (!S_ISDIR(smb_fname_hash->st.st_ex_mode)) {
230 file_is_valid(handle, smb_fname->base_name)) {
235 * Someone has recreated a file under an existing inode
236 * without deleting the streams directory.
237 * Move it away or remove if streams_depot:delete_lost is set.
241 delete_lost = lp_parm_bool(SNUM(handle->conn), "streams_depot",
242 "delete_lost", false);
245 DEBUG(3, ("Someone has recreated a file under an "
246 "existing inode. Removing: %s\n",
247 smb_fname_hash->base_name));
248 recursive_rmdir(talloc_tos(), handle->conn,
250 SMB_VFS_NEXT_RMDIR(handle, smb_fname_hash);
252 newname = talloc_asprintf(talloc_tos(), "lost-%lu",
254 DEBUG(3, ("Someone has recreated a file under an "
255 "existing inode. Renaming: %s to: %s\n",
256 smb_fname_hash->base_name,
258 if (newname == NULL) {
263 smb_fname_new = synthetic_smb_fname(
269 TALLOC_FREE(newname);
270 if (smb_fname_new == NULL) {
275 if (SMB_VFS_NEXT_RENAME(handle, smb_fname_hash,
276 smb_fname_new) == -1) {
277 TALLOC_FREE(smb_fname_new);
278 if ((errno == EEXIST) || (errno == ENOTEMPTY)) {
284 TALLOC_FREE(smb_fname_new);
293 if ((SMB_VFS_NEXT_MKDIR(handle, rootdir_fname, 0755) != 0)
294 && (errno != EEXIST)) {
298 tmp = talloc_asprintf(result, "%s/%2.2X", rootdir, first);
304 tmp_fname = synthetic_smb_fname(talloc_tos(),
309 if (tmp_fname == NULL) {
314 if ((SMB_VFS_NEXT_MKDIR(handle, tmp_fname, 0755) != 0)
315 && (errno != EEXIST)) {
320 TALLOC_FREE(tmp_fname);
322 tmp = talloc_asprintf(result, "%s/%2.2X/%2.2X", rootdir, first,
329 tmp_fname = synthetic_smb_fname(talloc_tos(),
334 if (tmp_fname == NULL) {
339 if ((SMB_VFS_NEXT_MKDIR(handle, tmp_fname, 0755) != 0)
340 && (errno != EEXIST)) {
345 TALLOC_FREE(tmp_fname);
347 /* smb_fname_hash is the struct smb_filename version of 'result' */
348 if ((SMB_VFS_NEXT_MKDIR(handle, smb_fname_hash, 0755) != 0)
349 && (errno != EEXIST)) {
353 if (check_valid && !mark_file_valid(handle, smb_fname->base_name)) {
357 TALLOC_FREE(rootdir_fname);
358 TALLOC_FREE(rootdir);
359 TALLOC_FREE(tmp_fname);
360 TALLOC_FREE(smb_fname_hash);
364 TALLOC_FREE(rootdir_fname);
365 TALLOC_FREE(rootdir);
366 TALLOC_FREE(tmp_fname);
367 TALLOC_FREE(smb_fname_hash);
372 * Given a stream name, populate smb_fname_out with the actual location of the
375 static NTSTATUS stream_smb_fname(vfs_handle_struct *handle,
376 const struct smb_filename *smb_fname,
377 struct smb_filename **smb_fname_out,
380 char *dirname, *stream_fname;
384 *smb_fname_out = NULL;
386 stype = strchr_m(smb_fname->stream_name + 1, ':');
389 if (strcasecmp_m(stype, ":$DATA") != 0) {
390 return NT_STATUS_INVALID_PARAMETER;
394 dirname = stream_dir(handle, smb_fname, NULL, create_dir);
396 if (dirname == NULL) {
397 status = map_nt_error_from_unix(errno);
401 stream_fname = talloc_asprintf(talloc_tos(), "%s/%s", dirname,
402 smb_fname->stream_name);
404 if (stream_fname == NULL) {
405 status = NT_STATUS_NO_MEMORY;
410 /* Append an explicit stream type if one wasn't specified. */
411 stream_fname = talloc_asprintf(talloc_tos(), "%s:$DATA",
413 if (stream_fname == NULL) {
414 status = NT_STATUS_NO_MEMORY;
418 /* Normalize the stream type to upercase. */
419 if (!strupper_m(strrchr_m(stream_fname, ':') + 1)) {
420 status = NT_STATUS_INVALID_PARAMETER;
425 DEBUG(10, ("stream filename = %s\n", stream_fname));
427 /* Create an smb_filename with stream_name == NULL. */
428 *smb_fname_out = synthetic_smb_fname(talloc_tos(),
433 if (*smb_fname_out == NULL) {
434 return NT_STATUS_NO_MEMORY;
440 DEBUG(5, ("stream_name failed: %s\n", strerror(errno)));
441 TALLOC_FREE(*smb_fname_out);
445 static NTSTATUS walk_streams(vfs_handle_struct *handle,
446 struct smb_filename *smb_fname_base,
448 bool (*fn)(const char *dirname,
454 struct smb_filename *dir_smb_fname = NULL;
455 DIR *dirhandle = NULL;
456 const char *dirent = NULL;
457 char *talloced = NULL;
459 dirname = stream_dir(handle, smb_fname_base, &smb_fname_base->st,
462 if (dirname == NULL) {
463 if (errno == ENOENT) {
469 return map_nt_error_from_unix(errno);
472 DEBUG(10, ("walk_streams: dirname=%s\n", dirname));
474 dir_smb_fname = synthetic_smb_fname(talloc_tos(),
478 smb_fname_base->flags);
479 if (dir_smb_fname == NULL) {
480 TALLOC_FREE(dirname);
481 return NT_STATUS_NO_MEMORY;
484 dirhandle = SMB_VFS_NEXT_OPENDIR(handle, dir_smb_fname, NULL, 0);
486 TALLOC_FREE(dir_smb_fname);
488 if (dirhandle == NULL) {
489 TALLOC_FREE(dirname);
490 return map_nt_error_from_unix(errno);
493 while ((dirent = vfs_readdirname(handle->conn, dirhandle, NULL,
494 &talloced)) != NULL) {
496 if (ISDOT(dirent) || ISDOTDOT(dirent)) {
497 TALLOC_FREE(talloced);
501 DEBUG(10, ("walk_streams: dirent=%s\n", dirent));
503 if (!fn(dirname, dirent, private_data)) {
504 TALLOC_FREE(talloced);
507 TALLOC_FREE(talloced);
510 SMB_VFS_NEXT_CLOSEDIR(handle, dirhandle);
512 if (pdirname != NULL) {
516 TALLOC_FREE(dirname);
523 * Helper to stat/lstat the base file of an smb_fname. This will actually
524 * fills in the stat struct in smb_filename.
526 static int streams_depot_stat_base(vfs_handle_struct *handle,
527 struct smb_filename *smb_fname,
530 char *tmp_stream_name;
533 tmp_stream_name = smb_fname->stream_name;
534 smb_fname->stream_name = NULL;
536 result = SMB_VFS_NEXT_STAT(handle, smb_fname);
538 result = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
540 smb_fname->stream_name = tmp_stream_name;
544 static int streams_depot_stat(vfs_handle_struct *handle,
545 struct smb_filename *smb_fname)
547 struct smb_filename *smb_fname_stream = NULL;
551 DEBUG(10, ("streams_depot_stat called for [%s]\n",
552 smb_fname_str_dbg(smb_fname)));
554 if (!is_ntfs_stream_smb_fname(smb_fname)) {
555 return SMB_VFS_NEXT_STAT(handle, smb_fname);
558 /* If the default stream is requested, just stat the base file. */
559 if (is_ntfs_default_stream_smb_fname(smb_fname)) {
560 return streams_depot_stat_base(handle, smb_fname, true);
563 /* Stat the actual stream now. */
564 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream,
566 if (!NT_STATUS_IS_OK(status)) {
568 errno = map_errno_from_nt_status(status);
572 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_stream);
574 /* Update the original smb_fname with the stat info. */
575 smb_fname->st = smb_fname_stream->st;
577 TALLOC_FREE(smb_fname_stream);
583 static int streams_depot_lstat(vfs_handle_struct *handle,
584 struct smb_filename *smb_fname)
586 struct smb_filename *smb_fname_stream = NULL;
590 DEBUG(10, ("streams_depot_lstat called for [%s]\n",
591 smb_fname_str_dbg(smb_fname)));
593 if (!is_ntfs_stream_smb_fname(smb_fname)) {
594 return SMB_VFS_NEXT_LSTAT(handle, smb_fname);
597 /* If the default stream is requested, just stat the base file. */
598 if (is_ntfs_default_stream_smb_fname(smb_fname)) {
599 return streams_depot_stat_base(handle, smb_fname, false);
602 /* Stat the actual stream now. */
603 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream,
605 if (!NT_STATUS_IS_OK(status)) {
607 errno = map_errno_from_nt_status(status);
611 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_stream);
614 TALLOC_FREE(smb_fname_stream);
618 static int streams_depot_open(vfs_handle_struct *handle,
619 struct smb_filename *smb_fname,
620 files_struct *fsp, int flags, mode_t mode)
622 struct smb_filename *smb_fname_stream = NULL;
623 struct smb_filename *smb_fname_base = NULL;
627 if (!is_ntfs_stream_smb_fname(smb_fname)) {
628 return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
631 /* If the default stream is requested, just open the base file. */
632 if (is_ntfs_default_stream_smb_fname(smb_fname)) {
633 char *tmp_stream_name;
635 tmp_stream_name = smb_fname->stream_name;
636 smb_fname->stream_name = NULL;
637 ret = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
638 smb_fname->stream_name = tmp_stream_name;
643 /* Ensure the base file still exists. */
644 smb_fname_base = synthetic_smb_fname(talloc_tos(),
645 smb_fname->base_name,
649 if (smb_fname_base == NULL) {
655 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
660 /* Determine the stream name, and then open it. */
661 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream, true);
662 if (!NT_STATUS_IS_OK(status)) {
664 errno = map_errno_from_nt_status(status);
668 ret = SMB_VFS_NEXT_OPEN(handle, smb_fname_stream, fsp, flags, mode);
671 TALLOC_FREE(smb_fname_stream);
672 TALLOC_FREE(smb_fname_base);
676 static int streams_depot_unlink(vfs_handle_struct *handle,
677 const struct smb_filename *smb_fname)
679 struct smb_filename *smb_fname_base = NULL;
682 DEBUG(10, ("streams_depot_unlink called for %s\n",
683 smb_fname_str_dbg(smb_fname)));
685 /* If there is a valid stream, just unlink the stream and return. */
686 if (is_ntfs_stream_smb_fname(smb_fname) &&
687 !is_ntfs_default_stream_smb_fname(smb_fname)) {
688 struct smb_filename *smb_fname_stream = NULL;
691 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream,
693 if (!NT_STATUS_IS_OK(status)) {
694 errno = map_errno_from_nt_status(status);
698 ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname_stream);
700 TALLOC_FREE(smb_fname_stream);
705 * We potentially need to delete the per-inode streams directory
708 smb_fname_base = synthetic_smb_fname(talloc_tos(),
709 smb_fname->base_name,
713 if (smb_fname_base == NULL) {
718 if (smb_fname_base->flags & SMB_FILENAME_POSIX_PATH) {
719 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_base);
721 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
725 TALLOC_FREE(smb_fname_base);
730 * We know the unlink should succeed as the ACL
731 * check is already done in the caller. Remove the
732 * file *after* the streams.
735 char *dirname = stream_dir(handle, smb_fname_base,
736 &smb_fname_base->st, false);
738 if (dirname != NULL) {
739 struct smb_filename *smb_fname_dir =
740 synthetic_smb_fname(talloc_tos(),
745 if (smb_fname_dir == NULL) {
746 TALLOC_FREE(smb_fname_base);
747 TALLOC_FREE(dirname);
751 SMB_VFS_NEXT_RMDIR(handle, smb_fname_dir);
752 TALLOC_FREE(smb_fname_dir);
754 TALLOC_FREE(dirname);
757 ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
758 TALLOC_FREE(smb_fname_base);
762 static int streams_depot_rmdir(vfs_handle_struct *handle,
763 const struct smb_filename *smb_fname)
765 struct smb_filename *smb_fname_base = NULL;
768 DEBUG(10, ("streams_depot_rmdir called for %s\n",
769 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,
780 if (smb_fname_base == NULL) {
785 if (smb_fname_base->flags & SMB_FILENAME_POSIX_PATH) {
786 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_base);
788 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
792 TALLOC_FREE(smb_fname_base);
797 * We know the rmdir should succeed as the ACL
798 * check is already done in the caller. Remove the
799 * directory *after* the streams.
802 char *dirname = stream_dir(handle, smb_fname_base,
803 &smb_fname_base->st, false);
805 if (dirname != NULL) {
806 struct smb_filename *smb_fname_dir =
807 synthetic_smb_fname(talloc_tos(),
812 if (smb_fname_dir == NULL) {
813 TALLOC_FREE(smb_fname_base);
814 TALLOC_FREE(dirname);
818 SMB_VFS_NEXT_RMDIR(handle, smb_fname_dir);
819 TALLOC_FREE(smb_fname_dir);
821 TALLOC_FREE(dirname);
824 ret = SMB_VFS_NEXT_RMDIR(handle, smb_fname_base);
825 TALLOC_FREE(smb_fname_base);
829 static int streams_depot_rename(vfs_handle_struct *handle,
830 const struct smb_filename *smb_fname_src,
831 const struct smb_filename *smb_fname_dst)
833 struct smb_filename *smb_fname_src_stream = NULL;
834 struct smb_filename *smb_fname_dst_stream = NULL;
835 bool src_is_stream, dst_is_stream;
839 DEBUG(10, ("streams_depot_rename called for %s => %s\n",
840 smb_fname_str_dbg(smb_fname_src),
841 smb_fname_str_dbg(smb_fname_dst)));
843 src_is_stream = is_ntfs_stream_smb_fname(smb_fname_src);
844 dst_is_stream = is_ntfs_stream_smb_fname(smb_fname_dst);
846 if (!src_is_stream && !dst_is_stream) {
847 return SMB_VFS_NEXT_RENAME(handle, smb_fname_src,
851 /* for now don't allow renames from or to the default stream */
852 if (is_ntfs_default_stream_smb_fname(smb_fname_src) ||
853 is_ntfs_default_stream_smb_fname(smb_fname_dst)) {
858 status = stream_smb_fname(handle, smb_fname_src, &smb_fname_src_stream,
860 if (!NT_STATUS_IS_OK(status)) {
861 errno = map_errno_from_nt_status(status);
865 status = stream_smb_fname(handle, smb_fname_dst,
866 &smb_fname_dst_stream, false);
867 if (!NT_STATUS_IS_OK(status)) {
868 errno = map_errno_from_nt_status(status);
872 ret = SMB_VFS_NEXT_RENAME(handle, smb_fname_src_stream,
873 smb_fname_dst_stream);
876 TALLOC_FREE(smb_fname_src_stream);
877 TALLOC_FREE(smb_fname_dst_stream);
881 static bool add_one_stream(TALLOC_CTX *mem_ctx, unsigned int *num_streams,
882 struct stream_struct **streams,
883 const char *name, off_t size,
886 struct stream_struct *tmp;
888 tmp = talloc_realloc(mem_ctx, *streams, struct stream_struct,
894 tmp[*num_streams].name = talloc_strdup(tmp, name);
895 if (tmp[*num_streams].name == NULL) {
899 tmp[*num_streams].size = size;
900 tmp[*num_streams].alloc_size = alloc_size;
907 struct streaminfo_state {
909 vfs_handle_struct *handle;
910 unsigned int num_streams;
911 struct stream_struct *streams;
915 static bool collect_one_stream(const char *dirname,
919 struct streaminfo_state *state =
920 (struct streaminfo_state *)private_data;
921 struct smb_filename *smb_fname = NULL;
925 sname = talloc_asprintf(talloc_tos(), "%s/%s", dirname, dirent);
927 state->status = NT_STATUS_NO_MEMORY;
932 smb_fname = synthetic_smb_fname(talloc_tos(), sname, NULL, NULL, 0);
933 if (smb_fname == NULL) {
934 state->status = NT_STATUS_NO_MEMORY;
939 if (SMB_VFS_NEXT_STAT(state->handle, smb_fname) == -1) {
940 DEBUG(10, ("Could not stat %s: %s\n", sname,
946 if (!add_one_stream(state->mem_ctx,
947 &state->num_streams, &state->streams,
948 dirent, smb_fname->st.st_ex_size,
949 SMB_VFS_GET_ALLOC_SIZE(state->handle->conn, NULL,
951 state->status = NT_STATUS_NO_MEMORY;
959 TALLOC_FREE(smb_fname);
963 static NTSTATUS streams_depot_streaminfo(vfs_handle_struct *handle,
964 struct files_struct *fsp,
965 const struct smb_filename *smb_fname,
967 unsigned int *pnum_streams,
968 struct stream_struct **pstreams)
970 struct smb_filename *smb_fname_base = NULL;
973 struct streaminfo_state state;
975 smb_fname_base = synthetic_smb_fname(talloc_tos(),
976 smb_fname->base_name,
980 if (smb_fname_base == NULL) {
981 return NT_STATUS_NO_MEMORY;
984 if ((fsp != NULL) && (fsp->fh->fd != -1)) {
985 ret = SMB_VFS_NEXT_FSTAT(handle, fsp, &smb_fname_base->st);
988 if (smb_fname_base->flags & SMB_FILENAME_POSIX_PATH) {
989 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_base);
991 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
996 status = map_nt_error_from_unix(errno);
1000 state.streams = *pstreams;
1001 state.num_streams = *pnum_streams;
1002 state.mem_ctx = mem_ctx;
1003 state.handle = handle;
1004 state.status = NT_STATUS_OK;
1006 if (S_ISLNK(smb_fname_base->st.st_ex_mode)) {
1008 * Currently we do't have SMB_VFS_LLISTXATTR
1009 * inside the VFS which means there's no way
1010 * to cope with a symlink when lp_posix_pathnames().
1011 * returns true. For now ignore links.
1012 * FIXME - by adding SMB_VFS_LLISTXATTR. JRA.
1014 status = NT_STATUS_OK;
1016 status = walk_streams(handle, smb_fname_base, NULL, collect_one_stream,
1020 if (!NT_STATUS_IS_OK(status)) {
1021 TALLOC_FREE(state.streams);
1025 if (!NT_STATUS_IS_OK(state.status)) {
1026 TALLOC_FREE(state.streams);
1027 status = state.status;
1031 *pnum_streams = state.num_streams;
1032 *pstreams = state.streams;
1033 status = SMB_VFS_NEXT_STREAMINFO(handle,
1041 TALLOC_FREE(smb_fname_base);
1045 static uint32_t streams_depot_fs_capabilities(struct vfs_handle_struct *handle,
1046 enum timestamp_set_resolution *p_ts_res)
1048 return SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res) | FILE_NAMED_STREAMS;
1051 static struct vfs_fn_pointers vfs_streams_depot_fns = {
1052 .fs_capabilities_fn = streams_depot_fs_capabilities,
1053 .open_fn = streams_depot_open,
1054 .stat_fn = streams_depot_stat,
1055 .lstat_fn = streams_depot_lstat,
1056 .unlink_fn = streams_depot_unlink,
1057 .rmdir_fn = streams_depot_rmdir,
1058 .rename_fn = streams_depot_rename,
1059 .streaminfo_fn = streams_depot_streaminfo,
1062 NTSTATUS vfs_streams_depot_init(void);
1063 NTSTATUS vfs_streams_depot_init(void)
1065 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "streams_depot",
1066 &vfs_streams_depot_fns);