From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: <1f7987e063f01beaba1c53723d3f5b97@felloff.net> From: Charles Forsyth Date: Wed, 30 Nov 2016 21:51:20 +0000 Message-ID: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=089e0112c7f498fc2805428bb419 Subject: Re: [9fans] create/create race Topicbox-Message-UUID: afb4bf40-ead9-11e9-9d60-3106f5b1d025 --089e0112c7f498fc2805428bb419 Content-Type: text/plain; charset=UTF-8 On 30 November 2016 at 16:16, Giacomo Tesio wrote: > Also I'm looking for "instances that *want* the existing effect", as > Charles perfectly described them, something that break without it, so that > I can dive deeper into the matter. cat >x x: already exists rm x cat >x # different race mk x cp x /tmp/x x: already exists rm x # this is getting tedious ed x 1342 $a hello world . w ?exists !rm x ! w 1354 basically, most programs or uses that save, copy or update data to a named file are replacing the contents, so "make sure name exists and truncate it" is the most common case, isn't it? There's no particular reason that couldn't be done by a user-level library call, create, that ran the three two or three primitive syscalls in sequence. The applications just want the wretched thing there and empty. (This is separate from some notion of file versioning, which could be done by close, making the create/trunc+update replacement action atomic.) Mind you, the 3 syscall version adds a more subtle race, which is that the whole path name is re-evaluated 3 times, which opens up the possibility of a name space change higher up changing the meaning a different way. Still even that is not very likely in practice. --089e0112c7f498fc2805428bb419 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

= On 30 November 2016 at 16:16, Giacomo Tesio <giacomo@tesio.it> wrote:
Also I'= m looking for "instances that *want* the existing effect", as Cha= rles perfectly described them, something that break without it, so that I c= an dive deeper into the matter.

cat >x
x: already exists
rm x=
cat >x
=C2=A0# different race
mk x
cp x /tmp/x
x:= already exists
rm x
= =C2=A0= # this is getting tedious

=
ed x
1342
<= div class=3D"gmail_extra">$a
hello world
.
w
?exists
!rm x
<= div class=3D"gmail_extra">!
w
1354

basically, most programs or uses that save, copy or updat= e data to a named file are replacing the contents, so "make sure name = exists and truncate it"
is the most co= mmon case, isn't it? There's no particular reason that couldn't= be done by a user-level library call,
crea= te, that ran the three two or three primitive syscalls in sequence. The app= lications just want the wretched thing there and empty.
(This is separate from some notion of file versioning, which c= ould be done by close, making the create/trunc+update replacement action at= omic.)
Mind you, the 3 syscall version adds= a more subtle race, which is that the whole path name is re-evaluated 3 ti= mes, which opens
up the possibility of a na= me space change higher up changing the meaning a different way. Still even = that is not very likely in practice.
--089e0112c7f498fc2805428bb419--