summaryrefslogtreecommitdiffstats
path: root/src/phrecn.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2013-12-21 18:16:14 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2013-12-21 18:16:14 +0100
commit5f4faee1f6f82fb3667653a951714c80932522db (patch)
tree87fea1a51da3b1b1d1cdb3cb9c6c1e895d4c8e31 /src/phrecn.c
parent439771c6ad98cfdafe05d923a5e5b338d7ff9f77 (diff)
src/phrecn.c: Remove some code in comment
Diffstat (limited to 'src/phrecn.c')
-rw-r--r--src/phrecn.c102
1 files changed, 0 insertions, 102 deletions
diff --git a/src/phrecn.c b/src/phrecn.c
index e9b0116..88fef16 100644
--- a/src/phrecn.c
+++ b/src/phrecn.c
@@ -229,108 +229,6 @@ static void gen_image(const char *filename, disk_t *disk, const alloc_data_t *li
fclose(out);
}
-#if 0
-static inline void list_append_block(alloc_list_t *list, const uint64_t offset, const uint64_t blocksize, const unsigned int data)
-{
- if(!td_list_empty(&list->list))
- {
- alloc_list_t *prev=td_list_entry(list->list.prev, alloc_list_t, list);
- if(prev->end+1==offset && prev->data==data)
- {
- prev->end=offset+blocksize-1;
- return ;
- }
- }
- {
- alloc_list_t *new_list=(alloc_list_t *)MALLOC(sizeof(*new_list));
- new_list->start=offset;
- new_list->end=offset+blocksize-1;
- new_list->data=data;
- td_list_add_tail(&new_list->list, &list->list);
- }
-}
-
-static void test_files_aux(file_recovery_t *file_recovery, struct ph_param *params, const uint64_t start, const uint64_t end)
-{
- uint64_t datasize=end-start+1;
- unsigned char *buffer=(unsigned char *) MALLOC(datasize);
- params->disk->pread(params->disk, buffer, datasize, start);
- if(file_recovery->file_stat==NULL)
- {
- struct td_list_head *tmpl;
- td_list_for_each(tmpl, &file_check_list.list)
- {
- struct td_list_head *tmp;
- const file_check_list_t *pos=td_list_entry(tmpl, file_check_list_t, list);
- td_list_for_each(tmp, &pos->file_checks[buffer[pos->offset]].list)
- {
- const file_check_t *file_check=td_list_entry(tmp, file_check_t, list);
- if((file_check->length==0 || memcmp(buffer + file_check->offset, file_check->value, file_check->length)==0) &&
- file_check->header_check(buffer, datasize, 0, file_recovery, file_recovery)!=0)
- {
- file_recovery->file_stat=file_check->file_stat;
- break;
- }
- }
- if(file_recovery->file_stat!=NULL)
- break;
- }
- if(file_recovery->file_stat==NULL)
- {
- free(buffer);
- return ;
- }
- /* file_recovery->loc is used by file_truncate */
- file_recovery->loc=NULL;
- /* list_free_add, list_space_used, update_search_space, list_truncate, free_list_allocation */
- file_recovery->location.start=start;
- }
- if(file_recovery->handle==NULL)
- {
- set_filename(file_recovery, params);
- file_recovery->handle=fopen(file_recovery->filename, "w+b");
- if(file_recovery->handle==NULL)
- {
- log_critical("Cannot create file %s: %s\n", file_recovery->filename, strerror(errno));
- free(buffer);
- return;
- }
- }
- if(fwrite(buffer, datasize, 1, file_recovery->handle)<1)
- {
- log_critical("Cannot write to file %s: %s\n", file_recovery->filename, strerror(errno));
- fclose(file_recovery->handle);
- file_recovery->handle=NULL;
- free(buffer);
- return;
- }
- list_append_block(&file_recovery->location, start, datasize, 1);
- file_recovery->calculated_file_size=0;
- file_recovery->file_size+=datasize;
- file_recovery->file_size_on_disk+=datasize;
- free(buffer);
-}
-
-static void test_files(alloc_data_t *list_search_space, struct ph_param *params)
-{
- alloc_data_t *current_search_space=list_search_space;
- uint64_t offset;
- file_recovery_t file_recovery;
- reset_file_recovery(&file_recovery);
- file_recovery.blocksize=512;
- offset=current_search_space->start;
- /* Recover a file with a known location */
- test_files_aux(&file_recovery, params, 1289*512, (1304+1)*512-1);
- test_files_aux(&file_recovery, params, 2881*512, (3259+1)*512-1);
- file_finish(&file_recovery, params, list_search_space, &current_search_space, &offset);
-
- /* Exclude some sectors from the search space */
- del_search_space(list_search_space, 121407*512, (121416+1)*512-1);
- del_search_space(list_search_space, 121445*512, (121448+1)*512-1);
- del_search_space(list_search_space, 121865*512, (122195+1)*512-1);
-}
-#endif
-
int photorec(struct ph_param *params, const struct ph_options *options, alloc_data_t *list_search_space)
{
pstatus_t ind_stop=PSTATUS_OK;