9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Charles Forsyth <charles.forsyth@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] create/create race
Date: Wed, 30 Nov 2016 21:51:20 +0000	[thread overview]
Message-ID: <CAOw7k5gY0pvv6o1y05hFR+jvfDckYpN5PdkxivWfD2xd0uqR5g@mail.gmail.com> (raw)
In-Reply-To: <CAHL7psGpqyb2T+H++eh-yOoVQqQBS1yu-Tnj_BfJKtNDY=zNLQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1288 bytes --]

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
> 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.

[-- Attachment #2: Type: text/html, Size: 3021 bytes --]

  reply	other threads:[~2016-11-30 21:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-24 21:25 Giacomo Tesio
2016-11-30 11:04 ` Giacomo Tesio
2016-11-30 11:19   ` cinap_lenrek
2016-11-30 13:14   ` G. David Butler
2016-11-30 13:32     ` cinap_lenrek
2016-11-30 13:53       ` Charles Forsyth
2016-11-30 15:02         ` Giacomo Tesio
2016-11-30 15:08           ` Charles Forsyth
2016-11-30 15:28             ` Giacomo Tesio
2016-11-30 15:34               ` Charles Forsyth
2016-11-30 15:40               ` cinap_lenrek
2016-11-30 16:16                 ` Giacomo Tesio
2016-11-30 21:51                   ` Charles Forsyth [this message]
2016-11-30 21:53                     ` Charles Forsyth
2016-11-30 23:15                       ` Giacomo Tesio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOw7k5gY0pvv6o1y05hFR+jvfDckYpN5PdkxivWfD2xd0uqR5g@mail.gmail.com \
    --to=charles.forsyth@gmail.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).