Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Rainer Weikusat Newsgroups: comp.os.linux.development.apps Subject: Re: mkdir() and thread safety() Date: Fri, 01 Apr 2011 21:03:00 +0100 Lines: 22 Message-ID: <87bp0pkadn.fsf@sapphire.mobileactivedefense.com> References: <9d56213c-a054-428e-866c-559da29fbbc3@o21g2000prh.googlegroups.com> <2d58ece6-bb9c-42e0-a990-fc13b92723ec@a21g2000prj.googlegroups.com> <87oc4vtn8o.fsf@sapphire.mobileactivedefense.com> <87tyejtx4u.fsf@sapphire.mobileactivedefense.com> <35d2db97-6ab2-42b1-a83a-c4764f3c3869@w7g2000pre.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: individual.net NQgY5C1JI+D3abuDWeBL7gTcpGoDGdZaPAiZwLXSmDMAtCkZQ= Cancel-Lock: sha1:GSjNa6Zs7njfguFvc4BYOyfR40E= sha1:NSUzvFUIUoU5ew/fNZAyQaeT7rU= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) Xref: x330-a1.tempe.blueboxinc.net comp.os.linux.development.apps:64 David Schwartz writes: > On Mar 31, 3:14 am, Rainer Weikusat wrote: >> David Schwartz writes: > >> > Yes, it is. The algorithm I specified will always fail if the named >> > file already existed before the operation started. > >> The operation starts when the 'backend' (whatever that happens to be) >> starts  to process the mkdir request, not at some arbitrarily distant >> random time in the past. > > The operation starts when the application calls 'mkdir'. The standard > only requires the operation to fail with EEXIST if the directory > exists before the operation starts. ... and just because the text doesn't explicitly state that 'the implementation is supposed to work correctly' doesn't mean that it was meant to allow incorrect implementations. Your non-atomic multi-step algorithm is such an incorrect implementation: Because of the TOCTOU race in it, its behaviour is actually undefined and cannot be defined.