9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] renaming to an existing file
@ 2009-08-05  1:25 Roman V Shaposhnik
  2009-08-05  1:41 ` Russ Cox
  0 siblings, 1 reply; 2+ messages in thread
From: Roman V Shaposhnik @ 2009-08-05  1:25 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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.




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [9fans] renaming to an existing file
  2009-08-05  1:25 [9fans] renaming to an existing file Roman V Shaposhnik
@ 2009-08-05  1:41 ` Russ Cox
  0 siblings, 0 replies; 2+ messages in thread
From: Russ Cox @ 2009-08-05  1:41 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> How can I achieve the same result with 9P?

You can't.  (Redefine 9P.)

Russ


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-08-05  1:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-05  1:25 [9fans] renaming to an existing file Roman V Shaposhnik
2009-08-05  1:41 ` Russ Cox

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