summaryrefslogtreecommitdiffstats
path: root/src/phrecn.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2010-11-11 20:46:03 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2010-11-11 20:46:03 +0100
commit4829758b9fcf8dc42b54cc93edd5ac657a74bd1d (patch)
tree868da344a4389f16316138b4f550032a9079ae45 /src/phrecn.c
parentfb04f66ce73998e511a1927dd6108f6c2c0bd934 (diff)
PhotoRec: display the data size and store image_remaining.dd where the files are recovered
Diffstat (limited to 'src/phrecn.c')
-rw-r--r--src/phrecn.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/phrecn.c b/src/phrecn.c
index d0130a1..496ef24 100644
--- a/src/phrecn.c
+++ b/src/phrecn.c
@@ -79,6 +79,7 @@
/* #define DEBUG */
/* #define DEBUG_BF */
#define READ_SIZE 1024*512
+#define DEFAULT_IMAGE_NAME "image_remaining.dd"
extern const file_hint_t file_hint_tar;
extern const file_hint_t file_hint_dir;
@@ -995,10 +996,36 @@ int photorec(disk_t *disk_car, partition_t *partition, const int verbose, const
log_flush();
}
#ifdef HAVE_NCURSES
- if(expert>0)
+ if(expert>0 && !td_list_empty(&list_search_space->list))
{
- if(ask_confirmation("Create a image_remaining.dd file with the unknown data (Answer N if not sure) (Y/N)")!=0)
- gen_image("image_remaining.dd", disk_car, list_search_space);
+ char msg[256];
+ uint64_t data_size=0;
+ struct td_list_head *search_walker = NULL;
+ td_list_for_each(search_walker, &list_search_space->list)
+ {
+ alloc_data_t *current_search_space;
+ current_search_space=td_list_entry(search_walker, alloc_data_t, list);
+ data_size += current_search_space->end - current_search_space->start + 1;
+ }
+ snprintf(msg, sizeof(msg),
+ "Create a image_remaining.dd (%u MB) file with the unknown data (Answer N if not sure) (Y/N)",
+ (unsigned int)(data_size/1000/1000));
+ if(ask_confirmation(msg)!=0)
+ {
+ char *filename;
+ char *res;
+ char *dst_path=strdup(recup_dir);
+ res=strrchr(dst_path, '/');
+ if(res!=NULL)
+ *res='\0';
+ filename=(char *)MALLOC(strlen(dst_path) + 1 + strlen(DEFAULT_IMAGE_NAME) + 1);
+ strcpy(filename, dst_path);
+ strcat(filename, "/");
+ strcat(filename, DEFAULT_IMAGE_NAME);
+ gen_image(filename, disk_car, list_search_space);
+ free(filename);
+ free(dst_path);
+ }
}
#endif
info_list_search_space(list_search_space, NULL, disk_car->sector_size, keep_corrupted_file, verbose);