VFS version error

Richard Sharpe realrichardsharpe at gmail.com
Sat Feb 28 08:59:08 MST 2015

On Sat, Feb 28, 2015 at 6:49 AM, Richard Sharpe
<realrichardsharpe at gmail.com> wrote:
> On Fri, Feb 27, 2015 at 11:11 PM, Sharayu Mantri <sm25541994 at gmail.com> wrote:
>> Sir,
>> I want to intercept vfs open, close, opendir, mkdir and other calls. I don't
>> understand the need of multi-threading. So , i want start with
>> skel_transparent.
> OK, having looked at the two modules I now understand.
> You took a demo module I wrote years ago and have now got that to work
> on Samba 3.6.3. That uses multi-threading, but it is not what you want
> to do.
> Then you took the transparent skelaton and tried to use that as a
> starting point for your own module and that has a symbol problem.
> The only big difference I can see is that the init function is not
> declared before it is used.
> How did you build the module?
> You might be better off to start with the instructions on the Wiki and
> construct a module from scratch rather than use the skelaton one. I am
> pretty sure there are no automatic tests to ensure it still works.
> Also, you are working with Samba 3.6.x which none of the developers
> work with these days.
>> You said the symbol should be changed. I don't understand. Can you elaborate
>> please?

1. I would suggest that you start from scratch and only implement one
of the VFS functions that simply has a DEBUG statement in it (so you
can see that it has been called when looking at the log) and calls
SMB_VFS_NEXT_<fn> (whatever function you are implementing.)

2. Be careful how you build. If you look in Makefile.in in
examples/VFS for 3.6.x you will see that when it compiles the module
it does -D$*_init=init_samba_module.

That is, it is changing the actual name of the function
<module_name>_init to init_samba_module. The reason for this is that
VFS modules have to be able to function as statically linked code and
as dynamically linked from dl_open. If it is a .so that is linked with
dl_open, there has to be a standard symbol (well, not really, I guess.
We could have used snprintf to construct the symbol ...) which is
init_samba_module, but in the code we call it
vfs_skel_transparent_init. Herein lies the problem. The example is
broken, and no one has noticed until now.

The file that it lives in is called skel_transparent.c and the
Makefile.in (when converted to Makefile) uses that name and does
-Dskel_transparent_init=init_samba_module which is not the name of the
symbol in the file.

There are two ways to fix this:

1. rename skel_transparent.c to vfs_skel_transparent.c

2. Change the code to have that function called skel_transparent_init.

However, you should really think about what you want to do because
Samba 3.6 is not getting any further development and is several years
old. You would be better off working with Samba 4.1.x or even 4.2.0
(which should be out soon.)

Unfortunately, things have changed with Samba 4.x and I have not yet
updated the Wiki page. Maybe in the next month or so.

Richard Sharpe

More information about the samba-technical mailing list