* Backported r20809 to the R5 version of BFS.

* Note that r20809 also fixes a bug in Inode::GetAttribute() - it could clobber
  the attribute parameter and still fail (which could create problems in WriteAttribute()).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20810 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2007-04-25 10:53:14 +00:00
parent cb0572cac5
commit a72b83c06e
@@ -786,9 +786,11 @@ Inode::WriteAttribute(Transaction *transaction, const char *name, int32 type, of
small_data *smallData = FindSmallData(name);
if (smallData != NULL) {
oldLength = smallData->DataSize();
if (oldLength > BPLUSTREE_MAX_KEY_LENGTH)
oldLength = BPLUSTREE_MAX_KEY_LENGTH;
memcpy(oldData = oldBuffer, smallData->Data(), oldLength);
if (oldLength > 0) {
if (oldLength > BPLUSTREE_MAX_KEY_LENGTH)
oldLength = BPLUSTREE_MAX_KEY_LENGTH;
memcpy(oldData = oldBuffer, smallData->Data(), oldLength);
}
}
fSmallDataLock.Unlock();
@@ -807,7 +809,7 @@ Inode::WriteAttribute(Transaction *transaction, const char *name, int32 type, of
if (attribute != NULL) {
if (attribute->Lock().LockWrite() == B_OK) {
// save the old attribute data (if this fails, oldLength will reflect it)
if (fVolume->CheckForLiveQuery(name)) {
if (fVolume->CheckForLiveQuery(name) && attribute->Size() > 0) {
oldLength = BPLUSTREE_MAX_KEY_LENGTH;
if (attribute->ReadAt(0, oldBuffer, &oldLength) == B_OK)
oldData = oldBuffer;
@@ -913,7 +915,7 @@ Inode::RemoveAttribute(Transaction *transaction, const char *name)
status_t
Inode::GetAttribute(const char *name, Inode **attribute)
Inode::GetAttribute(const char *name, Inode **_attribute)
{
// does this inode even have attributes?
if (Attributes().IsZero())
@@ -932,11 +934,12 @@ Inode::GetAttribute(const char *name, Inode **attribute)
vnode_id id;
if ((status = tree->Find((uint8 *)name, (uint16)strlen(name), &id)) == B_OK) {
Vnode vnode(fVolume, id);
Inode *inode;
// Check if the attribute is really an attribute
if (vnode.Get(attribute) < B_OK
|| !(*attribute)->IsAttribute())
if (vnode.Get(&inode) < B_OK || !inode->IsAttribute())
return B_ERROR;
*_attribute = inode;
vnode.Keep();
return B_OK;
}