[haiku-commits] haiku: hrev54058 - in src: tests/kits/storage add-ons/kernel/file_systems/bfs

  • From: Adrien Destugues <pulkomandy@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 18 Apr 2020 14:22:16 -0400 (EDT)

hrev54058 adds 1 changeset to branch 'master'
old head: 7ba52abdd38f37e7bd687334173108196760f609
new head: ee8cf35f07e207a2c17ba3c7d350a252c33e9497
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=ee8cf35f07e2+%5E7ba52abdd38f

----------------------------------------------------------------------------

ee8cf35f07e2: bfs: Return B_NAME_TOO_LONG from BPlusTree::Find
  
  This patch makes "UnitTester BNode" pass.
  
  Several tests which attempt to create or access a directory entry that
  exceeds the maximum length assume that B_NAME_TOO_LONG status will be
  returned, since that is what BeOS does. When constructing a BNode with
  a path like "/tmp/some really long filename larger than 256
  characters...", the vfs eventually calls bfs_lookup() which calls
  BPlusTree::Find(). In the case of a really long entry, Find() returns
  B_BAD_VALUE.
  
  This patch just changes BPlusTree::Find to return the more specific
  error that matches BeOS.
  
  Additionally this patch fixes some assertions in NodeTest. BeOS seems
  to have been missing some error checking code in the initialization of
  BNode, specifically with BNode(Directory*, const char*) and the
  equivalent SetTo method. If you provide an empty string for the child
  entry name to either of those, B_OK will be returned. But either way
  you initialize the object, when you try to use it, like with
  BNode::GetAttrInfo(), you'll get B_BAD_VALUE.
  
  This just changes any assertions for this situation to expect
  B_ENTRY_NOT_FOUND, which is the actual initialization error Haiku
  sets.
  
  This and the change to bfs resolves many assertions the following
  storage tests:
  * TestCaller BFile::Init Test 1
  * TestCaller BFile::Init Test 2
  * TestCaller BNode::Init Test1
  * TestCaller BNode::Init Test2
  * TestCaller BSymLink::Init Test 1
  * TestCaller BSymLink::Init Test 2
  
  Change-Id: I8598352aa341ffcab9f7bc3e6740ae1cb3dbab8c
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/2490
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

                                  [ Kyle Ambroff-Kao <kyle@xxxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev54058
Commit:      ee8cf35f07e207a2c17ba3c7d350a252c33e9497
URL:         https://git.haiku-os.org/haiku/commit/?id=ee8cf35f07e2
Author:      Kyle Ambroff-Kao <kyle@xxxxxxxxxxxxxx>
Date:        Tue Apr  7 01:54:11 2020 UTC
Committer:   Adrien Destugues <pulkomandy@xxxxxxxxx>
Commit-Date: Sat Apr 18 18:22:04 2020 UTC

----------------------------------------------------------------------------

2 files changed, 7 insertions(+), 6 deletions(-)
src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp | 7 ++++---
src/tests/kits/storage/NodeTest.cpp               | 6 +++---

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp 
b/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp
index 47125d67e5..c64c07c3c4 100644
--- a/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp
+++ b/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp
@@ -2276,11 +2276,12 @@ BPlusTree::Replace(Transaction& transaction, const 
uint8* key, uint16 keyLength,
 status_t
 BPlusTree::Find(const uint8* key, uint16 keyLength, off_t* _value)
 {
-       if (keyLength < BPLUSTREE_MIN_KEY_LENGTH
-               || keyLength > BPLUSTREE_MAX_KEY_LENGTH
-               || key == NULL)
+       if (key == NULL || keyLength < BPLUSTREE_MIN_KEY_LENGTH)
                RETURN_ERROR(B_BAD_VALUE);
 
+       if (keyLength > BPLUSTREE_MAX_KEY_LENGTH)
+               RETURN_ERROR(B_NAME_TOO_LONG);
+
        if (fAllowDuplicates)
                RETURN_ERROR(B_BAD_TYPE);
 
diff --git a/src/tests/kits/storage/NodeTest.cpp 
b/src/tests/kits/storage/NodeTest.cpp
index 193a128a2d..5dc8e22fef 100644
--- a/src/tests/kits/storage/NodeTest.cpp
+++ b/src/tests/kits/storage/NodeTest.cpp
@@ -383,7 +383,7 @@ NodeTest::InitTest1()
                BDirectory pathDir(dirSuperLink);
                CPPUNIT_ASSERT( pathDir.InitCheck() == B_OK );
                BNode node(&pathDir, "");
-               CPPUNIT_ASSERT( node.InitCheck() == B_OK );
+               CPPUNIT_ASSERT(node.InitCheck() == B_ENTRY_NOT_FOUND);
        }
        NextSubTest();
        {
@@ -564,8 +564,8 @@ NodeTest::InitTest2()
        //
        NextSubTest();
        CPPUNIT_ASSERT( pathDir.SetTo(dirSuperLink) == B_OK );
-       CPPUNIT_ASSERT( node.SetTo(&pathDir, "") == B_OK );
-       CPPUNIT_ASSERT( node.InitCheck() == B_OK );
+       CPPUNIT_ASSERT(node.SetTo(&pathDir, "") == B_ENTRY_NOT_FOUND);
+       CPPUNIT_ASSERT(node.InitCheck() == B_ENTRY_NOT_FOUND);
        //
        NextSubTest();
        CPPUNIT_ASSERT( pathDir.SetTo(existingSuperFile) == B_OK );


Other related posts:

  • » [haiku-commits] haiku: hrev54058 - in src: tests/kits/storage add-ons/kernel/file_systems/bfs - Adrien Destugues