MCPcopy Create free account
hub / github.com/cgsecurity/testdisk / ext2_fix_group

Function ext2_fix_group

src/ext2grp.c:39–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37#include "photorec.h"
38
39unsigned int ext2_fix_group(alloc_data_t *list_search_space, disk_t *disk, const partition_t *partition)
40{
41 struct td_list_head *search_walker = NULL;
42 unsigned char *buffer;
43 unsigned int blocksize;
44 if(partition->upart_type!=UP_EXT2 &&
45 partition->upart_type!=UP_EXT3 &&
46 partition->upart_type!=UP_EXT4)
47 {
48 log_error("Not a valid ext2/ext3/ext4 filesystem");
49 free_search_space(list_search_space);
50 return 0;
51 }
52
53 buffer=(unsigned char*)MALLOC(EXT2_SUPERBLOCK_SIZE);
54 if(disk->pread(disk, buffer, EXT2_SUPERBLOCK_SIZE, partition->part_offset + 0x400) != EXT2_SUPERBLOCK_SIZE)
55 {
56 free(buffer);
57 return 0;
58 }
59 {
60 const struct ext2_super_block *sb=(const struct ext2_super_block *)buffer;
61 const unsigned int mult=(unsigned int)le32(sb->s_blocks_per_group) * (EXT2_MIN_BLOCK_SIZE<<le32(sb->s_log_block_size));
62 td_list_for_each(search_walker, &list_search_space->list)
63 {
64 alloc_data_t *current_search_space;
65 current_search_space=td_list_entry(search_walker, alloc_data_t, list);
66 log_info("ext2_group: %llu\n", (long long unsigned)current_search_space->start);
67 current_search_space->start=current_search_space->start*mult + (le32(sb->s_log_block_size)==0?1024:0);
68 current_search_space->end=current_search_space->end*mult+mult-1 + (le32(sb->s_log_block_size)==0?1024:0);
69 }
70 blocksize=EXT2_MIN_BLOCK_SIZE<<le32(sb->s_log_block_size);
71 }
72 free(buffer);
73 return blocksize;
74}
75
76unsigned int ext2_fix_inode(alloc_data_t *list_search_space, disk_t *disk, const partition_t *partition)
77{

Callers 1

menu_photorec_cliFunction · 0.85

Calls 3

free_search_spaceFunction · 0.85
MALLOCFunction · 0.85
td_list_for_eachFunction · 0.70

Tested by

no test coverage detected