diff options
author | Christophe Grenier <grenier@cgsecurity.org> | 2014-03-30 20:03:31 +0200 |
---|---|---|
committer | Christophe Grenier <grenier@cgsecurity.org> | 2014-03-30 20:03:31 +0200 |
commit | 26ea4b911746598d7734d6282746c567eda623cf (patch) | |
tree | f3b54010dd6ad1d132cd5bb5ff2d6f074b18241b /src/photorec.c | |
parent | f013c26602c15900ac88dbcb35b4fcdaa27ff419 (diff) |
PhotoRec: when a file is recovered, check again each block after the end of the recovered file
Diffstat (limited to 'src/photorec.c')
-rw-r--r-- | src/photorec.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/photorec.c b/src/photorec.c index 5fa779a..724c7be 100644 --- a/src/photorec.c +++ b/src/photorec.c @@ -275,6 +275,26 @@ unsigned int photorec_mkdir(const char *recup_dir, const unsigned int initial_di return dir_num; } +void get_prev_location(alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset, const uint64_t prev_location) +{ + int nbr; + alloc_data_t *file_space=*current_search_space; + uint64_t size=0; + /* Search backward the first fragment of a file not successfully recovered + * Limit the search to 10 fragments or 1GB */ + for(nbr=0; nbr<10 && size < (uint64_t)1024*1024*1024; nbr++) + { + file_space=td_list_entry(file_space->list.prev, alloc_data_t, list); + if(file_space==list_search_space) + return; + size+=file_space->end - file_space->start + 1; + if(file_space->start < prev_location) + return ; + *current_search_space=file_space; + *offset=file_space->start; + } +} + int get_prev_file_header(alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset) { int nbr; |