Index: e2fsprogs/lib/ext2fs/block.c =================================================================== RCS file: /home/ratchova/cvs-xxx/e2fsprogs/lib/ext2fs/block.c,v retrieving revision 1.1.1.1.2.3 retrieving revision 1.1.1.1.2.4 diff -p -b -u -r1.1.1.1.2.3 -r1.1.1.1.2.4 --- e2fsprogs/lib/ext2fs/block.c 29 Jun 2006 14:11:49 -0000 1.1.1.1.2.3 +++ e2fsprogs/lib/ext2fs/block.c 30 Jun 2006 17:27:39 -0000 1.1.1.1.2.4 @@ -55,8 +55,8 @@ void show_index(struct ext3_extent_heade ix = EXT_FIRST_INDEX(eh); printf("this node has %d indexs\n",eh->e_num); for (i = 0; i < eh->eh_entries; i++, ix++) { - printf("index %d, block = %d, leaf = %d\n", i, - ix->ei_block, ix->ei_leaf); + printf("index %d, block = %u, leaf = %llu\n", i, + ix->ei_block, EI_GETLEAF(ix)); } } @@ -90,7 +90,7 @@ static int block_iterate_extents(struct ex = EXT_FIRST_EXTENT(eh); for (i = 0; i < eh->eh_entries; i++, ex++) { for(j=0; j< ex->ee_len; j++) { - block_address = ex->ee_start + j; + block_address = EE_GETSTART(ex) + j; ret = (*ctx->func)(ctx->fs, &block_address, (ex->ee_block + j), 0, i, ctx->priv_data); @@ -105,7 +105,7 @@ static int block_iterate_extents(struct return ret; ix = EXT_FIRST_INDEX(eh); for (i = 0; i < eh->eh_entries; i++, ix++) { - block_address = ix->ei_leaf; + block_address = EI_GETLEAF(ix); if (!(ctx->flags & BLOCK_FLAG_DEPTH_TRAVERSE) && !(ctx->flags & BLOCK_FLAG_DATA_ONLY)) { ret = (*ctx->func)(ctx->fs, &block_address, @@ -116,7 +116,7 @@ static int block_iterate_extents(struct } } ctx->errcode = io_channel_read_blk(ctx->fs->io, - ix->ei_leaf, 1, + EI_GETLEAF(ix), 1, block_buf); if(ctx->errcode) { ret |= BLOCK_ERROR; Index: e2fsprogs/lib/ext2fs/bmap.c =================================================================== RCS file: /home/ratchova/cvs-xxx/e2fsprogs/lib/ext2fs/bmap.c,v retrieving revision 1.1.1.1.2.2 retrieving revision 1.1.1.1.2.3 diff -p -b -u -r1.1.1.1.2.2 -r1.1.1.1.2.3 --- e2fsprogs/lib/ext2fs/bmap.c 29 Jun 2006 14:10:46 -0000 1.1.1.1.2.2 +++ e2fsprogs/lib/ext2fs/bmap.c 30 Jun 2006 17:27:39 -0000 1.1.1.1.2.3 @@ -46,7 +46,7 @@ static int block_extents_bmap(struct ext ex = EXT_FIRST_EXTENT(eh); for (i = 0; i < eh->eh_entries; i++, ex++) if ( (ex->ee_block <= block) && (block < ex->ee_block + ex->ee_len) ) { - *phys_blk = ex->ee_start + (block - ex->ee_block); + *phys_blk = EE_GETSTART(ex) + (block - ex->ee_block); return 0; } return BLOCK_ERROR; @@ -57,7 +57,7 @@ static int block_extents_bmap(struct ext ix = EXT_FIRST_INDEX(eh); for (i = 0; i < eh->eh_entries; i++, ix++) { ret = io_channel_read_blk(fs->io, - ix->ei_leaf, 1, + EI_GETLEAF(ix), 1, block_buf); if (ret) { ext2fs_free_mem(&block_buf); Index: e2fsprogs/lib/ext2fs/ext3_extents.h =================================================================== RCS file: /home/ratchova/cvs-xxx/e2fsprogs/lib/ext2fs/Attic/ext3_extents.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -p -b -u -r1.1.2.1 -r1.1.2.2 --- e2fsprogs/lib/ext2fs/ext3_extents.h 29 Jun 2006 09:30:11 -0000 1.1.2.1 +++ e2fsprogs/lib/ext2fs/ext3_extents.h 30 Jun 2006 17:27:39 -0000 1.1.2.2 @@ -75,6 +75,13 @@ struct ext3_extent { __u32 ee_start; /* low 32 bigs of physical block */ }; +#define EE_GETSTART(ee) ((blk_t)(((ee)->ee_start_hi << 16) + (ee)->ee_start)) +#define EE_SETSTART(ee, blk) \ + do { \ + (ee)->ee_start_hi = (blk) >> 32; \ + (ee)->ee_start = (blk) & 0xffffffffU; \ + } while (0) \ + /* * this is index on-disk structure * it's used at all the levels, but the bottom @@ -87,6 +94,13 @@ struct ext3_extent_idx { __u16 ei_unused; }; +#define EI_GETLEAF(ei) ((blk_t)(((ei)->ei_leaf_hi << 16) + (ei)->ei_leaf)) +#define EE_SETLEAF(ei, blk) \ + do { \ + (ei)->ei_leaf_hi = (blk) >> 32; \ + (ei)->ei_leaf = (blk) & 0xffffffffU; \ + } while (0) \ + /* * each block (leaves and indexes), even inode-stored has header */ Index: e2fsprogs/lib/ext2fs/initialize.c =================================================================== RCS file: /home/ratchova/cvs-xxx/e2fsprogs/lib/ext2fs/initialize.c,v retrieving revision 1.1.1.1.2.2 retrieving revision 1.1.1.1.2.3 diff -p -b -u -r1.1.1.1.2.2 -r1.1.1.1.2.3 --- e2fsprogs/lib/ext2fs/initialize.c 29 Jun 2006 14:11:49 -0000 1.1.1.1.2.2 +++ e2fsprogs/lib/ext2fs/initialize.c 30 Jun 2006 17:27:39 -0000 1.1.1.1.2.3 @@ -218,6 +218,10 @@ retry: fs->desc_blocks = (fs->group_desc_count + EXT2_DESC_PER_BLOCK(super) - 1) / EXT2_DESC_PER_BLOCK(super); + if (fs->desc_blocks >= super->s_blocks_per_group + 3) { + retval = EXT2_ET_TOOSMALL; + goto cleanup; + } i = fs->blocksize >= 4096 ? 1 : 4096 / fs->blocksize; inodes = EXT2_BLOCKS_COUNT(super) / i; Index: e2fsprogs/lib/ext2fs/mkdir.c =================================================================== RCS file: /home/ratchova/cvs-xxx/e2fsprogs/lib/ext2fs/mkdir.c,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.1.1.1.2.2 diff -p -b -u -r1.1.1.1.2.1 -r1.1.1.1.2.2 --- e2fsprogs/lib/ext2fs/mkdir.c 29 Jun 2006 09:30:11 -0000 1.1.1.1.2.1 +++ e2fsprogs/lib/ext2fs/mkdir.c 30 Jun 2006 17:27:39 -0000 1.1.1.1.2.2 @@ -100,8 +100,8 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, e eh->eh_max = (sizeof(inode.i_block) - sizeof(struct ext3_extent_header)) / sizeof(struct ext3_extent); ex->ee_block = 0; - ex->ee_start = blk; ex->ee_len = 1; + EE_SETSTART(ex, blk); inode.i_flags = EXT3_EXTENTS_FL; } else {