From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 Date: Tue, 24 May 2016 23:25:47 +0200 Message-ID: From: Giacomo Tesio To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=001a1146ee3858403d05339d3300 Subject: [9fans] create/create race Topicbox-Message-UUID: 946fb758-ead9-11e9-9d60-3106f5b1d025 --001a1146ee3858403d05339d3300 Content-Type: text/plain; charset=UTF-8 I'm pretty curious about the create(2)/create(5) race described in a comment in namec (see https://github.com/brho/plan9/blob/master/sys/src/9/port/chan.c#L1564-L1603) Does anyone know or remember the reasoning behind this design? What was wrong about using the create(5) semantics for the create(2) syscall? Giacomo --001a1146ee3858403d05339d3300 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I'm pretty curious about the create(2)/= create(5) race described in a comment in namec (see https://gi= thub.com/brho/plan9/blob/master/sys/src/9/port/chan.c#L1564-L1603)
<= br>
Does anyone know or remember the reasoning behind this design?
=
What was wrong about using the create(5) semantics for the create= (2) syscall?


Giacomo
--001a1146ee3858403d05339d3300-- From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: From: Giacomo Tesio Date: Wed, 30 Nov 2016 12:04:49 +0100 Message-ID: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=001a114a9a30774710054282aca5 Subject: Re: [9fans] create/create race Topicbox-Message-UUID: af6eeae2-ead9-11e9-9d60-3106f5b1d025 --001a114a9a30774710054282aca5 Content-Type: text/plain; charset=UTF-8 Hi guys, I know this is a noob question, but I'd really like to understand this aspect of the kernel design. I'm planning to experiment on the topic, modifying chan.c so that the semantics of create(2) match those of create(5) about existing files. I guess that the number of callers to fix is manageable. But since I can't see any good reason for the race being there in the first place (except maybe backward compatibility with unix, but that was not a problem for Plan 9 designers), I'm pretty sure I'm missing something obvious. So, please, do you know why the create syscall does not simply return an error if the file already exists? You might save me a few headache... Thanks for your help! Giacomo 2016-05-24 23:25 GMT+02:00 Giacomo Tesio : > I'm pretty curious about the create(2)/create(5) race described in a > comment in namec (see https://github.com/brho/plan9/ > blob/master/sys/src/9/port/chan.c#L1564-L1603) > > Does anyone know or remember the reasoning behind this design? > > What was wrong about using the create(5) semantics for the create(2) > syscall? > > > Giacomo > --001a114a9a30774710054282aca5 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi guys, I know this is a noob qu= estion, but I'd really like to understand this aspect of the kernel des= ign.

I'm planning to experiment on the topic, modifying ch= an.c so that the semantics of create(2) match those of create(5) about exis= ting files. I guess that the number of callers to fix is manageable.
But since I can't see any good reason for the race being there i= n the first place (except maybe backward compatibility with unix, but that = was not a problem for Plan 9 designers), I'm pretty sure I'm missin= g something obvious.


So, please, do you know why the creat= e syscall does not simply return an error if the file already exists?
You might save me a few headache...


Thanks for y= our help!


Giacomo



2016-05-24 23:25 GMT+02:00 Giacomo Tesio <giacomo@tesio.it>:
I= 9;m pretty curious about the create(2)/create(5) race described in a commen= t in namec (see https://github.com/brho/plan= 9/blob/master/sys/src/9/port/chan.c#L1564-L1603)

Does anyone know or remember the reasoning behind this design?

What was wrong about using the create(5) semantics for the create(2) sysc= all?


Giacomo

--001a114a9a30774710054282aca5-- From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: Date: Wed, 30 Nov 2016 12:19:21 +0100 From: cinap_lenrek@felloff.net To: 9fans@9fans.net In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] create/create race Topicbox-Message-UUID: af7368ba-ead9-11e9-9d60-3106f5b1d025 it is not clear to me what your issue is. the manual clearly states that you can pass OEXCL to create to get atomic create operation so in what way are you trying to change the system calls? Since create may succeed even if the file exists, a special mechanism is necessary for those applications that require an atomic create operation. If the OEXCL (0x1000) bit is set in the mode for a create, the call succeeds only if the file does not already exist; see open(5) for details. -- cinap From mboxrd@z Thu Jan 1 00:00:00 1970 From: "G. David Butler" Content-Type: multipart/alternative; boundary=Apple-Mail-A8425A18-E6D6-4412-920A-06BB00CAC476 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (1.0) Date: Wed, 30 Nov 2016 07:14:59 -0600 Message-Id: References: In-Reply-To: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Subject: Re: [9fans] create/create race Topicbox-Message-UUID: af77af9c-ead9-11e9-9d60-3106f5b1d025 --Apple-Mail-A8425A18-E6D6-4412-920A-06BB00CAC476 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Wow, this is a sore subject. Check the archives of this list for a long vers= ion of this discussion. David Sent from my phone. Please excuse misspellings and terseness. > On Nov 30, 2016, at 5:04 AM, Giacomo Tesio wrote: >=20 > Hi guys, I know this is a noob question, but I'd really like to understand= this aspect of the kernel design. >=20 > I'm planning to experiment on the topic, modifying chan.c so that the sema= ntics of create(2) match those of create(5) about existing files. I guess th= at the number of callers to fix is manageable. >=20 > But since I can't see any good reason for the race being there in the firs= t place (except maybe backward compatibility with unix, but that was not a p= roblem for Plan 9 designers), I'm pretty sure I'm missing something obvious.= >=20 >=20 > So, please, do you know why the create syscall does not simply return an e= rror if the file already exists? > You might save me a few headache...=20 >=20 >=20 > Thanks for your help! >=20 >=20 > Giacomo >=20 >=20 >=20 > 2016-05-24 23:25 GMT+02:00 Giacomo Tesio : >> I'm pretty curious about the create(2)/create(5) race described in a comm= ent in namec (see https://github.com/brho/plan9/blob/master/sys/src/9/port/c= han.c#L1564-L1603) >>=20 >> Does anyone know or remember the reasoning behind this design? >>=20 >> What was wrong about using the create(5) semantics for the create(2) sysc= all? >>=20 >>=20 >> Giacomo >=20 --Apple-Mail-A8425A18-E6D6-4412-920A-06BB00CAC476 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Wow, this is a sore subject. Check the= archives of this list for a long version of this discussion.

Dav= id

Sent from my phone. Please excuse misspel= lings and terseness.


On Nov 30, 2016, at 5= :04 AM, Giacomo Tesio <giacomo@tesio.= it> wrote:

Hi guys, I know this is a noob question, but I'd= really like to understand this aspect of the kernel design.

I'= m planning to experiment on the topic, modifying chan.c so that the semantic= s of create(2) match those of create(5) about existing files. I guess that t= he number of callers to fix is manageable.

But since I can't se= e any good reason for the race being there in the first place (except maybe b= ackward compatibility with unix, but that was not a problem for Plan 9 desig= ners), I'm pretty sure I'm missing something obvious.


So, p= lease, do you know why the create syscall does not simply return an error if= the file already exists?
You might save me a few headache...
<= br>
Thanks for your help!


Giacomo<= br>


= --Apple-Mail-A8425A18-E6D6-4412-920A-06BB00CAC476-- From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <725518204b6f4564c0a2569e655ac310@felloff.net> Date: Wed, 30 Nov 2016 14:32:28 +0100 From: cinap_lenrek@felloff.net To: 9fans@9fans.net In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] create/create race Topicbox-Message-UUID: af7c03f8-ead9-11e9-9d60-3106f5b1d025 > Wow, this is a sore subject. Check the archives of this list for a > long version of this discussion. > > David interesting, the thread starts here: http://marc.info/?l=9fans&m=111558704718788&w=2 -- cinap From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <725518204b6f4564c0a2569e655ac310@felloff.net> References: <725518204b6f4564c0a2569e655ac310@felloff.net> From: Charles Forsyth Date: Wed, 30 Nov 2016 13:53:58 +0000 Message-ID: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=089e0115ee3c61344e054285097b Subject: Re: [9fans] create/create race Topicbox-Message-UUID: af801bbe-ead9-11e9-9d60-3106f5b1d025 --089e0115ee3c61344e054285097b Content-Type: text/plain; charset=UTF-8 On 30 November 2016 at 13:32, wrote: > interesting, the thread starts here: > > http://marc.info/?l=9fans&m=111558704718788&w=2 > I suspect the discussion predated 9P2000 and the introduction of the OEXCL option. --089e0115ee3c61344e054285097b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable



I suspect t= he discussion predated 9P2000 and the introduction of the OEXCL option.
--089e0115ee3c61344e054285097b-- From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: <725518204b6f4564c0a2569e655ac310@felloff.net> From: Giacomo Tesio Date: Wed, 30 Nov 2016 16:02:56 +0100 Message-ID: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=001a11448a3203fd0705428600a9 Subject: Re: [9fans] create/create race Topicbox-Message-UUID: af859062-ead9-11e9-9d60-3106f5b1d025 --001a11448a3203fd0705428600a9 Content-Type: text/plain; charset=UTF-8 David it seem you walked my road already... :-) I'm actually on a research project, so I do not care too much about the issues on existing programs. I'm going to change/break them anyway. Also, as far as I can foresee, it should be viable to fix such programs in a partially automated way (eg via sed and a new "ocreate" library function that mimic the current behaviour). But reading that thread I can't actually see why the OEXCL path has been taken instead of eliminating the race mapping the syscall to the 9p message. I mean except backward compatibility. Maybe it was found a performance issue in some more common use case? Or a worse race prevented by the current semantic? For example I've found pretty cryptic this message from David: http://marc.info/?l=9fans&m=111558704718797&w=2 I'm surprised I haven't yet seen "What about union directories?" > > If create(2) is changed then it could succeed even though a > file with that name exists in the union. Then the above: > > if ((fd = create(file, mode, perm)) < 0) { > error... > } > > Would need to become: > > if ((fd = open(file, mode|OTRUNC)) < 0 || > (fd = create(file, mode, perm)) < 0 || > (fd = open(file, mode|OTRUNC)) < 0 || > error... > } > > This is precisely the current create(2) call and the nasty > race is clear. > > Why the initial open() would be needed if create(2) always send a Tcreate? Giacomo 2016-11-30 14:53 GMT+01:00 Charles Forsyth : > > On 30 November 2016 at 13:32, wrote: > >> interesting, the thread starts here: >> >> http://marc.info/?l=9fans&m=111558704718788&w=2 >> > > > I suspect the discussion predated 9P2000 and the introduction of the OEXCL > option. > --001a11448a3203fd0705428600a9 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
David it seem you walked my road already... :-)

I'm actually o= n a research project, so I do not care too much about the issues on existin= g programs. I'm going to change/break them anyway.
Also, as far as I can foresee, it should be viable to fix = such programs in a partially automated way (eg via sed and a new "ocre= ate" library function that mimic the current behaviour).

=
But reading that thread I can't actually see= why the OEXCL path has been taken instead of eliminating the race mapping = the syscall to the 9p message.
I mean e= xcept backward compatibility.

Maybe it was found a performance issu= e in some more common use case?
Or a worse race prevented by the curren= t semantic?


For example I'v= e found pretty cryptic this message from David: http://marc.info/?l=3D9fans&= amp;m=3D111558704718797&w=3D2

I'm surprised I haven't yet seen "Wh=
at about union directories?"

If create(2) is changed then it could succeed even though a
file with that name exists in the union.  Then the above:

if ((fd =3D create(file, mode, perm)) < 0) {
	error...
}

Would need to become:

if ((fd =3D open(file, mode|OTRUNC)) < 0 ||
    (fd =3D create(file, mode, perm)) < 0 ||
    (fd =3D open(file, mode|OTRUNC)) < 0 ||
	error...
}

This is precisely the current create(2) call and the nasty
race is clear.

Why t= he initial open() would be needed if create(2) always send a Tcreate?

Gia= como


2016-11-30 14:53 GMT+01:00 Charles Forsyt= h <charles.forsyth@gmail.com>:

On 30 November 2016= at 13:32, <cinap_lenrek@felloff.net> wrote:


I su= spect the discussion predated 9P2000 and the introduction of the OEXCL opti= on.



--001a11448a3203fd0705428600a9-- From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: <725518204b6f4564c0a2569e655ac310@felloff.net> From: Charles Forsyth Date: Wed, 30 Nov 2016 15:08:33 +0000 Message-ID: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=001a11360774247d5805428614a7 Subject: Re: [9fans] create/create race Topicbox-Message-UUID: af89caba-ead9-11e9-9d60-3106f5b1d025 --001a11360774247d5805428614a7 Content-Type: text/plain; charset=UTF-8 On 30 November 2016 at 15:02, Giacomo Tesio wrote: > > But reading that thread I can't actually see why the OEXCL path has been > taken instead of eliminating the race mapping the syscall to the 9p message. > I mean except backward compatibility. > I suppose you'll find out, but I'd expect that all but a handful of instances want the existing effect and are untroubled by any potential race. Given that OEXCL then seems to handle the handful, it seems a reasonable approach. The ocreate would just put the race in a different place, wouldn't it? --001a11360774247d5805428614a7 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

= On 30 November 2016 at 15:02, Giacomo Tesio <giacomo@tesio.it> wrote:
But reading that thread I can't actua= lly see why the OEXCL path has been taken instead of eliminating the race m= apping the syscall to the 9p message.
I= mean except backward compatibility.

I suppose= you'll find out, but I'd expect that all but a handful of instance= s want the existing effect and are untroubled by any potential race.
<= div class=3D"gmail_extra">Given that OEXCL then seems to handle the handful= , it seems a reasonable approach.
The ocrea= te would just put the race in a different place, wouldn't it?
--001a11360774247d5805428614a7-- From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: <725518204b6f4564c0a2569e655ac310@felloff.net> From: Giacomo Tesio Date: Wed, 30 Nov 2016 16:28:06 +0100 Message-ID: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=001a113ac0cc0dcd150542865a01 Subject: Re: [9fans] create/create race Topicbox-Message-UUID: af8e1e12-ead9-11e9-9d60-3106f5b1d025 --001a113ac0cc0dcd150542865a01 Content-Type: text/plain; charset=UTF-8 2016-11-30 16:08 GMT+01:00 Charles Forsyth : > > On 30 November 2016 at 15:02, Giacomo Tesio wrote: > >> >> But reading that thread I can't actually see why the OEXCL path has been >> taken instead of eliminating the race mapping the syscall to the 9p message. >> I mean except backward compatibility. >> > > I suppose you'll find out, but I'd expect that all but a handful of > instances want the existing effect and are untroubled by any potential race. > Given that OEXCL then seems to handle the handful, it seems a reasonable > approach. > The ocreate would just put the race in a different place, wouldn't it? > Well not exactly: I will use the new create syscall (without OEXCL support) when I need such level of control and use ocreate with OEXCL when I do not care about the race and want a "create or truncate" default behaviour. But actually, I cannot see a use case where the create(2) default behaviour can be *wanted*. I just see many use case where it can be tollerated: the create can fail anyway for other reasons so it does not add much complexity to the client... But I'm probably missing something obvious: can you provide an example where not having the truncate fallback in the syscall actually break the program or introduce a bug. It's exactly what I'm looking for. Giacomo --001a113ac0cc0dcd150542865a01 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
2016-11-30 16:08 GMT+01:00 Charles Forsyth <charl= es.forsyth@gmail.com>:

On 30 No= vember 2016 at 15:02, Giacomo Tesio <giacomo@tesio.it> wrote:=

But reading that thread I can't actually see wh= y the OEXCL path has been taken instead of eliminating the race mapping the= syscall to the 9p message.
I mean exce= pt backward compatibility.

I suppose yo= u'll find out, but I'd expect that all but a handful of instances w= ant the existing effect and are untroubled by any potential race.
Given that OEXCL then seems to handle the handful, i= t seems a reasonable approach.
The ocreate = would just put the race in a different place, wouldn't it?

Well not exactly: I= will use the new create syscall (without OEXCL support) when I need such l= evel of control and use ocreate with OEXCL when I do not care about the rac= e and want a "create or truncate" default behaviour.

But actually, I cannot see a use case where the= create(2) default behaviour can be *wanted*.
I just see many use case = where it can be tollerated: the create can fail anyway for other reasons so= it does not add much complexity to the client...
But I'm probably m= issing something obvious: can you provide an example where not having the t= runcate fallback in the syscall actually break the program or introduce a b= ug. It's exactly what I'm looking for.


Giacomo


--001a113ac0cc0dcd150542865a01-- From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: <725518204b6f4564c0a2569e655ac310@felloff.net> From: Charles Forsyth Date: Wed, 30 Nov 2016 15:34:57 +0000 Message-ID: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=089e0112c7f48bc5c305428672b5 Subject: Re: [9fans] create/create race Topicbox-Message-UUID: af92e67c-ead9-11e9-9d60-3106f5b1d025 --089e0112c7f48bc5c305428672b5 Content-Type: text/plain; charset=UTF-8 On 30 November 2016 at 15:28, Giacomo Tesio wrote: > I will use the new create syscall (without OEXCL support) when I need such > level of control and use ocreate with OEXCL Perhaps I'm confused. I thought OEXCL was just the same as the 9P create, which is what you were trying to get. With OEXCL set, it tries Tcreate; if that fails, it stops, and doesn't try open-with-truncate etc. --089e0112c7f48bc5c305428672b5 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

= On 30 November 2016 at 15:28, Giacomo Tesio <giacomo@tesio.it> wrote:
I will use the new create sys= call (without OEXCL support) when I need such level of control and use ocre= ate with OEXCL

Perhaps I'm confused. I thought O= EXCL was just the same as the 9P create, which is what you were trying to g= et.
With OEXCL set, it tries Tcreate; if th= at fails, it stops, and doesn't try open-with-truncate etc.
--089e0112c7f48bc5c305428672b5-- From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <1f7987e063f01beaba1c53723d3f5b97@felloff.net> Date: Wed, 30 Nov 2016 16:40:02 +0100 From: cinap_lenrek@felloff.net To: 9fans@9fans.net In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] create/create race Topicbox-Message-UUID: afa793f6-ead9-11e9-9d60-3106f5b1d025 > Well not exactly: I will use the new create syscall (without OEXCL support) > when I need such level of control and use ocreate with OEXCL when I do not > care about the race and want a "create or truncate" default behaviour. this makes no sense to me. the whole point of create with OEXCL is that it is atomic and it will *NOT* try to truncate-open the file when it already exist. OEXCL means just sending the Tcreate and nothing else. why is that not already what you try todo with your new create syscall? can you please state the problem that you are trying to fix? -- cinap From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <1f7987e063f01beaba1c53723d3f5b97@felloff.net> References: <1f7987e063f01beaba1c53723d3f5b97@felloff.net> From: Giacomo Tesio Date: Wed, 30 Nov 2016 17:16:23 +0100 Message-ID: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=001a114a9a30b7214b054287062f Subject: Re: [9fans] create/create race Topicbox-Message-UUID: afafec18-ead9-11e9-9d60-3106f5b1d025 --001a114a9a30b7214b054287062f Content-Type: text/plain; charset=UTF-8 2016-11-30 16:40 GMT+01:00 : > this makes no sense to me. the whole point of create with OEXCL is that > it is atomic and it will *NOT* try to truncate-open the file when it > already > exist. OEXCL means just sending the Tcreate and nothing else. why is that > not > already what you try todo with your new create syscall? > > can you please state the problem that you are trying to fix? > Well, describing the whole picture would take a while (and would move the thread topic to other unusual aspects of its design), but one of the reason that can explain my question is that I want to simplify the kernel code as much as possible, moving to user space all that can be moved without affecting the system security. In the end I'd like to get few orthogonal syscalls, so that you cannot obtain the exact effect of one in term of 2 or more other. I know that this seem a bit theoretical, but it's just a starting point and has a lot of really pragmatic implications in my research project. Stated in a different way, I want to keep it simple, and user space code is usually simpler than kernel space code. Btw, actually, I'm not proposing a change to Plan 9 or debating about its design. I'm just asking about the reasoning behind this specific choice, because I guess that it's deeper than it seem (so much that I cannot grasp it by reading the code). 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. Giacomo --001a114a9a30b7214b054287062f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
2016-11-30 16:40 GMT+01:00 <cinap_lenrek@felloff= .net>:
this makes no sense to= me. the whole point of create with OEXCL is that
it is atomic and it will *NOT* try to truncate-open the file when it alread= y
exist. OEXCL means just sending the Tcreate and nothing else. why is that n= ot
already what you try todo with your new create syscall?

can you please state the problem that you are trying to fix?

Well, describing th= e whole picture would take a while (and would move the thread topic to othe= r unusual aspects of its design), but one of the reason that can explain my= question is that I want to simplify the kernel code as much as possible, m= oving to user space all that can be moved without affecting the system secu= rity.
In the end I'd like to get fe= w orthogonal syscalls, so that you cannot obtain the exact effect of one in= term of 2 or more other.

I know th= at this seem a bit theoretical, but it's just a starting point and has = a lot of really pragmatic implications in my research project.
Stated in a different way, I want to keep it simple= , and user space code is usually simpler than kernel space code.
<= div class=3D"gmail_extra">

Btw, act= ually, I'm not proposing a change to Plan 9 or debating about its desig= n.
I'm just asking about the reasoning behind this specific choice, = because I guess that it's deeper than it seem (so much that I cannot gr= asp it by reading the code).


Al= so 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.


Giacomo


--001a114a9a30b7214b054287062f-- 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-- 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:53:31 +0000 Message-ID: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=001a1144c39663c64605428bbc22 Subject: Re: [9fans] create/create race Topicbox-Message-UUID: afb9722e-ead9-11e9-9d60-3106f5b1d025 --001a1144c39663c64605428bbc22 Content-Type: text/plain; charset=UTF-8 On 30 November 2016 at 21:51, Charles Forsyth wrote: > that the whole path name is re-evaluated 3 times That doesn't happen with the current implementation, because it walks to the parent directory, does the create/open etc at that point with a reference held. --001a1144c39663c64605428bbc22 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

= On 30 November 2016 at 21:51, Charles Forsyth <charles.forsyth@gma= il.com> wrote:
that the who= le path name is re-evaluated 3 times

That doesn't= happen with the current implementation, because it walks to the parent dir= ectory, does the create/open etc at that point with a reference held.
=
--001a1144c39663c64605428bbc22-- From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: <1f7987e063f01beaba1c53723d3f5b97@felloff.net> From: Giacomo Tesio Date: Thu, 1 Dec 2016 00:15:17 +0100 Message-ID: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=001a1135a438d501b505428ce0bc Subject: Re: [9fans] create/create race Topicbox-Message-UUID: afbdab64-ead9-11e9-9d60-3106f5b1d025 --001a1135a438d501b505428ce0bc Content-Type: text/plain; charset=UTF-8 Thanks Charles! This is exactly the kind of info I was looking for. Giacomo 2016-11-30 22:53 GMT+01:00 Charles Forsyth : > > On 30 November 2016 at 21:51, Charles Forsyth > wrote: > >> that the whole path name is re-evaluated 3 times > > > That doesn't happen with the current implementation, because it walks to > the parent directory, does the create/open etc at that point with a > reference held. > --001a1135a438d501b505428ce0bc Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Thanks Charles! This is exactly the kind of info I wa= s looking for.


Giacomo

2016-11-30 22:53 GMT+01:00 Charles Forsyth = <charles.forsyth@gmail.com>:
=
On 30 November 2016 at 21:51, Charles Forsyt= h <charles.forsyth@gmail.com> wrote:
that the whole path name is re-evaluated 3 times

That doesn't happen with the current implementati= on, because it walks to the parent directory, does the create/open etc at t= hat point with a reference held.

--001a1135a438d501b505428ce0bc--