summaryrefslogtreecommitdiff
path: root/ext2fs
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1999-10-03 10:23:12 +0000
committerRoland McGrath <roland@gnu.org>1999-10-03 10:23:12 +0000
commitc3f65c1f4035ef6c669426c1749c9e387ec7469a (patch)
tree0dee6ad7932af1dd4d4a0c6451632cd568b70830 /ext2fs
parentc3bcb575fa088392a48e5febd519f36e406eaf7a (diff)
1999-10-03 Roland McGrath <roland@baalperazim.frob.com>
* ext2fs.h (group_desc): Inline function replaced with macro. (group_desc_image): New variable. * hyper.c (get_hypermetadata): Initialize it. * ext2fs.h (sblock_block): Declare new variable. (SBLOCK_LBLOCK): Macro removed. (SBLOCK_OFFS): Define in terms of sblock_block. * ext2fs.c (options): Add --sblock/-S. (parse_opt): Parse it to set sblock_block. * hyper.c (sblock_block): New variable. (get_hypermetadata): Use sblock_block instead of constant SBLOCK_BLOCK. * hyper.c (get_hypermetadata): Use EXT2_MAX_BLOCK_SIZE instead of hard-wired 8192. Don't use ffs to compute log2_block_size, and don't check for the impossible case of non-power-of-two block size (the block size specification we start with is given as a power of two!). * ext2fs.h (block_size): Change type to unsigned int. (BLOCKSIZE_SCALE): Just use SBLOCK->s_log_block_size directly. * hyper.c (get_hypermetadata): Fix printf formats to silence warning. * dir.c (dirscanblock): Likewise.
Diffstat (limited to 'ext2fs')
-rw-r--r--ext2fs/hyper.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/ext2fs/hyper.c b/ext2fs/hyper.c
index 3377e649..9c76ec24 100644
--- a/ext2fs/hyper.c
+++ b/ext2fs/hyper.c
@@ -52,6 +52,8 @@ allocate_mod_map (void)
modified_global_blocks = 0;
}
+unsigned int sblock_block = SBLOCK_BLOCK; /* in 1k blocks */
+
static int ext2fs_clean; /* fs clean before we started writing? */
void
@@ -64,7 +66,7 @@ get_hypermetadata (void)
if (zeroblock)
munmap ((caddr_t) zeroblock, block_size);
- sblock = (struct ext2_super_block *)boffs_ptr (SBLOCK_OFFS);
+ sblock = (struct ext2_super_block *) boffs_ptr (SBLOCK_OFFS);
if (sblock->s_magic != EXT2_SUPER_MAGIC
#ifdef EXT2FS_PRE_02B_COMPAT
@@ -74,18 +76,16 @@ get_hypermetadata (void)
ext2_panic ("bad magic number %#x (should be %#x)",
sblock->s_magic, EXT2_SUPER_MAGIC);
- block_size = EXT2_MIN_BLOCK_SIZE << sblock->s_log_block_size;
-
- if (block_size > 8192)
- ext2_panic ("block size %ld is too big (max is 8192 bytes)", block_size);
+ log2_block_size = EXT2_MIN_BLOCK_LOG_SIZE + sblock->s_log_block_size;
+ block_size = 1 << log2_block_size;
- log2_block_size = ffs (block_size) - 1;
- if ((1 << log2_block_size) != block_size)
- ext2_panic ("block size %ld isn't a power of two!", block_size);
+ if (block_size > EXT2_MAX_BLOCK_SIZE)
+ ext2_panic ("block size %d is too big (max is %d bytes)",
+ block_size, EXT2_MAX_BLOCK_SIZE);
log2_dev_blocks_per_fs_block = log2_block_size - store->log2_block_size;
if (log2_dev_blocks_per_fs_block < 0)
- ext2_panic ("block size %ld isn't a power-of-two multiple of the device"
+ ext2_panic ("block size %d isn't a power-of-two multiple of the device"
" block size (%d)!",
block_size, store->block_size);
@@ -93,7 +93,7 @@ get_hypermetadata (void)
while ((512 << log2_stat_blocks_per_fs_block) < block_size)
log2_stat_blocks_per_fs_block++;
if ((512 << log2_stat_blocks_per_fs_block) != block_size)
- ext2_panic ("block size %ld isn't a power-of-two multiple of 512!",
+ ext2_panic ("block size %d isn't a power-of-two multiple of 512!",
block_size);
if (store->size < (sblock->s_blocks_count << log2_block_size))
@@ -151,6 +151,10 @@ get_hypermetadata (void)
diskfs_end_catch_exception ();
+ /* Cache a convenient pointer to the block group descriptors for allocation.
+ These are stored in the filesystem blocks following the superblock. */
+ group_desc_image = (struct ext2_group_desc *) bptr (bptr_block (sblock) + 1);
+
/* A handy source of page-aligned zeros. */
zeroblock = (vm_address_t) mmap (0, block_size, PROT_READ|PROT_WRITE,
MAP_ANON, 0, 0);