From fd4a010b054bb45d5d1feac80ccb5f7b5058a480 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Fri, 25 Apr 2008 03:21:14 +0000 Subject: [PATCH] rename() is supposed to fail when the target exists and is not a directory only if the source is a directory. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25144 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp b/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp index 4c6f15798e..70c1a5c843 100644 --- a/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp +++ b/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp @@ -1015,6 +1015,10 @@ bfs_rename(fs_volume *_volume, fs_vnode *_oldDir, const char *oldName, if (vnode.Get(&other) < B_OK) return B_NAME_IN_USE; + // only allowed, if either both nodes are directories or neither is + if (inode->IsDirectory() != other->IsDirectory()) + return other->IsDirectory() ? B_IS_A_DIRECTORY : B_NOT_A_DIRECTORY; + status = newDirectory->Remove(transaction, newName, NULL, other->IsDirectory()); if (status < B_OK)