VFS module in Samba 3.0 (read and write files doesn't work)

Alejandro Sánchez Acosta asanchez at opensistemas.com
Tue Jul 13 11:30:09 GMT 2004

On Tue, 2004-07-13 at 11:33 +0200, Simo Sorce wrote:
> On Tue, 2004-07-13 at 09:47, Alejandro Sánchez Acosta wrote:
> > Hello,
> > 
> > I'm making a VFS module for Samba 3.0 and I intercept at this moment
> > connect/disconnect/open/close calls.
> > 
> > If I try to intercept the read and write calls, I don't register
> > anything. In almost all situations I usually use syslog to register
> > messages in the /var/log/messages.
> > 
> > I think is because all the files are mapped in memory, so the
> > are protected with PROT_READ and PROT_WRITE and that is the reason
> > because I can't intercept that calls.
> I don't think so, you "intercept" them by wrapping them before they
> actually called inside the vfs layer.
> If you coded your module the right way there's no way for samba to
> the file system except by passing through your own read and write
> wrappers.

I do the same with open/connect/close/disconnect and it works without
any trouble and the code is simple.

static ssize_t
residente_read(vfs_handle_struct *handle, files_struct *fsp, int fd,
void *data, size_t n)
  residente_syslog("It has been done a read");

  DEBUG(3,("residente: residente_read\n"));

  return SMB_VFS_NEXT_READ(handle, fsp, fd, data, n);

And it doesn't register anything in /var/log/messages, but with the
other calls I have logs like:

You have open a file: fname
now you have closed the file

(intercepting open/close calls).

When I intercept readdir() syslog register fine the operations.

> > I know I can disable mmap in Samba, but is going to affect in the
> > performance.
> No need to disable mmap, and that's not used to read/write files

Yes, I see, I have put 'use mmap = no' in smb.conf and restarted samba
and I have the same trouble, it's so odd.

> > The reason because I intercept reads and writes is only because I
> > to know if you are reading or writting a file with Samba, so I don't
> > know if it is a better way to do it.
> > 
> > Any clue?
> You may have made something wrong, try to modify the example audit
> module and see what you get.

I haven't seen any module intercepting read/write in modules/* or

The same happens with audit intercepting the read and write calls.

> > P.D: I don't know if I have to intercept other calls to know if you
> > reading or writting a file, like sendfile(), pread() or pwrite().
> If you're unsure what calls you need to intercept, just run samba as
> single instance and strace it.

I have run strace smbd -i and I only cat the gnome-print-3bxVg1. Now
intercepting pread and pwrite works.


More information about the samba-technical mailing list