diff options
author | Theodore Ts'o <tytso@mit.edu> | 2006-08-30 03:08:13 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2006-08-30 03:08:13 -0400 |
commit | a8862d9e90d0d94761ba28dbbf9674308fd7d7c0 (patch) | |
tree | 5fdfe5d2e83ac3c8c579b2579eb7dd76ee33f7b7 /resize/resize2fs.c | |
parent | 5830d6be9c33e23bb20c339036083e6e4fa6795e (diff) | |
download | e2fsprogs-a8862d9e90d0d94761ba28dbbf9674308fd7d7c0.tar.gz |
Fix potential 2**32-1 overflow by using e2p_percent()
Add a new functiom, e2p_percent(), which correct calculates the percentage
of a number based on a given percentage, without worrying about overflow
issues. This is used where we calculate the number of reserved blocks using
a percentage of the total number of blocks in a filesystem.
Based on patches from Eric Sandeen, but generalized to use this new function.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
Diffstat (limited to 'resize/resize2fs.c')
-rw-r--r-- | resize/resize2fs.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/resize/resize2fs.c b/resize/resize2fs.c index 74b517b7..7d3bde90 100644 --- a/resize/resize2fs.c +++ b/resize/resize2fs.c @@ -245,8 +245,8 @@ retry: */ blk = old_fs->super->s_r_blocks_count * 100 / old_fs->super->s_blocks_count; - fs->super->s_r_blocks_count = ((fs->super->s_blocks_count * blk) - / 100); + fs->super->s_r_blocks_count = e2p_percent(blk, + fs->super->s_blocks_count); /* * Adjust the bitmaps for size |