Primary superblock is at 1024 (SUPERBLOCK_OFFSET) Group 0 begin at s_first_data_block */
| 109 | Group 0 begin at s_first_data_block |
| 110 | */ |
| 111 | int recover_EXT2(const disk_t *disk, const struct ext2_super_block *sb, partition_t *partition, const int verbose, const int dump_ind) |
| 112 | { |
| 113 | if(test_EXT2(sb, partition)!=0) |
| 114 | return 1; |
| 115 | if(dump_ind!=0) |
| 116 | { |
| 117 | if(partition!=NULL && disk!=NULL) |
| 118 | log_info("\nEXT2/EXT3 magic value at %u/%u/%u\n", |
| 119 | offset2cylinder(disk,partition->part_offset), |
| 120 | offset2head(disk,partition->part_offset), |
| 121 | offset2sector(disk,partition->part_offset)); |
| 122 | /* There is a little offset ... */ |
| 123 | dump_log(sb,DEFAULT_SECTOR_SIZE); |
| 124 | } |
| 125 | if(partition==NULL) |
| 126 | return 0; |
| 127 | set_EXT2_info(sb, partition, verbose); |
| 128 | partition->part_type_i386=P_LINUX; |
| 129 | partition->part_type_mac=PMAC_LINUX; |
| 130 | partition->part_type_sun=PSUN_LINUX; |
| 131 | partition->part_type_gpt=GPT_ENT_TYPE_LINUX_DATA; |
| 132 | partition->part_size=td_ext2fs_blocks_count(sb) * EXT2_MIN_BLOCK_SIZE<<le32(sb->s_log_block_size); |
| 133 | guid_cpy(&partition->part_uuid, (const efi_guid_t *)&sb->s_uuid); |
| 134 | if(verbose>0) |
| 135 | { |
| 136 | log_info("\n"); |
| 137 | } |
| 138 | partition->sborg_offset=0x400; |
| 139 | partition->sb_size=EXT2_SUPERBLOCK_SIZE; |
| 140 | if(le16(sb->s_block_group_nr)>0) |
| 141 | { |
| 142 | const unsigned long int block_nr=(le32(sb->s_first_data_block)+le16(sb->s_block_group_nr)*le32(sb->s_blocks_per_group)); |
| 143 | if(partition->part_offset< (uint64_t)block_nr * (EXT2_MIN_BLOCK_SIZE<<le32(sb->s_log_block_size))) |
| 144 | { |
| 145 | log_error("recover_EXT2: part_offset problem\n"); |
| 146 | return 1; |
| 147 | } |
| 148 | partition->sb_offset=(uint64_t)block_nr * (EXT2_MIN_BLOCK_SIZE<<le32(sb->s_log_block_size)); |
| 149 | partition->part_offset-=partition->sb_offset; |
| 150 | log_warning("recover_EXT2: \"e2fsck -b %lu -B %u device\" may be needed\n", |
| 151 | block_nr, partition->blocksize); |
| 152 | } |
| 153 | else |
| 154 | { |
| 155 | partition->sb_offset=0; |
| 156 | } |
| 157 | if(verbose>0) |
| 158 | { |
| 159 | log_info("recover_EXT2: s_block_group_nr=%u/%u, s_mnt_count=%u/%u, s_blocks_per_group=%u, s_inodes_per_group=%u\n", |
| 160 | le16(sb->s_block_group_nr), |
| 161 | (unsigned int)(td_ext2fs_blocks_count(sb) /le32(sb->s_blocks_per_group)), |
| 162 | le16(sb->s_mnt_count), le16(sb->s_max_mnt_count), |
| 163 | (unsigned int)le32(sb->s_blocks_per_group), |
| 164 | (unsigned int)le32(sb->s_inodes_per_group)); |
| 165 | log_info("recover_EXT2: s_blocksize=%u\n", partition->blocksize); |
| 166 | log_info("recover_EXT2: s_blocks_count %lu\n", (long unsigned int)td_ext2fs_blocks_count(sb)); |
| 167 | if(disk==NULL) |
| 168 | log_info("recover_EXT2: part_size %lu\n", (long unsigned)(partition->part_size / DEFAULT_SECTOR_SIZE)); |
no test coverage detected