Ejemplo n.º 1
0
// Return a pointer to an inode given its number. In a real filesystem, this
// would require finding the correct block group, rather than assuming it's in
// the first.
struct ext2_inode * _ref_get_inode(void * fs, __u32 inode_num) {
    struct ext2_group_desc * bgd = get_block_group(fs, 0);
    __u32 inode_table_block = bgd->bg_inode_table;
    struct ext2_inode * inode_table = get_block(fs, inode_table_block);
    // Since inode 0 doesn't ever exist, the table starts from 1.
    return inode_table + inode_num - 1;
}
Ejemplo n.º 2
0
// Return a pointer to an inode given its number. In a real filesystem, this
// would require finding the correct block group, but you may assume it's in the
// first one.
struct ext2_inode * get_inode(void * fs, __u32 inode_num) {
    struct ext2_super_block * superBlock = get_super_block(fs);
    // superBlock->s_inodes_per_group = 0, we're assuming only one block group so inode_num-1 is index into inode table
    // hardcode 0 b/c assume only one block group
    struct ext2_group_desc * blockGroupDescriptor = get_block_group(fs, 0);
    struct ext2_inode * startOfINodeTable = (struct ext2_inode *) get_block(fs, blockGroupDescriptor->bg_inode_table);
    return startOfINodeTable + inode_num - 1;
}
Ejemplo n.º 3
0
// Return a pointer to an inode given its number. In a real filesystem, this
// would require finding the correct block group, but you may assume it's in the
// first one.
struct ext2_inode * get_inode(void * fs, __u32 inode_num) {
  struct ext2_super_block* s = get_super_block(fs);
  __u32 inode_per_group = EXT2_INODES_PER_GROUP(s);
  __u32 group_offset = (inode_num - 1) / inode_per_group;
  __u32 inode_offset = (inode_num - 1) % inode_per_group;
  __u32 inode_table_block = get_block_group(fs, group_offset)->bg_inode_table; 
  return get_block(fs, inode_table_block) + inode_offset * EXT2_INODE_SIZE(s); 
}
Ejemplo n.º 4
0
// Return a pointer to an inode given its number. In a real filesystem, this
// would require finding the correct block group, but you may assume it's in the
// first one.
struct ext2_inode * get_inode(void * fs, __u32 inode_num) {
  // Get the address of the block group descriptor.
  struct ext2_group_desc * group_desc_ptr = get_block_group(fs, 0);
  // Get the address of the inode table.
  void * inode_tbl_ptr = get_block(fs, group_desc_ptr->bg_inode_table);
  // Calculate the address of the inode.
  return inode_tbl_ptr + (inode_num - 1) * EXT2_INODE_SIZE(get_super_block(fs));
}
Ejemplo n.º 5
0
// Return a pointer to an inode given its number. In a real filesystem, this
// would require finding the correct block group, but you may assume it's in the
// first one.
struct ext2_inode *get_inode(void *fs, __u32 inode_num) {
    struct ext2_group_desc *bg = get_block_group(fs, 0);
    // The inode table begins from 1. This is because an inode number 0 is always invalid.
    return get_block(fs, bg->bg_inode_table) + EXT2_INODE_SIZE(get_super_block(fs)) * (inode_num - 1);
}
Ejemplo n.º 6
0
// first one.
struct ext2_inode * get_inode(void * fs, __u32 inode_num) {
    struct ext2_group_desc *des = get_block_group(fs, 0);
    void *bg_inode_table = get_block(fs, des->bg_inode_table);
    return (struct ext2_inode *) bg_inode_table + (inode_num - 1);
}