| 220 | } |
| 221 | |
| 222 | static pstatus_t fat_unformat_aux(struct ph_param *params, const struct ph_options *options, const uint64_t start_data, alloc_data_t *list_search_space) |
| 223 | { |
| 224 | pstatus_t ind_stop=PSTATUS_OK; |
| 225 | uint64_t offset; |
| 226 | uint64_t offset_end; |
| 227 | unsigned char *buffer_start; |
| 228 | unsigned char *buffer; |
| 229 | time_t start_time; |
| 230 | time_t previous_time; |
| 231 | const unsigned int cluster_size=params->blocksize; |
| 232 | const unsigned int read_size=(cluster_size>65536?cluster_size:65536); |
| 233 | alloc_data_t *current_search_space; |
| 234 | disk_t *disk=params->disk; |
| 235 | const partition_t *partition=params->partition; |
| 236 | const unsigned long int no_of_cluster=(partition->part_size - start_data) / cluster_size; |
| 237 | log_info("fat_unformat_aux: no_of_cluster=%lu\n", no_of_cluster); |
| 238 | |
| 239 | #ifdef HAVE_NCURSES |
| 240 | aff_copy(stdscr); |
| 241 | #endif |
| 242 | start_time=time(NULL); |
| 243 | previous_time=start_time; |
| 244 | current_search_space=td_list_last_entry(&list_search_space->list, alloc_data_t, list); |
| 245 | if(current_search_space==list_search_space) |
| 246 | { |
| 247 | return PSTATUS_OK; |
| 248 | } |
| 249 | offset_end=current_search_space->end; |
| 250 | current_search_space=td_list_first_entry(&list_search_space->list, alloc_data_t, list); |
| 251 | offset=set_search_start(params, ¤t_search_space, list_search_space); |
| 252 | if(options->verbose>0) |
| 253 | info_list_search_space(list_search_space, current_search_space, disk->sector_size, 0, options->verbose); |
| 254 | buffer_start=(unsigned char *)MALLOC(READ_SIZE); |
| 255 | buffer=buffer_start; |
| 256 | disk->pread(disk, buffer_start, READ_SIZE, offset); |
| 257 | for(;offset < offset_end; offset+=cluster_size) |
| 258 | { |
| 259 | if(buffer[0]=='.' && is_fat_directory(buffer)) |
| 260 | { |
| 261 | file_info_t dir_list; |
| 262 | TD_INIT_LIST_HEAD(&dir_list.list); |
| 263 | dir_fat_aux(buffer, read_size, 0, &dir_list); |
| 264 | if(!td_list_empty(&dir_list.list)) |
| 265 | { |
| 266 | struct td_list_head *file_walker = NULL; |
| 267 | unsigned int dir_inode=0; |
| 268 | unsigned int nbr; |
| 269 | int stop=0; |
| 270 | log_info("Sector %llu\n", (long long unsigned)offset/disk->sector_size); |
| 271 | dir_aff_log(NULL, &dir_list); |
| 272 | del_search_space(list_search_space, offset, offset + cluster_size -1); |
| 273 | for(file_walker=dir_list.list.next, nbr=0; |
| 274 | stop==0 && file_walker!=&dir_list.list; |
| 275 | file_walker=file_walker->next, nbr++) |
| 276 | { |
| 277 | const file_info_t *current_file=td_list_entry_const(file_walker, const file_info_t, list); |
| 278 | if(current_file->st_ino==1 || |
| 279 | current_file->st_ino >= no_of_cluster+2) |
no test coverage detected