[PATCH][SAMBA3] allow VFS modules to extend files_struct

James Peach jpeach at samba.org
Mon Jun 5 23:16:13 GMT 2006


On Mon, 2006-06-05 at 13:58 -0700, Jiri Klouda wrote:
> Hi,
> wouldn't it be better if each module just kept this data in its own
> data segment in any form they wish? It seems like this is fracturing
> the allocated data of each module and making it harder to cleanup.

If you want to attach a structure, you can do this:

        struct foo * pfoo;
        if ((pfoo = VFS_FSP_ADD_EXTENSION(handle, fsp, struct foo)) {
                /* do stuff */
        }

If you want, you can also manage the payload yourself:

        struct foo * pfoo;
        void ** payload;
        if ((payload = VFS_FSP_ADD_EXTENSION(handle, fsp, void *)) {
                /* do stuff */
        	*payload = pfoo;
        }
        
        /* sometime later */
        struct foo * pfoo;
        void ** payload;
        if ((payload = VFS_FSP_FETCH_EXTENSION(handle, fsp)) {
                /* do stuff */
        	pfoo = *(struct foo **)payload;
        }
        
I'm not sure why you'd want to do the latter. My need for this is simply
to attach a number of SMB_OFF_T data members to files_struct. If you
need something more complicated, then either of the above examples
should be sufficient, yes?

> Also, instead of allocating a specific size block, wouldn't it be 
> better to just have one void pointer and let the module manage it 
> in the way they see fit? Like to put it under a different common
> talloc parent?

This interface does allow you to do that if you want. I don't want to
force you to do that, however, because I believe (guess?) that most uses
of this API will be adding simple data members. I don't want to force
multiple VFS modules to contain extra memory management code.

-- 
James Peach | jpeach at samba.org



More information about the samba-technical mailing list