Next | Internals of ext2fs | 20 |
When you ask for a file by name, Unix looks in the directory to find the i-number
From the i-number, it can get the inode; for example fs/ext2/inode.c:
void ext2_read_inode (struct inode * inode) { ... block_group = (inode->i_ino - 1) / EXT2_INODES_PER_GROUP(inode->i_sb); ... 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]; ... gdp = (struct ext2_group_desc *) bh->b_data; ... offset = ((inode->i_ino - 1) % EXT2_INODES_PER_GROUP(inode->i_sb)) * EXT2_INODE_SIZE(inode->i_sb); block = le32_to_cpu(gdp[desc].bg_inode_table) + (offset >> EXT2_BLOCK_SIZE_BITS(inode->i_sb)); if (!(bh = bread (inode->i_dev, block, inode->i_sb->s_blocksize))) { ext2_error (inode->i_sb, "ext2_read_inode", ... }
From the inode, the kernel can get the data in the file
If the file is another directory, the data is links---more names and i-numbers
Next | Copyright © 2001 M. J. Dominus |