[Samba] O_EXCL unreliable?

Urban Widmark urban at teststation.com
Mon Jun 17 16:11:02 GMT 2002


On Mon, 17 Jun 2002, Egon Eckert wrote:

> > Looks like an smbfs problem to me (is that what
> > you're mounting the Samba filesystem with).
> 
> May be.  It's Linux/i386 2.4.18, smbmount version "2.2.3a-6 for
> Debian".
> 
> Running strace on the server (smbd 2.2.3a on Debian woody)
> shows, that some flags are missing in the actual open() call:
> O_TRUNC and O_EXCL (both are set and visible in strace on the
> client).  I understand, this may be caused by the smbfs as
> well, not just by the smbd.

smbfs does not do anything useful with O_EXCL or O_TRUNC. Both could be at
least partially supported by using a less obsolete smb for sending the
open request. I don't know if that kills the race the manpage speaks of.


> We switched to use "rename()" for our synchronisation purposes
> instead.  I hope *this* will work as expected at last...

rename on smbfs works like this:

+ If the file being moved is open, close it.
+ If the "target" exists
  + close it if it was open 
  + tell the server to unlink it
+ Send the move request.

unlink() also closes if the file is open locally.

I don't know the exact reasons for closing things like this but I'm
guessing that some programs expecting unixy behaviour was happier if they
could do "open/read/unlink" and not have to do a close before the unlink.

The former is posix and the second is how smb works. Or something.


I suggested to someone that they may be better of with a lock directory
instead of a file on smbfs. I don't know/remember if that helped.

/Urban





More information about the samba mailing list