[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Bug moving file over link?



On 19:41 08 Feb 2003, Jeremy Fitzhardinge <jeremy goop org> wrote:
| On Sat, 2003-02-08 at 16:57, Andrew Morton wrote:
| > The Open Group base specification 6 says:
| > 
| > "If the old argument and the new argument resolve to the same existing file,
| >  rename() shall return successfully and perform no other action."
| > 
| > http://www.opengroup.org/onlinepubs/007904975/functions/rename.html
| 
| Seems to be an ambiguous to me.  I would interpret that to mean that if
| old and new ended up referring to the same direntry in the same
| directory then there should be no operation, rather than two entries
| pointing to the same inode.  Hm, their definition of "file" does seem to
| mean the inode, which makes rename's behaviour a bit counter-intuitive
| here.

Counterintuitive but "correct".

It's surprisingly hard to unambiguously sy what we all would probably
prefer: that only when the paths resolve to the same file _and_ final
filename should no action occur (I'd rather some kind of E* return
myself, but no matter). The guys in the open group aren't idiots or
fascists. Bear in mind that this check could be pretty hard to do. I've
used the phrase "same file _and_ final filename" up there, but "final
filename" is very vague; a precise wording that protected rename("x","x")
and rename("path1/to/x","path1/to/x") but allowed rename("x","y") for
the "right" cases might be very tricky, and then there's the issue of
implementation; the simple "inodes match" check is very easy and portable.

Cheers,
-- 
Cameron Simpson, DoD#743        cs zip com au    http://www.zip.com.au/~cs/

We would've believed it was an accidental shooting if he hadn't changed
magazines ......TWICE	- suicide will apana org au





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]