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

Method photorec_aux

src/qpsearch.cpp:71–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69#define READ_SIZE 1024*512
70
71pstatus_t QPhotorec::photorec_aux(alloc_data_t *list_search_space)
72{
73 uint64_t offset;
74 unsigned char *buffer_start;
75 unsigned char *buffer_olddata;
76 unsigned char *buffer;
77 time_t start_time;
78 time_t previous_time;
79 time_t next_checkpoint;
80 pstatus_t ind_stop=PSTATUS_OK;
81 unsigned int buffer_size;
82 const unsigned int blocksize=params->blocksize;
83 const unsigned int read_size=(blocksize>65536?blocksize:65536);
84 uint64_t offset_before_back=0;
85 unsigned int back=0;
86 pfstatus_t file_recovered_old=PFSTATUS_BAD;
87 alloc_data_t *current_search_space;
88 file_recovery_t file_recovery;
89 memset(&file_recovery, 0, sizeof(file_recovery));
90 reset_file_recovery(&file_recovery);
91 file_recovery.blocksize=blocksize;
92 buffer_size=blocksize + READ_SIZE;
93 buffer_start=(unsigned char *)MALLOC(buffer_size);
94 buffer_olddata=buffer_start;
95 buffer=buffer_olddata+blocksize;
96 start_time=time(NULL);
97 previous_time=start_time;
98 next_checkpoint=start_time+5*60;
99 memset(buffer_olddata,0,blocksize);
100 current_search_space=td_list_first_entry(&list_search_space->list, alloc_data_t, list);
101 offset=set_search_start(params, &current_search_space, list_search_space);
102 if(options->verbose > 0)
103 info_list_search_space(list_search_space, current_search_space, params->disk->sector_size, 0, options->verbose);
104 if(options->verbose > 1)
105 {
106 log_verbose("Reading sector %10llu/%llu\n",
107 (unsigned long long)((offset-params->partition->part_offset)/params->disk->sector_size),
108 (unsigned long long)((params->partition->part_size-1)/params->disk->sector_size));
109 }
110 params->disk->pread(params->disk, buffer, READ_SIZE, offset);
111 header_ignored(NULL);
112 while(current_search_space!=list_search_space)
113 {
114 pfstatus_t file_recovered=PFSTATUS_BAD;
115 uint64_t old_offset=offset;
116 data_check_t data_check_status=DC_SCAN;
117#ifdef DEBUG
118 log_debug("sector %llu\n",
119 (unsigned long long)((offset-params->partition->part_offset)/params->disk->sector_size));
120 if(!(current_search_space->start<=offset && offset<=current_search_space->end))
121 {
122 log_critical("BUG: offset=%llu not in [%llu-%llu]\n",
123 (unsigned long long)(offset/params->disk->sector_size),
124 (unsigned long long)(current_search_space->start/params->disk->sector_size),
125 (unsigned long long)(current_search_space->end/params->disk->sector_size));
126 log_close();
127 exit(1);
128 }

Callers

nothing calls this directly

Calls 15

reset_file_recoveryFunction · 0.85
MALLOCFunction · 0.85
set_search_startFunction · 0.85
info_list_search_spaceFunction · 0.85
header_ignoredFunction · 0.85
log_closeFunction · 0.85
photorec_check_headerFunction · 0.85
ind_blockFunction · 0.85
file_block_appendFunction · 0.85
is_fatFunction · 0.85
file_finish2Function · 0.85
forgetFunction · 0.85

Tested by

no test coverage detected