From f02a32d9878980debf1abdb6ae064f86223b1e08 Mon Sep 17 00:00:00 2001 From: anujbillore-0-0 Date: Wed, 11 Mar 2026 12:47:17 +0530 Subject: [PATCH] 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 Reviewed-by: Adrien Destugues Tested-by: Commit checker robot --- src/add-ons/kernel/file_systems/btrfs/Attribute.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/add-ons/kernel/file_systems/btrfs/Attribute.cpp b/src/add-ons/kernel/file_systems/btrfs/Attribute.cpp index 6f1c5627a2..7e7412fbd4 100644 --- a/src/add-ons/kernel/file_systems/btrfs/Attribute.cpp +++ b/src/add-ons/kernel/file_systems/btrfs/Attribute.cpp @@ -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; }