| 74 | } |
| 75 | |
| 76 | unsigned int ext2_fix_inode(alloc_data_t *list_search_space, disk_t *disk, const partition_t *partition) |
| 77 | { |
| 78 | struct td_list_head *search_walker = NULL; |
| 79 | unsigned char *buffer; |
| 80 | unsigned int blocksize; |
| 81 | if(partition->upart_type!=UP_EXT2 && |
| 82 | partition->upart_type!=UP_EXT3 && |
| 83 | partition->upart_type!=UP_EXT4) |
| 84 | { |
| 85 | log_error("Not a valid ext2/ext3/ext4 filesystem"); |
| 86 | free_search_space(list_search_space); |
| 87 | return 0; |
| 88 | } |
| 89 | |
| 90 | buffer=(unsigned char*)MALLOC(EXT2_SUPERBLOCK_SIZE); |
| 91 | if(disk->pread(disk, buffer, EXT2_SUPERBLOCK_SIZE, partition->part_offset + 0x400) != EXT2_SUPERBLOCK_SIZE) |
| 92 | { |
| 93 | free(buffer); |
| 94 | return 0; |
| 95 | } |
| 96 | { |
| 97 | const struct ext2_super_block *sb=(const struct ext2_super_block *)buffer; |
| 98 | const unsigned int divd=(unsigned int)le32(sb->s_inodes_per_group); |
| 99 | const unsigned int mult=(unsigned int)le32(sb->s_blocks_per_group) * (EXT2_MIN_BLOCK_SIZE<<le32(sb->s_log_block_size)); |
| 100 | td_list_for_each(search_walker, &list_search_space->list) |
| 101 | { |
| 102 | alloc_data_t *current_search_space; |
| 103 | current_search_space=td_list_entry(search_walker, alloc_data_t, list); |
| 104 | log_info("ext2_inode: %llu\n", (long long unsigned)current_search_space->start); |
| 105 | current_search_space->start=current_search_space->start/divd*mult + (sb->s_log_block_size==0?1024:0); |
| 106 | current_search_space->end=current_search_space->end/divd*mult+mult-1 + (sb->s_log_block_size==0?1024:0); |
| 107 | } |
| 108 | blocksize=EXT2_MIN_BLOCK_SIZE<<le32(sb->s_log_block_size); |
| 109 | } |
| 110 | free(buffer); |
| 111 | return blocksize; |
| 112 | } |
no test coverage detected