Subject: CVS commit: src/sys/nfs
To: None <source-changes@NetBSD.org>
From: YAMAMOTO Takashi <yamt@netbsd.org>
List: source-changes
Date: 07/01/2006 11:29:42
Module Name:	src
Committed By:	yamt
Date:		Sat Jul  1 11:29:42 UTC 2006

Modified Files:
	src/sys/nfs: nfs_var.h nfs_vnops.c

Log Message:
if a file is sillyrename'ed because it's a destination of rename,
make sillyrename (try to) use LINK operation rather than RENAME.
PR/33861 from Jed Davis.  he provided the almost same patch.
according to him, it also happen to be what opensolaris does in this case.

from the PR:
> In nfs_rename(), if the destination appears to exist and is "in use"
> (this check is apparently satisfied even if the file isn't in use by
> anything except the rename itself), it will sillyrename it, then delete
> the sillyrenamed file even if the rename fails -- for instance, because
> the "from" file no longer exists on the server.

> mkdir a b; touch a/x; perl -e 'fork(); rename("a/x","b/x") or die "$!\n"'
>
> Afterwards, neither a/x nor b/x will exist.

> 1) Lookup of b/x; fails with NOENT.
> 2) Rename from a/x to b/x; succeeds.
> 3) Lookup of b/x; fails with NOENT.
> 4) Rename from b/x to b/.nfsA23a3; succeeds.
> 5) Rename from a/x to b/x; fails with NOENT.
> 6) Remove of b/.nfsA23a3; succeeds.


To generate a diff of this commit:
cvs rdiff -r1.61 -r1.62 src/sys/nfs/nfs_var.h
cvs rdiff -r1.238 -r1.239 src/sys/nfs/nfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.