Developing a VFS module [english checked and now better]
Julien Thomas
omnikron at free.fr
Wed May 4 11:39:31 GMT 2005
Jeremy Allison wrote:
>>From conn->snum call lp_servicename(conn->snum).
>
>Jeremy.
>
Thanks,
With the help of Marek Grác, I succeed to store data using handle->data.
I store it in the CONNECT VFS operation and so, I am able to get it in
the DISCONNECT VFS operation.
Here the next message I post him, you could give your opinion. In
particular, I have a question about the build of the module.
Marek Grác wrote:
> Salut,
>
> Ok, so you have to write your own pc_data (my own struct
> firefs_per_connection) and then use
>
> SMB_VFS_HANDLE_GET_DATA(handle, pc_data, firefs_per_connection, return);
>
> SMB_VFS_HANDLE_SET_DATA(handle, pc_data, NULL, firefs_per_connection,
> return -1);
>
> Using this method you can pass values to every operation. I used it to
> pass database handlers and configuration options.
>
> PS: Be patient next time :) There is hockey championship so I'm not
> online everyday
Thanks a lot !!
That was the good way !
Here is what I done. Tell me if I should use SMB_VFS_HANDLE_GET/SET_DATA
macros instead of :
static int inra_connect(vfs_handle_struct *handle,
connection_struct *conn,
const char *service,
const char *user)
{
int result;
result = SMB_VFS_NEXT_CONNECT(handle, conn, service, user);
handle->data = (void *) malloc(sizeof(fstring));
fstr_sprintf(handle->data, "%s", service);
...
return result;
}
And so I can get back "service" on disconnection events :
static void inra_disconnect(vfs_handle_struct *handle,
connection_struct *conn)
{
char *service;
SMB_VFS_NEXT_DISCONNECT(handle, conn);
service = (char *)handle->data
...
}
It is dangerous to store data like this ? Should I use the macros
functions ?
I have another question... I can't build my module himself. I have to
use Samba's sources Makefile and update it to deal with my module. So I
put it (the module) in sources/vfs and it is built as an .so in
sources/bin.
I tryed the example provided with a configure/autogen and co in
example/VFS... The module build fine but is not usable. Samba's log
report that it is not found (same if I put the complete path in
smb.conf). I think it should be better for my use to buil it
staticaly... but I don't know well how to build (static or shared).
Thanks a lot Marek,
--
Julien Thomas
More information about the samba-technical
mailing list