summaryrefslogtreecommitdiffstats
path: root/src/photorec.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2011-08-28 09:53:47 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2011-08-28 09:53:47 +0200
commit789bb8645ba36a8f73ec48e6b9e8a61650fc6e5d (patch)
tree8d1741aed1229d264ce8550e676afb2c94662809 /src/photorec.c
parent94082d99f501a58c397da923d505ec5b2944a6bd (diff)
PhotoRec session management: restart PhotoRec at the same location than previously
Diffstat (limited to 'src/photorec.c')
-rw-r--r--src/photorec.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/photorec.c b/src/photorec.c
index a171e43..9ac6d00 100644
--- a/src/photorec.c
+++ b/src/photorec.c
@@ -942,3 +942,45 @@ void set_filename(file_recovery_t *file_recovery, struct ph_param *params)
}
}
+static void set_search_start_aux(alloc_data_t **new_current_search_space, alloc_data_t *list_search_space, const uint64_t offset)
+{
+ 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);
+ if(current_search_space->start<=offset && offset<= current_search_space->end)
+ {
+ *new_current_search_space=current_search_space;
+ return;
+ }
+ }
+ /* not found */
+ *new_current_search_space=list_search_space;
+}
+
+uint64_t set_search_start(struct ph_param *params, alloc_data_t **new_current_search_space, alloc_data_t *list_search_space)
+{
+ uint64_t offset=(*new_current_search_space)->start;
+ if(params->offset!=-1)
+ {
+ offset=params->offset;
+ set_search_start_aux(new_current_search_space, list_search_space, offset);
+ }
+ else if(params->cmd_run!=NULL && params->cmd_run[0]!='\0')
+ {
+ offset=0;
+ while(*params->cmd_run==',')
+ params->cmd_run++;
+ while(*params->cmd_run >= '0' && *params->cmd_run <= '9')
+ {
+ offset=offset * 10 + (*params->cmd_run - '0');
+ params->cmd_run++;
+ }
+ offset*=params->disk->sector_size;
+ set_search_start_aux(new_current_search_space, list_search_space, offset);
+ }
+ return offset;
+}
+
+