9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Roman Shaposhnik <rvs@sun.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] mv on directory
Date: Sun,  2 Nov 2008 19:02:19 -0800	[thread overview]
Message-ID: <DE80F336-A146-4CF0-9F5E-65CCFBBED24C@sun.com> (raw)
In-Reply-To: <a4e6962a0811011912n122c667n7ff6e59434f59e30@mail.gmail.com>

On Nov 1, 2008, at 7:12 PM, Eric Van Hensbergen wrote:
> On Sat, Nov 1, 2008 at 4:05 PM, Roman Shaposhnik <rvs@sun.com> wrote:
>> On Nov 1, 2008, at 8:04 AM, Eric Van Hensbergen wrote:
>>>
>>> I would imagine that 99% of the time (more?) the behavior people
>>> desire would be what you describe.
>>
>> But what is the behavior? Is it literally the above set of rc
>> commands?
>> Or is there an atomicity expectation as well? After dircp dirA dirB
>> the contents of dirB could be surprising, especially given the later
>> rm -r dirA.
>>
>> It seems that mv(1) was taken as far as one could go in terms
>> of having a non-surprising behavior: mv dir1/file  dir2/file is
>> equivalent to cp -x dir1/file dir2/file ; rm dir1/file.
>>
>
> Well, I suppose there'd have to be a bit more wrapping around checking
> for failure of the copy before the erase -- but otherwise perhaps I'm
> being dense and don't see the surprise.

Well, it could be that I'm just too easily surprised. I'll try to
explain. Suppose
that you have the following sequence of directory renames (all within
the single FS
tree):
(1)     /a          ->    /b
(2)     /a/1       ->    /a/2

Because of the POSIX atomicity guarantee the minute you have (1) succeed
your (2) will fail because /a/1 no longer exists. The following, on
the other
hand:
   (1)  mv-dircp /a     /b
   (2)  mv-dircp /a/1 /a/2
is likely to produce /b/2, which, I find surprising. As a side note:
the results
are even more surprising/subtle when renames need to be serialized
in a DSCM. There's been quite a few debates on what DSCM does it
better. Just like Al said -- somebody at UCB had one heck of a trip ;-)

> Its clear you won't get the
> atomicity, but there's no clear way to obtain that -- and, as I said,
> I'm not sure who depends on that when using the mv command.


I would argue that personally I've been conditioned by POSIX to
be able to do:
     $ mv <root of the huge file hierarchy>  .hidden-from-everybody
and expect all references to anything in the original file hierarchy
to fail from that point on.

Thanks,
Roman.



  reply	other threads:[~2008-11-03  3:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1.1225540801.26550.9fans@9fans.net>
2008-11-01 13:48 ` Josh Wood
2008-11-01 14:17   ` Rudolf Sykora
2008-11-01 15:04     ` Eric Van Hensbergen
2008-11-01 21:05       ` Roman Shaposhnik
2008-11-02  2:12         ` Eric Van Hensbergen
2008-11-03  3:02           ` Roman Shaposhnik [this message]
2008-11-01 16:30 Josh Wood
2008-11-01 21:25 ` Roman Shaposhnik
  -- strict thread matches above, loose matches on Subject: below --
2008-10-31 20:15 Rudolf Sykora

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=DE80F336-A146-4CF0-9F5E-65CCFBBED24C@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).