Go to file
Bruce Evans 206e5b7e27 Fixed some races and misleading comments in ufs_rename().
1. When a directory is renamed to an existing (empty) directory,
it is possible for the target vnode to become the source vnode
underneath you (because another process may complete the same
rename).  It was assumed that this can't happen, and the bogus
errno EINVAL was returned.  This was fairly harmless.

Fix: return ENOENT instead, as if the source directory was renamed
a little earlier.

2. The same metamorphosis is possible for non-directories.  It was
assumed that this can't happen, and the code for handling "just
removing a link name" happened to be used.  This would have worked
except for fatal bugs in the link name removal - the link name was
assumed to still be there, and a null pointer was followed.

Fix: check the result of relookup().  This fixes PR 1930.

Notes:

(a) POSIX seems to say that removing link names shall have no effect.
BSD (4.4Lite2 at least) does something reasonable instead.

(b) The relookup() may find a file unrelated to the original.
Removing this isn't correct.  Consider 3 existing files A, B and
C, and concurrent renames: AB = rename(A, B), another AB, and
CA = rename("c", "a").  If rename() is atomic, then only the
following results are possible:

	AB, AB (fails), CA: A = original C, B = original A, C = gone
	AB, CA, AB:         A = gone,       B = original C, C = gone
	CA, AB, AB (fails): A = gone,       B = original C, C = gone

but ufs_rename() can give:

	A,AB,CA,B (sorta):  A = gone,       B = original A, C = gone

This usually doesn't matter, since getting into a race is usually
an error.
---

These fixes should be in 2.1.6 and 2.2.
1996-11-04 16:05:51 +00:00
bin
contrib This commit was generated by cvs2svn to compensate for changes in r19370, 1996-11-03 17:03:03 +00:00
eBones
etc
games
gnu Get rid of bogus #ifdef's. 1996-11-04 04:36:31 +00:00
include
lib Compile libtelnet from eBones, not secure. 1996-11-03 16:59:04 +00:00
libexec Compile telnetd from eBones instead of secure. 1996-11-03 17:00:12 +00:00
lkm
release Use macros for package names so it's easier to update them in one 1996-11-04 12:56:33 +00:00
sbin fix usage string 1996-11-04 00:53:12 +00:00
secure
share In one place, bsd.port.mk was not enclosed in <tt></tt>. 1996-11-04 00:27:07 +00:00
sys Fixed some races and misleading comments in ufs_rename(). 1996-11-04 16:05:51 +00:00
tools
usr.bin Install message catalog links according to standard naming convention 1996-11-04 02:52:33 +00:00
usr.sbin Use macros for package names so it's easier to update them in one 1996-11-04 12:56:33 +00:00
COPYRIGHT
Makefile