vfs_ceph_new: add missing newline in debug-logging
[Samba.git] / source3 / modules / vfs_streams_xattr.c
blob4cc69b42a8ad2ac5bbf4c73387550d5867a5e3ea
1 /*
2 * Store streams in xattrs
4 * Copyright (C) Volker Lendecke, 2008
6 * Partly based on James Peach's Darwin module, which is
8 * Copyright (C) James Peach 2006-2007
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, see <http://www.gnu.org/licenses/>.
24 #include "includes.h"
25 #include "smbd/smbd.h"
26 #include "system/filesys.h"
27 #include "lib/util/tevent_unix.h"
28 #include "librpc/gen_ndr/ioctl.h"
29 #include "hash_inode.h"
31 #undef DBGC_CLASS
32 #define DBGC_CLASS DBGC_VFS
34 struct streams_xattr_config {
35 const char *prefix;
36 size_t prefix_len;
37 bool store_stream_type;
40 struct stream_io {
41 char *base;
42 char *xattr_name;
43 void *fsp_name_ptr;
44 files_struct *fsp;
45 vfs_handle_struct *handle;
48 static ssize_t get_xattr_size_fsp(struct files_struct *fsp,
49 const char *xattr_name)
51 NTSTATUS status;
52 struct ea_struct ea;
53 ssize_t result;
55 status = get_ea_value_fsp(talloc_tos(),
56 fsp,
57 xattr_name,
58 &ea);
59 if (!NT_STATUS_IS_OK(status)) {
60 return -1;
63 result = ea.value.length-1;
64 TALLOC_FREE(ea.value.data);
65 return result;
68 /**
69 * Given a stream name, populate xattr_name with the xattr name to use for
70 * accessing the stream.
72 static NTSTATUS streams_xattr_get_name(vfs_handle_struct *handle,
73 TALLOC_CTX *ctx,
74 const char *stream_name,
75 char **xattr_name)
77 size_t stream_name_len = strlen(stream_name);
78 char *stype;
79 struct streams_xattr_config *config;
81 SMB_VFS_HANDLE_GET_DATA(handle, config, struct streams_xattr_config,
82 return NT_STATUS_UNSUCCESSFUL);
84 SMB_ASSERT(stream_name[0] == ':');
85 stream_name += 1;
88 * With vfs_fruit option "fruit:encoding = native" we're
89 * already converting stream names that contain illegal NTFS
90 * characters from their on-the-wire Unicode Private Range
91 * encoding to their native ASCII representation.
93 * As as result the name of xattrs storing the streams (via
94 * vfs_streams_xattr) may contain a colon, so we have to use
95 * strrchr_m() instead of strchr_m() for matching the stream
96 * type suffix.
98 * In check_path_syntax() we've already ensured the streamname
99 * we got from the client is valid.
101 stype = strrchr_m(stream_name, ':');
103 if (stype) {
105 * We only support one stream type: "$DATA"
107 if (strcasecmp_m(stype, ":$DATA") != 0) {
108 return NT_STATUS_INVALID_PARAMETER;
111 /* Split name and type */
112 stream_name_len = (stype - stream_name);
115 *xattr_name = talloc_asprintf(ctx, "%s%.*s%s",
116 config->prefix,
117 (int)stream_name_len,
118 stream_name,
119 config->store_stream_type ? ":$DATA" : "");
120 if (*xattr_name == NULL) {
121 return NT_STATUS_NO_MEMORY;
124 DEBUG(10, ("xattr_name: %s, stream_name: %s\n", *xattr_name,
125 stream_name));
127 return NT_STATUS_OK;
130 static bool streams_xattr_recheck(struct stream_io *sio)
132 NTSTATUS status;
133 char *xattr_name = NULL;
135 if (sio->fsp->fsp_name == sio->fsp_name_ptr) {
136 return true;
139 if (sio->fsp->fsp_name->stream_name == NULL) {
140 /* how can this happen */
141 errno = EINVAL;
142 return false;
145 status = streams_xattr_get_name(sio->handle, talloc_tos(),
146 sio->fsp->fsp_name->stream_name,
147 &xattr_name);
148 if (!NT_STATUS_IS_OK(status)) {
149 return false;
152 TALLOC_FREE(sio->xattr_name);
153 TALLOC_FREE(sio->base);
154 sio->xattr_name = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(sio->handle, sio->fsp),
155 xattr_name);
156 if (sio->xattr_name == NULL) {
157 DBG_DEBUG("sio->xattr_name==NULL\n");
158 return false;
160 TALLOC_FREE(xattr_name);
162 sio->base = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(sio->handle, sio->fsp),
163 sio->fsp->fsp_name->base_name);
164 if (sio->base == NULL) {
165 DBG_DEBUG("sio->base==NULL\n");
166 return false;
169 sio->fsp_name_ptr = sio->fsp->fsp_name;
171 return true;
174 static int streams_xattr_fstat(vfs_handle_struct *handle, files_struct *fsp,
175 SMB_STRUCT_STAT *sbuf)
177 int ret = -1;
178 struct stream_io *io = (struct stream_io *)
179 VFS_FETCH_FSP_EXTENSION(handle, fsp);
181 if (io == NULL || !fsp_is_alternate_stream(fsp)) {
182 return SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
185 DBG_DEBUG("streams_xattr_fstat called for %s\n", fsp_str_dbg(io->fsp));
187 if (!streams_xattr_recheck(io)) {
188 return -1;
191 ret = SMB_VFS_NEXT_FSTAT(handle, fsp->base_fsp, sbuf);
192 if (ret == -1) {
193 return -1;
196 sbuf->st_ex_size = get_xattr_size_fsp(fsp->base_fsp,
197 io->xattr_name);
198 if (sbuf->st_ex_size == -1) {
199 SET_STAT_INVALID(*sbuf);
200 return -1;
203 DEBUG(10, ("sbuf->st_ex_size = %d\n", (int)sbuf->st_ex_size));
205 sbuf->st_ex_ino = hash_inode(sbuf, io->xattr_name);
206 sbuf->st_ex_mode &= ~S_IFMT;
207 sbuf->st_ex_mode &= ~S_IFDIR;
208 sbuf->st_ex_mode |= S_IFREG;
209 sbuf->st_ex_blocks = sbuf->st_ex_size / STAT_ST_BLOCKSIZE + 1;
211 return 0;
214 static int streams_xattr_stat(vfs_handle_struct *handle,
215 struct smb_filename *smb_fname)
217 NTSTATUS status;
218 int result = -1;
219 char *xattr_name = NULL;
220 char *tmp_stream_name = NULL;
221 struct smb_filename *pathref = NULL;
222 struct files_struct *fsp = smb_fname->fsp;
224 if (!is_named_stream(smb_fname)) {
225 return SMB_VFS_NEXT_STAT(handle, smb_fname);
228 /* Note if lp_posix_paths() is true, we can never
229 * get here as is_named_stream() is
230 * always false. So we never need worry about
231 * not following links here. */
233 /* Populate the stat struct with info from the base file. */
234 tmp_stream_name = smb_fname->stream_name;
235 smb_fname->stream_name = NULL;
236 result = SMB_VFS_NEXT_STAT(handle, smb_fname);
237 smb_fname->stream_name = tmp_stream_name;
239 if (result == -1) {
240 return -1;
243 /* Derive the xattr name to lookup. */
244 status = streams_xattr_get_name(handle, talloc_tos(),
245 smb_fname->stream_name, &xattr_name);
246 if (!NT_STATUS_IS_OK(status)) {
247 errno = map_errno_from_nt_status(status);
248 return -1;
251 /* Augment the base file's stat information before returning. */
252 if (fsp == NULL) {
253 status = synthetic_pathref(talloc_tos(),
254 handle->conn->cwd_fsp,
255 smb_fname->base_name,
256 NULL,
257 NULL,
258 smb_fname->twrp,
259 smb_fname->flags,
260 &pathref);
261 if (!NT_STATUS_IS_OK(status)) {
262 TALLOC_FREE(xattr_name);
263 SET_STAT_INVALID(smb_fname->st);
264 errno = ENOENT;
265 return -1;
267 fsp = pathref->fsp;
268 } else {
269 fsp = fsp->base_fsp;
272 smb_fname->st.st_ex_size = get_xattr_size_fsp(fsp,
273 xattr_name);
274 if (smb_fname->st.st_ex_size == -1) {
275 TALLOC_FREE(xattr_name);
276 TALLOC_FREE(pathref);
277 SET_STAT_INVALID(smb_fname->st);
278 errno = ENOENT;
279 return -1;
282 smb_fname->st.st_ex_ino = hash_inode(&smb_fname->st, xattr_name);
283 smb_fname->st.st_ex_mode &= ~S_IFMT;
284 smb_fname->st.st_ex_mode |= S_IFREG;
285 smb_fname->st.st_ex_blocks =
286 smb_fname->st.st_ex_size / STAT_ST_BLOCKSIZE + 1;
288 TALLOC_FREE(xattr_name);
289 TALLOC_FREE(pathref);
290 return 0;
293 static int streams_xattr_lstat(vfs_handle_struct *handle,
294 struct smb_filename *smb_fname)
296 if (is_named_stream(smb_fname)) {
298 * There can never be EA's on a symlink.
299 * Windows will never see a symlink, and
300 * in SMB_FILENAME_POSIX_PATH mode we don't
301 * allow EA's on a symlink.
303 SET_STAT_INVALID(smb_fname->st);
304 errno = ENOENT;
305 return -1;
307 return SMB_VFS_NEXT_LSTAT(handle, smb_fname);
310 static int streams_xattr_openat(struct vfs_handle_struct *handle,
311 const struct files_struct *dirfsp,
312 const struct smb_filename *smb_fname,
313 files_struct *fsp,
314 const struct vfs_open_how *how)
316 NTSTATUS status;
317 struct streams_xattr_config *config = NULL;
318 struct stream_io *sio = NULL;
319 struct ea_struct ea;
320 char *xattr_name = NULL;
321 int fakefd = -1;
322 bool set_empty_xattr = false;
323 int ret;
325 SMB_VFS_HANDLE_GET_DATA(handle, config, struct streams_xattr_config,
326 return -1);
328 DBG_DEBUG("called for %s with flags 0x%x\n",
329 smb_fname_str_dbg(smb_fname),
330 how->flags);
332 if (!is_named_stream(smb_fname)) {
333 return SMB_VFS_NEXT_OPENAT(handle,
334 dirfsp,
335 smb_fname,
336 fsp,
337 how);
340 if (how->resolve != 0) {
341 errno = ENOSYS;
342 return -1;
345 SMB_ASSERT(fsp_is_alternate_stream(fsp));
346 SMB_ASSERT(dirfsp == NULL);
348 status = streams_xattr_get_name(handle, talloc_tos(),
349 smb_fname->stream_name, &xattr_name);
350 if (!NT_STATUS_IS_OK(status)) {
351 errno = map_errno_from_nt_status(status);
352 goto fail;
355 status = get_ea_value_fsp(talloc_tos(),
356 fsp->base_fsp,
357 xattr_name,
358 &ea);
360 DBG_DEBUG("get_ea_value_fsp returned %s\n", nt_errstr(status));
362 if (!NT_STATUS_IS_OK(status)) {
363 if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
365 * The base file is not there. This is an error even if
366 * we got O_CREAT, the higher levels should have created
367 * the base file for us.
369 DBG_DEBUG("streams_xattr_open: base file %s not around, "
370 "returning ENOENT\n", smb_fname->base_name);
371 errno = ENOENT;
372 goto fail;
375 if (!(how->flags & O_CREAT)) {
376 errno = ENOATTR;
377 goto fail;
380 set_empty_xattr = true;
383 if (how->flags & O_TRUNC) {
384 set_empty_xattr = true;
387 if (set_empty_xattr) {
389 * The attribute does not exist or needs to be truncated
393 * Darn, xattrs need at least 1 byte
395 char null = '\0';
397 DEBUG(10, ("creating or truncating attribute %s on file %s\n",
398 xattr_name, smb_fname->base_name));
400 ret = SMB_VFS_FSETXATTR(fsp->base_fsp,
401 xattr_name,
402 &null, sizeof(null),
403 how->flags & O_EXCL ? XATTR_CREATE : 0);
404 if (ret != 0) {
405 goto fail;
409 fakefd = vfs_fake_fd();
411 sio = VFS_ADD_FSP_EXTENSION(handle, fsp, struct stream_io, NULL);
412 if (sio == NULL) {
413 errno = ENOMEM;
414 goto fail;
417 sio->xattr_name = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(handle, fsp),
418 xattr_name);
419 if (sio->xattr_name == NULL) {
420 errno = ENOMEM;
421 goto fail;
425 * so->base needs to be a copy of fsp->fsp_name->base_name,
426 * making it identical to streams_xattr_recheck(). If the
427 * open is changing directories, fsp->fsp_name->base_name
428 * will be the full path from the share root, whilst
429 * smb_fname will be relative to the $cwd.
431 sio->base = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(handle, fsp),
432 fsp->fsp_name->base_name);
433 if (sio->base == NULL) {
434 errno = ENOMEM;
435 goto fail;
438 sio->fsp_name_ptr = fsp->fsp_name;
439 sio->handle = handle;
440 sio->fsp = fsp;
442 return fakefd;
444 fail:
445 if (fakefd >= 0) {
446 vfs_fake_fd_close(fakefd);
447 fakefd = -1;
450 return -1;
453 static int streams_xattr_close(vfs_handle_struct *handle,
454 files_struct *fsp)
456 int ret;
457 int fd;
459 fd = fsp_get_pathref_fd(fsp);
461 DBG_DEBUG("streams_xattr_close called [%s] fd [%d]\n",
462 smb_fname_str_dbg(fsp->fsp_name), fd);
464 if (!fsp_is_alternate_stream(fsp)) {
465 return SMB_VFS_NEXT_CLOSE(handle, fsp);
468 ret = vfs_fake_fd_close(fd);
469 fsp_set_fd(fsp, -1);
471 return ret;
474 static int streams_xattr_unlinkat(vfs_handle_struct *handle,
475 struct files_struct *dirfsp,
476 const struct smb_filename *smb_fname,
477 int flags)
479 NTSTATUS status;
480 int ret = -1;
481 char *xattr_name = NULL;
482 struct smb_filename *pathref = NULL;
483 struct files_struct *fsp = smb_fname->fsp;
485 if (!is_named_stream(smb_fname)) {
486 return SMB_VFS_NEXT_UNLINKAT(handle,
487 dirfsp,
488 smb_fname,
489 flags);
492 /* A stream can never be rmdir'ed */
493 SMB_ASSERT((flags & AT_REMOVEDIR) == 0);
495 status = streams_xattr_get_name(handle, talloc_tos(),
496 smb_fname->stream_name, &xattr_name);
497 if (!NT_STATUS_IS_OK(status)) {
498 errno = map_errno_from_nt_status(status);
499 goto fail;
502 if (fsp == NULL) {
503 status = synthetic_pathref(talloc_tos(),
504 handle->conn->cwd_fsp,
505 smb_fname->base_name,
506 NULL,
507 NULL,
508 smb_fname->twrp,
509 smb_fname->flags,
510 &pathref);
511 if (!NT_STATUS_IS_OK(status)) {
512 errno = ENOENT;
513 goto fail;
515 fsp = pathref->fsp;
516 } else {
517 SMB_ASSERT(fsp_is_alternate_stream(smb_fname->fsp));
518 fsp = fsp->base_fsp;
521 ret = SMB_VFS_FREMOVEXATTR(fsp, xattr_name);
523 if ((ret == -1) && (errno == ENOATTR)) {
524 errno = ENOENT;
525 goto fail;
528 ret = 0;
530 fail:
531 TALLOC_FREE(xattr_name);
532 TALLOC_FREE(pathref);
533 return ret;
536 static int streams_xattr_renameat(vfs_handle_struct *handle,
537 files_struct *srcfsp,
538 const struct smb_filename *smb_fname_src,
539 files_struct *dstfsp,
540 const struct smb_filename *smb_fname_dst,
541 const struct vfs_rename_how *how)
543 NTSTATUS status;
544 int ret = -1;
545 char *src_xattr_name = NULL;
546 char *dst_xattr_name = NULL;
547 bool src_is_stream, dst_is_stream;
548 ssize_t oret;
549 ssize_t nret;
550 struct ea_struct ea;
551 struct smb_filename *pathref_src = NULL;
552 struct smb_filename *pathref_dst = NULL;
553 struct smb_filename *full_src = NULL;
554 struct smb_filename *full_dst = NULL;
556 src_is_stream = is_ntfs_stream_smb_fname(smb_fname_src);
557 dst_is_stream = is_ntfs_stream_smb_fname(smb_fname_dst);
559 if (!src_is_stream && !dst_is_stream) {
560 return SMB_VFS_NEXT_RENAMEAT(handle,
561 srcfsp,
562 smb_fname_src,
563 dstfsp,
564 smb_fname_dst,
565 how);
568 if (how->flags != 0) {
569 errno = EINVAL;
570 goto done;
573 /* For now don't allow renames from or to the default stream. */
574 if (is_ntfs_default_stream_smb_fname(smb_fname_src) ||
575 is_ntfs_default_stream_smb_fname(smb_fname_dst)) {
576 errno = ENOSYS;
577 goto done;
580 /* Don't rename if the streams are identical. */
581 if (strcasecmp_m(smb_fname_src->stream_name,
582 smb_fname_dst->stream_name) == 0) {
583 goto done;
586 /* Get the xattr names. */
587 status = streams_xattr_get_name(handle, talloc_tos(),
588 smb_fname_src->stream_name,
589 &src_xattr_name);
590 if (!NT_STATUS_IS_OK(status)) {
591 errno = map_errno_from_nt_status(status);
592 goto fail;
594 status = streams_xattr_get_name(handle, talloc_tos(),
595 smb_fname_dst->stream_name,
596 &dst_xattr_name);
597 if (!NT_STATUS_IS_OK(status)) {
598 errno = map_errno_from_nt_status(status);
599 goto fail;
602 full_src = full_path_from_dirfsp_atname(talloc_tos(),
603 srcfsp,
604 smb_fname_src);
605 if (full_src == NULL) {
606 errno = ENOMEM;
607 goto fail;
609 full_dst = full_path_from_dirfsp_atname(talloc_tos(),
610 dstfsp,
611 smb_fname_dst);
612 if (full_dst == NULL) {
613 errno = ENOMEM;
614 goto fail;
617 /* Get a pathref for full_src (base file, no stream name). */
618 status = synthetic_pathref(talloc_tos(),
619 handle->conn->cwd_fsp,
620 full_src->base_name,
621 NULL,
622 NULL,
623 full_src->twrp,
624 full_src->flags,
625 &pathref_src);
626 if (!NT_STATUS_IS_OK(status)) {
627 errno = ENOENT;
628 goto fail;
631 /* Read the old stream from the base file fsp. */
632 status = get_ea_value_fsp(talloc_tos(),
633 pathref_src->fsp,
634 src_xattr_name,
635 &ea);
636 if (!NT_STATUS_IS_OK(status)) {
637 errno = map_errno_from_nt_status(status);
638 goto fail;
641 /* Get a pathref for full_dst (base file, no stream name). */
642 status = synthetic_pathref(talloc_tos(),
643 handle->conn->cwd_fsp,
644 full_dst->base_name,
645 NULL,
646 NULL,
647 full_dst->twrp,
648 full_dst->flags,
649 &pathref_dst);
650 if (!NT_STATUS_IS_OK(status)) {
651 errno = ENOENT;
652 goto fail;
655 /* (Over)write the new stream on the base file fsp. */
656 nret = SMB_VFS_FSETXATTR(
657 pathref_dst->fsp,
658 dst_xattr_name,
659 ea.value.data,
660 ea.value.length,
662 if (nret < 0) {
663 if (errno == ENOATTR) {
664 errno = ENOENT;
666 goto fail;
670 * Remove the old stream from the base file fsp.
672 oret = SMB_VFS_FREMOVEXATTR(pathref_src->fsp,
673 src_xattr_name);
674 if (oret < 0) {
675 if (errno == ENOATTR) {
676 errno = ENOENT;
678 goto fail;
681 done:
682 errno = 0;
683 ret = 0;
684 fail:
685 TALLOC_FREE(pathref_src);
686 TALLOC_FREE(pathref_dst);
687 TALLOC_FREE(full_src);
688 TALLOC_FREE(full_dst);
689 TALLOC_FREE(src_xattr_name);
690 TALLOC_FREE(dst_xattr_name);
691 return ret;
694 static NTSTATUS walk_xattr_streams(vfs_handle_struct *handle,
695 files_struct *fsp,
696 const struct smb_filename *smb_fname,
697 bool (*fn)(struct ea_struct *ea,
698 void *private_data),
699 void *private_data)
701 NTSTATUS status;
702 char **names;
703 size_t i, num_names;
704 struct streams_xattr_config *config;
706 SMB_VFS_HANDLE_GET_DATA(handle, config, struct streams_xattr_config,
707 return NT_STATUS_UNSUCCESSFUL);
709 status = get_ea_names_from_fsp(talloc_tos(),
710 smb_fname->fsp,
711 &names,
712 &num_names);
713 if (!NT_STATUS_IS_OK(status)) {
714 return status;
717 for (i=0; i<num_names; i++) {
718 struct ea_struct ea;
721 * We want to check with samba_private_attr_name()
722 * whether the xattr name is a private one,
723 * unfortunately it flags xattrs that begin with the
724 * default streams prefix as private.
726 * By only calling samba_private_attr_name() in case
727 * the xattr does NOT begin with the default prefix,
728 * we know that if it returns 'true' it definitely one
729 * of our internal xattr like "user.DOSATTRIB".
731 if (strncasecmp_m(names[i], SAMBA_XATTR_DOSSTREAM_PREFIX,
732 strlen(SAMBA_XATTR_DOSSTREAM_PREFIX)) != 0) {
733 if (samba_private_attr_name(names[i])) {
734 continue;
738 if (strncmp(names[i], config->prefix,
739 config->prefix_len) != 0) {
740 continue;
743 status = get_ea_value_fsp(names,
744 smb_fname->fsp,
745 names[i],
746 &ea);
747 if (!NT_STATUS_IS_OK(status)) {
748 DEBUG(10, ("Could not get ea %s for file %s: %s\n",
749 names[i],
750 smb_fname->base_name,
751 nt_errstr(status)));
752 continue;
755 ea.name = talloc_asprintf(
756 ea.value.data, ":%s%s",
757 names[i] + config->prefix_len,
758 config->store_stream_type ? "" : ":$DATA");
759 if (ea.name == NULL) {
760 DEBUG(0, ("talloc failed\n"));
761 continue;
764 if (!fn(&ea, private_data)) {
765 TALLOC_FREE(ea.value.data);
766 return NT_STATUS_OK;
769 TALLOC_FREE(ea.value.data);
772 TALLOC_FREE(names);
773 return NT_STATUS_OK;
776 static bool add_one_stream(TALLOC_CTX *mem_ctx, unsigned int *num_streams,
777 struct stream_struct **streams,
778 const char *name, off_t size,
779 off_t alloc_size)
781 struct stream_struct *tmp;
783 tmp = talloc_realloc(mem_ctx, *streams, struct stream_struct,
784 (*num_streams)+1);
785 if (tmp == NULL) {
786 return false;
789 tmp[*num_streams].name = talloc_strdup(tmp, name);
790 if (tmp[*num_streams].name == NULL) {
791 return false;
794 tmp[*num_streams].size = size;
795 tmp[*num_streams].alloc_size = alloc_size;
797 *streams = tmp;
798 *num_streams += 1;
799 return true;
802 struct streaminfo_state {
803 TALLOC_CTX *mem_ctx;
804 vfs_handle_struct *handle;
805 unsigned int num_streams;
806 struct stream_struct *streams;
807 NTSTATUS status;
810 static bool collect_one_stream(struct ea_struct *ea, void *private_data)
812 struct streaminfo_state *state =
813 (struct streaminfo_state *)private_data;
815 if (!add_one_stream(state->mem_ctx,
816 &state->num_streams, &state->streams,
817 ea->name, ea->value.length-1,
818 smb_roundup(state->handle->conn,
819 ea->value.length-1))) {
820 state->status = NT_STATUS_NO_MEMORY;
821 return false;
824 return true;
827 static NTSTATUS streams_xattr_fstreaminfo(vfs_handle_struct *handle,
828 struct files_struct *fsp,
829 TALLOC_CTX *mem_ctx,
830 unsigned int *pnum_streams,
831 struct stream_struct **pstreams)
833 NTSTATUS status;
834 struct streaminfo_state state;
836 state.streams = *pstreams;
837 state.num_streams = *pnum_streams;
838 state.mem_ctx = mem_ctx;
839 state.handle = handle;
840 state.status = NT_STATUS_OK;
842 status = walk_xattr_streams(handle,
843 fsp,
844 fsp->fsp_name,
845 collect_one_stream,
846 &state);
848 if (!NT_STATUS_IS_OK(status)) {
849 TALLOC_FREE(state.streams);
850 return status;
853 if (!NT_STATUS_IS_OK(state.status)) {
854 TALLOC_FREE(state.streams);
855 return state.status;
858 *pnum_streams = state.num_streams;
859 *pstreams = state.streams;
861 return SMB_VFS_NEXT_FSTREAMINFO(handle,
862 fsp,
863 mem_ctx,
864 pnum_streams,
865 pstreams);
868 static uint32_t streams_xattr_fs_capabilities(struct vfs_handle_struct *handle,
869 enum timestamp_set_resolution *p_ts_res)
871 return SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res) | FILE_NAMED_STREAMS;
874 static int streams_xattr_connect(vfs_handle_struct *handle,
875 const char *service, const char *user)
877 struct streams_xattr_config *config;
878 const char *default_prefix = SAMBA_XATTR_DOSSTREAM_PREFIX;
879 const char *prefix;
880 int rc;
882 rc = SMB_VFS_NEXT_CONNECT(handle, service, user);
883 if (rc != 0) {
884 return rc;
887 config = talloc_zero(handle->conn, struct streams_xattr_config);
888 if (config == NULL) {
889 DEBUG(1, ("talloc_zero() failed\n"));
890 errno = ENOMEM;
891 return -1;
894 prefix = lp_parm_const_string(SNUM(handle->conn),
895 "streams_xattr", "prefix",
896 default_prefix);
897 config->prefix = talloc_strdup(config, prefix);
898 if (config->prefix == NULL) {
899 DEBUG(1, ("talloc_strdup() failed\n"));
900 errno = ENOMEM;
901 return -1;
903 config->prefix_len = strlen(config->prefix);
904 DEBUG(10, ("streams_xattr using stream prefix: %s\n", config->prefix));
906 config->store_stream_type = lp_parm_bool(SNUM(handle->conn),
907 "streams_xattr",
908 "store_stream_type",
909 true);
911 SMB_VFS_HANDLE_SET_DATA(handle, config,
912 NULL, struct stream_xattr_config,
913 return -1);
915 return 0;
918 static ssize_t streams_xattr_pwrite(vfs_handle_struct *handle,
919 files_struct *fsp, const void *data,
920 size_t n, off_t offset)
922 struct stream_io *sio =
923 (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
924 struct ea_struct ea;
925 NTSTATUS status;
926 int ret;
928 DEBUG(10, ("streams_xattr_pwrite called for %d bytes\n", (int)n));
930 if (sio == NULL) {
931 return SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
934 if (!streams_xattr_recheck(sio)) {
935 return -1;
938 if ((offset + n) >= lp_smbd_max_xattr_size(SNUM(handle->conn))) {
940 * Requested write is beyond what can be read based on
941 * samba configuration.
942 * ReFS returns STATUS_FILESYSTEM_LIMITATION, which causes
943 * entire file to be skipped by File Explorer. VFAT returns
944 * NT_STATUS_OBJECT_NAME_COLLISION causes user to be prompted
945 * to skip writing metadata, but copy data.
947 DBG_ERR("Write to xattr [%s] on file [%s] exceeds maximum "
948 "supported extended attribute size. "
949 "Depending on filesystem type and operating system "
950 "(OS) specifics, this value may be increased using "
951 "the value of the parameter: "
952 "smbd max xattr size = <bytes>. Consult OS and "
953 "filesystem manpages prior to increasing this limit.\n",
954 sio->xattr_name, sio->base);
955 errno = EOVERFLOW;
956 return -1;
959 status = get_ea_value_fsp(talloc_tos(),
960 fsp->base_fsp,
961 sio->xattr_name,
962 &ea);
963 if (!NT_STATUS_IS_OK(status)) {
964 return -1;
967 if ((offset + n) > ea.value.length-1) {
968 uint8_t *tmp;
970 tmp = talloc_realloc(talloc_tos(), ea.value.data, uint8_t,
971 offset + n + 1);
973 if (tmp == NULL) {
974 TALLOC_FREE(ea.value.data);
975 errno = ENOMEM;
976 return -1;
978 ea.value.data = tmp;
979 ea.value.length = offset + n + 1;
980 ea.value.data[offset+n] = 0;
983 memcpy(ea.value.data + offset, data, n);
985 ret = SMB_VFS_FSETXATTR(fsp->base_fsp,
986 sio->xattr_name,
987 ea.value.data,
988 ea.value.length,
990 TALLOC_FREE(ea.value.data);
992 if (ret == -1) {
993 return -1;
996 return n;
999 static ssize_t streams_xattr_pread(vfs_handle_struct *handle,
1000 files_struct *fsp, void *data,
1001 size_t n, off_t offset)
1003 struct stream_io *sio =
1004 (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
1005 struct ea_struct ea;
1006 NTSTATUS status;
1007 size_t length, overlap;
1009 DEBUG(10, ("streams_xattr_pread: offset=%d, size=%d\n",
1010 (int)offset, (int)n));
1012 if (sio == NULL) {
1013 return SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
1016 if (!streams_xattr_recheck(sio)) {
1017 return -1;
1020 status = get_ea_value_fsp(talloc_tos(),
1021 fsp->base_fsp,
1022 sio->xattr_name,
1023 &ea);
1024 if (!NT_STATUS_IS_OK(status)) {
1025 return -1;
1028 length = ea.value.length-1;
1030 DBG_DEBUG("get_ea_value_fsp returned %d bytes\n",
1031 (int)length);
1033 /* Attempt to read past EOF. */
1034 if (length <= offset) {
1035 return 0;
1038 overlap = (offset + n) > length ? (length - offset) : n;
1039 memcpy(data, ea.value.data + offset, overlap);
1041 TALLOC_FREE(ea.value.data);
1042 return overlap;
1045 struct streams_xattr_pread_state {
1046 ssize_t nread;
1047 struct vfs_aio_state vfs_aio_state;
1050 static void streams_xattr_pread_done(struct tevent_req *subreq);
1052 static struct tevent_req *streams_xattr_pread_send(
1053 struct vfs_handle_struct *handle,
1054 TALLOC_CTX *mem_ctx,
1055 struct tevent_context *ev,
1056 struct files_struct *fsp,
1057 void *data,
1058 size_t n, off_t offset)
1060 struct tevent_req *req = NULL;
1061 struct tevent_req *subreq = NULL;
1062 struct streams_xattr_pread_state *state = NULL;
1063 struct stream_io *sio =
1064 (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
1066 req = tevent_req_create(mem_ctx, &state,
1067 struct streams_xattr_pread_state);
1068 if (req == NULL) {
1069 return NULL;
1072 if (sio == NULL) {
1073 subreq = SMB_VFS_NEXT_PREAD_SEND(state, ev, handle, fsp,
1074 data, n, offset);
1075 if (tevent_req_nomem(req, subreq)) {
1076 return tevent_req_post(req, ev);
1078 tevent_req_set_callback(subreq, streams_xattr_pread_done, req);
1079 return req;
1082 state->nread = SMB_VFS_PREAD(fsp, data, n, offset);
1083 if (state->nread != n) {
1084 if (state->nread != -1) {
1085 errno = EIO;
1087 tevent_req_error(req, errno);
1088 return tevent_req_post(req, ev);
1091 tevent_req_done(req);
1092 return tevent_req_post(req, ev);
1095 static void streams_xattr_pread_done(struct tevent_req *subreq)
1097 struct tevent_req *req = tevent_req_callback_data(
1098 subreq, struct tevent_req);
1099 struct streams_xattr_pread_state *state = tevent_req_data(
1100 req, struct streams_xattr_pread_state);
1102 state->nread = SMB_VFS_PREAD_RECV(subreq, &state->vfs_aio_state);
1103 TALLOC_FREE(subreq);
1105 if (tevent_req_error(req, state->vfs_aio_state.error)) {
1106 return;
1108 tevent_req_done(req);
1111 static ssize_t streams_xattr_pread_recv(struct tevent_req *req,
1112 struct vfs_aio_state *vfs_aio_state)
1114 struct streams_xattr_pread_state *state = tevent_req_data(
1115 req, struct streams_xattr_pread_state);
1117 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
1118 return -1;
1121 *vfs_aio_state = state->vfs_aio_state;
1122 return state->nread;
1125 struct streams_xattr_pwrite_state {
1126 ssize_t nwritten;
1127 struct vfs_aio_state vfs_aio_state;
1130 static void streams_xattr_pwrite_done(struct tevent_req *subreq);
1132 static struct tevent_req *streams_xattr_pwrite_send(
1133 struct vfs_handle_struct *handle,
1134 TALLOC_CTX *mem_ctx,
1135 struct tevent_context *ev,
1136 struct files_struct *fsp,
1137 const void *data,
1138 size_t n, off_t offset)
1140 struct tevent_req *req = NULL;
1141 struct tevent_req *subreq = NULL;
1142 struct streams_xattr_pwrite_state *state = NULL;
1143 struct stream_io *sio =
1144 (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
1146 req = tevent_req_create(mem_ctx, &state,
1147 struct streams_xattr_pwrite_state);
1148 if (req == NULL) {
1149 return NULL;
1152 if (sio == NULL) {
1153 subreq = SMB_VFS_NEXT_PWRITE_SEND(state, ev, handle, fsp,
1154 data, n, offset);
1155 if (tevent_req_nomem(req, subreq)) {
1156 return tevent_req_post(req, ev);
1158 tevent_req_set_callback(subreq, streams_xattr_pwrite_done, req);
1159 return req;
1162 state->nwritten = SMB_VFS_PWRITE(fsp, data, n, offset);
1163 if (state->nwritten != n) {
1164 if (state->nwritten != -1) {
1165 errno = EIO;
1167 tevent_req_error(req, errno);
1168 return tevent_req_post(req, ev);
1171 tevent_req_done(req);
1172 return tevent_req_post(req, ev);
1175 static void streams_xattr_pwrite_done(struct tevent_req *subreq)
1177 struct tevent_req *req = tevent_req_callback_data(
1178 subreq, struct tevent_req);
1179 struct streams_xattr_pwrite_state *state = tevent_req_data(
1180 req, struct streams_xattr_pwrite_state);
1182 state->nwritten = SMB_VFS_PWRITE_RECV(subreq, &state->vfs_aio_state);
1183 TALLOC_FREE(subreq);
1185 if (tevent_req_error(req, state->vfs_aio_state.error)) {
1186 return;
1188 tevent_req_done(req);
1191 static ssize_t streams_xattr_pwrite_recv(struct tevent_req *req,
1192 struct vfs_aio_state *vfs_aio_state)
1194 struct streams_xattr_pwrite_state *state = tevent_req_data(
1195 req, struct streams_xattr_pwrite_state);
1197 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
1198 return -1;
1201 *vfs_aio_state = state->vfs_aio_state;
1202 return state->nwritten;
1205 static int streams_xattr_ftruncate(struct vfs_handle_struct *handle,
1206 struct files_struct *fsp,
1207 off_t offset)
1209 int ret;
1210 uint8_t *tmp;
1211 struct ea_struct ea;
1212 NTSTATUS status;
1213 struct stream_io *sio =
1214 (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
1216 DEBUG(10, ("streams_xattr_ftruncate called for file %s offset %.0f\n",
1217 fsp_str_dbg(fsp), (double)offset));
1219 if (sio == NULL) {
1220 return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset);
1223 if (!streams_xattr_recheck(sio)) {
1224 return -1;
1227 status = get_ea_value_fsp(talloc_tos(),
1228 fsp->base_fsp,
1229 sio->xattr_name,
1230 &ea);
1231 if (!NT_STATUS_IS_OK(status)) {
1232 return -1;
1235 tmp = talloc_realloc(talloc_tos(), ea.value.data, uint8_t,
1236 offset + 1);
1238 if (tmp == NULL) {
1239 TALLOC_FREE(ea.value.data);
1240 errno = ENOMEM;
1241 return -1;
1244 /* Did we expand ? */
1245 if (ea.value.length < offset + 1) {
1246 memset(&tmp[ea.value.length], '\0',
1247 offset + 1 - ea.value.length);
1250 ea.value.data = tmp;
1251 ea.value.length = offset + 1;
1252 ea.value.data[offset] = 0;
1254 ret = SMB_VFS_FSETXATTR(fsp->base_fsp,
1255 sio->xattr_name,
1256 ea.value.data,
1257 ea.value.length,
1260 TALLOC_FREE(ea.value.data);
1262 if (ret == -1) {
1263 return -1;
1266 return 0;
1269 static int streams_xattr_fallocate(struct vfs_handle_struct *handle,
1270 struct files_struct *fsp,
1271 uint32_t mode,
1272 off_t offset,
1273 off_t len)
1275 struct stream_io *sio =
1276 (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
1278 DEBUG(10, ("streams_xattr_fallocate called for file %s offset %.0f"
1279 "len = %.0f\n",
1280 fsp_str_dbg(fsp), (double)offset, (double)len));
1282 if (sio == NULL) {
1283 return SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len);
1286 if (!streams_xattr_recheck(sio)) {
1287 return -1;
1290 /* Let the pwrite code path handle it. */
1291 errno = ENOSYS;
1292 return -1;
1295 static int streams_xattr_fchown(vfs_handle_struct *handle, files_struct *fsp,
1296 uid_t uid, gid_t gid)
1298 struct stream_io *sio =
1299 (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
1301 if (sio == NULL) {
1302 return SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
1305 return 0;
1308 static int streams_xattr_fchmod(vfs_handle_struct *handle,
1309 files_struct *fsp,
1310 mode_t mode)
1312 struct stream_io *sio =
1313 (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
1315 if (sio == NULL) {
1316 return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
1319 return 0;
1322 static ssize_t streams_xattr_fgetxattr(struct vfs_handle_struct *handle,
1323 struct files_struct *fsp,
1324 const char *name,
1325 void *value,
1326 size_t size)
1328 struct stream_io *sio =
1329 (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
1331 if (sio == NULL) {
1332 return SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
1335 errno = ENOTSUP;
1336 return -1;
1339 static ssize_t streams_xattr_flistxattr(struct vfs_handle_struct *handle,
1340 struct files_struct *fsp,
1341 char *list,
1342 size_t size)
1344 struct stream_io *sio =
1345 (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
1347 if (sio == NULL) {
1348 return SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
1351 errno = ENOTSUP;
1352 return -1;
1355 static int streams_xattr_fremovexattr(struct vfs_handle_struct *handle,
1356 struct files_struct *fsp,
1357 const char *name)
1359 struct stream_io *sio =
1360 (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
1362 if (sio == NULL) {
1363 return SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
1366 errno = ENOTSUP;
1367 return -1;
1370 static int streams_xattr_fsetxattr(struct vfs_handle_struct *handle,
1371 struct files_struct *fsp,
1372 const char *name,
1373 const void *value,
1374 size_t size,
1375 int flags)
1377 struct stream_io *sio =
1378 (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
1380 if (sio == NULL) {
1381 return SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value,
1382 size, flags);
1385 errno = ENOTSUP;
1386 return -1;
1389 struct streams_xattr_fsync_state {
1390 int ret;
1391 struct vfs_aio_state vfs_aio_state;
1394 static void streams_xattr_fsync_done(struct tevent_req *subreq);
1396 static struct tevent_req *streams_xattr_fsync_send(
1397 struct vfs_handle_struct *handle,
1398 TALLOC_CTX *mem_ctx,
1399 struct tevent_context *ev,
1400 struct files_struct *fsp)
1402 struct tevent_req *req = NULL;
1403 struct tevent_req *subreq = NULL;
1404 struct streams_xattr_fsync_state *state = NULL;
1405 struct stream_io *sio =
1406 (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
1408 req = tevent_req_create(mem_ctx, &state,
1409 struct streams_xattr_fsync_state);
1410 if (req == NULL) {
1411 return NULL;
1414 if (sio == NULL) {
1415 subreq = SMB_VFS_NEXT_FSYNC_SEND(state, ev, handle, fsp);
1416 if (tevent_req_nomem(req, subreq)) {
1417 return tevent_req_post(req, ev);
1419 tevent_req_set_callback(subreq, streams_xattr_fsync_done, req);
1420 return req;
1424 * There's no pathname based sync variant and we don't have access to
1425 * the basefile handle, so we can't do anything here.
1428 tevent_req_done(req);
1429 return tevent_req_post(req, ev);
1432 static void streams_xattr_fsync_done(struct tevent_req *subreq)
1434 struct tevent_req *req = tevent_req_callback_data(
1435 subreq, struct tevent_req);
1436 struct streams_xattr_fsync_state *state = tevent_req_data(
1437 req, struct streams_xattr_fsync_state);
1439 state->ret = SMB_VFS_FSYNC_RECV(subreq, &state->vfs_aio_state);
1440 TALLOC_FREE(subreq);
1441 if (state->ret != 0) {
1442 tevent_req_error(req, errno);
1443 return;
1446 tevent_req_done(req);
1449 static int streams_xattr_fsync_recv(struct tevent_req *req,
1450 struct vfs_aio_state *vfs_aio_state)
1452 struct streams_xattr_fsync_state *state = tevent_req_data(
1453 req, struct streams_xattr_fsync_state);
1455 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
1456 return -1;
1459 *vfs_aio_state = state->vfs_aio_state;
1460 return state->ret;
1463 static bool streams_xattr_lock(vfs_handle_struct *handle,
1464 files_struct *fsp,
1465 int op,
1466 off_t offset,
1467 off_t count,
1468 int type)
1470 struct stream_io *sio =
1471 (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
1473 if (sio == NULL) {
1474 return SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
1477 return true;
1480 static bool streams_xattr_getlock(vfs_handle_struct *handle,
1481 files_struct *fsp,
1482 off_t *poffset,
1483 off_t *pcount,
1484 int *ptype,
1485 pid_t *ppid)
1487 struct stream_io *sio =
1488 (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
1490 if (sio == NULL) {
1491 return SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset,
1492 pcount, ptype, ppid);
1495 errno = ENOTSUP;
1496 return false;
1499 static int streams_xattr_filesystem_sharemode(vfs_handle_struct *handle,
1500 files_struct *fsp,
1501 uint32_t share_access,
1502 uint32_t access_mask)
1504 struct stream_io *sio =
1505 (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
1507 if (sio == NULL) {
1508 return SMB_VFS_NEXT_FILESYSTEM_SHAREMODE(handle,
1509 fsp,
1510 share_access,
1511 access_mask);
1514 return 0;
1517 static int streams_xattr_linux_setlease(vfs_handle_struct *handle,
1518 files_struct *fsp,
1519 int leasetype)
1521 struct stream_io *sio =
1522 (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
1524 if (sio == NULL) {
1525 return SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
1528 return 0;
1531 static bool streams_xattr_strict_lock_check(struct vfs_handle_struct *handle,
1532 files_struct *fsp,
1533 struct lock_struct *plock)
1535 struct stream_io *sio =
1536 (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
1538 if (sio == NULL) {
1539 return SMB_VFS_NEXT_STRICT_LOCK_CHECK(handle, fsp, plock);
1542 return true;
1545 static int streams_xattr_fcntl(vfs_handle_struct *handle,
1546 files_struct *fsp,
1547 int cmd,
1548 va_list cmd_arg)
1550 va_list dup_cmd_arg;
1551 void *arg;
1552 int ret;
1554 if (fsp_is_alternate_stream(fsp)) {
1555 switch (cmd) {
1556 case F_GETFL:
1557 case F_SETFL:
1558 break;
1559 default:
1560 DBG_ERR("Unsupported fcntl() cmd [%d] on [%s]\n",
1561 cmd, fsp_str_dbg(fsp));
1562 errno = EINVAL;
1563 return -1;
1567 va_copy(dup_cmd_arg, cmd_arg);
1568 arg = va_arg(dup_cmd_arg, void *);
1570 ret = SMB_VFS_NEXT_FCNTL(handle, fsp, cmd, arg);
1572 va_end(dup_cmd_arg);
1574 return ret;
1577 static struct vfs_fn_pointers vfs_streams_xattr_fns = {
1578 .fs_capabilities_fn = streams_xattr_fs_capabilities,
1579 .connect_fn = streams_xattr_connect,
1580 .openat_fn = streams_xattr_openat,
1581 .close_fn = streams_xattr_close,
1582 .stat_fn = streams_xattr_stat,
1583 .fstat_fn = streams_xattr_fstat,
1584 .lstat_fn = streams_xattr_lstat,
1585 .pread_fn = streams_xattr_pread,
1586 .pwrite_fn = streams_xattr_pwrite,
1587 .pread_send_fn = streams_xattr_pread_send,
1588 .pread_recv_fn = streams_xattr_pread_recv,
1589 .pwrite_send_fn = streams_xattr_pwrite_send,
1590 .pwrite_recv_fn = streams_xattr_pwrite_recv,
1591 .unlinkat_fn = streams_xattr_unlinkat,
1592 .renameat_fn = streams_xattr_renameat,
1593 .ftruncate_fn = streams_xattr_ftruncate,
1594 .fallocate_fn = streams_xattr_fallocate,
1595 .fstreaminfo_fn = streams_xattr_fstreaminfo,
1597 .fsync_send_fn = streams_xattr_fsync_send,
1598 .fsync_recv_fn = streams_xattr_fsync_recv,
1600 .lock_fn = streams_xattr_lock,
1601 .getlock_fn = streams_xattr_getlock,
1602 .filesystem_sharemode_fn = streams_xattr_filesystem_sharemode,
1603 .linux_setlease_fn = streams_xattr_linux_setlease,
1604 .strict_lock_check_fn = streams_xattr_strict_lock_check,
1605 .fcntl_fn = streams_xattr_fcntl,
1607 .fchown_fn = streams_xattr_fchown,
1608 .fchmod_fn = streams_xattr_fchmod,
1610 .fgetxattr_fn = streams_xattr_fgetxattr,
1611 .flistxattr_fn = streams_xattr_flistxattr,
1612 .fremovexattr_fn = streams_xattr_fremovexattr,
1613 .fsetxattr_fn = streams_xattr_fsetxattr,
1616 static_decl_vfs;
1617 NTSTATUS vfs_streams_xattr_init(TALLOC_CTX *ctx)
1619 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "streams_xattr",
1620 &vfs_streams_xattr_fns);