From owner-freebsd-bugs Tue Sep 10 4:10:11 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id ACE3737B400 for ; Tue, 10 Sep 2002 04:10:04 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 66CC643E65 for ; Tue, 10 Sep 2002 04:10:04 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g8ABA4JU016982 for ; Tue, 10 Sep 2002 04:10:04 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g8ABA4nL016981; Tue, 10 Sep 2002 04:10:04 -0700 (PDT) Date: Tue, 10 Sep 2002 04:10:04 -0700 (PDT) Message-Id: <200209101110.g8ABA4nL016981@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: David Malone Subject: Re: kern/42617: rename(2) IEEE Std 1003.1-2001 Violation Reply-To: David Malone Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR kern/42617; it has been noted by GNATS. From: David Malone To: Matthias Andree 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