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@gmail.com>
This commit is contained in:
parent
7ba52abdd3
commit
ee8cf35f07
@ -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);
|
||||
|
||||
|
@ -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 );
|
||||
|
Loading…
Reference in New Issue
Block a user