9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Roman V Shaposhnik <rvs@sun.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: [9fans] renaming to an existing file
Date: Tue,  4 Aug 2009 18:25:50 -0700	[thread overview]
Message-ID: <1249435550.479.16703.camel@work.SFBay.Sun.COM> (raw)

I've just realized that in 9P the wstat would refuse
to rename an entry if a target name already exists.

So how can I atomically replace one file with another
one, so that during the operation clients opening
it would not fail?

In POSIX rename gives you such an atomicity:
-----------------------------------------------------------------------
If the old argument points to the pathname of a file that is not a
directory, the new argument shall not point to the pathname of a
directory. If the link named by the new argument exists, it shall be
removed and old renamed to new. In this case, a link named new shall
remain visible to other processes throughout the renaming operation and
refer either to the file referred to by new or old before the operation
began.
------------------------------------------------------------------------

How can I achieve the same result with 9P?

Thanks,
Roman.




             reply	other threads:[~2009-08-05  1:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-05  1:25 Roman V Shaposhnik [this message]
2009-08-05  1:41 ` Russ Cox

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=1249435550.479.16703.camel@work.SFBay.Sun.COM \
    --to=rvs@sun.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).