freebsd-skq/sys
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
..
alpha Declare pointers to signal handling functions in full instead of as 1996-10-25 16:20:34 +00:00
amd64 Fix a problem with running down processes that have left wired 1996-11-03 03:40:47 +00:00
compat/linux Changed type of ni_dirp in struct namei' from caddr_t to const char *' 1996-09-03 23:17:15 +00:00
compile
conf Set REVISION=3.0 and RELDATE=199701 1996-11-03 12:04:05 +00:00
ddb if there is no console, cngetc should act like getc and return -1 1996-10-30 21:40:25 +00:00
dev Fix the broken EOF handling in the floppy driver. The most obvious 1996-11-02 23:31:11 +00:00
fs Fix a potential deadlock from the previous commit. 1996-10-30 03:52:57 +00:00
geom Remove devconf, it never grew up to be of any use. 1996-09-06 23:09:20 +00:00
gnu Removing old isdn stuff. 1996-10-20 18:24:17 +00:00
i386 Fix a problem with running down processes that have left wired 1996-11-03 03:40:47 +00:00
isa Fix the broken EOF handling in the floppy driver. The most obvious 1996-11-02 23:31:11 +00:00
isofs/cd9660 Fix signed/unsigned comparison warnings. 1996-10-20 21:01:46 +00:00
kern Further improved version of hadling a HALT when there is no console. 1996-10-31 00:57:28 +00:00
libkern collate_range_cmp -> __collate_range_cmp 1996-10-31 04:32:27 +00:00
miscfs Fix a potential deadlock from the previous commit. 1996-10-30 03:52:57 +00:00
modules Prepare kernel to take advantage of "branded" ELF binaries. 1996-10-16 17:51:08 +00:00
msdosfs MSDOS FS used to allocate a buffer before extending the VM object. In 1996-10-02 05:01:17 +00:00
net Fix comments, which appear to have been mangled long ago and far away. 1996-10-21 23:05:57 +00:00
netatalk bzero the entire at_ifaddr struct we malloc, not just the first part of it.. 1996-09-11 09:38:52 +00:00
netinet Fix braino on my part. When we have three different port ranges (default, 1996-10-30 06:13:10 +00:00
netipx Accept odd length ipx packets. (Win95 and some dialup servers use it.) 1996-08-18 08:38:15 +00:00
netkey This is the `netkey' kernel key-management service (the PF_KEY analogue 1996-06-14 17:22:18 +00:00
netns Bring back netns so that Netcon can take over support for it, as agreed. 1996-10-17 18:42:33 +00:00
nfs If a large (>4096 bytes) directory was modified, the old directory 1996-10-21 10:07:52 +00:00
nfsclient If a large (>4096 bytes) directory was modified, the old directory 1996-10-21 10:07:52 +00:00
nfsserver This fixes a problem with the nfs socket handling code which happens 1996-10-11 10:15:33 +00:00
pc98 The last update/merge of PC98 stuff before 2.2. The whole 1996-11-02 10:41:28 +00:00
pccard Cleaned up all headers that include <sys/ioctl.h> or <sys/ioccom.h>: 1996-09-21 14:59:43 +00:00
pci Add support for the SDL RISCom N2pci cards. Bring in the enhancements 1996-10-29 03:53:21 +00:00
powerpc/include Add commands for ptrace get/set registers.. (Same numbers as NetBSD) 1996-01-24 18:51:48 +00:00
rpc Fix a bunch of spelling errors in the comment fields 1996-01-30 23:33:04 +00:00
scsi Try number two. Add missing paren in MSG_IDENTIFY macro. 1996-10-07 03:53:43 +00:00
sys if there is no console, cngetc should act like getc and return -1 1996-10-30 21:40:25 +00:00
tools Another mega commit to staticize things. 1995-12-14 09:55:16 +00:00
ufs Fixed some races and misleading comments in ufs_rename(). 1996-11-04 16:05:51 +00:00
vm Change mmap to use OBJT_DEFAULT instead of OBJT_SWAP by default 1996-10-29 22:07:11 +00:00
Makefile The Great PC98 Merge. 1996-06-14 11:02:28 +00:00