summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_extattr.c
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2002-09-10 11:09:13 +0000
committerbde <bde@FreeBSD.org>2002-09-10 11:09:13 +0000
commit8aa3df4eb23614a40cdabd77332b1b29ff0bc21e (patch)
treefbf60a21a76d1e310c894136153d8d3364de0a27 /sys/kern/vfs_extattr.c
parentf21645dfc296a1b300c85a784a37a1b2c3200fe2 (diff)
downloadFreeBSD-src-8aa3df4eb23614a40cdabd77332b1b29ff0bc21e.zip
FreeBSD-src-8aa3df4eb23614a40cdabd77332b1b29ff0bc21e.tar.gz
vfs_syscalls.c:
Changed rename(2) to follow the letter of the POSIX spec. POSIX requires rename() to have no effect if its args "resolve to the same existing file". I think "file" can only reasonably be read as referring to the inode, although the rationale and "resolve" seem to say that sameness is at the level of (resolved) directory entries. ext2fs_vnops.c, ufs_vnops.c: Replaced code that gave the historical BSD behaviour of removing one link name by checks that this code is now unreachable. This fixes some races. All vnodes needed to be unlocked for the removal, and locking at another level using something like IN_RENAME was not even attempted, so it was possible for rename(x, y) to return with both x and y removed even without any unlink(2) syscalls (one process can remove x using rename(x, y) and another process can remove y using rename(y, x)). Prodded by: alfred MFC after: 8 weeks PR: 42617
Diffstat (limited to 'sys/kern/vfs_extattr.c')
-rw-r--r--sys/kern/vfs_extattr.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c
index 3015105..e1b2d7f 100644
--- a/sys/kern/vfs_extattr.c
+++ b/sys/kern/vfs_extattr.c
@@ -2744,14 +2744,10 @@ kern_rename(struct thread *td, char *from, char *to, enum uio_seg pathseg)
if (fvp == tdvp)
error = EINVAL;
/*
- * If source is the same as the destination (that is the
- * same inode number with the same name in the same directory),
- * then there is nothing to do.
+ * If the source is the same as the destination (that is, if they
+ * are links to the same vnode), 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) {
OpenPOWER on IntegriCloud