[Samba] Re: Windows share modes and Linux file locking, flock & fcntl

Peter Sirokman lothaine at gmail.com
Tue Jan 29 15:35:55 GMT 2008


> In particular I am looking at a machine running Linux exporting its
> local filesystem using Samba, with a Windows client accessing the
> file share.  If I use byte range locking (fcntl() on Linux, LockFile()
> on Windows) things work as expected, and applications using the
> file system locally and remotely see the locks set by the other.

> However, if a program on the Windows client opens a file with a
> share mode that denies access to other processes, I can't seem to
> detect this in a local Linux process, either with fcntl() or with flock().
> I included the test programs I used below. I have seen references
> that this should be possible
> (http://lists.samba.org/archive/samba/2004-February/080455.html
> last paragraph) but I may be misunderstanding things.

There seems to be a library for accessing Samba's database of share modes
in the Samba source tree (for version 3.0.28).  The relevant files are

./bin/libsmbsharemodes.so
./bin/libsmbsharemodes.a
./include/smb_share_modes.h
./libsmb/smb_share_modes.c
./libsmb/smb_share_modes.o

On the other hand, it doesn't appear to be possible to use local system
calls to detect share modes because their semantics are too different from
file locks, see threads below.

http://lists.samba.org/archive/samba/2007-March/subject.html#130305
http://lists.samba.org/archive/samba-technical/2005-February/thread.html#39425

Peter


More information about the samba mailing list