[Samba] What's Happening

Urban Widmark urban at teststation.com
Sat May 25 07:00:03 GMT 2002

On Fri, 24 May 2002, Kenneth Loafman wrote:

> I misspoke when I said file locking.  The locking is via a guard file
> created with "open(guard, O_WRONLY | O_CREAT | O_EXCL, 0644)", which
> should protect against other processes opening it once it has been
> created.  It appears that is not working either.

My open manpage has the following:

"O_EXCL is broken on NFS  file  systems,  programs  which  rely  on  it for
 performing locking tasks will contain a race  condition."

Perhaps the same applies to smbfs. I don't know why it doesn't work, if in
fact this is what doesn't work.

You could try using a directory instead of a file as guard, but if all
processes that you need locking between are on the same linux machine you
could just put it locally.

Note that my comment regarding locking has nothing to do with the error
messages you saw which are network related, except possibly the -26 error.
And that is simply a verbose way of saying that the file open failed.

One thing to note is that when a connection is lost the smb server closes
any files you had open. After smbfs reconnects it also starts to reopen
files behind your back as you access them, but that leaves a hole where
someone else could open the file.

> If locking does not work, and guard files don't work, how does one
> maintain a queue via Samba?  Are there any papers on the subject?  Do I
> need to put the guard files on an NFS mounted FS on a Linux box?  I seem
> to recall that NFS has locking problems as well.

Note that samba is not involved in this, please use the word smbfs. The
only samba parts that are used are the ones that connect to a server and
they do not deserve any blame.

smbfs works fine for many simpler tasks, single user accessing files,
running programs from a central server, remote edits. But people seem to
run into various limitations when they want to do more advanced things.


More information about the samba mailing list