* Seems like GCC4 does not like declaring structures inside unnamed unions;

that looks like a compiler bug to me, though.
* Pulled struct data_stream out of the union (now called ext2_data_stream),
  based on a patch by Maurice, thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26214 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-07-02 09:43:12 +00:00
parent 13de3d0767
commit b7cb8f8c30
3 changed files with 14 additions and 12 deletions
@@ -110,12 +110,12 @@ Inode::FindBlock(off_t offset, uint32& block)
if (index < EXT2_DIRECT_BLOCKS) { if (index < EXT2_DIRECT_BLOCKS) {
// direct blocks // direct blocks
block = B_LENDIAN_TO_HOST_INT32(Node().u.stream.direct[index]); block = B_LENDIAN_TO_HOST_INT32(Node().stream.direct[index]);
} else if ((index -= EXT2_DIRECT_BLOCKS) < perBlock) { } else if ((index -= EXT2_DIRECT_BLOCKS) < perBlock) {
// indirect blocks // indirect blocks
CachedBlock cached(fVolume); CachedBlock cached(fVolume);
uint32* indirectBlocks = (uint32*)cached.SetTo(B_LENDIAN_TO_HOST_INT32( uint32* indirectBlocks = (uint32*)cached.SetTo(B_LENDIAN_TO_HOST_INT32(
Node().u.stream.indirect)); Node().stream.indirect));
if (indirectBlocks == NULL) if (indirectBlocks == NULL)
return B_IO_ERROR; return B_IO_ERROR;
@@ -124,7 +124,7 @@ Inode::FindBlock(off_t offset, uint32& block)
// double indirect blocks // double indirect blocks
CachedBlock cached(fVolume); CachedBlock cached(fVolume);
uint32* indirectBlocks = (uint32*)cached.SetTo(B_LENDIAN_TO_HOST_INT32( uint32* indirectBlocks = (uint32*)cached.SetTo(B_LENDIAN_TO_HOST_INT32(
Node().u.stream.double_indirect)); Node().stream.double_indirect));
if (indirectBlocks == NULL) if (indirectBlocks == NULL)
return B_IO_ERROR; return B_IO_ERROR;
@@ -138,7 +138,7 @@ Inode::FindBlock(off_t offset, uint32& block)
// triple indirect blocks // triple indirect blocks
CachedBlock cached(fVolume); CachedBlock cached(fVolume);
uint32* indirectBlocks = (uint32*)cached.SetTo(B_LENDIAN_TO_HOST_INT32( uint32* indirectBlocks = (uint32*)cached.SetTo(B_LENDIAN_TO_HOST_INT32(
Node().u.stream.triple_indirect)); Node().stream.triple_indirect));
if (indirectBlocks == NULL) if (indirectBlocks == NULL)
return B_IO_ERROR; return B_IO_ERROR;
+9 -7
View File
@@ -138,6 +138,13 @@ struct ext2_block_group {
#define EXT2_ROOT_NODE 2 #define EXT2_ROOT_NODE 2
#define EXT2_SHORT_SYMLINK_LENGTH 60 #define EXT2_SHORT_SYMLINK_LENGTH 60
struct ext2_data_stream {
uint32 direct[EXT2_DIRECT_BLOCKS];
uint32 indirect;
uint32 double_indirect;
uint32 triple_indirect;
};
struct ext2_inode { struct ext2_inode {
uint16 mode; uint16 mode;
uint16 uid; uint16 uid;
@@ -152,14 +159,9 @@ struct ext2_inode {
uint32 flags; uint32 flags;
uint32 _reserved1; uint32 _reserved1;
union { union {
struct data_stream { ext2_data_stream stream;
uint32 direct[EXT2_DIRECT_BLOCKS];
uint32 indirect;
uint32 double_indirect;
uint32 triple_indirect;
} stream;
char symlink[EXT2_SHORT_SYMLINK_LENGTH]; char symlink[EXT2_SHORT_SYMLINK_LENGTH];
} u; };
uint32 generation; uint32 generation;
uint32 file_access_control; uint32 file_access_control;
union { union {
@@ -414,7 +414,7 @@ ext2_read_link(fs_volume *_volume, fs_vnode *_node, char *buffer,
if (inode->Size() > EXT2_SHORT_SYMLINK_LENGTH) if (inode->Size() > EXT2_SHORT_SYMLINK_LENGTH)
return inode->ReadAt(0, (uint8 *)buffer, _bufferSize); return inode->ReadAt(0, (uint8 *)buffer, _bufferSize);
memcpy(buffer, inode->Node().u.symlink, *_bufferSize); memcpy(buffer, inode->Node().symlink, *_bufferSize);
return B_OK; return B_OK;
} }