summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1999-10-07 17:04:29 +0000
committerRoland McGrath <roland@gnu.org>1999-10-07 17:04:29 +0000
commitc3a1f72b28b32b127e0e476f033d8492a40c92a3 (patch)
tree8f9959567cc0fbf4768ed4a4270d089addbf5f71
parentafa91eb47b1290b24651ef276296c345da9217b9 (diff)
1999-10-06 Roland McGrath <roland@baalperazim.frob.com>
* hyper.c (get_hypermetadata): Avoid overflow in calculation of disk size vs superblock-specified requirement. Add a warning for wasted disk blocks after last filesystem block.
-rw-r--r--ext2fs/hyper.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/ext2fs/hyper.c b/ext2fs/hyper.c
index 9c76ec24..4012f9f7 100644
--- a/ext2fs/hyper.c
+++ b/ext2fs/hyper.c
@@ -96,9 +96,16 @@ get_hypermetadata (void)
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))
- ext2_panic ("disk size (%ld bytes) too small; superblock says we need %d",
- store->size, sblock->s_blocks_count << log2_block_size);
+ if ((store->size >> log2_block_size) < sblock->s_blocks_count)
+ ext2_panic ("disk size (%qd bytes) too small; superblock says we need %qd",
+ (long long int) store->size,
+ (long long int) sblock->s_blocks_count << log2_block_size);
+ if (log2_dev_blocks_per_fs_block != 0
+ && (store->size & ((1 << log2_dev_blocks_per_fs_block) - 1)) != 0)
+ ext2_warning ("%ld (%d byte) device blocks "
+ " unused after last filesystem (%d byte) block",
+ (store->size & ((1 << log2_dev_blocks_per_fs_block) - 1)),
+ store->block_size, block_size);
/* Set these handy variables. */
inodes_per_block = block_size / EXT2_INODE_SIZE (sblock);