Re: VFS problem

2002-06-02 Thread Alexander Bokovoy

On Sat, Jun 01, 2002 at 09:25:10AM -0700, Jim Myers wrote:
 I'm trying to write a VFS module that uses the conn-vfs_private problem.
 It appears this field is never referenced in existing Samba code and is NOT
 initialized in vfs.c:vfs_init_custom.
 
 It appears to me that this function needs the following line added:
   conn-vfs_private = NULL;
 
 However there is a further design problem. There is no way for a custom VFS
 to properly initialize and cleanup as there is no first-time call that
 allows access to the conn structure, nor is there a cleanup call to free
 any memory pointed to by vfs_private.
 
 I would think it would be could to add the conn structure as a parameter to
 the custom VFS init function: vfs_init and and a new cleanup call as well
 so the associated memory could be freed.
I did that in stackable VFS where each module could have their own
vfs_private information. This is against Samba 3.0 (HEAD of a couple weeks
ago).

Look in examples/VFS/*.c to see details of how to use this with stackable
VFS (attached).

-- 
/ Alexander Bokovoy
Software architect and analyst // SaM-Solutions Ltd.
---
The little pieces of my life I give to you, with love, to make a quilt
to keep away the cold.



samba-3.0-cascaded-vfs.1.1.patch.bz2
Description: BZip2 compressed data


Re: VFS problem

2002-06-02 Thread Juergen Hasch

Hi Jim,

Am Samstag, 1. Juni 2002 18:25 schrieb Jim Myers:
 I'm trying to write a VFS module that uses the conn-vfs_private problem.
 It appears this field is never referenced in existing Samba code and is NOT
 initialized in vfs.c:vfs_init_custom.

 It appears to me that this function needs the following line added:
   conn-vfs_private = NULL;

 However there is a further design problem. There is no way for a custom VFS
 to properly initialize and cleanup as there is no first-time call that
 allows access to the conn structure, nor is there a cleanup call to free
 any memory pointed to by vfs_private.

 I would think it would be could to add the conn structure as a parameter to
 the custom VFS init function: vfs_init and and a new cleanup call as well
 so the associated memory could be freed.

 Jim Myers
 IBM Almaden Research Center
 B3-239, 408-927-2013

what's the problem with conn-vfs_private not being initialized ?
You can start using it on connect and don't have to worry about it's contents. 
And you clean it up on disconnect. 

In my recycle bin module for Samba 2_2 I'm using vfs_private like this:

static int recycle_connect(struct connection_struct *conn, const char 
*service, const char *user)
{
TALLOC_CTX *ctx=NULL;

if (!(ctx = talloc_init_named(recycle bin))) {
DEBUG(0, (Failed to allocate memory in VFS module recycle_bin\n));
return 0;
}
conn-vfs_private= (void *)ctx;
return 0;
}

static void recycle_disconnect(struct connection_struct *conn)
{
talloc_destroy((TALLOC_CTX *)conn-vfs_private);
default_vfs_ops.disconnect(conn);
}

...Juergen






Re: VFS problem

2002-06-02 Thread Juergen Hasch

Hi Jim,

Am Sonntag, 2. Juni 2002 22:58 schrieb Jim Myers:
 I was aware of that, but from the traces I took (with log level=10),
 connect was sometimes NOT called!
 I saw examples where after Samba was restarted and I tried to access a file
 in the VFS share, the first call after vfs_init was an open.

 So that strategy did not work (using Samba 3.0alpha17)

then this is clearly a bug. What I did for testing was to create a persistent
structure in connect(), which gets deleted in disconnect(). When a vfs 
function is called, it searches a linked list of persistent objects until it 
finds it's connection number SNUM(conn).

...Juergen