From d1b4b85c3a201705c5d3d2916c7a9ca00a04e44c Mon Sep 17 00:00:00 2001 From: Eric Sandeen Date: Tue, 12 Sep 2006 14:56:18 -0400 Subject: [PATCH] Fix more rounding overflows for filesystems that have 2**32-1 blocks Signed-off-by: Eric Sandeen --- e2fsck/ChangeLog | 4 ++++ e2fsck/pass1.c | 2 +- misc/ChangeLog | 4 ++++ misc/mke2fs.c | 2 +- resize/ChangeLog | 6 ++++++ resize/online.c | 3 +-- resize/resize2fs.c | 2 +- 7 files changed, 18 insertions(+), 5 deletions(-) diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog index 94bdf2f24..e87d7a87c 100644 --- a/e2fsck/ChangeLog +++ b/e2fsck/ChangeLog @@ -1,3 +1,7 @@ +2006-08-30 Eric Sandeen + + * pass1.c (handle_bad_fs_blocks): use blk_t, not int for first_block. + 2006-08-30 Eric Sandeen * unix.c (show_stats): use ext2_ino_t for inode containers. diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index e6778af1f..9a84b783a 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -1953,7 +1953,7 @@ static void handle_fs_bad_blocks(e2fsck_t ctx) { ext2_filsys fs = ctx->fs; dgrp_t i; - int first_block; + blk_t first_block; for (i = 0; i < fs->group_desc_count; i++) { first_block = ext2fs_group_first_block(fs, i); diff --git a/misc/ChangeLog b/misc/ChangeLog index f59d471ba..93cd1edf1 100644 --- a/misc/ChangeLog +++ b/misc/ChangeLog @@ -1,3 +1,7 @@ +2006-08-30 Eric Sandeen + + * mke2fs.c (PRS): Avoid overflow in megs calculation. + 2006-08-30 Eric Sandeen * mke2fs.c (PRS): Disallow > 2^32 inodes at mkfs time. diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 256c8133e..87ae68705 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -1260,7 +1260,7 @@ static void PRS(int argc, char *argv[]) } if (!fs_type) { - int megs = fs_param.s_blocks_count * + int megs = (__u64)fs_param.s_blocks_count * (EXT2_BLOCK_SIZE(&fs_param) / 1024) / 1024; if (megs <= 3) diff --git a/resize/ChangeLog b/resize/ChangeLog index b740df0fd..bc4dd92c4 100644 --- a/resize/ChangeLog +++ b/resize/ChangeLog @@ -1,3 +1,9 @@ +2006-08-30 Eric Sandeen + + * online.c (online_resize_fs): use div_ceil for r_frac calculation. + * resize2fs.c (adjust_fs_info): avoid overflow in blk calculation + when figuring new reserved blocks count. + 2006-08-30 Eric Sandeen * resize2fs.c (adjust_fs_info): Disallow > 2^32 indoes at resize time. diff --git a/resize/online.c b/resize/online.c index 26b263e76..a1c19c3e9 100644 --- a/resize/online.c +++ b/resize/online.c @@ -59,8 +59,7 @@ errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt, exit(1); } - r_frac = ((100 * sb->s_r_blocks_count) + sb->s_blocks_count-1) / - sb->s_blocks_count; + r_frac = ext2fs_div_ceil(100 * sb->s_r_blocks_count, sb->s_blocks_count); retval = ext2fs_read_bitmaps(fs); if (retval) diff --git a/resize/resize2fs.c b/resize/resize2fs.c index 60180abbb..e1057eca1 100644 --- a/resize/resize2fs.c +++ b/resize/resize2fs.c @@ -250,7 +250,7 @@ retry: /* * Adjust the number of reserved blocks */ - blk = old_fs->super->s_r_blocks_count * 100 / + blk = (__u64)old_fs->super->s_r_blocks_count * 100 / old_fs->super->s_blocks_count; fs->super->s_r_blocks_count = e2p_percent(blk, fs->super->s_blocks_count); -- 2.47.2