diff options
author | Theodore Ts'o <tytso@mit.edu> | 2006-03-17 20:39:52 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2006-03-17 20:39:52 -0500 |
commit | a612f3432eec6b3adcae3e6b62713173147f34a4 (patch) | |
tree | 65442d310be29b8b556a0a800baa86210da27d67 /lib | |
parent | bf69235ad0073c80386b70caba0e1b58e5f85697 (diff) | |
download | e2fsprogs-a612f3432eec6b3adcae3e6b62713173147f34a4.tar.gz |
Fix a signed vs unsigned bug in calc_reserved_gdt_blocks()
This fixes mke2fs -O resize_inode for very large filesystems (i.e., 20GB).
Addresses Debian Bug #346580
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ext2fs/ChangeLog | 5 | ||||
-rw-r--r-- | lib/ext2fs/initialize.c | 8 |
2 files changed, 9 insertions, 4 deletions
diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index eb8c09c3..afcd5a10 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,5 +1,10 @@ 2006-03-17 Theodore Ts'o <tytso@mit.edu> + * initialize.c (calc_reserved_gdt_blocks): Fix a signed vs + unsigned problem which caused mke2fs -O resize_inode to + bomb out on large filesystems. (Addresses Debian Bug + #346580) + * ext2_fs.h (EXT2_IOC_GETVERSION_NEW, EXT2_IOC_SETVERSION_NEW, EXT2_IOC_GROUP_EXTEND, EXT2_IOC_GROUP_ADD): Add ioctl definitions diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c index 71e279da..83eea72e 100644 --- a/lib/ext2fs/initialize.c +++ b/lib/ext2fs/initialize.c @@ -63,14 +63,14 @@ * The absolute maximum number of GDT blocks we can reserve is determined by * the number of block pointers that can fit into a single block. */ -static int calc_reserved_gdt_blocks(ext2_filsys fs) +static unsigned int calc_reserved_gdt_blocks(ext2_filsys fs) { struct ext2_super_block *sb = fs->super; unsigned long bpg = sb->s_blocks_per_group; unsigned int gdpb = fs->blocksize / sizeof(struct ext2_group_desc); unsigned long max_blocks = 0xffffffff; unsigned long rsv_groups; - int rsv_gdb; + unsigned int rsv_gdb; /* We set it at 1024x the current filesystem size, or * the upper block count limit (2^32), whichever is lower. @@ -79,10 +79,10 @@ static int calc_reserved_gdt_blocks(ext2_filsys fs) max_blocks = sb->s_blocks_count * 1024; rsv_groups = (max_blocks - sb->s_first_data_block + bpg - 1) / bpg; rsv_gdb = (rsv_groups + gdpb - 1) / gdpb - fs->desc_blocks; - if (rsv_gdb > (int) EXT2_ADDR_PER_BLOCK(sb)) + if (rsv_gdb > EXT2_ADDR_PER_BLOCK(sb)) rsv_gdb = EXT2_ADDR_PER_BLOCK(sb); #ifdef RES_GDT_DEBUG - printf("max_blocks %lu, rsv_groups = %lu, rsv_gdb = %lu\n", + printf("max_blocks %lu, rsv_groups = %lu, rsv_gdb = %u\n", max_blocks, rsv_groups, rsv_gdb); #endif |