btrfs: Fix attribute lookup with same name hash in _FindEntry()

Previously _FindEntry() always returned the first entry regardless
of name, which would return wrong results when multiple attributes
shared the same hash. Now it properly searches through all entries
to find the one matching the requested name.

Hashtags: gsoc2026
Change-Id: Ia07ea852ab8bdfb178fa2d3b9677bc0e03427342
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10474
Haiku-Format: Haiku-format Bot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
anujbillore-0-0
2026-04-08 11:24:20 +00:00
committed by Adrien Destugues
parent aa194141c4
commit f02a32d987
@@ -182,12 +182,13 @@ Attribute::_FindEntry(btrfs_dir_entry* entries, size_t length,
btrfs_dir_entry* entry = entries;
uint16 current = 0;
while (current < length) {
if (entry->NameLength() == nameLength
&& strncmp((char*)entry->name, name, nameLength) == 0) {
*_entry = entry;
return B_OK;
}
current += entry->Length();
break;
// TODO there could be several entries with the same name hash
entry = (btrfs_dir_entry*)((uint8*)entry + entry->Length());
}
*_entry = entry;
return B_OK;
return B_ENTRY_NOT_FOUND;
}