Date: Tue, 10 Sep 2002 04:10:04 -0700 (PDT) From: David Malone <dwmalone@maths.tcd.ie> To: freebsd-bugs@FreeBSD.org Subject: Re: kern/42617: rename(2) IEEE Std 1003.1-2001 Violation Message-ID: <200209101110.g8ABA4nL016981@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/42617; it has been noted by GNATS. From: David Malone <dwmalone@maths.tcd.ie> To: Matthias Andree <matthias.andree@web.de> Cc: FreeBSD-gnats-submit@FreeBSD.org Subject: Re: kern/42617: rename(2) IEEE Std 1003.1-2001 Violation Date: Tue, 10 Sep 2002 12:06:36 +0100 On Tue, Sep 10, 2002 at 02:59:34AM +0200, Matthias Andree wrote: > When using rename with old and new path referring to the same file (through > hard links), old path is removed. This is a violation of IEEE Std 1003.1-2001. > This is also a violation of the Single Unix Specification 2. Either demands > that if the old argument and the new argument point to the same existing file, > rename() shall do nothing and return success. Doing nothing and returning success would seem to be inconsistent with C99: The rename function causes the file whose name is the string pointed to by old to be henceforth known by the name given by the string pointed to by new. The file named old is no longer accessable by that name. Mind you, it does say that if the new file exists before prior to the rename call, then the behaviour is implimentation defined. What does the wording in IEEE Std 1003.1-2001 look like? I'd guess the patch below would change the behaviour do be what you are suggesting. David. Index: vfs_syscalls.c =================================================================== RCS file: /FreeBSD/FreeBSD-CVS/src/sys/kern/vfs_syscalls.c,v retrieving revision 1.151.2.16 diff -u -r1.151.2.16 vfs_syscalls.c --- vfs_syscalls.c 26 Apr 2002 00:46:04 -0000 1.151.2.16 +++ vfs_syscalls.c 10 Sep 2002 11:03:54 -0000 @@ -2702,10 +2702,7 @@ * same inode number with the same name in the same directory), * then there is nothing to do. */ - if (fvp == tvp && fromnd.ni_dvp == tdvp && - fromnd.ni_cnd.cn_namelen == tond.ni_cnd.cn_namelen && - !bcmp(fromnd.ni_cnd.cn_nameptr, tond.ni_cnd.cn_nameptr, - fromnd.ni_cnd.cn_namelen)) + if (fvp == tvp) error = -1; out: if (!error) { To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209101110.g8ABA4nL016981>