From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Sun, 2 Nov 2008 19:02:19 -0800 From: Roman Shaposhnik In-reply-to: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Message-id: MIME-version: 1.0 Content-type: text/plain; delsp=yes; format=flowed; charset=US-ASCII Content-transfer-encoding: 7BIT References: <4C2C9539-5ABB-4230-BC8A-A1765DFC0E1C@utopian.net> <88AA41FF-421E-4E72-AC4E-FE8CED83D599@sun.com> Subject: Re: [9fans] mv on directory Topicbox-Message-UUID: 2cfa3e4a-ead4-11e9-9d60-3106f5b1d025 On Nov 1, 2008, at 7:12 PM, Eric Van Hensbergen wrote: > On Sat, Nov 1, 2008 at 4:05 PM, Roman Shaposhnik 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 .hidden-from-everybody and expect all references to anything in the original file hierarchy to fail from that point on. Thanks, Roman.