[PATCH] module stuff (BIG patch :-)

Stefan (metze) Metzmacher metze at metzemix.de
Wed Dec 18 16:37:00 GMT 2002

Hi Jelmer,

here are the things I changed from the last patch:

in Makefile.in:

DATADIR = @datadir@  jht agree:-)

module stuff:
we now have a

#define SMB_MODULE_INIT_SYMBOL_STR "smb_module_init"
#define SMB_MODULE_INIT_SYMBOL           smb_module_init

maybe we could postfix a version number? ->
         SMB_MODULE_INIT_SYMBOL smb_module_init_0_0

we now have the same syntax for the smb_register_*() functions

NTSTATUS smb_register_<subsystem>(struct <subsystem>_function_entry *func, 
int interfaceversion);

so we never have to change the parameter of the smb_register_fn's
(the subsystem can change the struct and the interfaceversion, but we'll 
allways have:
NTSTATUS smb_register_fn(void *,int); )

CHARSET stuff:

change prototype
NTSTATUS  smb_register_charset(struct charset_function *func, int 


PASSDB stuff:

change prototype
NTSTATUS  smb_register_passdb(struct pdb_backend_function_entry *func, int 

a module now registeres only a struct of function pointers and no init 
there's a new *_init_private_data function that provides the initialisation

we have to get rid of the 'passdb backend = ldapsam:ldap://localhost/'
syntax, (but later if abartlet is back :-)

AUTH stuff:

NTSTATUS smb_register_auth(struct auth_method_function_entry *func, int 

a module now registers a struct of function pointers...(maybe we should add 
a init_private_data() as in PASSDB too)


the 'auth method = module:module_param' syntax is gone :-)

VFS stuff:

change the prototype
NTSTATUS  smb_register_vfs(struct vfs_object_function_entry *func, int 

we now have conn->vfs_objects (a DLIST with all vfs_objects of the connection)

each vfs module got a global id number, with this number or it's registered 
name it can search itsself in the list. and got it's default options , 
opaque options or any other operations from other modules of the connection.

for making it easy for module writers we have:

vfs_get_deafult_ops(conn,module_id)  to get a pointer to a vfs_ops struct
vfs_get_default_op(conn,module_id,operation_type) to get a pointer to a 
specified operation function



the vfs_init() and vfs_done() function are gone...
and only the vfs_op_tuple array is registered by each module.
( if the module needs to init private data it should be done in the connect 
and disconnect functions)

(tridge: I hope your happy now)

- 'vfs options' is removed ( parametric options should be used)
- 'vfs objects = <module1_name>{[<module2_name>]}

here th ething witch were in the last patch:

here is a new patch for the modules stuff, parametric options and new 

- it adds 'modules path' and 'modules' as per share parameter
    (vfs path is now an alias for modules path)

- it add two new parameters to the smb_load_modules function

int smb_load_modules(const char **modules, connection_struct *conn, 

conn == NULL - for the global section.

SMB_MODULE_TYPES types - this is the bitmask witch module types should be 
loaded here, ( we don't need a winsdb module in smbd... also 
smb_register_winsdb() is not linked to smbd, witch would cause trouble)

now we can use 
to load the charsets before the fork in smbd

smb_load_modules(lp_modules(SNUM(conn)),SNUM(conn),MODULE_TYPE_VFS) for 
loading the vfs modules per share..

lp_module_path is dyn_LIBDIR by default...

lib_path() for loading upcase.dat,... is replaced by data_path() witch is 
default dyn_DATADIR

for making jerry and jht happy I use :
DATADIR = @libdir@     in Makefile.in but it should be changed to
DATADIR = @datadir@

%-Macros can be in 'modules path' and 'modules'

- parametric options now all take a default value.
  char *lp_param_string() and char **lp_param_string_list() can be used as 
every othere
  lp_* function with char * or char **
  you should not try to free() the return values of this function!!!

- smb_register_vfs()
    Each SAMBA module must provide following global function:
     init_module         -- module initalization function

         NTSTATUS init_module(SMB_MODULE_TYPES types)
                 if (types & MODULE_TYPE_VFS) {
                         if (smb_register_vfs("recycle", vfs_recycle_init, 
                                 return NT_STATUS_OK;
                         } else {
                                 return NT_STATUS_UNSUCCESSFUL;

                 return NT_STATUS_OK;

     Each VFS module must provide following global function:
     vfs_*_init          -- vfs initialization function

     vfs_*_init (e.g. vfs_recycle_init ) must return proper initialized 
vfs_op_tuple[] array
     which describes all operations this module claims to intercept. This 
     is called whenever module is loaded into smbd process using sys_dlopen().

     vfs_*_init must have a list (indexed by the SNUM(conn) or CNUM(conn))
     for storing the default_vfs_ops and if module wants to store private
     information for further usage.

     vfs_op_tuple *vfs_recycle_init(struct connection_struct *conn, struct 
vfs_ops *default_vfs_ops, const char *param);

'vfs path' is removed
'vfs options' is removed ( parametric options should be used)

'vfs object' move to 'vfs objects'  ( but 'vfs object' is an alias)

'vfs objects = <module1_name>{[<module2_name>]}

- vfs_audit.c is installed as audit.so
- vfs_recycle.c is installed as recycle.so
- vfs_nettalk.c is installed as nettalk.so

vfs_audit.c and vfs_recycle.c  are now per connection safe
vfs_netatalk.c should be updated to use SMB_VFS_INTERFACE_VERSION 6 later

I have tested this patch this afternoon and I have no problems...

Stefan "metze" Metzmacher <metze at metzemix.de>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: modules-20021218-02.diff.tgz
Type: application/x-compressed
Size: 51936 bytes
Desc: not available
Url : http://lists.samba.org/archive/samba-technical/attachments/20021218/28c631de/modules-20021218-02.diff.bin

More information about the samba-technical mailing list