代码是:
void ext2_read_inode (struct inode * inode)
{
struct buffer_head * bh;
struct ext2_inode * raw_inode;
unsigned long block_group;
unsigned long group_desc;
unsigned long desc;
unsigned long block;
unsigned long offset;
struct ext2_group_desc * gdp;
if (
( inode->i_ino != EXT2_ROOT_INO
&& inode->i_ino != EXT2_ACL_IDX_INO
&& inode->i_ino != EXT2_ACL_DATA_INO
&& inode->i_ino < EXT2_FIRST_INO(inode->i_sb)
) || inode->i_ino > le32_to_cpu(
inode->i_sb->u.ext2_sb.s_es->s_inodes_count)
)
{
ext2_error(inode->i_sb, "ext2_read_inode",
"bad inode number: %lu", inode->i_ino);
goto bad_inode;
}
block_group = (inode->i_ino - 1) / EXT2_INODES_PER_GROUP(inode->i_sb);
if (block_group >= inode->i_sb->u.ext2_sb.s_groups_count) {
ext2_error(inode->i_sb, "ext2_read_inode", "group >= groups count");
goto bad_inode;
}
group_desc = block_group >> EXT2_DESC_PER_BLOCK_BITS(inode->i_sb);
desc = block_group & (EXT2_DESC_PER_BLOCK(inode->i_sb) - 1);
bh = inode->i_sb->u.ext2_sb.s_group_desc[group_desc];
/* ... other code omitted ... */
}
你能解释一下为什么会出现在-1
这里:
block_group = (inode->i_ino - 1) / EXT2_INODES_PER_GROUP(inode->i_sb);
和这里:
desc = block_group & (EXT2_DESC_PER_BLOCK(inode->i_sb) - 1);
谢谢你。