* Reverted r27196 and solved it differently (in a more robust way): instead of

guessing that the first attribute will be a name attribute, fCurrentSmallData
  now takes hidden attributes into account.
* I haven't tested this change, though, so if it messes things up again, please
  yell at me :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27441 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2008-09-12 09:25:17 +00:00
parent 2e2bff94a9
commit c4b2fd5be3

View File

@ -2599,16 +2599,13 @@ AttributeIterator::GetNext(char* name, size_t* _length, uint32* _type,
RecursiveLocker _(&fInode->SmallDataLock()); RecursiveLocker _(&fInode->SmallDataLock());
int32 i = 0; int32 index = 0;
for (;;item = item->Next()) { for (; !item->IsLast(node); item = item->Next(), index++) {
if (item->IsLast(node))
break;
if (item->NameSize() == FILE_NAME_NAME_LENGTH if (item->NameSize() == FILE_NAME_NAME_LENGTH
&& *item->Name() == FILE_NAME_NAME) && *item->Name() == FILE_NAME_NAME)
continue; continue;
if (i++ == fCurrentSmallData) if (index >= fCurrentSmallData)
break; break;
} }
@ -2618,15 +2615,12 @@ AttributeIterator::GetNext(char* name, size_t* _length, uint32* _type,
*_length = item->NameSize(); *_length = item->NameSize();
*_id = (ino_t)fCurrentSmallData; *_id = (ino_t)fCurrentSmallData;
fCurrentSmallData = i; fCurrentSmallData = index;
} return B_OK;
else {
// stop traversing the small_data section
fCurrentSmallData = -1;
} }
if (fCurrentSmallData != -1) // stop traversing the small_data section
return B_OK; fCurrentSmallData = -1;
} }
// read attributes out of the attribute directory // read attributes out of the attribute directory
@ -2641,7 +2635,7 @@ AttributeIterator::GetNext(char* name, size_t* _length, uint32* _type,
if (get_vnode(volume->FSVolume(), volume->ToVnode(fInode->Attributes()), if (get_vnode(volume->FSVolume(), volume->ToVnode(fInode->Attributes()),
(void**)&fAttributes) != B_OK) { (void**)&fAttributes) != B_OK) {
FATAL(("get_vnode() failed in AttributeIterator::GetNext(ino_t" FATAL(("get_vnode() failed in AttributeIterator::GetNext(ino_t"
" = %Ld,name = \"%s\")\n",fInode->ID(),name)); " = %Ld,name = \"%s\")\n", fInode->ID(), name));
return B_ENTRY_NOT_FOUND; return B_ENTRY_NOT_FOUND;
} }
@ -2649,7 +2643,7 @@ AttributeIterator::GetNext(char* name, size_t* _length, uint32* _type,
if (fAttributes->GetTree(&tree) < B_OK if (fAttributes->GetTree(&tree) < B_OK
|| (fIterator = new TreeIterator(tree)) == NULL) { || (fIterator = new TreeIterator(tree)) == NULL) {
FATAL(("could not get tree in AttributeIterator::GetNext(ino_t" FATAL(("could not get tree in AttributeIterator::GetNext(ino_t"
" = %Ld,name = \"%s\")\n",fInode->ID(),name)); " = %Ld,name = \"%s\")\n", fInode->ID(), name));
return B_ENTRY_NOT_FOUND; return B_ENTRY_NOT_FOUND;
} }
} }
@ -2661,7 +2655,7 @@ AttributeIterator::GetNext(char* name, size_t* _length, uint32* _type,
if (status < B_OK) if (status < B_OK)
return status; return status;
Vnode vnode(volume,id); Vnode vnode(volume, id);
Inode* attribute; Inode* attribute;
if ((status = vnode.Get(&attribute)) == B_OK) { if ((status = vnode.Get(&attribute)) == B_OK) {
*_type = attribute->Type(); *_type = attribute->Type();
@ -2676,11 +2670,8 @@ AttributeIterator::GetNext(char* name, size_t* _length, uint32* _type,
void void
AttributeIterator::Update(uint16 index, int8 change) AttributeIterator::Update(uint16 index, int8 change)
{ {
// fCurrentSmallData points already to the next item. OTOH, index is always // fCurrentSmallData points already to the next item
// the position when considering the special name attribute while the if (index < fCurrentSmallData)
// attribute iterators do ignore that (they always start at the second
// position in the small data section, not the first).
if (index <= fCurrentSmallData)
fCurrentSmallData += change; fCurrentSmallData += change;
} }