Module Name: src
Committed By: hannken
Date: Fri Dec 26 15:22:15 UTC 2014
Modified Files:
src/sys/fs/sysvbfs: bfs.c sysvbfs_vnops.c
Log Message:
Sysvbfs_rename: Call bfs_file_delete(bfs, to_name, true) before calling
bfs_file_rename() and remove the bfs_file_delete() from bfs_file_rename().
After calling bfs_file_rename() it was too late to set "tnode->removed"
as the inode already disappeared.
To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/fs/sysvbfs/bfs.c
cvs rdiff -u -r1.54 -r1.55 src/sys/fs/sysvbfs/sysvbfs_vnops.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/fs/sysvbfs/bfs.c
diff -u src/sys/fs/sysvbfs/bfs.c:1.17 src/sys/fs/sysvbfs/bfs.c:1.18
--- src/sys/fs/sysvbfs/bfs.c:1.17 Thu Jan 9 13:23:57 2014
+++ src/sys/fs/sysvbfs/bfs.c Fri Dec 26 15:22:15 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: bfs.c,v 1.17 2014/01/09 13:23:57 hannken Exp $ */
+/* $NetBSD: bfs.c,v 1.18 2014/12/26 15:22:15 hannken Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bfs.c,v 1.17 2014/01/09 13:23:57 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bfs.c,v 1.18 2014/12/26 15:22:15 hannken Exp $");
#define BFS_DEBUG
#include <sys/param.h>
@@ -344,7 +344,6 @@ bfs_file_rename(struct bfs *bfs, const c
goto out;
}
- bfs_file_delete(bfs, to_name, false);
strncpy(dirent->name, to_name, BFS_FILENAME_MAXLEN);
bfs_writeback_dirent(bfs, dirent, false);
Index: src/sys/fs/sysvbfs/sysvbfs_vnops.c
diff -u src/sys/fs/sysvbfs/sysvbfs_vnops.c:1.54 src/sys/fs/sysvbfs/sysvbfs_vnops.c:1.55
--- src/sys/fs/sysvbfs/sysvbfs_vnops.c:1.54 Fri Aug 8 19:14:45 2014
+++ src/sys/fs/sysvbfs/sysvbfs_vnops.c Fri Dec 26 15:22:15 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: sysvbfs_vnops.c,v 1.54 2014/08/08 19:14:45 gson Exp $ */
+/* $NetBSD: sysvbfs_vnops.c,v 1.55 2014/12/26 15:22:15 hannken Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.54 2014/08/08 19:14:45 gson Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.55 2014/12/26 15:22:15 hannken Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -581,21 +581,23 @@ sysvbfs_rename(void *arg)
goto out;
}
+ /*
+ * Remove the target if it exists.
+ */
+ if (tvp != NULL) {
+ error = bfs_file_delete(bfs, to_name, true);
+ if (error)
+ goto out;
+ }
error = bfs_file_rename(bfs, from_name, to_name);
out:
- if (tvp) {
- if (error == 0) {
- struct sysvbfs_node *tbnode = tvp->v_data;
- tbnode->removed = 1;
- }
- vput(tvp);
- }
-
/* tdvp == tvp probably can't happen with this fs, but safety first */
if (tdvp == tvp)
vrele(tdvp);
else
vput(tdvp);
+ if (tvp)
+ vput(tvp);
vrele(fdvp);
vrele(fvp);