diff --git a/src/add-ons/kernel/file_systems/bfs/Inode.cpp b/src/add-ons/kernel/file_systems/bfs/Inode.cpp index daa5c1600e..56af7ff4cf 100644 --- a/src/add-ons/kernel/file_systems/bfs/Inode.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Inode.cpp @@ -302,7 +302,7 @@ Inode::MakeSpaceForSmallData(Transaction *transaction, const char *name, int32 b ASSERT(fSmallDataLock.IsLocked()); while (bytes > 0) { - small_data *item = Node()->small_data_start, *max = NULL; + small_data *item = Node()->SmallDataStart(), *max = NULL; int32 index = 0, maxIndex = 0; for (; !item->IsLast(Node()); item = item->Next(), index++) { // should not remove those @@ -408,7 +408,7 @@ Inode::RemoveSmallData(Transaction *transaction, const char *name) // search for the small_data item - small_data *item = Node()->small_data_start; + small_data *item = Node()->SmallDataStart(); int32 index = 0; while (!item->IsLast(Node()) && strcmp(item->Name(), name)) { item = item->Next(); @@ -449,7 +449,7 @@ Inode::AddSmallData(Transaction *transaction, const char *name, uint32 type, SimpleLocker locker(fSmallDataLock); - small_data *item = Node()->small_data_start; + small_data *item = Node()->SmallDataStart(); int32 index = 0; while (!item->IsLast(Node()) && strcmp(item->Name(), name)) { item = item->Next(); @@ -480,7 +480,7 @@ Inode::AddSmallData(Transaction *transaction, const char *name, uint32 type, return B_ERROR; // reset our pointers - item = Node()->small_data_start; + item = Node()->SmallDataStart(); index = 0; while (!item->IsLast(Node()) && strcmp(item->Name(), name)) { item = item->Next(); @@ -531,7 +531,7 @@ Inode::AddSmallData(Transaction *transaction, const char *name, uint32 type, return B_ERROR; // get new last item! - item = Node()->small_data_start; + item = Node()->SmallDataStart(); index = 0; while (!item->IsLast(Node())) { item = item->Next(); @@ -584,7 +584,7 @@ Inode::GetNextSmallData(small_data **_smallData) const // begin from the start? if (data == NULL) - data = Node()->small_data_start; + data = Node()->SmallDataStart(); else data = data->Next(); @@ -2091,7 +2091,7 @@ AttributeIterator::GetNext(char *name, size_t *_length, uint32 *_type, vnode_id // read attributes out of the small data section if (fCurrentSmallData >= 0) { - small_data *item = fInode->Node()->small_data_start; + small_data *item = fInode->Node()->SmallDataStart(); fInode->SmallDataLock().Lock(); diff --git a/src/add-ons/kernel/file_systems/bfs/bfs.h b/src/add-ons/kernel/file_systems/bfs/bfs.h index f7cdc00c16..aba6a04c14 100644 --- a/src/add-ons/kernel/file_systems/bfs/bfs.h +++ b/src/add-ons/kernel/file_systems/bfs/bfs.h @@ -133,11 +133,8 @@ struct small_data { uint32 type; uint16 name_size; uint16 data_size; - -#if __MWERKS__ - char name[1]; // name_size long, followed by data - // ToDo: this is bad and breaks the code -#else + +#if !__MWERKS__ //-- mwcc doesn't support thingy[0], so we patch Name() instead char name[0]; // name_size long, followed by data #endif @@ -186,13 +183,18 @@ struct bfs_inode { }; int32 pad[4]; -#if __MWERKS__ - small_data small_data_start[1]; - // ToDo: this reduces the space you have in an inode for attributes -#else +#if !__MWERKS__ small_data small_data_start[0]; #endif - + + inline small_data *SmallDataStart() const { + #if __MWERKS__ + return (small_data *)(&pad[4] /* last item in pad + sizeof(int32) */); + #else + return small_data_start; + #endif + } + int32 Magic1() const { return BFS_ENDIAN_TO_HOST_INT32(magic1); } int32 UserID() const { return BFS_ENDIAN_TO_HOST_INT32(uid); } int32 GroupID() const { return BFS_ENDIAN_TO_HOST_INT32(gid); } @@ -341,14 +343,18 @@ block_run::Run(int32 group, uint16 start, uint16 length) inline char * small_data::Name() const { +#if __MWERKS__ + return (char *)(uint32(&data_size)+uint32(sizeof(data_size))); +#else return const_cast(name); +#endif } inline uint8 * small_data::Data() const { - return (uint8 *)name + NameSize() + 3; + return (uint8 *)Name() + NameSize() + 3; }