Re: ext2fs problem with rename() system call

Jamie Lokier (lkd@tantalophile.demon.co.uk)
Thu, 7 Jan 1999 18:07:46 +0000


On Thu, Jan 07, 1999 at 04:03:30PM +0000, Tom Eastep wrote:
> Jamie Lokier wrote:
> >
> > 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.
> >
>
> No, it shouldn't - From POSIX.1, section 5.5.3.2:
>
> "If the _old_ argument and the _new_ argument both refer to links
> to the same existing file, the rename() function shall return
> successfully and perform no other action."

I guess GNU `ln -fb a b' and `cp -flb a b' are broken then. They fail if
`b' and `b~' point to the same file, which is quite likely in these cases.
`ln -f a b' and `cp -fl a b' are fine.

Should I submit a bug report for fileutils then?

Other commands that make backups tend to simply write to `b' and `b~'
together, losing the old contents of the destination file. But that
sounds like quite reasonable behaviour under the circumstances.

-- Jamie

-
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/