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;
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_const_string(
141 SNUM(handle->conn), "streams_depot", "directory",
144 rootdir_fname = synthetic_smb_fname(talloc_tos(),
148 if (rootdir_fname == NULL) {
153 /* Stat the base file if it hasn't already been done. */
154 if (base_sbuf == NULL) {
155 struct smb_filename *smb_fname_base;
157 smb_fname_base = synthetic_smb_fname(
158 talloc_tos(), smb_fname->base_name, NULL, NULL);
159 if (smb_fname_base == NULL) {
163 if (SMB_VFS_NEXT_STAT(handle, smb_fname_base) == -1) {
164 TALLOC_FREE(smb_fname_base);
167 base_sbuf_tmp = smb_fname_base->st;
168 TALLOC_FREE(smb_fname_base);
170 base_sbuf_tmp = *base_sbuf;
173 id = SMB_VFS_FILE_ID_CREATE(handle->conn, &base_sbuf_tmp);
175 push_file_id_16((char *)id_buf, &id);
177 hash = hash_fn(data_blob_const(id_buf, sizeof(id_buf)));
180 second = (hash >> 8) & 0xff;
182 id_hex = hex_encode_talloc(talloc_tos(), id_buf, sizeof(id_buf));
184 if (id_hex == NULL) {
189 result = talloc_asprintf(talloc_tos(), "%s/%2.2X/%2.2X/%s", rootdir,
190 first, second, id_hex);
194 if (result == NULL) {
199 smb_fname_hash = synthetic_smb_fname(talloc_tos(), result, NULL, NULL);
200 if (smb_fname_hash == NULL) {
205 if (SMB_VFS_NEXT_STAT(handle, smb_fname_hash) == 0) {
206 struct smb_filename *smb_fname_new = NULL;
210 if (!S_ISDIR(smb_fname_hash->st.st_ex_mode)) {
216 file_is_valid(handle, smb_fname->base_name)) {
221 * Someone has recreated a file under an existing inode
222 * without deleting the streams directory.
223 * Move it away or remove if streams_depot:delete_lost is set.
227 delete_lost = lp_parm_bool(SNUM(handle->conn), "streams_depot",
228 "delete_lost", false);
231 DEBUG(3, ("Someone has recreated a file under an "
232 "existing inode. Removing: %s\n",
233 smb_fname_hash->base_name));
234 recursive_rmdir(talloc_tos(), handle->conn,
236 SMB_VFS_NEXT_RMDIR(handle, smb_fname_hash);
238 newname = talloc_asprintf(talloc_tos(), "lost-%lu",
240 DEBUG(3, ("Someone has recreated a file under an "
241 "existing inode. Renaming: %s to: %s\n",
242 smb_fname_hash->base_name,
244 if (newname == NULL) {
249 smb_fname_new = synthetic_smb_fname(
250 talloc_tos(), newname, NULL, NULL);
251 TALLOC_FREE(newname);
252 if (smb_fname_new == NULL) {
257 if (SMB_VFS_NEXT_RENAME(handle, smb_fname_hash,
258 smb_fname_new) == -1) {
259 TALLOC_FREE(smb_fname_new);
260 if ((errno == EEXIST) || (errno == ENOTEMPTY)) {
266 TALLOC_FREE(smb_fname_new);
275 if ((SMB_VFS_NEXT_MKDIR(handle, rootdir_fname, 0755) != 0)
276 && (errno != EEXIST)) {
280 tmp = talloc_asprintf(result, "%s/%2.2X", rootdir, first);
286 tmp_fname = synthetic_smb_fname(talloc_tos(), tmp, NULL, NULL);
287 if (tmp_fname == NULL) {
292 if ((SMB_VFS_NEXT_MKDIR(handle, tmp_fname, 0755) != 0)
293 && (errno != EEXIST)) {
298 TALLOC_FREE(tmp_fname);
300 tmp = talloc_asprintf(result, "%s/%2.2X/%2.2X", rootdir, first,
307 tmp_fname = synthetic_smb_fname(talloc_tos(), tmp, NULL, NULL);
308 if (tmp_fname == NULL) {
313 if ((SMB_VFS_NEXT_MKDIR(handle, tmp_fname, 0755) != 0)
314 && (errno != EEXIST)) {
319 TALLOC_FREE(tmp_fname);
321 /* smb_fname_hash is the struct smb_filename version of 'result' */
322 if ((SMB_VFS_NEXT_MKDIR(handle, smb_fname_hash, 0755) != 0)
323 && (errno != EEXIST)) {
327 if (check_valid && !mark_file_valid(handle, smb_fname->base_name)) {
331 TALLOC_FREE(rootdir_fname);
332 TALLOC_FREE(tmp_fname);
333 TALLOC_FREE(smb_fname_hash);
337 TALLOC_FREE(rootdir_fname);
338 TALLOC_FREE(tmp_fname);
339 TALLOC_FREE(smb_fname_hash);
344 * Given a stream name, populate smb_fname_out with the actual location of the
347 static NTSTATUS stream_smb_fname(vfs_handle_struct *handle,
348 const struct smb_filename *smb_fname,
349 struct smb_filename **smb_fname_out,
352 char *dirname, *stream_fname;
356 *smb_fname_out = NULL;
358 stype = strchr_m(smb_fname->stream_name + 1, ':');
361 if (strcasecmp_m(stype, ":$DATA") != 0) {
362 return NT_STATUS_INVALID_PARAMETER;
366 dirname = stream_dir(handle, smb_fname, NULL, create_dir);
368 if (dirname == NULL) {
369 status = map_nt_error_from_unix(errno);
373 stream_fname = talloc_asprintf(talloc_tos(), "%s/%s", dirname,
374 smb_fname->stream_name);
376 if (stream_fname == NULL) {
377 status = NT_STATUS_NO_MEMORY;
382 /* Append an explicit stream type if one wasn't specified. */
383 stream_fname = talloc_asprintf(talloc_tos(), "%s:$DATA",
385 if (stream_fname == NULL) {
386 status = NT_STATUS_NO_MEMORY;
390 /* Normalize the stream type to upercase. */
391 if (!strupper_m(strrchr_m(stream_fname, ':') + 1)) {
392 status = NT_STATUS_INVALID_PARAMETER;
397 DEBUG(10, ("stream filename = %s\n", stream_fname));
399 /* Create an smb_filename with stream_name == NULL. */
400 *smb_fname_out = synthetic_smb_fname(
401 talloc_tos(), stream_fname, NULL, NULL);
402 if (*smb_fname_out == NULL) {
403 return NT_STATUS_NO_MEMORY;
409 DEBUG(5, ("stream_name failed: %s\n", strerror(errno)));
410 TALLOC_FREE(*smb_fname_out);
414 static NTSTATUS walk_streams(vfs_handle_struct *handle,
415 struct smb_filename *smb_fname_base,
417 bool (*fn)(const char *dirname,
423 struct smb_filename *dir_smb_fname = NULL;
424 DIR *dirhandle = NULL;
425 const char *dirent = NULL;
426 char *talloced = NULL;
428 dirname = stream_dir(handle, smb_fname_base, &smb_fname_base->st,
431 if (dirname == NULL) {
432 if (errno == ENOENT) {
438 return map_nt_error_from_unix(errno);
441 DEBUG(10, ("walk_streams: dirname=%s\n", dirname));
443 dir_smb_fname = synthetic_smb_fname(talloc_tos(),
447 if (dir_smb_fname == NULL) {
448 TALLOC_FREE(dirname);
449 return NT_STATUS_NO_MEMORY;
452 dirhandle = SMB_VFS_NEXT_OPENDIR(handle, dir_smb_fname, NULL, 0);
454 TALLOC_FREE(dir_smb_fname);
456 if (dirhandle == NULL) {
457 TALLOC_FREE(dirname);
458 return map_nt_error_from_unix(errno);
461 while ((dirent = vfs_readdirname(handle->conn, dirhandle, NULL,
462 &talloced)) != NULL) {
464 if (ISDOT(dirent) || ISDOTDOT(dirent)) {
465 TALLOC_FREE(talloced);
469 DEBUG(10, ("walk_streams: dirent=%s\n", dirent));
471 if (!fn(dirname, dirent, private_data)) {
472 TALLOC_FREE(talloced);
475 TALLOC_FREE(talloced);
478 SMB_VFS_NEXT_CLOSEDIR(handle, dirhandle);
480 if (pdirname != NULL) {
484 TALLOC_FREE(dirname);
491 * Helper to stat/lstat the base file of an smb_fname. This will actually
492 * fills in the stat struct in smb_filename.
494 static int streams_depot_stat_base(vfs_handle_struct *handle,
495 struct smb_filename *smb_fname,
498 char *tmp_stream_name;
501 tmp_stream_name = smb_fname->stream_name;
502 smb_fname->stream_name = NULL;
504 result = SMB_VFS_NEXT_STAT(handle, smb_fname);
506 result = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
508 smb_fname->stream_name = tmp_stream_name;
512 static int streams_depot_stat(vfs_handle_struct *handle,
513 struct smb_filename *smb_fname)
515 struct smb_filename *smb_fname_stream = NULL;
519 DEBUG(10, ("streams_depot_stat called for [%s]\n",
520 smb_fname_str_dbg(smb_fname)));
522 if (!is_ntfs_stream_smb_fname(smb_fname)) {
523 return SMB_VFS_NEXT_STAT(handle, smb_fname);
526 /* If the default stream is requested, just stat the base file. */
527 if (is_ntfs_default_stream_smb_fname(smb_fname)) {
528 return streams_depot_stat_base(handle, smb_fname, true);
531 /* Stat the actual stream now. */
532 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream,
534 if (!NT_STATUS_IS_OK(status)) {
536 errno = map_errno_from_nt_status(status);
540 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_stream);
542 /* Update the original smb_fname with the stat info. */
543 smb_fname->st = smb_fname_stream->st;
545 TALLOC_FREE(smb_fname_stream);
551 static int streams_depot_lstat(vfs_handle_struct *handle,
552 struct smb_filename *smb_fname)
554 struct smb_filename *smb_fname_stream = NULL;
558 DEBUG(10, ("streams_depot_lstat called for [%s]\n",
559 smb_fname_str_dbg(smb_fname)));
561 if (!is_ntfs_stream_smb_fname(smb_fname)) {
562 return SMB_VFS_NEXT_LSTAT(handle, smb_fname);
565 /* If the default stream is requested, just stat the base file. */
566 if (is_ntfs_default_stream_smb_fname(smb_fname)) {
567 return streams_depot_stat_base(handle, smb_fname, false);
570 /* Stat the actual stream now. */
571 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream,
573 if (!NT_STATUS_IS_OK(status)) {
575 errno = map_errno_from_nt_status(status);
579 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_stream);
582 TALLOC_FREE(smb_fname_stream);
586 static int streams_depot_open(vfs_handle_struct *handle,
587 struct smb_filename *smb_fname,
588 files_struct *fsp, int flags, mode_t mode)
590 struct smb_filename *smb_fname_stream = NULL;
591 struct smb_filename *smb_fname_base = NULL;
595 if (!is_ntfs_stream_smb_fname(smb_fname)) {
596 return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
599 /* If the default stream is requested, just open the base file. */
600 if (is_ntfs_default_stream_smb_fname(smb_fname)) {
601 char *tmp_stream_name;
603 tmp_stream_name = smb_fname->stream_name;
604 smb_fname->stream_name = NULL;
605 ret = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
606 smb_fname->stream_name = tmp_stream_name;
611 /* Ensure the base file still exists. */
612 smb_fname_base = synthetic_smb_fname(
613 talloc_tos(), smb_fname->base_name, NULL, NULL);
614 if (smb_fname_base == NULL) {
620 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
625 /* Determine the stream name, and then open it. */
626 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream, true);
627 if (!NT_STATUS_IS_OK(status)) {
629 errno = map_errno_from_nt_status(status);
633 ret = SMB_VFS_NEXT_OPEN(handle, smb_fname_stream, fsp, flags, mode);
636 TALLOC_FREE(smb_fname_stream);
637 TALLOC_FREE(smb_fname_base);
641 static int streams_depot_unlink(vfs_handle_struct *handle,
642 const struct smb_filename *smb_fname)
644 struct smb_filename *smb_fname_base = NULL;
647 DEBUG(10, ("streams_depot_unlink called for %s\n",
648 smb_fname_str_dbg(smb_fname)));
650 /* If there is a valid stream, just unlink the stream and return. */
651 if (is_ntfs_stream_smb_fname(smb_fname) &&
652 !is_ntfs_default_stream_smb_fname(smb_fname)) {
653 struct smb_filename *smb_fname_stream = NULL;
656 status = stream_smb_fname(handle, smb_fname, &smb_fname_stream,
658 if (!NT_STATUS_IS_OK(status)) {
659 errno = map_errno_from_nt_status(status);
663 ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname_stream);
665 TALLOC_FREE(smb_fname_stream);
670 * We potentially need to delete the per-inode streams directory
673 smb_fname_base = synthetic_smb_fname(
674 talloc_tos(), smb_fname->base_name, NULL, NULL);
675 if (smb_fname_base == NULL) {
680 if (lp_posix_pathnames()) {
681 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_base);
683 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
687 TALLOC_FREE(smb_fname_base);
691 ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
693 char *dirname = stream_dir(handle, smb_fname_base,
694 &smb_fname_base->st, false);
696 if (dirname != NULL) {
697 struct smb_filename *smb_fname_dir =
698 synthetic_smb_fname(talloc_tos(),
702 if (smb_fname_dir == NULL) {
703 TALLOC_FREE(smb_fname_base);
704 TALLOC_FREE(dirname);
708 SMB_VFS_NEXT_RMDIR(handle, smb_fname_dir);
709 TALLOC_FREE(smb_fname_dir);
711 TALLOC_FREE(dirname);
714 TALLOC_FREE(smb_fname_base);
718 static int streams_depot_rmdir(vfs_handle_struct *handle,
719 const struct smb_filename *smb_fname)
721 struct smb_filename *smb_fname_base = NULL;
724 DEBUG(10, ("streams_depot_rmdir called for %s\n",
725 smb_fname->base_name));
728 * We potentially need to delete the per-inode streams directory
731 smb_fname_base = synthetic_smb_fname(talloc_tos(),
732 smb_fname->base_name,
735 if (smb_fname_base == NULL) {
740 if (lp_posix_pathnames()) {
741 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_base);
743 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
747 TALLOC_FREE(smb_fname_base);
751 ret = SMB_VFS_NEXT_RMDIR(handle, smb_fname_base);
753 char *dirname = stream_dir(handle, smb_fname_base,
754 &smb_fname_base->st, false);
756 if (dirname != NULL) {
757 struct smb_filename *smb_fname_dir =
758 synthetic_smb_fname(talloc_tos(),
762 if (smb_fname_dir == NULL) {
763 TALLOC_FREE(smb_fname_base);
764 TALLOC_FREE(dirname);
768 SMB_VFS_NEXT_RMDIR(handle, smb_fname_dir);
769 TALLOC_FREE(smb_fname_dir);
771 TALLOC_FREE(dirname);
774 TALLOC_FREE(smb_fname_base);
778 static int streams_depot_rename(vfs_handle_struct *handle,
779 const struct smb_filename *smb_fname_src,
780 const struct smb_filename *smb_fname_dst)
782 struct smb_filename *smb_fname_src_stream = NULL;
783 struct smb_filename *smb_fname_dst_stream = NULL;
784 bool src_is_stream, dst_is_stream;
788 DEBUG(10, ("streams_depot_rename called for %s => %s\n",
789 smb_fname_str_dbg(smb_fname_src),
790 smb_fname_str_dbg(smb_fname_dst)));
792 src_is_stream = is_ntfs_stream_smb_fname(smb_fname_src);
793 dst_is_stream = is_ntfs_stream_smb_fname(smb_fname_dst);
795 if (!src_is_stream && !dst_is_stream) {
796 return SMB_VFS_NEXT_RENAME(handle, smb_fname_src,
800 /* for now don't allow renames from or to the default stream */
801 if (is_ntfs_default_stream_smb_fname(smb_fname_src) ||
802 is_ntfs_default_stream_smb_fname(smb_fname_dst)) {
807 status = stream_smb_fname(handle, smb_fname_src, &smb_fname_src_stream,
809 if (!NT_STATUS_IS_OK(status)) {
810 errno = map_errno_from_nt_status(status);
814 status = stream_smb_fname(handle, smb_fname_dst,
815 &smb_fname_dst_stream, false);
816 if (!NT_STATUS_IS_OK(status)) {
817 errno = map_errno_from_nt_status(status);
821 ret = SMB_VFS_NEXT_RENAME(handle, smb_fname_src_stream,
822 smb_fname_dst_stream);
825 TALLOC_FREE(smb_fname_src_stream);
826 TALLOC_FREE(smb_fname_dst_stream);
830 static bool add_one_stream(TALLOC_CTX *mem_ctx, unsigned int *num_streams,
831 struct stream_struct **streams,
832 const char *name, off_t size,
835 struct stream_struct *tmp;
837 tmp = talloc_realloc(mem_ctx, *streams, struct stream_struct,
843 tmp[*num_streams].name = talloc_strdup(tmp, name);
844 if (tmp[*num_streams].name == NULL) {
848 tmp[*num_streams].size = size;
849 tmp[*num_streams].alloc_size = alloc_size;
856 struct streaminfo_state {
858 vfs_handle_struct *handle;
859 unsigned int num_streams;
860 struct stream_struct *streams;
864 static bool collect_one_stream(const char *dirname,
868 struct streaminfo_state *state =
869 (struct streaminfo_state *)private_data;
870 struct smb_filename *smb_fname = NULL;
874 sname = talloc_asprintf(talloc_tos(), "%s/%s", dirname, dirent);
876 state->status = NT_STATUS_NO_MEMORY;
881 smb_fname = synthetic_smb_fname(talloc_tos(), sname, NULL, NULL);
882 if (smb_fname == NULL) {
883 state->status = NT_STATUS_NO_MEMORY;
888 if (SMB_VFS_NEXT_STAT(state->handle, smb_fname) == -1) {
889 DEBUG(10, ("Could not stat %s: %s\n", sname,
895 if (!add_one_stream(state->mem_ctx,
896 &state->num_streams, &state->streams,
897 dirent, smb_fname->st.st_ex_size,
898 SMB_VFS_GET_ALLOC_SIZE(state->handle->conn, NULL,
900 state->status = NT_STATUS_NO_MEMORY;
908 TALLOC_FREE(smb_fname);
912 static NTSTATUS streams_depot_streaminfo(vfs_handle_struct *handle,
913 struct files_struct *fsp,
914 const struct smb_filename *smb_fname,
916 unsigned int *pnum_streams,
917 struct stream_struct **pstreams)
919 struct smb_filename *smb_fname_base = NULL;
922 struct streaminfo_state state;
924 smb_fname_base = synthetic_smb_fname(talloc_tos(),
925 smb_fname->base_name,
928 if (smb_fname_base == NULL) {
929 return NT_STATUS_NO_MEMORY;
932 if ((fsp != NULL) && (fsp->fh->fd != -1)) {
933 ret = SMB_VFS_NEXT_FSTAT(handle, fsp, &smb_fname_base->st);
936 if (lp_posix_pathnames()) {
937 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_base);
939 ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
944 status = map_nt_error_from_unix(errno);
948 state.streams = *pstreams;
949 state.num_streams = *pnum_streams;
950 state.mem_ctx = mem_ctx;
951 state.handle = handle;
952 state.status = NT_STATUS_OK;
954 if (S_ISLNK(smb_fname_base->st.st_ex_mode)) {
956 * Currently we do't have SMB_VFS_LLISTXATTR
957 * inside the VFS which means there's no way
958 * to cope with a symlink when lp_posix_pathnames().
959 * returns true. For now ignore links.
960 * FIXME - by adding SMB_VFS_LLISTXATTR. JRA.
962 status = NT_STATUS_OK;
964 status = walk_streams(handle, smb_fname_base, NULL, collect_one_stream,
968 if (!NT_STATUS_IS_OK(status)) {
969 TALLOC_FREE(state.streams);
973 if (!NT_STATUS_IS_OK(state.status)) {
974 TALLOC_FREE(state.streams);
975 status = state.status;
979 *pnum_streams = state.num_streams;
980 *pstreams = state.streams;
981 status = SMB_VFS_NEXT_STREAMINFO(handle,
989 TALLOC_FREE(smb_fname_base);
993 static uint32_t streams_depot_fs_capabilities(struct vfs_handle_struct *handle,
994 enum timestamp_set_resolution *p_ts_res)
996 return SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res) | FILE_NAMED_STREAMS;
999 static struct vfs_fn_pointers vfs_streams_depot_fns = {
1000 .fs_capabilities_fn = streams_depot_fs_capabilities,
1001 .open_fn = streams_depot_open,
1002 .stat_fn = streams_depot_stat,
1003 .lstat_fn = streams_depot_lstat,
1004 .unlink_fn = streams_depot_unlink,
1005 .rmdir_fn = streams_depot_rmdir,
1006 .rename_fn = streams_depot_rename,
1007 .streaminfo_fn = streams_depot_streaminfo,
1010 NTSTATUS vfs_streams_depot_init(void);
1011 NTSTATUS vfs_streams_depot_init(void)
1013 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "streams_depot",
1014 &vfs_streams_depot_fns);