Adopted the PPC big endian fixes for disk_super_block::Initialize() and made them
a bit nicer. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17557 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/* Volume - BFS super block, mounting, etc.
|
/* Volume - BFS super block, mounting, etc.
|
||||||
*
|
*
|
||||||
* Copyright 2001-2004, Axel Dörfler, [email protected].
|
* Copyright 2001-2006, Axel Dörfler, [email protected].
|
||||||
* This file may be used under the terms of the MIT License.
|
* This file may be used under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -193,27 +193,31 @@ disk_super_block::Initialize(const char *diskName, off_t numBlocks, uint32 block
|
|||||||
magic1 = HOST_ENDIAN_TO_BFS_INT32(SUPER_BLOCK_MAGIC1);
|
magic1 = HOST_ENDIAN_TO_BFS_INT32(SUPER_BLOCK_MAGIC1);
|
||||||
magic2 = HOST_ENDIAN_TO_BFS_INT32(SUPER_BLOCK_MAGIC2);
|
magic2 = HOST_ENDIAN_TO_BFS_INT32(SUPER_BLOCK_MAGIC2);
|
||||||
magic3 = HOST_ENDIAN_TO_BFS_INT32(SUPER_BLOCK_MAGIC3);
|
magic3 = HOST_ENDIAN_TO_BFS_INT32(SUPER_BLOCK_MAGIC3);
|
||||||
fs_byte_order = SUPER_BLOCK_FS_LENDIAN;
|
fs_byte_order = HOST_ENDIAN_TO_BFS_INT32(SUPER_BLOCK_FS_LENDIAN);
|
||||||
flags = SUPER_BLOCK_DISK_CLEAN;
|
flags = HOST_ENDIAN_TO_BFS_INT32(SUPER_BLOCK_DISK_CLEAN);
|
||||||
|
|
||||||
strlcpy(name, diskName, sizeof(name));
|
strlcpy(name, diskName, sizeof(name));
|
||||||
|
|
||||||
block_size = inode_size = HOST_ENDIAN_TO_BFS_INT32(blockSize);
|
int32 blockShift = 9;
|
||||||
for (block_shift = 9; (1UL << block_shift) < blockSize; block_shift++);
|
while ((1UL << blockShift) < blockSize) {
|
||||||
|
blockShift++;
|
||||||
|
}
|
||||||
|
|
||||||
num_blocks = numBlocks;
|
block_size = inode_size = HOST_ENDIAN_TO_BFS_INT32(blockSize);
|
||||||
|
block_shift = HOST_ENDIAN_TO_BFS_INT32(blockShift);
|
||||||
|
|
||||||
|
num_blocks = HOST_ENDIAN_TO_BFS_INT64(numBlocks);
|
||||||
used_blocks = 0;
|
used_blocks = 0;
|
||||||
|
|
||||||
// Get the minimum ag_shift (that's determined by the block size)
|
// Get the minimum ag_shift (that's determined by the block size)
|
||||||
|
|
||||||
blocks_per_ag = 1;
|
|
||||||
ag_shift = 13;
|
|
||||||
|
|
||||||
int32 bitsPerBlock = blockSize << 3;
|
int32 bitsPerBlock = blockSize << 3;
|
||||||
off_t bitmapBlocks = (numBlocks + bitsPerBlock - 1) / bitsPerBlock;
|
off_t bitmapBlocks = (numBlocks + bitsPerBlock - 1) / bitsPerBlock;
|
||||||
|
int32 blocksPerGroup = 1;
|
||||||
|
int32 groupShift = 13;
|
||||||
|
|
||||||
for (int32 i = 8192; i < bitsPerBlock; i *= 2) {
|
for (int32 i = 8192; i < bitsPerBlock; i *= 2) {
|
||||||
ag_shift++;
|
groupShift++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Many allocation groups help applying allocation policies, but if
|
// Many allocation groups help applying allocation policies, but if
|
||||||
@@ -221,17 +225,23 @@ disk_super_block::Initialize(const char *diskName, off_t numBlocks, uint32 block
|
|||||||
// files (see above to get an explanation of the kDesiredAllocationGroups
|
// files (see above to get an explanation of the kDesiredAllocationGroups
|
||||||
// constant).
|
// constant).
|
||||||
|
|
||||||
|
int32 numGroups;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
num_ags = (bitmapBlocks + blocks_per_ag - 1) / blocks_per_ag;
|
numGroups = (bitmapBlocks + blocksPerGroup - 1) / blocksPerGroup;
|
||||||
if (num_ags > kDesiredAllocationGroups) {
|
if (numGroups > kDesiredAllocationGroups) {
|
||||||
if (ag_shift == 16)
|
if (groupShift == 16)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
ag_shift++;
|
groupShift++;
|
||||||
blocks_per_ag *= 2;
|
blocksPerGroup *= 2;
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
num_ags = HOST_ENDIAN_TO_BFS_INT32(numGroups);
|
||||||
|
blocks_per_ag = HOST_ENDIAN_TO_BFS_INT32(1);
|
||||||
|
ag_shift = HOST_ENDIAN_TO_BFS_INT32(groupShift);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -181,8 +181,10 @@ disk_super_block::Initialize(const char *diskName, off_t numBlocks, uint32 block
|
|||||||
|
|
||||||
strlcpy(name, diskName, sizeof(name));
|
strlcpy(name, diskName, sizeof(name));
|
||||||
|
|
||||||
int32 blockShift;
|
int32 blockShift = 9;
|
||||||
for (blockShift = 9; (1UL << blockShift) < blockSize; blockShift++);
|
while ((1UL << blockShift) < blockSize) {
|
||||||
|
blockShift++;
|
||||||
|
}
|
||||||
|
|
||||||
block_size = inode_size = HOST_ENDIAN_TO_BFS_INT32(blockSize);
|
block_size = inode_size = HOST_ENDIAN_TO_BFS_INT32(blockSize);
|
||||||
block_shift = HOST_ENDIAN_TO_BFS_INT32(blockShift);
|
block_shift = HOST_ENDIAN_TO_BFS_INT32(blockShift);
|
||||||
|
|||||||
Reference in New Issue
Block a user