From a628d23613699afef9360db89f98413164b5860d Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 18 Jul 2010 13:17:43 +0000 Subject: [PATCH] Prevent creation of entries in unlinked directories. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37563 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../system/kernel/file_corruption/fs/checksumfs.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/tests/system/kernel/file_corruption/fs/checksumfs.cpp b/src/tests/system/kernel/file_corruption/fs/checksumfs.cpp index 339625985c..353374d1fa 100644 --- a/src/tests/system/kernel/file_corruption/fs/checksumfs.cpp +++ b/src/tests/system/kernel/file_corruption/fs/checksumfs.cpp @@ -546,6 +546,10 @@ checksumfs_create_symlink(fs_volume* fsVolume, fs_vnode* parent, if (error != B_OK) return error; + // don't create an entry in an unlinked directory + if (directory->HardLinks() == 0) + RETURN_ERROR(B_ENTRY_NOT_FOUND); + // create a symlink node SymLink* newSymLink; error = volume->CreateSymLink(mode, transaction, newSymLink); @@ -849,13 +853,16 @@ checksumfs_create(fs_volume* fsVolume, fs_vnode* parent, const char* name, RETURN_ERROR(error); // The entry doesn't exist yet. We have to create a new file. -// TODO: Don't do that in an unlinked directory! // check the directory write permission error = check_access(directory, W_OK); if (error != B_OK) return error; + // don't create an entry in an unlinked directory + if (directory->HardLinks() == 0) + RETURN_ERROR(B_ENTRY_NOT_FOUND); + // start a transaction and attach the directory Transaction transaction(volume); error = transaction.StartAndAddNode(directory, @@ -1121,6 +1128,10 @@ checksumfs_create_dir(fs_volume* fsVolume, fs_vnode* parent, const char* name, if (error != B_OK) return error; + // don't create an entry in an unlinked directory + if (directory->HardLinks() == 0) + RETURN_ERROR(B_ENTRY_NOT_FOUND); + // create a directory node Directory* newDirectory; error = volume->CreateDirectory(perms, transaction, newDirectory);