fix ext2 inode size and calculations
Weirich
PATCH 1/1 fix ext2 inode size and calculations
Fixed some indentations since patch from 2009-06-09.
Hope this is good now, anyway the whole ext2fs.c file does not conform to coding style guidelines, so maybe someone wants to run Lindent on it...?
Regards,
Bernhard
From: unsik Kim <[email protected]>
ext2/ext2fs.c +32 -21
@@ -110,7 +110,7 @@uint32_t inode_table_id;uint16_t free_blocks;uint16_t free_inodes; -uint16_t pad; +uint16_t used_dir_cnt;uint32_t reserved[3 ]; };
@@ -182,14 +182,22 @@static int ext2fs_blockgroup (struct ext2_data *data,int group,struct ext2_block_group *blkgrp) { +unsigned int blkno; +unsigned int blkoff; +unsigned int desc_per_blk; + + desc_per_blk =EXT2_BLOCK_SIZE (data) /sizeof (struct ext2_block_group ); + + blkno =__le32_to_cpu (data->sblock.first_data_block) +1 + + group / desc_per_blk; + blkoff = (group % desc_per_blk) *sizeof (struct ext2_block_group );#ifdef DEBUG -printf ("ext2fs read blockgroup\n" ); +printf ("ext2fs read %d group descriptor (blkno %d blkoff %d)\n" , + group, blkno, blkoff);#endif -return (ext2fs_devread - (((__le32_to_cpu (data->sblock.first_data_block) + -1 ) <<LOG2_EXT2_BLOCK_SIZE (data)), - group *sizeof (struct ext2_block_group ), -sizeof (struct ext2_block_group ), (char *) blkgrp)); +return (ext2fs_devread (blkno <<LOG2_EXT2_BLOCK_SIZE (data), + blkoff,sizeof (struct ext2_block_group ), (char *)blkgrp)); + }
@@ -203,34 +211,37 @@unsigned int blkno;unsigned int blkoff; -/* It is easier to calculate if the first inode is 0. */ - ino--;#ifdef DEBUG printf ("ext2fs read inode %d\n" , ino);#endif - status =ext2fs_blockgroup (data, - ino / -__le32_to_cpu (sblock->inodes_per_group), - &blkgrp); +/* It is easier to calculate if the first inode is 0. */ + ino--; + status =ext2fs_blockgroup (data, ino /__le32_to_cpu + (sblock->inodes_per_group), &blkgrp);if (status ==0 ) {return (0 ); } - inodes_per_block =EXT2_BLOCK_SIZE (data) /128 ; - blkno = (ino %__le32_to_cpu (sblock->inodes_per_group)) / - inodes_per_block; - blkoff = (ino %__le32_to_cpu (sblock->inodes_per_group)) % - inodes_per_block; + + inodes_per_block =EXT2_BLOCK_SIZE (data) /__le16_to_cpu (sblock->inode_size); + +#ifdef DEBUG +printf ("ext2fs read inode blkno %d blkoff %d\n" , blkno, blkoff); +#endif + + blkno =__le32_to_cpu (blkgrp.inode_table_id) + + (ino %__le32_to_cpu (sblock->inodes_per_group)) + / inodes_per_block; + blkoff = (ino % inodes_per_block) *__le16_to_cpu (sblock->inode_size);#ifdef DEBUG printf ("ext2fs read inode blkno %d blkoff %d\n" , blkno, blkoff);#endif /* Read the inode. */ - status =ext2fs_devread (((__le32_to_cpu (blkgrp.inode_table_id) + - blkno) <<LOG2_EXT2_BLOCK_SIZE (data)), -sizeof (struct ext2_inode ) * blkoff, + status =ext2fs_devread (blkno <<LOG2_EXT2_BLOCK_SIZE (data), blkoff,sizeof (struct ext2_inode ), (char *) inode);if (status ==0 ) {return (0 ); } +return (1 ); }
PATCH 1/1 fix ext2 inode size and calculations
Dear "Weirich, Bernhard",
ext2/ext2fs.c
Quoted 12 lines · In message <CE92B8B581B4584FB8CA86B51EDE8AC51640BAEBD1@wupexchange.riedel.net>…
Fixed some indentations since patch from 2009-06-09.
Hope this is good now, anyway the wholeext2fs.cfile does not conform to coding style guidelines, so maybe someone wants to run Lindent on it...?Regards,
BernhardFrom: unsik Kim <[email protected]>
Signed-off-by unsik Kim <[email protected]>Signed-off-by Bernhard Weirich <[email protected]>ext2/ext2fs.c +0
-0
Applied, after manually fixing all the formal issues with this patch (unusable commit message, line too long, incorrect number of leading slashes in the file names (needs -p0 instead of the required -p1), etc.
I tested this on several configurations on PowerPC (big-endian), and I confirm that this fixes the problems we had with 256 byte inode sizes
- the code now works both with the old default of 128 bytes and with 256 bytes inodes.
Thanks.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Change is the essential process of all existence. -- Spock, "Let That Be Your Last Battlefield", stardate 5730.2