Inode::WriteAttribute() did not adopt a changed "type" when the attribute was a file,

causing subsequent reads with that type to fail.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19825 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2007-01-16 14:33:23 +00:00
parent ee144512ec
commit 458ff7ff31
+15 -8
View File
@@ -1,9 +1,10 @@
/* Inode - inode access functions
*
* Copyright 2001-2006, Axel Dörfler, [email protected].
/*
* Copyright 2001-2007, Axel Dörfler, [email protected].
* This file may be used under the terms of the MIT License.
*/
//! inode access functions
#include "Debug.h"
#include "Inode.h"
@@ -321,7 +322,7 @@ Inode::CheckPermissions(int accessMode) const
}
// #pragma mark -
// #pragma mark - attributes
void
@@ -753,7 +754,8 @@ Inode::SetName(Transaction &transaction, const char *name)
*/
status_t
Inode::ReadAttribute(const char *name, int32 type, off_t pos, uint8 *buffer, size_t *_length)
Inode::ReadAttribute(const char *name, int32 type, off_t pos, uint8 *buffer,
size_t *_length)
{
if (pos < 0)
pos = 0;
@@ -802,8 +804,8 @@ Inode::ReadAttribute(const char *name, int32 type, off_t pos, uint8 *buffer, siz
*/
status_t
Inode::WriteAttribute(Transaction &transaction, const char *name, int32 type, off_t pos,
const uint8 *buffer, size_t *_length)
Inode::WriteAttribute(Transaction &transaction, const char *name, int32 type,
off_t pos, const uint8 *buffer, size_t *_length)
{
// needed to maintain the index
uint8 oldBuffer[BPLUSTREE_MAX_KEY_LENGTH], *oldData = NULL;
@@ -855,6 +857,11 @@ Inode::WriteAttribute(Transaction &transaction, const char *name, int32 type, of
}
// ToDo: check if the data fits in the inode now and delete the attribute file if so
status = attribute->WriteAt(transaction, pos, buffer, _length);
if (status == B_OK) {
// The attribute type might have been changed - we need to adopt
// the new one - the attribute's inode will be written back on close
attribute->Node().type = HOST_ENDIAN_TO_BFS_INT32(type);
}
attribute->Lock().UnlockWrite();
} else
@@ -2313,7 +2320,7 @@ Inode::Create(Transaction &transaction, Inode *parent, const char *name, int32 m
}
// #pragma mark -
// #pragma mark - AttributeIterator
AttributeIterator::AttributeIterator(Inode *inode)