| 122 | } |
| 123 | |
| 124 | pstatus_t photorec_bf(struct ph_param *params, const struct ph_options *options, alloc_data_t *list_search_space) |
| 125 | { |
| 126 | struct td_list_head *search_walker = NULL; |
| 127 | struct td_list_head *p= NULL; |
| 128 | unsigned char *buffer_start; |
| 129 | const unsigned int blocksize=params->blocksize; |
| 130 | const unsigned int read_size=(blocksize>65536?blocksize:65536); |
| 131 | unsigned int buffer_size; |
| 132 | pstatus_t ind_stop=PSTATUS_OK; |
| 133 | int pass2=params->pass; |
| 134 | int phase; |
| 135 | buffer_size=blocksize+READ_SIZE; |
| 136 | buffer_start=(unsigned char *)MALLOC(buffer_size); |
| 137 | for(phase=0; phase<2; phase++) |
| 138 | { |
| 139 | const unsigned int file_nbr_phase_old=params->file_nbr; |
| 140 | for(search_walker=list_search_space->list.prev, p=search_walker->prev; |
| 141 | search_walker!=&list_search_space->list && ind_stop==PSTATUS_OK; |
| 142 | p=search_walker->prev) |
| 143 | { |
| 144 | alloc_data_t *current_search_space; |
| 145 | unsigned char *buffer; |
| 146 | unsigned char *buffer_olddata; |
| 147 | uint64_t offset; |
| 148 | int need_to_check_file; |
| 149 | int go_backward=1; |
| 150 | file_recovery_t file_recovery; |
| 151 | // memset(&file_recovery, 0, sizeof(file_recovery_t)); |
| 152 | reset_file_recovery(&file_recovery); |
| 153 | file_recovery.blocksize=blocksize; |
| 154 | current_search_space=td_list_entry(search_walker, alloc_data_t, list); |
| 155 | offset=current_search_space->start; |
| 156 | buffer_olddata=buffer_start; |
| 157 | buffer=buffer_olddata + blocksize; |
| 158 | memset(buffer_olddata, 0, blocksize); |
| 159 | params->disk->pread(params->disk, buffer, READ_SIZE, offset); |
| 160 | info_list_search_space(list_search_space, current_search_space, params->disk->sector_size, 0, options->verbose); |
| 161 | #ifdef DEBUG_BF |
| 162 | #endif |
| 163 | log_flush(); |
| 164 | |
| 165 | do |
| 166 | { |
| 167 | const uint64_t old_offset=offset; |
| 168 | need_to_check_file=0; |
| 169 | if(offset==current_search_space->start) |
| 170 | { |
| 171 | const struct td_list_head *tmpl; |
| 172 | file_recovery_t file_recovery_new; |
| 173 | // memset(&file_recovery_new, 0, sizeof(file_recovery_t)); |
| 174 | file_recovery_new.blocksize=blocksize; |
| 175 | file_recovery_new.location.start=offset; |
| 176 | file_recovery_new.file_stat=NULL; |
| 177 | td_list_for_each(tmpl, &file_check_list.list) |
| 178 | { |
| 179 | const struct td_list_head *tmp; |
| 180 | const file_check_list_t *pos=td_list_entry_const(tmpl, const file_check_list_t, list); |
| 181 | td_list_for_each(tmp, &pos->file_checks[buffer[pos->offset]].list) |
no test coverage detected