Re: ext2fs problem with rename() system call

Guest section DW (dwguest@win.tue.nl)
Thu, 7 Jan 1999 20:04:21 +0100 (MET)


From: Jamie Lokier <lkd@tantalophile.demon.co.uk>
To: torvalds@transmeta.com, Remy.Card@linux.org, linux-kernel@vger.rutgers.edu

There is a problem with the rename() system call in 2.1.131 on ext2fs.

1. The problem is that if source and destination are the same file, it
returns zero ("success") but does not remove the source file. It
should remove the source file.

The behaviour you sketch is excellent. POSIX 5.5.3.2 (in ISO/IEC 9945-1:1996(E))
says:

If old and new both refer to links to the same existing file,
the rename() function shall return successfully and perform
no other action.

So, there is no problem here.

Of course this stipulation is probably not what the authors intended,
but it is the law, as far as I can see. (I do not have a copy of later
amendments and clarifications at hand here. Maybe someone can check.)

[The rationale explains the requirement by saying that "mv x x" must
not delete the file x. I agree entirely that it is a bit unexpected
that after "mv x y" the name x still exists if x and y happen to be
the same file.]

Andries

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/