Linux apps vs share modes

TomKleinpeter tomk at
Thu Nov 18 23:45:09 GMT 2004


I'm working on some software that will run on a Linux machine and
manage files that may be accessed by Windows users via Samba.  One of
my big concerns is overwriting files that the user has opened but not
saved in Windows.  I've done some testing, and things seem to work
great when the Windows app has locked specific parts of the file
(using LockFileEx), because that translates into POSIX locks which I
can check with fcntl.

Things don't work so great when the Windows app has just opened the
file using CreateFile, even though I see an entry like this in

FLOCK  MSNFS   NONE  299 03:02:163937 0 EOF ....

It is my understanding that the Windows share modes (DENY_ALL, etc)
are not propagated to POSIX locks, but is there a non standard way
that I can check if they exist?  A previous thread suggested grepping
the output of smbstatus, but I don't think that will be efficient
enough for me.  On a longshot, I've tried calling flock with
LOCK_WRITE | LOCK_MAND, but that didn't seem to work.  Any ideas?

I'm using Samba 2.2.7 and the 2.4.20 kernel, by the way.

Thanks for your time,

More information about the samba-technical mailing list