Make VFS op "streaminfo" stackable

Volker Lendecke Volker.Lendecke at SerNet.DE
Fri Aug 26 08:06:33 MDT 2011


On Fri, Aug 26, 2011 at 03:53:12PM +0200, Frank Lahm wrote:
> 2011/8/26 Frank Lahm <franklahm at googlemail.com>:
> > I'm currently starring at struct vfs_handle_struct trying to come up
> > with anything that could be used to determine inside
> > smb_vfs_call_streaminfo() whether it has been called through
> > SMB_VFS_STREAMINFO (which should do the initialisation) or
> > SMB_VFS_NEXT_STREAMINFO.
> 
> This should work, shouldn't it ?
> 
> 
> diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
> index 35a8331..c846174 100644
> --- a/source3/smbd/vfs.c
> +++ b/source3/smbd/vfs.c
> @@ -1673,6 +1673,11 @@ NTSTATUS smb_vfs_call_streaminfo(struct
> vfs_handle_struct *handle,
>                                  struct stream_struct **streams)
>  {
>         VFS_FIND(streaminfo);
> +       if (handle->prev->next == NULL) {
> +               /* VFS op chain start */
> +               *num_streams = 0;
> +               *streams = NULL;
> +       }
>         return handle->fns->streaminfo(handle, fsp, fname, mem_ctx,
>                                        num_streams, streams);
>  }

It might work, but I think this is the wrong layer. The
semantics of the streaminfo call would be that every module
adds its streams, otherwise you don't get stackability. This
means it's the callers responsibility to null out the
arguments before calling into SMB_VFS_STREAMINFO. This could
be done by a common wrapper. I know this is not perfect and
possibly error-prone, but a comment in the common wrapper
might give potential further callers the hint. And not
initializing the arguments will pretty quickly result in a
crash.

I would like to keep the smb_vfs_call_xx functions
completely boilerplate.

Other opinions?

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen


More information about the samba-technical mailing list