2.2.5pre1: unlink design flaw

jd at epcnet.de jd at epcnet.de
Thu Jun 13 15:49:02 GMT 2002

> From: <idra at samba.org>
> >
> > On smbfs you cannot create links. Nor on fatfs.
> But samba runs on posix file systems too, and they have it.

Thats not the point. I said that the race condition does not occur
under posix file systems, cause unlink NEVER returns ETXTBSY.

I did not seen it in the linux source.

> I think smbfs/fat32 can be made posix compliant for this particular
> operation and that's the right way to go IMO.

I bet smbfs cannot be made posix compliant:

Following scenario:

open file A direct on server X (console)

mount share T on server X with smbfs
open file A over smbfs to server X
unlink A on smbfs share (ETXTBSY, mark it in smbfs as deleted, return DELETE OK to samba)
close file A (last smbfs reference, try a second unlink -> ETXTBSY! - now what?)
unmount share on server X

mount share on server X
Huhu, file A appears. But i have deleted it over samba without error?

You see what i mean?

With your solution you would get:

unlink -> "shadow ok from smbfs"
close -> "smbfs tries unlink internally"
result: file still exists or not depending if it was opened by a second process on server

My solution:

Posix fs:

unlink -> succeed or fail (but never with ETXTBSY)
close -> succeed
second unlink always skipped
result: file deleted

Non-Posix fs:

unlink -> fail with ETXTBSY
close -> succeed
only if ETXTBSY unlink -> succeed or ETXTBSY for fail
result: file deleted


      Jochen Dolze
ISP & Web Design
Bleichstrasse 24
89077 Ulm

Tel.  +49 731 1416 0
Fax  +49 731 1416 120

More information about the samba-technical mailing list