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

Method photorec_find_blocksize

src/qphbs.cpp:63–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63pstatus_t QPhotorec::photorec_find_blocksize(alloc_data_t *list_search_space)
64{
65 uint64_t offset=0;
66 unsigned char *buffer_start;
67 unsigned char *buffer_olddata;
68 unsigned char *buffer;
69 time_t start_time;
70 time_t previous_time;
71 unsigned int buffer_size;
72 const unsigned int blocksize=params->blocksize;
73 const unsigned int read_size=(blocksize>65536?blocksize:65536);
74 alloc_data_t *current_search_space;
75 file_recovery_t file_recovery;
76
77 params->file_nbr=0;
78 reset_file_recovery(&file_recovery);
79 file_recovery.blocksize=blocksize;
80 buffer_size=blocksize + READ_SIZE;
81 buffer_start=(unsigned char *)MALLOC(buffer_size);
82 buffer_olddata=buffer_start;
83 buffer=buffer_olddata + blocksize;
84 start_time=time(NULL);
85 previous_time=start_time;
86 memset(buffer_olddata, 0, blocksize);
87 current_search_space=td_list_entry(list_search_space->list.next, alloc_data_t, list);
88 if(current_search_space!=list_search_space)
89 offset=current_search_space->start;
90 if(options->verbose>0)
91 info_list_search_space(list_search_space, current_search_space, params->disk->sector_size, 0, options->verbose);
92 params->offset=offset;
93 QCoreApplication::processEvents();
94 params->disk->pread(params->disk, buffer, READ_SIZE, offset);
95 while(current_search_space!=list_search_space)
96 {
97 uint64_t old_offset=offset;
98 {
99 file_recovery_t file_recovery_new;
100 if(file_recovery.file_stat!=NULL && file_recovery.file_stat->file_hint==&file_hint_tar &&
101 is_valid_tar_header((const struct tar_posix_header *)(buffer-0x200)))
102 { /* Currently saving a tar, do not check the data for know header */
103 }
104 else
105 {
106 const struct td_list_head *tmpl;
107 file_recovery_new.file_stat=NULL;
108 td_list_for_each(tmpl, &file_check_list.list)
109 {
110 const struct td_list_head *tmp;
111 const file_check_list_t *tmp2=td_list_entry_const(tmpl, const file_check_list_t, list);
112 td_list_for_each(tmp, &tmp2->file_checks[buffer[tmp2->offset]].list)
113 {
114 const file_check_t *file_check=td_list_entry_const(tmp, const file_check_t, list);
115 if((file_check->length==0 || memcmp(buffer + file_check->offset, file_check->value, file_check->length)==0) &&
116 file_check->header_check(buffer, read_size, 1, &file_recovery, &file_recovery_new)!=0)
117 {
118 file_recovery_new.file_stat=file_check->file_stat;
119 break;
120 }

Callers

nothing calls this directly

Calls 8

reset_file_recoveryFunction · 0.85
MALLOCFunction · 0.85
info_list_search_spaceFunction · 0.85
is_valid_tar_headerFunction · 0.85
file_foundFunction · 0.85
get_next_sectorFunction · 0.85
td_list_for_eachFunction · 0.70
file_recovery_cpyFunction · 0.70

Tested by

no test coverage detected