static int ext2fs_read_inode (struct ext2_data *data, int ino, struct ext2_inode *inode) { struct ext2_block_group blkgrp; struct ext2_sblock *sblock = &data->sblock; int inodes_per_block; int status; 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); if (status == 0) { return (0); } #ifdef CFG_EXT2_SUPPORT_DYNAMIC_REV inodes_per_block = EXT2_BLOCK_SIZE (data) / ext2_inode_size; #else inodes_per_block = EXT2_BLOCK_SIZE (data) / 128; #endif blkno = (ino % __le32_to_cpu (sblock->inodes_per_group)) / inodes_per_block; blkoff = (ino % __le32_to_cpu (sblock->inodes_per_group)) % inodes_per_block; #ifdef DEBUG printf ("ext2fs read inode blkno %d blkoff %d\n", blkno, blkoff); #endif /* Read the inode. */ #ifdef CFG_EXT2_SUPPORT_DYNAMIC_REV status = ext2fs_devread (((__le32_to_cpu (blkgrp.inode_table_id) + blkno) << LOG2_EXT2_BLOCK_SIZE (data)), ext2_inode_size * blkoff, sizeof (struct ext2_inode), (char *) inode); #else status = ext2fs_devread (((__le32_to_cpu (blkgrp.inode_table_id) + blkno) << LOG2_EXT2_BLOCK_SIZE (data)), sizeof (struct ext2_inode) * blkoff, sizeof (struct ext2_inode), (char *) inode); #endif if (status == 0) { return (0); } return (1); }
static quik_err_t ext2fs_read_inode(struct ext2_data *data, int ino, struct ext2_inode *inode) { struct ext2_block_group blkgrp; struct ext2_sblock *sblock = &data->sblock; int inodes_per_block; quik_err_t err; unsigned int blkno; unsigned int blkoff; #ifdef DEBUG printk ("ext2fs read inode %d, inode_size %d\n", ino, inode_size); #endif /* It is easier to calculate if the first inode is 0. */ ino--; err = ext2fs_blockgroup(data, ino / __le32_to_cpu (sblock->inodes_per_group), &blkgrp); if (err != ERR_NONE) { return err; } inodes_per_block = EXT2_BLOCK_SIZE(data) / inode_size; blkno = __le32_to_cpu(blkgrp.inode_table_id) + (ino % __le32_to_cpu(sblock->inodes_per_group)) / inodes_per_block; blkoff = (ino % inodes_per_block) * inode_size; #ifdef DEBUG printk ("ext2fs read inode blkno %d blkoff %d\n", blkno, blkoff); #endif /* Read the inode. */ err = part_read(data->part, blkno << LOG2_EXT2_BLOCK_SIZE (data), blkoff, sizeof(struct ext2_inode), (char *) inode); if (err != ERR_NONE) { return err; } return ERR_NONE; }
static int ext2fs_read_inode (struct ext2_data *data, int ino, struct ext2_inode *inode) { struct ext2_block_group blkgrp; struct ext2_sblock *sblock = &data->sblock; int inodes_per_block; int status; unsigned int blkno; unsigned int blkoff; #ifdef DEBUG printf ("ext2fs read inode %d, inode_size %d\n", ino, inode_size); #endif /* 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) / inode_size; blkno = __le32_to_cpu (blkgrp.inode_table_id) + (ino % __le32_to_cpu (sblock->inodes_per_group)) / inodes_per_block; blkoff = (ino % inodes_per_block) * inode_size; #ifdef DEBUG printf ("ext2fs read inode blkno %d blkoff %d\n", blkno, blkoff); #endif /* Read the inode. */ status = ext2fs_devread (blkno << LOG2_EXT2_BLOCK_SIZE (data), blkoff, sizeof (struct ext2_inode), (char *) inode); if (status == 0) { return (0); } return (1); }