Make VFS op "streaminfo" stackable

Frank Lahm franklahm at googlemail.com
Mon Aug 29 07:43:02 MDT 2011


2011/8/26 Jeremy Allison <jra at samba.org>:
> To do special initialization before calling a vfs op, use a wrapper
> function and then ensure all calls from the main code go through
> this. See functions like vfs_stat_fsp() for details.

Something like this ?
----8<---

diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index 185bc76..0c0a04b 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -655,6 +655,12 @@ int smb_vfs_call_chflags(struct vfs_handle_struct
*handle, const char *path,
                         unsigned int flags);
 struct file_id smb_vfs_call_file_id_create(struct vfs_handle_struct *handle,
                                           const SMB_STRUCT_STAT *sbuf);
+NTSTATUS smb_vfs_call_streaminfo_start(struct vfs_handle_struct *handle,
+                                      struct files_struct *fsp,
+                                      const char *fname,
+                                      TALLOC_CTX *mem_ctx,
+                                      unsigned int *num_streams,
+                                      struct stream_struct **streams);
 NTSTATUS smb_vfs_call_streaminfo(struct vfs_handle_struct *handle,
                                 struct files_struct *fsp,
                                 const char *fname,
diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h
index d04be9b..bbd12a5 100644
--- a/source3/include/vfs_macros.h
+++ b/source3/include/vfs_macros.h
@@ -320,7 +320,7 @@
        smb_vfs_call_file_id_create((handle)->next, (sbuf))

 #define SMB_VFS_STREAMINFO(conn, fsp, fname, mem_ctx, num_streams, streams) \
-       smb_vfs_call_streaminfo((conn)->vfs_handles, (fsp), (fname),
(mem_ctx), (num_streams), (streams))
+       smb_vfs_call_streaminfo_start((conn)->vfs_handles, (fsp),
(fname), (mem_ctx), (num_streams), (streams))
 #define SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx,
num_streams, streams) \
        smb_vfs_call_streaminfo((handle)->next, (fsp), (fname),
(mem_ctx), (num_streams), (streams))

diff --git a/source3/modules/vfs_streams_xattr.c
b/source3/modules/vfs_streams_xattr.c
index 34e01b0..e3cc822 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -1665,6 +1665,20 @@ struct file_id
smb_vfs_call_file_id_create(struct vfs_handle_struct *handle,
        return handle->fns->file_id_create(handle, sbuf);
 }

+NTSTATUS smb_vfs_call_streaminfo_start(struct vfs_handle_struct *handle,
+                                      struct files_struct *fsp,
+                                      const char *fname,
+                                      TALLOC_CTX *mem_ctx,
+                                      unsigned int *num_streams,
+                                      struct stream_struct **streams)
+{
+       *num_streams = 0;
+       *streams = NULL;
+       VFS_FIND(streaminfo);
+       return handle->fns->streaminfo(handle, fsp, fname, mem_ctx,
+                                      num_streams, streams);
+}
+
 NTSTATUS smb_vfs_call_streaminfo(struct vfs_handle_struct *handle,
                                 struct files_struct *fsp,
                                 const char *fname,
---8<---

I've created bugreport
<https://bugzilla.samba.org/show_bug.cgi?id=8419> for this.
I'll highly appreciate your feedback so I can proceed with working on
the module itself.

Thanks!
-f


More information about the samba-technical mailing list