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", handle->conn->cwd);
140 rootdir = lp_parm_talloc_string(talloc_tos(),
141 SNUM(handle->conn), "streams_depot", "directory",
143 if (rootdir == NULL) {
148 rootdir_fname = synthetic_smb_fname(talloc_tos(),
152 if (rootdir_fname == NULL) {
157 /* Stat the base file if it hasn't already been done. */
158 if (base_sbuf == NULL) {
159 struct smb_filename *smb_fname_base;
161 smb_fname_base = synthetic_smb_fname(
162 talloc_tos(), smb_fname->base_name, NULL, NULL);
163 if (smb_fname_base == NULL) {
167 if (SMB_VFS_NEXT_STAT(handle, smb_fname_base) == -1) {
168 TALLOC_FREE(smb_fname_base);
171 base_sbuf_tmp = smb_fname_base->st;
172 TALLOC_FREE(smb_fname_base);
174 base_sbuf_tmp = *base_sbuf;
177 id = SMB_VFS_FILE_ID_CREATE(handle->conn, &base_sbuf_tmp);
179 push_file_id_16((char *)id_buf, &id);
181 hash = hash_fn(data_blob_const(id_buf, sizeof(id_buf)));
184 second = (hash >> 8) & 0xff;
186 id_hex = hex_encode_talloc(talloc_tos(), id_buf, sizeof(id_buf));
188 if (id_hex == NULL) {
193 result = talloc_asprintf(talloc_tos(), "%s/%2.2X/%2.2X/%s", rootdir,
194 first, second, id_hex);
198 if (result == NULL) {
203 smb_fname_hash = synthetic_smb_fname(talloc_tos(), result, NULL, NULL);
204 if (smb_fname_hash == NULL) {
209 if (SMB_VFS_NEXT_STAT(handle, smb_fname_hash) == 0) {
210 struct smb_filename *smb_fname_new = NULL;
214 if (!S_ISDIR(smb_fname_hash->st.st_ex_mode)) {
220 file_is_valid(handle, smb_fname->base_name)) {
225 * Someone has recreated a file under an existing inode
226 * without deleting the streams directory.
227 * Move it away or remove if streams_depot:delete_lost is set.
231 delete_lost = lp_parm_bool(SNUM(handle->conn), "streams_depot",
232 "delete_lost", false);
235 DEBUG(3, ("Someone has recreated a file under an "
236 "existing inode. Removing: %s\n",
237 smb_fname_hash->base_name));
238 recursive_rmdir(talloc_tos(), handle->conn,
240 SMB_VFS_NEXT_RMDIR(handle, smb_fname_hash);
242 newname = talloc_asprintf(talloc_tos(), "lost-%lu",
244 DEBUG(3, ("Someone has recreated a file under an "
245 "existing inode. Renaming: %s to: %s\n",
246 smb_fname_hash->base_name,
248 if (newname == NULL) {
253 smb_fname_new = synthetic_smb_fname(
254 talloc_tos(), newname, NULL, NULL);
255 TALLOC_FREE(newname);
256 if (smb_fname_new == NULL) {
261 if (SMB_VFS_NEXT_RENAME(handle, smb_fname_hash,
262 smb_fname_new) == -1) {
263 TALLOC_FREE(smb_fname_new);
264 if ((errno == EEXIST) || (errno == ENOTEMPTY)) {
270 TALLOC_FREE(smb_fname_new);
279 if ((SMB_VFS_NEXT_MKDIR(handle, rootdir_fname, 0755) != 0)
280 && (errno != EEXIST)) {
284 tmp = talloc_asprintf(result, "%s/%2.2X", rootdir, first);
290 tmp_fname = synthetic_smb_fname(talloc_tos(), tmp, NULL, NULL);
291 if (tmp_fname == NULL) {
296 if ((SMB_VFS_NEXT_MKDIR(handle, tmp_fname, 0755) != 0)
297 && (errno != EEXIST)) {
302 TALLOC_FREE(tmp_fname);
304 tmp = talloc_asprintf(result, "%s/%2.2X/%2.2X", rootdir, first,
311 tmp_fname = synthetic_smb_fname(talloc_tos(), tmp, NULL, NULL);
312 if (tmp_fname == NULL) {
317 if ((SMB_VFS_NEXT_MKDIR(handle, tmp_fname, 0755) != 0)
318 && (errno != EEXIST)) {
323 TALLOC_FREE(tmp_fname);
325 /* smb_fname_hash is the struct smb_filename version of 'result' */
326 if ((SMB_VFS_NEXT_MKDIR(handle, smb_fname_hash, 0755) != 0)
327 && (errno != EEXIST)) {
331 if (check_valid && !mark_file_valid(handle, smb_fname->base_name)) {
335 TALLOC_FREE(rootdir_fname);
336 TALLOC_FREE(rootdir);
337 TALLOC_FREE(tmp_fname);
338 TALLOC_FREE(smb_fname_hash);
342 TALLOC_FREE(rootdir_fname);
343 TALLOC_FREE(rootdir);
344 TALLOC_FREE(tmp_fname);
345 TALLOC_FREE(smb_fname_hash);
350 * Given a stream name, populate smb_fname_out with the actual location of the
353 static NTSTATUS stream_smb_fname(vfs_handle_struct *handle,
354 const struct smb_filename *smb_fname,
355 struct smb_filename **smb_fname_out,
358 char *dirname, *stream_fname;
362 *smb_fname_out = NULL;
364 stype = strchr_m(smb_fname->stream_name + 1, ':');
367 if (strcasecmp_m(stype, ":$DATA") != 0) {
368 return NT_STATUS_INVALID_PARAMETER;
372 dirname = stream_dir(handle, smb_fname, NULL, create_dir);
374 if (dirname == NULL) {
375 status = map_nt_error_from_unix(errno);
379 stream_fname = talloc_asprintf(talloc_tos(), "%s/%s", dirname,
380 smb_fname->stream_name);
382 if (stream_fname == NULL) {
383 status = NT_STATUS_NO_MEMORY;
388 /* Append an explicit stream type if one wasn't specified. */
389 stream_fname = talloc_asprintf(talloc_tos(), "%s:$DATA",
391 if (stream_fname == NULL) {
392 status = NT_STATUS_NO_MEMORY;
396 /* Normalize the stream type to upercase. */
397 if (!strupper_m(strrchr_m(stream_fname, ':') + 1)) {
398 status = NT_STATUS_INVALID_PARAMETER;
403 DEBUG(10, ("stream filename = %s\n", stream_fname));
405 /* Create an smb_filename with stream_name == NULL. */
406 *smb_fname_out = synthetic_smb_fname(
407 talloc_tos(), stream_fname, NULL, NULL);
408 if (*smb_fname_out == NULL) {
409 return NT_STATUS_NO_MEMORY;
415 DEBUG(5, ("stream_name failed: %s\n", strerror(errno)));
416 TALLOC_FREE(*smb_fname_out);
420 static NTSTATUS walk_streams(vfs_handle_struct *handle,
421 struct smb_filename *smb_fname_base,
423 bool (*fn)(const char *dirname,
429 struct smb_filename *dir_smb_fname = NULL;
430 DIR *dirhandle = NULL;
431 const char *dirent = NULL;
432 char *talloced = NULL;
434 dirname = stream_dir(handle, smb_fname_base, &smb_fname_base->st,
437 if (dirname == NULL) {
438 if (errno == ENOENT) {
444 return map_nt_error_from_unix(errno);
447 DEBUG(10, ("walk_streams: dirname=%s\n", dirname));
449 dir_smb_fname = synthetic_smb_fname(talloc_tos(),
453 if (dir_smb_fname == NULL) {
454 TALLOC_FREE(dirname);
455 return NT_STATUS_NO_MEMORY;
458 dirhandle = SMB_VFS_NEXT_OPENDIR(handle, dir_smb_fname, NULL, 0);
460 TALLOC_FREE(dir_smb_fname);
462 if (dirhandle == NULL) {
463 TALLOC_FREE(dirname);
464 return map_nt_error_from_unix(errno);
467 while ((dirent = vfs_readdirname(handle->conn, dirhandle, NULL,
468 &talloced)) != NULL) {
470 if (ISDOT(dirent) || ISDOTDOT(dirent)) {
471 TALLOC_FREE(talloced);
475 DEBUG(10, ("walk_streams: dirent=%s\n", dirent));
477 if (!fn(dirname, dirent, private_data)) {
478 TALLOC_FREE(talloced);
481 TALLOC_FREE(talloced);
484 SMB_VFS_NEXT_CLOSEDIR(handle, dirhandle);
486 if (pdirname != NULL) {
490 TALLOC_FREE(dirname);
497 * Helper to stat/lstat the base file of an smb_fname. This will actually
498 * fills in the stat struct in smb_filename.
500 static int streams_depot_stat_base(vfs_handle_struct *handle,
501 struct smb_filename *smb_fname,
504 char *tmp_stream_name;
507 tmp_stream_name = smb_fname->stream_name;
508 smb_fname->stream_name = NULL;
510 result = SMB_VFS_NEXT_STAT(handle, smb_fname);
512 result = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
514 smb_fname->stream_name = tmp_stream_name;
518 static int streams_depot_stat(vfs_handle_struct *handle,
519 struct smb_filename *smb_fname)
521 struct smb_filename *smb_fname_stream = NULL;
525 DEBUG(10, ("streams_depot_stat called for [%s]\n",
526 smb_fname_str_dbg(smb_fname)));
528 if (!is_ntfs_stream_smb_fname(smb_fname)) {
529 return SMB_VFS_NEXT_STAT(handle, smb_fname);
532 /* If the default stream is requested, just stat the base file. */
533 if (is_ntfs_default_stream_smb_fname(smb_fname)) {
534 return streams_depot_stat_base(handle, smb_fname, true);
537 /* Stat the actual stream now. */
538 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream,
540 if (!NT_STATUS_IS_OK(status)) {
542 errno = map_errno_from_nt_status(status);
546 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_stream);
548 /* Update the original smb_fname with the stat info. */
549 smb_fname->st = smb_fname_stream->st;
551 TALLOC_FREE(smb_fname_stream);
557 static int streams_depot_lstat(vfs_handle_struct *handle,
558 struct smb_filename *smb_fname)
560 struct smb_filename *smb_fname_stream = NULL;
564 DEBUG(10, ("streams_depot_lstat called for [%s]\n",
565 smb_fname_str_dbg(smb_fname)));
567 if (!is_ntfs_stream_smb_fname(smb_fname)) {
568 return SMB_VFS_NEXT_LSTAT(handle, smb_fname);
571 /* If the default stream is requested, just stat the base file. */
572 if (is_ntfs_default_stream_smb_fname(smb_fname)) {
573 return streams_depot_stat_base(handle, smb_fname, false);
576 /* Stat the actual stream now. */
577 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream,
579 if (!NT_STATUS_IS_OK(status)) {
581 errno = map_errno_from_nt_status(status);
585 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_stream);
588 TALLOC_FREE(smb_fname_stream);
592 static int streams_depot_open(vfs_handle_struct *handle,
593 struct smb_filename *smb_fname,
594 files_struct *fsp, int flags, mode_t mode)
596 struct smb_filename *smb_fname_stream = NULL;
597 struct smb_filename *smb_fname_base = NULL;
601 if (!is_ntfs_stream_smb_fname(smb_fname)) {
602 return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
605 /* If the default stream is requested, just open the base file. */
606 if (is_ntfs_default_stream_smb_fname(smb_fname)) {
607 char *tmp_stream_name;
609 tmp_stream_name = smb_fname->stream_name;
610 smb_fname->stream_name = NULL;
611 ret = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
612 smb_fname->stream_name = tmp_stream_name;
617 /* Ensure the base file still exists. */
618 smb_fname_base = synthetic_smb_fname(
619 talloc_tos(), smb_fname->base_name, NULL, NULL);
620 if (smb_fname_base == NULL) {
626 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
631 /* Determine the stream name, and then open it. */
632 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream, true);
633 if (!NT_STATUS_IS_OK(status)) {
635 errno = map_errno_from_nt_status(status);
639 ret = SMB_VFS_NEXT_OPEN(handle, smb_fname_stream, fsp, flags, mode);
642 TALLOC_FREE(smb_fname_stream);
643 TALLOC_FREE(smb_fname_base);
647 static int streams_depot_unlink(vfs_handle_struct *handle,
648 const struct smb_filename *smb_fname)
650 struct smb_filename *smb_fname_base = NULL;
653 DEBUG(10, ("streams_depot_unlink called for %s\n",
654 smb_fname_str_dbg(smb_fname)));
656 /* If there is a valid stream, just unlink the stream and return. */
657 if (is_ntfs_stream_smb_fname(smb_fname) &&
658 !is_ntfs_default_stream_smb_fname(smb_fname)) {
659 struct smb_filename *smb_fname_stream = NULL;
662 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream,
664 if (!NT_STATUS_IS_OK(status)) {
665 errno = map_errno_from_nt_status(status);
669 ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname_stream);
671 TALLOC_FREE(smb_fname_stream);
676 * We potentially need to delete the per-inode streams directory
679 smb_fname_base = synthetic_smb_fname(
680 talloc_tos(), smb_fname->base_name, NULL, NULL);
681 if (smb_fname_base == NULL) {
686 if (lp_posix_pathnames()) {
687 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_base);
689 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
693 TALLOC_FREE(smb_fname_base);
697 ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
699 char *dirname = stream_dir(handle, smb_fname_base,
700 &smb_fname_base->st, false);
702 if (dirname != NULL) {
703 struct smb_filename *smb_fname_dir =
704 synthetic_smb_fname(talloc_tos(),
708 if (smb_fname_dir == NULL) {
709 TALLOC_FREE(smb_fname_base);
710 TALLOC_FREE(dirname);
714 SMB_VFS_NEXT_RMDIR(handle, smb_fname_dir);
715 TALLOC_FREE(smb_fname_dir);
717 TALLOC_FREE(dirname);
720 TALLOC_FREE(smb_fname_base);
724 static int streams_depot_rmdir(vfs_handle_struct *handle,
725 const struct smb_filename *smb_fname)
727 struct smb_filename *smb_fname_base = NULL;
730 DEBUG(10, ("streams_depot_rmdir called for %s\n",
731 smb_fname->base_name));
734 * We potentially need to delete the per-inode streams directory
737 smb_fname_base = synthetic_smb_fname(talloc_tos(),
738 smb_fname->base_name,
741 if (smb_fname_base == NULL) {
746 if (lp_posix_pathnames()) {
747 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_base);
749 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
753 TALLOC_FREE(smb_fname_base);
757 ret = SMB_VFS_NEXT_RMDIR(handle, smb_fname_base);
759 char *dirname = stream_dir(handle, smb_fname_base,
760 &smb_fname_base->st, false);
762 if (dirname != NULL) {
763 struct smb_filename *smb_fname_dir =
764 synthetic_smb_fname(talloc_tos(),
768 if (smb_fname_dir == NULL) {
769 TALLOC_FREE(smb_fname_base);
770 TALLOC_FREE(dirname);
774 SMB_VFS_NEXT_RMDIR(handle, smb_fname_dir);
775 TALLOC_FREE(smb_fname_dir);
777 TALLOC_FREE(dirname);
780 TALLOC_FREE(smb_fname_base);
784 static int streams_depot_rename(vfs_handle_struct *handle,
785 const struct smb_filename *smb_fname_src,
786 const struct smb_filename *smb_fname_dst)
788 struct smb_filename *smb_fname_src_stream = NULL;
789 struct smb_filename *smb_fname_dst_stream = NULL;
790 bool src_is_stream, dst_is_stream;
794 DEBUG(10, ("streams_depot_rename called for %s => %s\n",
795 smb_fname_str_dbg(smb_fname_src),
796 smb_fname_str_dbg(smb_fname_dst)));
798 src_is_stream = is_ntfs_stream_smb_fname(smb_fname_src);
799 dst_is_stream = is_ntfs_stream_smb_fname(smb_fname_dst);
801 if (!src_is_stream && !dst_is_stream) {
802 return SMB_VFS_NEXT_RENAME(handle, smb_fname_src,
806 /* for now don't allow renames from or to the default stream */
807 if (is_ntfs_default_stream_smb_fname(smb_fname_src) ||
808 is_ntfs_default_stream_smb_fname(smb_fname_dst)) {
813 status = stream_smb_fname(handle, smb_fname_src, &smb_fname_src_stream,
815 if (!NT_STATUS_IS_OK(status)) {
816 errno = map_errno_from_nt_status(status);
820 status = stream_smb_fname(handle, smb_fname_dst,
821 &smb_fname_dst_stream, false);
822 if (!NT_STATUS_IS_OK(status)) {
823 errno = map_errno_from_nt_status(status);
827 ret = SMB_VFS_NEXT_RENAME(handle, smb_fname_src_stream,
828 smb_fname_dst_stream);
831 TALLOC_FREE(smb_fname_src_stream);
832 TALLOC_FREE(smb_fname_dst_stream);
836 static bool add_one_stream(TALLOC_CTX *mem_ctx, unsigned int *num_streams,
837 struct stream_struct **streams,
838 const char *name, off_t size,
841 struct stream_struct *tmp;
843 tmp = talloc_realloc(mem_ctx, *streams, struct stream_struct,
849 tmp[*num_streams].name = talloc_strdup(tmp, name);
850 if (tmp[*num_streams].name == NULL) {
854 tmp[*num_streams].size = size;
855 tmp[*num_streams].alloc_size = alloc_size;
862 struct streaminfo_state {
864 vfs_handle_struct *handle;
865 unsigned int num_streams;
866 struct stream_struct *streams;
870 static bool collect_one_stream(const char *dirname,
874 struct streaminfo_state *state =
875 (struct streaminfo_state *)private_data;
876 struct smb_filename *smb_fname = NULL;
880 sname = talloc_asprintf(talloc_tos(), "%s/%s", dirname, dirent);
882 state->status = NT_STATUS_NO_MEMORY;
887 smb_fname = synthetic_smb_fname(talloc_tos(), sname, NULL, NULL);
888 if (smb_fname == NULL) {
889 state->status = NT_STATUS_NO_MEMORY;
894 if (SMB_VFS_NEXT_STAT(state->handle, smb_fname) == -1) {
895 DEBUG(10, ("Could not stat %s: %s\n", sname,
901 if (!add_one_stream(state->mem_ctx,
902 &state->num_streams, &state->streams,
903 dirent, smb_fname->st.st_ex_size,
904 SMB_VFS_GET_ALLOC_SIZE(state->handle->conn, NULL,
906 state->status = NT_STATUS_NO_MEMORY;
914 TALLOC_FREE(smb_fname);
918 static NTSTATUS streams_depot_streaminfo(vfs_handle_struct *handle,
919 struct files_struct *fsp,
920 const struct smb_filename *smb_fname,
922 unsigned int *pnum_streams,
923 struct stream_struct **pstreams)
925 struct smb_filename *smb_fname_base = NULL;
928 struct streaminfo_state state;
930 smb_fname_base = synthetic_smb_fname(talloc_tos(),
931 smb_fname->base_name,
934 if (smb_fname_base == NULL) {
935 return NT_STATUS_NO_MEMORY;
938 if ((fsp != NULL) && (fsp->fh->fd != -1)) {
939 ret = SMB_VFS_NEXT_FSTAT(handle, fsp, &smb_fname_base->st);
942 if (lp_posix_pathnames()) {
943 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_base);
945 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
950 status = map_nt_error_from_unix(errno);
954 state.streams = *pstreams;
955 state.num_streams = *pnum_streams;
956 state.mem_ctx = mem_ctx;
957 state.handle = handle;
958 state.status = NT_STATUS_OK;
960 if (S_ISLNK(smb_fname_base->st.st_ex_mode)) {
962 * Currently we do't have SMB_VFS_LLISTXATTR
963 * inside the VFS which means there's no way
964 * to cope with a symlink when lp_posix_pathnames().
965 * returns true. For now ignore links.
966 * FIXME - by adding SMB_VFS_LLISTXATTR. JRA.
968 status = NT_STATUS_OK;
970 status = walk_streams(handle, smb_fname_base, NULL, collect_one_stream,
974 if (!NT_STATUS_IS_OK(status)) {
975 TALLOC_FREE(state.streams);
979 if (!NT_STATUS_IS_OK(state.status)) {
980 TALLOC_FREE(state.streams);
981 status = state.status;
985 *pnum_streams = state.num_streams;
986 *pstreams = state.streams;
987 status = SMB_VFS_NEXT_STREAMINFO(handle,
995 TALLOC_FREE(smb_fname_base);
999 static uint32_t streams_depot_fs_capabilities(struct vfs_handle_struct *handle,
1000 enum timestamp_set_resolution *p_ts_res)
1002 return SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res) | FILE_NAMED_STREAMS;
1005 static struct vfs_fn_pointers vfs_streams_depot_fns = {
1006 .fs_capabilities_fn = streams_depot_fs_capabilities,
1007 .open_fn = streams_depot_open,
1008 .stat_fn = streams_depot_stat,
1009 .lstat_fn = streams_depot_lstat,
1010 .unlink_fn = streams_depot_unlink,
1011 .rmdir_fn = streams_depot_rmdir,
1012 .rename_fn = streams_depot_rename,
1013 .streaminfo_fn = streams_depot_streaminfo,
1016 NTSTATUS vfs_streams_depot_init(void);
1017 NTSTATUS vfs_streams_depot_init(void)
1019 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "streams_depot",
1020 &vfs_streams_depot_fns);