From b631d2f40d9e9b66e90533ad6e7595380a5dcda7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 27 Sep 2006 13:10:13 +0000 Subject: [PATCH] * Fixed the bug Bruno observed (and worked around) in a safer way - the node data was not written back before GetNextSmallData() was called (which let the region appear empty even though it wasn't). * I left the shortcut in case of the "name" attribute in there, because it should be a bit faster. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18949 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/file_systems/bfs/Inode.cpp | 6 +++++- src/add-ons/kernel/file_systems/bfs/Query.cpp | 21 +++++-------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/Inode.cpp b/src/add-ons/kernel/file_systems/bfs/Inode.cpp index ea5c1d0f93..e5cee4844b 100644 --- a/src/add-ons/kernel/file_systems/bfs/Inode.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Inode.cpp @@ -699,7 +699,8 @@ Inode::Name(const bfs_inode *node) const small_data *smallData = NULL; while (GetNextSmallData((bfs_inode *)node, &smallData) == B_OK) { - if (*smallData->Name() == FILE_NAME_NAME && smallData->NameSize() == FILE_NAME_NAME_LENGTH) + if (*smallData->Name() == FILE_NAME_NAME + && smallData->NameSize() == FILE_NAME_NAME_LENGTH) return (const char *)smallData->Data(); } return NULL; @@ -2227,6 +2228,9 @@ Inode::Create(Transaction &transaction, Inode *parent, const char *name, int32 m node->type = HOST_ENDIAN_TO_BFS_INT32(type); + inode->WriteBack(transaction); + // make sure the initialized node is available to others + // only add the name to regular files, directories, or symlinks // don't add it to attributes, or indices if (tree && inode->IsRegularNode() && inode->SetName(transaction, name) < B_OK) diff --git a/src/add-ons/kernel/file_systems/bfs/Query.cpp b/src/add-ons/kernel/file_systems/bfs/Query.cpp index 30039b6439..8686879277 100644 --- a/src/add-ons/kernel/file_systems/bfs/Query.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Query.cpp @@ -4,7 +4,7 @@ * by J. Kercheval, and on code written by Kenneth Almquist, though * it shares no code. * - * Copyright 2001-2005, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2001-2006, Axel Dörfler, axeld@pinc-software.de. * This file may be used under the terms of the MIT License. */ @@ -1600,24 +1600,13 @@ Query::LiveUpdate(Inode *inode, const char *attribute, int32 type, const uint8 * char nameBuffer[B_FILE_NAME_LENGTH]; if (name == NULL) { - - // We have to special-case the name attribute here because - // Inode::Getname will return NULL as we are in the middle - // of the transaction at this point when a new file is - // created. We just use newKey which happens to contain - // the new file name anyway. - // - // TODO: Check if there is any sense in leaving this if - // statement as it is or if we can completelly remove the - // original code. - if (strcmp(attribute, "name") == 0) { - name = (const char *)newKey; - } - else - { + if (strcmp(attribute, "name")) { if (inode->GetName(nameBuffer) != B_OK) nameBuffer[0] = '\0'; name = nameBuffer; + } else { + // a shortcut to prevent having to scan the attribute section + name = (const char *)newKey; } }