Developing a VFS plugin for inhouse backup solution

Stefan (metze) Metzmacher metze at samba.org
Sun Feb 13 11:11:15 GMT 2005


> On Sat, Feb 12, 2005 at 10:06:02PM -0800, Jeremy Allison wrote:
>> On Sat, Feb 12, 2005 at 05:12:46PM -0800, Brian Gunlogson wrote:
>> > Inside my VFS SMB_VFS_OP_OPEN I want to store per-file data. The data
>> needs to be accessible when
>> > SMB_VFS_OP_CLOSE is called. Where (in what structure) should per-file
>> data be stored?
>>
>> This is a bug in Samba really. We should have a "private" data pointer
>> available in the files_struct and the connection_struct for VFS use.
>> I'll
>> fix this for 3.0.12.
> We do have it already in vfs_handle_struct. Each VFS functions gets a
> handle specific to particular VFS module and can operate on data stored in
> handle by SMB_VFS_HANDLE_XXX_DATA() macros.

per file data can't be a simple void *private_data on the files_struct!

each module in the stack would need to have it's on private pointer for
the open file.
Implementing this in the calling samba code would be very complicated

so I think the best way to solve that for such a module is:

- create a file table on the per connection modules private data
  (maybe use the idr tree code, which is also used in samba4)

- implement all SMB_VFS functions which take files_struct as arg

- and on open store the per file data in the idr tree with the fnum as key

- on close or anyother operation fetch the private data from the idr tree
  and maybe then remove it from the idr tree on close

--
metze

Stefan Metzmacher <metze at samba dot org>


More information about the samba-technical mailing list