PhotoRec: use a single parameter to forward the options (code cleanup)
This commit is contained in:
parent
fbdc01bbc3
commit
a217bf73ff
13 changed files with 160 additions and 165 deletions
|
@ -320,12 +320,12 @@ static int fat_unformat_aux(disk_t *disk, partition_t *partition, const int verb
|
|||
return 0;
|
||||
}
|
||||
|
||||
int fat_unformat(disk_t *disk, partition_t *partition, const int verbose, const char *recup_dir, const int interface, unsigned int *file_nbr, unsigned int *blocksize, alloc_data_t *list_search_space, const time_t real_start_time, unsigned int *dir_num, const unsigned int expert)
|
||||
int fat_unformat(disk_t *disk, partition_t *partition, const struct ph_options *options, const char *recup_dir, const int interface, unsigned int *file_nbr, unsigned int *blocksize, alloc_data_t *list_search_space, const time_t real_start_time, unsigned int *dir_num)
|
||||
{
|
||||
unsigned int sectors_per_cluster=0;
|
||||
uint64_t start_data=0;
|
||||
*blocksize=0;
|
||||
if(pfind_sectors_per_cluster(disk, partition, verbose, interface, §ors_per_cluster, &start_data, list_search_space)==0)
|
||||
if(pfind_sectors_per_cluster(disk, partition, options->verbose, interface, §ors_per_cluster, &start_data, list_search_space)==0)
|
||||
{
|
||||
display_message("Can't find FAT cluster size\n");
|
||||
return 0;
|
||||
|
@ -341,13 +341,13 @@ int fat_unformat(disk_t *disk, partition_t *partition, const int verbose, const
|
|||
uint64_t offset=start_data;
|
||||
*blocksize=sectors_per_cluster * disk->sector_size;
|
||||
#ifdef HAVE_NCURSES
|
||||
if(expert>0)
|
||||
if(options->expert>0)
|
||||
*blocksize=menu_choose_blocksize(*blocksize, disk->sector_size, &offset);
|
||||
#endif
|
||||
update_blocksize(*blocksize,list_search_space, offset);
|
||||
}
|
||||
/* start_data is relative to the disk */
|
||||
fat_unformat_aux(disk, partition, verbose, recup_dir, interface, file_nbr,
|
||||
fat_unformat_aux(disk, partition, options->verbose, recup_dir, interface, file_nbr,
|
||||
*blocksize, start_data, list_search_space,
|
||||
real_start_time, dir_num);
|
||||
return 0;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
int fat_unformat(disk_t *disk, partition_t *partition, const int verbose, const char *recup_dir, const int interface, unsigned int *file_nbr, unsigned int *blocksize, alloc_data_t *list_search_space, const time_t real_start_time, unsigned int *dir_num, const unsigned int expert);
|
||||
int fat_unformat(disk_t *disk, partition_t *partition, const struct ph_options *options, const char *recup_dir, const int interface, unsigned int *file_nbr, unsigned int *blocksize, alloc_data_t *list_search_space, const time_t real_start_time, unsigned int *dir_num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* closing brace for extern "c" */
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
#define INTER_NOTE_Y (LINES-4)
|
||||
#endif
|
||||
|
||||
static int photorec_disk_selection_cli(int verbose, const char *recup_dir, const list_disk_t *list_disk, file_enable_t *file_enable, alloc_data_t *list_search_space, const char *cmd_device, char **current_cmd)
|
||||
static int photorec_disk_selection_cli(struct ph_options *options, const char *recup_dir, const list_disk_t *list_disk, file_enable_t *file_enable, alloc_data_t *list_search_space, const char *cmd_device, char **current_cmd)
|
||||
{
|
||||
const list_disk_t *element_disk;
|
||||
disk_t *disk=NULL;
|
||||
|
@ -91,13 +91,13 @@ static int photorec_disk_selection_cli(int verbose, const char *recup_dir, const
|
|||
}
|
||||
}
|
||||
autodetect_arch(disk);
|
||||
if(interface_partition_type(disk, verbose, current_cmd)==0)
|
||||
menu_photorec(disk, verbose, recup_dir, file_enable, current_cmd, list_search_space);
|
||||
if(interface_partition_type(disk, options->verbose, current_cmd)==0)
|
||||
menu_photorec(disk, options, recup_dir, file_enable, current_cmd, list_search_space);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_NCURSES
|
||||
static int photorec_disk_selection_ncurses(int verbose, const char *recup_dir, const list_disk_t *list_disk, file_enable_t *file_enable, alloc_data_t *list_search_space)
|
||||
static int photorec_disk_selection_ncurses(struct ph_options *options, const char *recup_dir, const list_disk_t *list_disk, file_enable_t *file_enable, alloc_data_t *list_search_space)
|
||||
{
|
||||
char * current_cmd=NULL;
|
||||
int command;
|
||||
|
@ -125,7 +125,7 @@ static int photorec_disk_selection_ncurses(int verbose, const char *recup_dir, c
|
|||
/* ncurses interface */
|
||||
while(1)
|
||||
{
|
||||
const char *options;
|
||||
const char *menu_options;
|
||||
int i;
|
||||
aff_copy(stdscr);
|
||||
wmove(stdscr,4,0);
|
||||
|
@ -183,19 +183,19 @@ static int photorec_disk_selection_ncurses(int verbose, const char *recup_dir, c
|
|||
if(use_sudo > 0)
|
||||
{
|
||||
if(i<=NBR_DISK_MAX && element_disk==NULL)
|
||||
options="OSQ";
|
||||
menu_options="OSQ";
|
||||
else
|
||||
options="PNOSQ";
|
||||
menu_options="PNOSQ";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(i<=NBR_DISK_MAX && element_disk==NULL)
|
||||
options="OQ";
|
||||
menu_options="OQ";
|
||||
else
|
||||
options="PNOQ";
|
||||
menu_options="PNOQ";
|
||||
}
|
||||
command = wmenuSelect_ext(stdscr, INTER_NOTE_Y-1, INTER_DISK_Y, INTER_DISK_X, menuMain, 8,
|
||||
options, MENU_HORIZ | MENU_BUTTON | MENU_ACCEPT_OTHERS, &menu,&real_key);
|
||||
menu_options, MENU_HORIZ | MENU_BUTTON | MENU_ACCEPT_OTHERS, &menu,&real_key);
|
||||
#if defined(KEY_MOUSE) && defined(ENABLE_MOUSE)
|
||||
if(command == KEY_MOUSE)
|
||||
{
|
||||
|
@ -224,7 +224,7 @@ static int photorec_disk_selection_ncurses(int verbose, const char *recup_dir, c
|
|||
}
|
||||
else
|
||||
command = menu_to_command(INTER_NOTE_Y-1, INTER_DISK_Y, INTER_DISK_X, menuMain, 8,
|
||||
options, MENU_HORIZ | MENU_BUTTON | MENU_ACCEPT_OTHERS, event.y, event.x);
|
||||
menu_options, MENU_HORIZ | MENU_BUTTON | MENU_ACCEPT_OTHERS, event.y, event.x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -268,8 +268,8 @@ static int photorec_disk_selection_ncurses(int verbose, const char *recup_dir, c
|
|||
const int hpa_dco=is_hpa_or_dco(disk);
|
||||
autodetect_arch(disk);
|
||||
if((hpa_dco==0 || interface_check_hidden_ncurses(disk, hpa_dco)==0) &&
|
||||
interface_partition_type(disk, verbose, ¤t_cmd)==0)
|
||||
menu_photorec(disk, verbose, recup_dir, file_enable, ¤t_cmd, list_search_space);
|
||||
interface_partition_type(disk, options->verbose, ¤t_cmd)==0)
|
||||
menu_photorec(disk, options, recup_dir, file_enable, ¤t_cmd, list_search_space);
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
|
@ -287,7 +287,7 @@ static int photorec_disk_selection_ncurses(int verbose, const char *recup_dir, c
|
|||
}
|
||||
#endif
|
||||
|
||||
int do_curses_photorec(int verbose, const char *recup_dir, const list_disk_t *list_disk, file_enable_t *file_enable, char *cmd_device, char **current_cmd)
|
||||
int do_curses_photorec(struct ph_options *options, const char *recup_dir, const list_disk_t *list_disk, file_enable_t *file_enable, char *cmd_device, char **current_cmd)
|
||||
{
|
||||
static alloc_data_t list_search_space={
|
||||
.list = TD_LIST_HEAD_INIT(list_search_space.list)
|
||||
|
@ -313,9 +313,9 @@ int do_curses_photorec(int verbose, const char *recup_dir, const list_disk_t *li
|
|||
}
|
||||
#endif
|
||||
if(cmd_device!=NULL && *current_cmd!=NULL)
|
||||
return photorec_disk_selection_cli(verbose, recup_dir, list_disk, file_enable, &list_search_space, cmd_device, current_cmd);
|
||||
return photorec_disk_selection_cli(options, recup_dir, list_disk, file_enable, &list_search_space, cmd_device, current_cmd);
|
||||
#ifdef HAVE_NCURSES
|
||||
return photorec_disk_selection_ncurses(verbose, recup_dir, list_disk, file_enable, &list_search_space);
|
||||
return photorec_disk_selection_ncurses(options, recup_dir, list_disk, file_enable, &list_search_space);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
int do_curses_photorec(int verbose, const char *recup_dir, const list_disk_t *list_disk, file_enable_t *file_enable, char *cmd_device, char**cmd_run);
|
||||
int do_curses_photorec(struct ph_options *options, const char *recup_dir, const list_disk_t *list_disk, file_enable_t *file_enable, char *cmd_device, char**cmd_run);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* closing brace for extern "C" */
|
||||
|
|
23
src/phmain.c
23
src/phmain.c
|
@ -102,7 +102,7 @@ int main( int argc, char **argv )
|
|||
{
|
||||
int i;
|
||||
int use_sudo=0;
|
||||
int help=0, version=0, verbose=0;
|
||||
int help=0, version=0;
|
||||
int create_log=TD_LOG_NONE;
|
||||
int run_setlocale=1;
|
||||
int testdisk_mode=TESTDISK_O_RDONLY|TESTDISK_O_READAHEAD_32K;
|
||||
|
@ -114,6 +114,15 @@ int main( int argc, char **argv )
|
|||
const char *logfile="photorec.log";
|
||||
const arch_fnct_t *arch=&arch_none;
|
||||
FILE *log_handle=NULL;
|
||||
struct ph_options options={
|
||||
.paranoid=1,
|
||||
.allow_partial_last_cylinder=0,
|
||||
.keep_corrupted_file=0,
|
||||
.mode_ext2=0,
|
||||
.expert=0,
|
||||
.lowmem=0,
|
||||
.verbose=0
|
||||
};
|
||||
/* random (weak is ok) is need fot GPT */
|
||||
srand(time(NULL));
|
||||
#ifdef HAVE_SIGACTION
|
||||
|
@ -151,7 +160,7 @@ int main( int argc, char **argv )
|
|||
}
|
||||
else if((strcmp(argv[i],"/debug")==0) || (strcmp(argv[i],"-debug")==0))
|
||||
{
|
||||
verbose++;
|
||||
options.verbose++;
|
||||
if(create_log==TD_LOG_NONE)
|
||||
create_log=TD_LOG_APPEND;
|
||||
}
|
||||
|
@ -192,7 +201,7 @@ int main( int argc, char **argv )
|
|||
cmd_device=argv[++i];
|
||||
cmd_run=argv[++i];
|
||||
/* There is no log currently */
|
||||
disk_car=file_test_availability(cmd_device,verbose,arch,testdisk_mode);
|
||||
disk_car=file_test_availability(cmd_device, options.verbose, arch, testdisk_mode);
|
||||
if(disk_car==NULL)
|
||||
{
|
||||
printf("\nUnable to open file or device %s\n",cmd_device);
|
||||
|
@ -204,7 +213,7 @@ int main( int argc, char **argv )
|
|||
}
|
||||
else
|
||||
{
|
||||
disk_t *disk_car=file_test_availability(argv[i],verbose,arch,testdisk_mode);
|
||||
disk_t *disk_car=file_test_availability(argv[i], options.verbose, arch, testdisk_mode);
|
||||
if(disk_car==NULL)
|
||||
{
|
||||
printf("\nUnable to open file or device %s\n",argv[i]);
|
||||
|
@ -309,8 +318,8 @@ int main( int argc, char **argv )
|
|||
screen_buffer_reset();
|
||||
/* Scan for available device only if no device or image has been supplied in parameter */
|
||||
if(list_disk==NULL)
|
||||
list_disk=hd_parse(list_disk,verbose,arch,testdisk_mode);
|
||||
hd_update_all_geometry(list_disk,0,verbose);
|
||||
list_disk=hd_parse(list_disk, options.verbose, arch, testdisk_mode);
|
||||
hd_update_all_geometry(list_disk, 0, options.verbose);
|
||||
/* Activate the cache, even if photorec has its own */
|
||||
for(element_disk=list_disk;element_disk!=NULL;element_disk=element_disk->next)
|
||||
{
|
||||
|
@ -333,7 +342,7 @@ int main( int argc, char **argv )
|
|||
log_info("\n");
|
||||
reset_list_file_enable(list_file_enable);
|
||||
file_options_load(list_file_enable);
|
||||
use_sudo=do_curses_photorec(verbose, recup_dir, list_disk, list_file_enable, cmd_device, &cmd_run);
|
||||
use_sudo=do_curses_photorec(&options, recup_dir, list_disk, list_file_enable, cmd_device, &cmd_run);
|
||||
#ifdef HAVE_NCURSES
|
||||
end_ncurses();
|
||||
#endif
|
||||
|
|
|
@ -692,7 +692,7 @@ int file_finish(file_recovery_t *file_recovery, const char *recup_dir, const int
|
|||
return file_recovered;
|
||||
}
|
||||
|
||||
alloc_data_t *file_finish2(file_recovery_t *file_recovery, const char *recup_dir, const int paranoid, unsigned int *file_nbr,
|
||||
alloc_data_t *file_finish2(file_recovery_t *file_recovery, const char *recup_dir, const struct ph_options *options, unsigned int *file_nbr,
|
||||
const unsigned int blocksize, alloc_data_t *list_search_space,
|
||||
unsigned int *dir_num, const photorec_status_t status, const disk_t *disk)
|
||||
{
|
||||
|
@ -706,7 +706,7 @@ alloc_data_t *file_finish2(file_recovery_t *file_recovery, const char *recup_dir
|
|||
{
|
||||
if(status!=STATUS_EXT2_ON_SAVE_EVERYTHING && status!=STATUS_EXT2_OFF_SAVE_EVERYTHING)
|
||||
{
|
||||
if(file_recovery->file_stat!=NULL && file_recovery->file_check!=NULL && paranoid>0)
|
||||
if(file_recovery->file_stat!=NULL && file_recovery->file_check!=NULL && options->paranoid>0)
|
||||
{ /* Check if recovered file is valid */
|
||||
file_recovery->file_check(file_recovery);
|
||||
}
|
||||
|
|
|
@ -27,12 +27,23 @@ extern "C" {
|
|||
|
||||
enum photorec_status { STATUS_FIND_OFFSET, STATUS_UNFORMAT, STATUS_EXT2_ON, STATUS_EXT2_ON_BF, STATUS_EXT2_OFF, STATUS_EXT2_OFF_BF, STATUS_EXT2_ON_SAVE_EVERYTHING, STATUS_EXT2_OFF_SAVE_EVERYTHING, STATUS_QUIT };
|
||||
typedef enum photorec_status photorec_status_t;
|
||||
struct ph_options
|
||||
{
|
||||
int paranoid;
|
||||
int allow_partial_last_cylinder;
|
||||
int keep_corrupted_file;
|
||||
unsigned int mode_ext2;
|
||||
unsigned int expert;
|
||||
unsigned int lowmem;
|
||||
int verbose;
|
||||
};
|
||||
|
||||
|
||||
int get_prev_file_header(alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset);
|
||||
int file_finish(file_recovery_t *file_recovery, const char *recup_dir, const int paranoid, unsigned int *file_nbr,
|
||||
const unsigned int blocksize, alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset,
|
||||
unsigned int *dir_num, const photorec_status_t status, const disk_t *disk);
|
||||
alloc_data_t *file_finish2(file_recovery_t *file_recovery, const char *recup_dir, const int paranoid, unsigned int *file_nbr,
|
||||
alloc_data_t *file_finish2(file_recovery_t *file_recovery, const char *recup_dir, const struct ph_options *options, unsigned int *file_nbr,
|
||||
const unsigned int blocksize, alloc_data_t *list_search_space,
|
||||
unsigned int *dir_num, const photorec_status_t status, const disk_t *disk);
|
||||
void write_stats_log(const file_stat_t *file_stats);
|
||||
|
|
160
src/phrecn.c
160
src/phrecn.c
|
@ -87,11 +87,6 @@ extern const file_hint_t file_hint_tar;
|
|||
extern const file_hint_t file_hint_dir;
|
||||
extern file_check_list_t file_check_list;
|
||||
|
||||
#ifdef HAVE_NCURSES
|
||||
static void recovery_finished(disk_t *disk, const partition_t *partition, const unsigned int file_nbr, const char *recup_dir, const int ind_stop);
|
||||
#endif
|
||||
|
||||
static int photorec_aux(disk_t *disk_car, partition_t *partition, const int verbose, const int paranoid, const char *recup_dir, const int interface, file_stat_t *file_stats, unsigned int *file_nbr, const unsigned int blocksize, alloc_data_t *list_search_space, const time_t real_start_time, unsigned int *dir_num, const photorec_status_t status, const unsigned int pass, const unsigned int lowmem);
|
||||
static int interface_cannot_create_file(void);
|
||||
|
||||
/* ==================== INLINE FUNCTIONS ========================= */
|
||||
|
@ -181,7 +176,7 @@ static alloc_data_t *file_add_data(alloc_data_t *data, const uint64_t offset, co
|
|||
}
|
||||
}
|
||||
|
||||
static int photorec_aux(disk_t *disk_car, partition_t *partition, const int verbose, const int paranoid, const char *recup_dir, const int interface, file_stat_t *file_stats, unsigned int *file_nbr, const unsigned int blocksize, alloc_data_t *list_search_space, const time_t real_start_time, unsigned int *dir_num, const photorec_status_t status, const unsigned int pass, const unsigned int lowmem)
|
||||
static int photorec_aux(disk_t *disk_car, partition_t *partition, const struct ph_options *options, const char *recup_dir, const int interface, file_stat_t *file_stats, unsigned int *file_nbr, const unsigned int blocksize, alloc_data_t *list_search_space, const time_t real_start_time, unsigned int *dir_num, const photorec_status_t status, const unsigned int pass)
|
||||
{
|
||||
uint64_t offset=0;
|
||||
unsigned char *buffer_start;
|
||||
|
@ -206,9 +201,9 @@ static int photorec_aux(disk_t *disk_car, partition_t *partition, const int verb
|
|||
current_search_space=td_list_entry(list_search_space->list.next, alloc_data_t, list);
|
||||
if(current_search_space!=list_search_space)
|
||||
offset=current_search_space->start;
|
||||
if(verbose>0)
|
||||
info_list_search_space(list_search_space, current_search_space, disk_car->sector_size, 0, verbose);
|
||||
if(verbose>1)
|
||||
if(options->verbose > 0)
|
||||
info_list_search_space(list_search_space, current_search_space, disk_car->sector_size, 0, options->verbose);
|
||||
if(options->verbose > 1)
|
||||
{
|
||||
log_verbose("Reading sector %10llu/%llu\n",
|
||||
(unsigned long long)((offset-partition->part_offset)/disk_car->sector_size),
|
||||
|
@ -243,7 +238,7 @@ static int photorec_aux(disk_t *disk_car, partition_t *partition, const int verb
|
|||
else if(file_recovery.file_stat!=NULL && file_recovery.file_stat->file_hint==&file_hint_tar &&
|
||||
header_check_tar(buffer-0x200,0x200,0,&file_recovery,&file_recovery_new))
|
||||
{ /* Currently saving a tar, do not check the data for know header */
|
||||
if(verbose>1)
|
||||
if(options->verbose > 1)
|
||||
{
|
||||
log_verbose("Currently saving a tar file, sector %lu.\n",
|
||||
(unsigned long)((offset-partition->part_offset)/disk_car->sector_size));
|
||||
|
@ -275,11 +270,11 @@ static int photorec_aux(disk_t *disk_car, partition_t *partition, const int verb
|
|||
current_search_space=file_found(current_search_space, offset, file_recovery_new.file_stat);
|
||||
file_recovery_new.loc=current_search_space;
|
||||
file_recovery_new.location.start=offset;
|
||||
if(verbose>1)
|
||||
if(options->verbose > 1)
|
||||
log_trace("A known header has been found, recovery of the previous file is finished\n");
|
||||
{
|
||||
alloc_data_t *datanext;
|
||||
datanext=file_finish2(&file_recovery, recup_dir, paranoid, file_nbr, blocksize, list_search_space, dir_num,status, disk_car);
|
||||
datanext=file_finish2(&file_recovery, recup_dir, options, file_nbr, blocksize, list_search_space, dir_num,status, disk_car);
|
||||
if(datanext!=NULL)
|
||||
{
|
||||
current_search_space=datanext;
|
||||
|
@ -288,12 +283,12 @@ static int photorec_aux(disk_t *disk_car, partition_t *partition, const int verb
|
|||
}
|
||||
}
|
||||
reset_file_recovery(&file_recovery);
|
||||
if(lowmem>0)
|
||||
if(options->lowmem > 0)
|
||||
forget(list_search_space,current_search_space);
|
||||
if(move_next!=0)
|
||||
{
|
||||
file_recovery_cpy(&file_recovery, &file_recovery_new);
|
||||
if(verbose>1)
|
||||
if(options->verbose > 1)
|
||||
{
|
||||
log_info("%s header found at sector %lu\n",
|
||||
((file_recovery.extension!=NULL && file_recovery.extension[0]!='\0')?
|
||||
|
@ -303,7 +298,7 @@ static int photorec_aux(disk_t *disk_car, partition_t *partition, const int verb
|
|||
(unsigned long)(file_recovery.location.start/disk_car->sector_size));
|
||||
}
|
||||
|
||||
if(file_recovery.file_stat->file_hint==&file_hint_dir && verbose>0)
|
||||
if(file_recovery.file_stat->file_hint==&file_hint_dir && options->verbose > 0)
|
||||
{ /* FAT directory found, list the file */
|
||||
file_data_t *dir_list;
|
||||
dir_list=dir_fat_aux(buffer,read_size,0,0);
|
||||
|
@ -347,7 +342,7 @@ static int photorec_aux(disk_t *disk_car, partition_t *partition, const int verb
|
|||
{
|
||||
current_search_space=file_add_data(current_search_space, offset, 0);
|
||||
file_recovery.file_size_on_disk+=blocksize;
|
||||
if(verbose>1)
|
||||
if(options->verbose > 1)
|
||||
{
|
||||
log_verbose("Skipping sector %10lu/%lu\n",
|
||||
(unsigned long)((offset-partition->part_offset)/disk_car->sector_size),
|
||||
|
@ -383,7 +378,7 @@ static int photorec_aux(disk_t *disk_car, partition_t *partition, const int verb
|
|||
file_recovery.file_size_on_disk+=blocksize;
|
||||
if(res==2)
|
||||
{
|
||||
if(verbose>1)
|
||||
if(options->verbose > 1)
|
||||
log_trace("EOF found\n");
|
||||
}
|
||||
}
|
||||
|
@ -403,7 +398,7 @@ static int photorec_aux(disk_t *disk_car, partition_t *partition, const int verb
|
|||
if(res==2)
|
||||
{
|
||||
alloc_data_t *datanext;
|
||||
datanext=file_finish2(&file_recovery, recup_dir, paranoid, file_nbr, blocksize, list_search_space, dir_num,status, disk_car);
|
||||
datanext=file_finish2(&file_recovery, recup_dir, options, file_nbr, blocksize, list_search_space, dir_num,status, disk_car);
|
||||
if(datanext!=NULL)
|
||||
{
|
||||
current_search_space=datanext;
|
||||
|
@ -411,7 +406,7 @@ static int photorec_aux(disk_t *disk_car, partition_t *partition, const int verb
|
|||
move_next=0;
|
||||
}
|
||||
reset_file_recovery(&file_recovery);
|
||||
if(lowmem>0)
|
||||
if(options->lowmem > 0)
|
||||
forget(list_search_space,current_search_space);
|
||||
}
|
||||
}
|
||||
|
@ -437,7 +432,7 @@ static int photorec_aux(disk_t *disk_car, partition_t *partition, const int verb
|
|||
current_search_space, current_search_space->list.prev, current_search_space->list.next);
|
||||
log_trace("End of media\n");
|
||||
#endif
|
||||
datanext=file_finish2(&file_recovery, recup_dir, paranoid, file_nbr, blocksize, list_search_space, dir_num,status, disk_car);
|
||||
datanext=file_finish2(&file_recovery, recup_dir, options, file_nbr, blocksize, list_search_space, dir_num,status, disk_car);
|
||||
if(datanext!=NULL)
|
||||
{
|
||||
current_search_space=datanext;
|
||||
|
@ -445,7 +440,7 @@ static int photorec_aux(disk_t *disk_car, partition_t *partition, const int verb
|
|||
move_next=0;
|
||||
}
|
||||
reset_file_recovery(&file_recovery);
|
||||
if(lowmem>0)
|
||||
if(options->lowmem > 0)
|
||||
forget(list_search_space,current_search_space);
|
||||
}
|
||||
buffer_olddata+=blocksize;
|
||||
|
@ -460,7 +455,7 @@ static int photorec_aux(disk_t *disk_car, partition_t *partition, const int verb
|
|||
memcpy(buffer_start,buffer_olddata,blocksize);
|
||||
buffer_olddata=buffer_start;
|
||||
buffer=buffer_olddata + blocksize;
|
||||
if(verbose>1)
|
||||
if(options->verbose > 1)
|
||||
{
|
||||
log_verbose("Reading sector %10llu/%llu\n",
|
||||
(unsigned long long)((offset-partition->part_offset)/disk_car->sector_size),
|
||||
|
@ -745,7 +740,7 @@ static void test_files(disk_t *disk, partition_t *partition, alloc_data_t *list_
|
|||
}
|
||||
#endif
|
||||
|
||||
int photorec(disk_t *disk_car, partition_t *partition, const int verbose, const int paranoid, char *recup_dir, const int keep_corrupted_file, const int interface, file_enable_t *files_enable, unsigned int mode_ext2, char **current_cmd, alloc_data_t *list_search_space, unsigned int blocksize, const unsigned int expert, const unsigned int lowmem, const unsigned int carve_free_space_only)
|
||||
int photorec(disk_t *disk_car, partition_t *partition, const struct ph_options *options, char *recup_dir, const int interface, file_enable_t *files_enable, char **current_cmd, alloc_data_t *list_search_space, unsigned int blocksize, const unsigned int carve_free_space_only)
|
||||
{
|
||||
char *new_recup_dir=NULL;
|
||||
file_stat_t *file_stats;
|
||||
|
@ -817,23 +812,23 @@ int photorec(disk_t *disk_car, partition_t *partition, const int verbose, const
|
|||
{
|
||||
const unsigned int old_blocksize=blocksize;
|
||||
blocksize=0;
|
||||
ind_stop=fat_unformat(disk_car, partition, verbose, recup_dir, interface, &file_nbr, &blocksize, list_search_space, real_start_time, &dir_num, expert);
|
||||
ind_stop=fat_unformat(disk_car, partition, options, recup_dir, interface, &file_nbr, &blocksize, list_search_space, real_start_time, &dir_num);
|
||||
if(blocksize==0)
|
||||
blocksize=old_blocksize;
|
||||
}
|
||||
else if(status==STATUS_FIND_OFFSET)
|
||||
{
|
||||
ind_stop=photorec_find_blocksize(disk_car, partition, verbose, interface, file_stats, &file_nbr, &blocksize, list_search_space, real_start_time);
|
||||
ind_stop=photorec_find_blocksize(disk_car, partition, options->verbose, interface, file_stats, &file_nbr, &blocksize, list_search_space, real_start_time);
|
||||
}
|
||||
else if(status==STATUS_EXT2_ON_BF || status==STATUS_EXT2_OFF_BF)
|
||||
{
|
||||
ind_stop=photorec_bf(disk_car, partition, verbose, recup_dir, interface, file_stats, &file_nbr, blocksize, list_search_space, real_start_time, &dir_num, status, pass);
|
||||
session_save(list_search_space, disk_car, partition, files_enable, blocksize, paranoid, keep_corrupted_file, mode_ext2, expert, lowmem, carve_free_space_only, verbose);
|
||||
ind_stop=photorec_bf(disk_car, partition, options->verbose, recup_dir, interface, file_stats, &file_nbr, blocksize, list_search_space, real_start_time, &dir_num, status, pass);
|
||||
session_save(list_search_space, disk_car, partition, files_enable, blocksize, options, carve_free_space_only);
|
||||
}
|
||||
else
|
||||
{
|
||||
ind_stop=photorec_aux(disk_car, partition, verbose, paranoid, recup_dir, interface, file_stats, &file_nbr, blocksize, list_search_space, real_start_time, &dir_num, status, pass, lowmem);
|
||||
session_save(list_search_space, disk_car, partition, files_enable, blocksize, paranoid, keep_corrupted_file, mode_ext2, expert, lowmem, carve_free_space_only, verbose);
|
||||
ind_stop=photorec_aux(disk_car, partition, options, recup_dir, interface, file_stats, &file_nbr, blocksize, list_search_space, real_start_time, &dir_num, status, pass);
|
||||
session_save(list_search_space, disk_car, partition, files_enable, blocksize, options, carve_free_space_only);
|
||||
}
|
||||
if(ind_stop==3)
|
||||
{ /* no more space */
|
||||
|
@ -874,7 +869,7 @@ int photorec(disk_t *disk_car, partition_t *partition, const int verbose, const
|
|||
}
|
||||
else if(ind_stop>0)
|
||||
{
|
||||
if(session_save(list_search_space, disk_car, partition, files_enable, blocksize, paranoid, keep_corrupted_file, mode_ext2, expert, lowmem, carve_free_space_only, verbose)<0)
|
||||
if(session_save(list_search_space, disk_car, partition, files_enable, blocksize, options, carve_free_space_only) < 0)
|
||||
{
|
||||
/* Failed to save the session! */
|
||||
#ifdef HAVE_NCURSES
|
||||
|
@ -890,7 +885,7 @@ int photorec(disk_t *disk_car, partition_t *partition, const int verbose, const
|
|||
#endif
|
||||
}
|
||||
}
|
||||
else if(paranoid>0)
|
||||
else if(options->paranoid>0)
|
||||
{
|
||||
switch(status)
|
||||
{
|
||||
|
@ -898,7 +893,7 @@ int photorec(disk_t *disk_car, partition_t *partition, const int verbose, const
|
|||
{
|
||||
uint64_t start_offset;
|
||||
file_nbr=0;
|
||||
status=(mode_ext2>0?STATUS_EXT2_ON:STATUS_EXT2_OFF);
|
||||
status=(options->mode_ext2>0?STATUS_EXT2_ON:STATUS_EXT2_OFF);
|
||||
if(blocksize_is_known==0)
|
||||
blocksize=find_blocksize(list_search_space, disk_car->sector_size, &start_offset);
|
||||
else if(td_list_empty(&list_search_space->list))
|
||||
|
@ -906,7 +901,7 @@ int photorec(disk_t *disk_car, partition_t *partition, const int verbose, const
|
|||
else
|
||||
start_offset=(td_list_entry(list_search_space->list.next, alloc_data_t, list))->start % blocksize;
|
||||
#ifdef HAVE_NCURSES
|
||||
if(expert>0)
|
||||
if(options->expert>0)
|
||||
{
|
||||
if(ask_confirmation("Try to unformat a FAT filesystem (Y/N)")!=0)
|
||||
status=STATUS_UNFORMAT;
|
||||
|
@ -927,25 +922,25 @@ int photorec(disk_t *disk_car, partition_t *partition, const int verbose, const
|
|||
break;
|
||||
case STATUS_UNFORMAT:
|
||||
{
|
||||
status=(mode_ext2>0?STATUS_EXT2_ON:STATUS_EXT2_OFF);
|
||||
status=(options->mode_ext2>0?STATUS_EXT2_ON:STATUS_EXT2_OFF);
|
||||
file_nbr=0;
|
||||
}
|
||||
break;
|
||||
case STATUS_EXT2_ON:
|
||||
status=(paranoid>1?STATUS_EXT2_ON_BF:STATUS_EXT2_OFF);
|
||||
status=(options->paranoid>1?STATUS_EXT2_ON_BF:STATUS_EXT2_OFF);
|
||||
break;
|
||||
case STATUS_EXT2_ON_BF:
|
||||
status=STATUS_EXT2_OFF;
|
||||
break;
|
||||
case STATUS_EXT2_OFF:
|
||||
if(paranoid>1)
|
||||
if(options->paranoid>1)
|
||||
{
|
||||
status=STATUS_EXT2_OFF_BF;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(keep_corrupted_file>0)
|
||||
status=(mode_ext2>0?STATUS_EXT2_ON_SAVE_EVERYTHING:STATUS_EXT2_OFF_SAVE_EVERYTHING);
|
||||
if(options->keep_corrupted_file>0)
|
||||
status=(options->mode_ext2>0?STATUS_EXT2_ON_SAVE_EVERYTHING:STATUS_EXT2_OFF_SAVE_EVERYTHING);
|
||||
else
|
||||
{
|
||||
status=STATUS_QUIT;
|
||||
|
@ -954,8 +949,8 @@ int photorec(disk_t *disk_car, partition_t *partition, const int verbose, const
|
|||
}
|
||||
break;
|
||||
case STATUS_EXT2_OFF_BF:
|
||||
if(keep_corrupted_file>0)
|
||||
status=(mode_ext2>0?STATUS_EXT2_ON_SAVE_EVERYTHING:STATUS_EXT2_OFF_SAVE_EVERYTHING);
|
||||
if(options->keep_corrupted_file>0)
|
||||
status=(options->mode_ext2>0?STATUS_EXT2_ON_SAVE_EVERYTHING:STATUS_EXT2_OFF_SAVE_EVERYTHING);
|
||||
else
|
||||
{
|
||||
status=STATUS_QUIT;
|
||||
|
@ -977,9 +972,9 @@ int photorec(disk_t *disk_car, partition_t *partition, const int verbose, const
|
|||
{
|
||||
case STATUS_FIND_OFFSET:
|
||||
file_nbr=0;
|
||||
status=(mode_ext2>0?STATUS_EXT2_ON_SAVE_EVERYTHING:STATUS_EXT2_OFF_SAVE_EVERYTHING);
|
||||
status=(options->mode_ext2>0?STATUS_EXT2_ON_SAVE_EVERYTHING:STATUS_EXT2_OFF_SAVE_EVERYTHING);
|
||||
#ifdef HAVE_NCURSES
|
||||
if(expert>0)
|
||||
if(options->expert>0)
|
||||
{
|
||||
uint64_t offset=0;
|
||||
if(!td_list_empty(&list_search_space->list))
|
||||
|
@ -996,7 +991,7 @@ int photorec(disk_t *disk_car, partition_t *partition, const int verbose, const
|
|||
#endif
|
||||
break;
|
||||
case STATUS_UNFORMAT:
|
||||
status=(mode_ext2>0?STATUS_EXT2_ON_SAVE_EVERYTHING:STATUS_EXT2_OFF_SAVE_EVERYTHING);
|
||||
status=(options->mode_ext2>0?STATUS_EXT2_ON_SAVE_EVERYTHING:STATUS_EXT2_OFF_SAVE_EVERYTHING);
|
||||
file_nbr=0;
|
||||
break;
|
||||
default:
|
||||
|
@ -1028,7 +1023,7 @@ int photorec(disk_t *disk_car, partition_t *partition, const int verbose, const
|
|||
log_flush();
|
||||
}
|
||||
#ifdef HAVE_NCURSES
|
||||
if(expert>0 && !td_list_empty(&list_search_space->list))
|
||||
if(options->expert>0 && !td_list_empty(&list_search_space->list))
|
||||
{
|
||||
char msg[256];
|
||||
uint64_t data_size=0;
|
||||
|
@ -1060,7 +1055,7 @@ int photorec(disk_t *disk_car, partition_t *partition, const int verbose, const
|
|||
}
|
||||
}
|
||||
#endif
|
||||
info_list_search_space(list_search_space, NULL, disk_car->sector_size, keep_corrupted_file, verbose);
|
||||
info_list_search_space(list_search_space, NULL, disk_car->sector_size, options->keep_corrupted_file, options->verbose);
|
||||
/* Free memory */
|
||||
free_search_space(list_search_space);
|
||||
#ifdef HAVE_NCURSES
|
||||
|
@ -1076,7 +1071,7 @@ int photorec(disk_t *disk_car, partition_t *partition, const int verbose, const
|
|||
}
|
||||
|
||||
#ifdef HAVE_NCURSES
|
||||
static void interface_options_photorec_ncurses(int *paranoid, int *allow_partial_last_cylinder, int *keep_corrupted_file, unsigned int *mode_ext2, unsigned int *expert, unsigned int *lowmem)
|
||||
static void interface_options_photorec_ncurses(struct ph_options *options)
|
||||
{
|
||||
unsigned int menu = 6;
|
||||
struct MenuItem menuOptions[]=
|
||||
|
@ -1094,7 +1089,7 @@ static void interface_options_photorec_ncurses(int *paranoid, int *allow_partial
|
|||
{
|
||||
int car;
|
||||
int real_key;
|
||||
switch(*paranoid)
|
||||
switch(options->paranoid)
|
||||
{
|
||||
case 0:
|
||||
menuOptions[0].name="Paranoid : No";
|
||||
|
@ -1106,52 +1101,41 @@ static void interface_options_photorec_ncurses(int *paranoid, int *allow_partial
|
|||
menuOptions[0].name="Paranoid : Yes (Brute force enabled)";
|
||||
break;
|
||||
}
|
||||
menuOptions[1].name=*allow_partial_last_cylinder?"Allow partial last cylinder : Yes":"Allow partial last cylinder : No";
|
||||
menuOptions[2].name=*keep_corrupted_file?"Keep corrupted files : Yes":"Keep corrupted files : No";
|
||||
menuOptions[3].name=*mode_ext2?"ext2/ext3 mode: Yes":"ext2/ext3 mode : No";
|
||||
menuOptions[4].name=*expert?"Expert mode : Yes":"Expert mode : No";
|
||||
menuOptions[5].name=*lowmem?"Low memory: Yes":"Low memory: No";
|
||||
/* Jpg
|
||||
Mov
|
||||
Mpg
|
||||
Minolta MRW
|
||||
Canon CRW
|
||||
Signa/Foveon X3F
|
||||
Fuji RAF
|
||||
Rollei RDC
|
||||
MP3
|
||||
|
||||
*/
|
||||
menuOptions[1].name=options->allow_partial_last_cylinder?"Allow partial last cylinder : Yes":"Allow partial last cylinder : No";
|
||||
menuOptions[2].name=options->keep_corrupted_file?"Keep corrupted files : Yes":"Keep corrupted files : No";
|
||||
menuOptions[3].name=options->mode_ext2?"ext2/ext3 mode: Yes":"ext2/ext3 mode : No";
|
||||
menuOptions[4].name=options->expert?"Expert mode : Yes":"Expert mode : No";
|
||||
menuOptions[5].name=options->lowmem?"Low memory: Yes":"Low memory: No";
|
||||
aff_copy(stdscr);
|
||||
car=wmenuSelect_ext(stdscr, 23, INTER_OPTION_Y, INTER_OPTION_X, menuOptions, 0, "PAKELQ", MENU_VERT|MENU_VERT_ARROW2VALID, &menu,&real_key);
|
||||
switch(car)
|
||||
{
|
||||
case 'p':
|
||||
case 'P':
|
||||
if(*paranoid<2)
|
||||
(*paranoid)++;
|
||||
if(options->paranoid<2)
|
||||
options->paranoid++;
|
||||
else
|
||||
*paranoid=0;
|
||||
options->paranoid=0;
|
||||
break;
|
||||
case 'a':
|
||||
case 'A':
|
||||
*allow_partial_last_cylinder=!*allow_partial_last_cylinder;
|
||||
options->allow_partial_last_cylinder=!options->allow_partial_last_cylinder;
|
||||
break;
|
||||
case 'k':
|
||||
case 'K':
|
||||
*keep_corrupted_file=!*keep_corrupted_file;
|
||||
options->keep_corrupted_file=!options->keep_corrupted_file;
|
||||
break;
|
||||
case 's':
|
||||
case 'S':
|
||||
*mode_ext2=!*mode_ext2;
|
||||
options->mode_ext2=!options->mode_ext2;
|
||||
break;
|
||||
case 'e':
|
||||
case 'E':
|
||||
*expert=!*expert;
|
||||
options->expert=!options->expert;
|
||||
break;
|
||||
case 'l':
|
||||
case 'L':
|
||||
*lowmem=!*lowmem;
|
||||
options->lowmem=!options->lowmem;
|
||||
break;
|
||||
case key_ESC:
|
||||
case 'q':
|
||||
|
@ -1162,7 +1146,7 @@ static void interface_options_photorec_ncurses(int *paranoid, int *allow_partial
|
|||
}
|
||||
#endif
|
||||
|
||||
void interface_options_photorec(int *paranoid, int *allow_partial_last_cylinder, int *keep_corrupted_file, unsigned int *mode_ext2, unsigned int *expert, unsigned int *lowmem, char **current_cmd)
|
||||
void interface_options_photorec(struct ph_options *options, char **current_cmd)
|
||||
{
|
||||
if(*current_cmd!=NULL)
|
||||
{
|
||||
|
@ -1175,47 +1159,47 @@ void interface_options_photorec(int *paranoid, int *allow_partial_last_cylinder,
|
|||
if(strncmp(*current_cmd,"paranoid_no",11)==0)
|
||||
{
|
||||
(*current_cmd)+=11;
|
||||
*paranoid=0;
|
||||
options->paranoid=0;
|
||||
}
|
||||
else if(strncmp(*current_cmd,"paranoid_bf",11)==0)
|
||||
{
|
||||
(*current_cmd)+=11;
|
||||
*paranoid=2;
|
||||
options->paranoid=2;
|
||||
}
|
||||
else if(strncmp(*current_cmd,"paranoid",8)==0)
|
||||
{
|
||||
(*current_cmd)+=8;
|
||||
*paranoid=1;
|
||||
options->paranoid=1;
|
||||
}
|
||||
/* TODO: allow_partial_last_cylinder */
|
||||
/* keep_corrupted_file */
|
||||
else if(strncmp(*current_cmd,"keep_corrupted_file_no",22)==0)
|
||||
{
|
||||
(*current_cmd)+=22;
|
||||
*keep_corrupted_file=0;
|
||||
options->keep_corrupted_file=0;
|
||||
}
|
||||
else if(strncmp(*current_cmd,"keep_corrupted_file",19)==0)
|
||||
{
|
||||
(*current_cmd)+=19;
|
||||
*keep_corrupted_file=1;
|
||||
options->keep_corrupted_file=1;
|
||||
}
|
||||
/* mode_ext2 */
|
||||
else if(strncmp(*current_cmd,"mode_ext2",9)==0)
|
||||
{
|
||||
(*current_cmd)+=9;
|
||||
*mode_ext2=1;
|
||||
options->mode_ext2=1;
|
||||
}
|
||||
/* expert */
|
||||
else if(strncmp(*current_cmd,"expert",6)==0)
|
||||
{
|
||||
(*current_cmd)+=6;
|
||||
*expert=1;
|
||||
options->expert=1;
|
||||
}
|
||||
/* lowmem */
|
||||
else if(strncmp(*current_cmd,"lowmem",6)==0)
|
||||
{
|
||||
(*current_cmd)+=6;
|
||||
*lowmem=1;
|
||||
options->lowmem=1;
|
||||
}
|
||||
else
|
||||
keep_asking=0;
|
||||
|
@ -1224,18 +1208,18 @@ void interface_options_photorec(int *paranoid, int *allow_partial_last_cylinder,
|
|||
else
|
||||
{
|
||||
#ifdef HAVE_NCURSES
|
||||
interface_options_photorec_ncurses(paranoid, allow_partial_last_cylinder, keep_corrupted_file, mode_ext2, expert, lowmem);
|
||||
interface_options_photorec_ncurses(options);
|
||||
#endif
|
||||
}
|
||||
/* write new options to log file */
|
||||
log_info("New options :\n Paranoid : %s\n", *paranoid?"Yes":"No");
|
||||
log_info(" Brute force : %s\n", ((*paranoid)>1?"Yes":"No"));
|
||||
log_info("New options :\n Paranoid : %s\n", options->paranoid?"Yes":"No");
|
||||
log_info(" Brute force : %s\n", ((options->paranoid)>1?"Yes":"No"));
|
||||
log_info(" Allow partial last cylinder : %s\n Keep corrupted files : %s\n ext2/ext3 mode : %s\n Expert mode : %s\n Low memory : %s\n",
|
||||
*allow_partial_last_cylinder?"Yes":"No",
|
||||
*keep_corrupted_file?"Yes":"No",
|
||||
*mode_ext2?"Yes":"No",
|
||||
*expert?"Yes":"No",
|
||||
*lowmem?"Yes":"No");
|
||||
options->allow_partial_last_cylinder?"Yes":"No",
|
||||
options->keep_corrupted_file?"Yes":"No",
|
||||
options->mode_ext2?"Yes":"No",
|
||||
options->expert?"Yes":"No",
|
||||
options->lowmem?"Yes":"No");
|
||||
}
|
||||
|
||||
#ifdef HAVE_NCURSES
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
int photorec(disk_t *disk_car, partition_t *partition, const int verbose, const int paranoid, char *recup_dir, const int keep_corrupted_file, const int interface, file_enable_t *file_enable, const unsigned int mode_ext2, char **current_cmd, alloc_data_t *list_search_space, unsigned int blocksize, const unsigned int expert, const unsigned int lowmem, const unsigned int carve_free_space_only);
|
||||
int photorec(disk_t *disk_car, partition_t *partition, const struct ph_options *options, char *recup_dir, const int interface, file_enable_t *file_enable, char **current_cmd, alloc_data_t *list_search_space, unsigned int blocksize, const unsigned int carve_free_space_only);
|
||||
void interface_file_select(file_enable_t *files_enable, char**current_cmd);
|
||||
void interface_options_photorec(int *paranoid, int *allow_partial_last_cylinder, int *keep_corrupted_file, unsigned int *mode_ext2, unsigned int *expert, unsigned int *lowmem, char**current_cmd);
|
||||
void interface_options_photorec(struct ph_options *options, char**current_cmd);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* closing brace for extern "C" */
|
||||
|
|
|
@ -74,19 +74,13 @@ static int spacerange_cmp(const struct td_list_head *a, const struct td_list_hea
|
|||
#define INTER_SELECT (LINES-2-7-1)
|
||||
#endif
|
||||
|
||||
void menu_photorec(disk_t *disk_car, const int verbose, const char *recup_dir, file_enable_t *file_enable, char **current_cmd, alloc_data_t*list_search_space)
|
||||
void menu_photorec(disk_t *disk_car, struct ph_options *options, const char *recup_dir, file_enable_t *file_enable, char **current_cmd, alloc_data_t*list_search_space)
|
||||
{
|
||||
int insert_error=0;
|
||||
list_part_t *list_part;
|
||||
list_part_t *current_element;
|
||||
int allow_partial_last_cylinder=0;
|
||||
int paranoid=1;
|
||||
int keep_corrupted_file=0;
|
||||
unsigned int current_element_num;
|
||||
unsigned int mode_ext2=0;
|
||||
unsigned int blocksize=0;
|
||||
unsigned int expert=0;
|
||||
unsigned int lowmem=0;
|
||||
unsigned int carve_free_space_only=0;
|
||||
int done=0;
|
||||
int mode_init_space=(td_list_empty(&list_search_space->list)?INIT_SPACE_WHOLE:INIT_SPACE_PREINIT);
|
||||
|
@ -104,7 +98,7 @@ void menu_photorec(disk_t *disk_car, const int verbose, const char *recup_dir, f
|
|||
{0,NULL,NULL}
|
||||
};
|
||||
#endif
|
||||
list_part=disk_car->arch->read_part(disk_car,verbose,0);
|
||||
list_part=disk_car->arch->read_part(disk_car,options->verbose,0);
|
||||
{
|
||||
partition_t *partition_wd;
|
||||
partition_wd=new_whole_disk(disk_car);
|
||||
|
@ -191,19 +185,18 @@ void menu_photorec(disk_t *disk_car, const int verbose, const char *recup_dir, f
|
|||
{
|
||||
blocksize=remove_used_space(disk_car, partition, list_search_space);
|
||||
}
|
||||
photorec(disk_car, partition, verbose, paranoid, res, keep_corrupted_file,1,file_enable,mode_ext2,current_cmd,list_search_space,blocksize,expert, lowmem, carve_free_space_only);
|
||||
photorec(disk_car, partition, options, res, 1, file_enable, current_cmd, list_search_space, blocksize, carve_free_space_only);
|
||||
}
|
||||
if(res!=recup_dir)
|
||||
free(res);
|
||||
}
|
||||
else if(strncmp(*current_cmd,"options",7)==0)
|
||||
{
|
||||
int old_allow_partial_last_cylinder=allow_partial_last_cylinder;
|
||||
const int old_allow_partial_last_cylinder=options->allow_partial_last_cylinder;
|
||||
(*current_cmd)+=7;
|
||||
interface_options_photorec(¶noid, &allow_partial_last_cylinder,
|
||||
&keep_corrupted_file, &mode_ext2, &expert, &lowmem, current_cmd);
|
||||
if(old_allow_partial_last_cylinder!=allow_partial_last_cylinder)
|
||||
hd_update_geometry(disk_car,allow_partial_last_cylinder,verbose);
|
||||
interface_options_photorec(options, current_cmd);
|
||||
if(old_allow_partial_last_cylinder!=options->allow_partial_last_cylinder)
|
||||
hd_update_geometry(disk_car, options->allow_partial_last_cylinder, options->verbose);
|
||||
}
|
||||
else if(strncmp(*current_cmd,"fileopt",7)==0)
|
||||
{
|
||||
|
@ -240,7 +233,7 @@ void menu_photorec(disk_t *disk_car, const int verbose, const char *recup_dir, f
|
|||
{
|
||||
unsigned int groupnr;
|
||||
(*current_cmd)+=11;
|
||||
mode_ext2=1;
|
||||
options->mode_ext2=1;
|
||||
groupnr=atoi(*current_cmd);
|
||||
while(*current_cmd[0]!=',' && *current_cmd[0]!='\0')
|
||||
(*current_cmd)++;
|
||||
|
@ -262,7 +255,7 @@ void menu_photorec(disk_t *disk_car, const int verbose, const char *recup_dir, f
|
|||
{
|
||||
unsigned int inodenr;
|
||||
(*current_cmd)+=11;
|
||||
mode_ext2=1;
|
||||
options->mode_ext2=1;
|
||||
inodenr=atoi(*current_cmd);
|
||||
while(*current_cmd[0]!=',' && *current_cmd[0]!='\0')
|
||||
(*current_cmd)++;
|
||||
|
@ -333,7 +326,7 @@ void menu_photorec(disk_t *disk_car, const int verbose, const char *recup_dir, f
|
|||
if(element!=NULL)
|
||||
wprintw(stdscr, "Next");
|
||||
command = wmenuSelect(stdscr, INTER_SELECT_Y+1, INTER_SELECT_Y, INTER_SELECT_X, menuMain, 8,
|
||||
(expert==0?"SOFQ":"SOFGQ"), MENU_HORIZ | MENU_BUTTON | MENU_ACCEPT_OTHERS, menu);
|
||||
(options->expert==0?"SOFQ":"SOFGQ"), MENU_HORIZ | MENU_BUTTON | MENU_ACCEPT_OTHERS, menu);
|
||||
#if defined(KEY_MOUSE) && defined(ENABLE_MOUSE)
|
||||
if(command == KEY_MOUSE)
|
||||
{
|
||||
|
@ -360,7 +353,7 @@ void menu_photorec(disk_t *disk_car, const int verbose, const char *recup_dir, f
|
|||
}
|
||||
else
|
||||
command = menu_to_command(INTER_SELECT_Y+1, INTER_SELECT_Y, INTER_SELECT_X, menuMain, 8,
|
||||
(expert==0?"SOFQ":"SOFGQ"), MENU_HORIZ | MENU_BUTTON | MENU_ACCEPT_OTHERS, event.y, event.x);
|
||||
(options->expert==0?"SOFQ":"SOFGQ"), MENU_HORIZ | MENU_BUTTON | MENU_ACCEPT_OTHERS, event.y, event.x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -401,7 +394,7 @@ void menu_photorec(disk_t *disk_car, const int verbose, const char *recup_dir, f
|
|||
{
|
||||
char *res;
|
||||
partition_t *partition=current_element->part;
|
||||
ask_mode_ext2(disk_car, partition, &mode_ext2, &carve_free_space_only);
|
||||
ask_mode_ext2(disk_car, partition, &options->mode_ext2, &carve_free_space_only);
|
||||
menu=0;
|
||||
if(recup_dir!=NULL)
|
||||
res=(char *)recup_dir;
|
||||
|
@ -436,7 +429,7 @@ void menu_photorec(disk_t *disk_car, const int verbose, const char *recup_dir, f
|
|||
* To carve the whole space, need to quit and reselect the partition */
|
||||
done = 1;
|
||||
}
|
||||
photorec(disk_car, partition, verbose, paranoid, res, keep_corrupted_file,1,file_enable,mode_ext2, current_cmd, list_search_space,blocksize,expert, lowmem, carve_free_space_only);
|
||||
photorec(disk_car, partition, options, res, 1, file_enable, current_cmd, list_search_space, blocksize, carve_free_space_only);
|
||||
}
|
||||
if(res!=recup_dir)
|
||||
free(res);
|
||||
|
@ -445,11 +438,10 @@ void menu_photorec(disk_t *disk_car, const int verbose, const char *recup_dir, f
|
|||
case 'o':
|
||||
case 'O':
|
||||
{
|
||||
int old_allow_partial_last_cylinder=allow_partial_last_cylinder;
|
||||
interface_options_photorec(¶noid, &allow_partial_last_cylinder,
|
||||
&keep_corrupted_file, &mode_ext2, &expert, &lowmem, current_cmd);
|
||||
if(old_allow_partial_last_cylinder!=allow_partial_last_cylinder)
|
||||
hd_update_geometry(disk_car,allow_partial_last_cylinder,verbose);
|
||||
const int old_allow_partial_last_cylinder=options->allow_partial_last_cylinder;
|
||||
interface_options_photorec(options, current_cmd);
|
||||
if(old_allow_partial_last_cylinder!=options->allow_partial_last_cylinder)
|
||||
hd_update_geometry(disk_car, options->allow_partial_last_cylinder, options->verbose);
|
||||
menu=1;
|
||||
}
|
||||
break;
|
||||
|
@ -460,7 +452,7 @@ void menu_photorec(disk_t *disk_car, const int verbose, const char *recup_dir, f
|
|||
break;
|
||||
case 'g':
|
||||
case 'G':
|
||||
if(expert!=0)
|
||||
if(options->expert!=0)
|
||||
change_geometry(disk_car, current_cmd);
|
||||
break;
|
||||
case 'a':
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
void menu_photorec(disk_t *disk_car, const int verbose, const char *recup_dir, file_enable_t *file_enable, char **current_cmd, alloc_data_t*list_search_space);
|
||||
void menu_photorec(disk_t *disk_car, struct ph_options *options, const char *recup_dir, file_enable_t *file_enable, char **current_cmd, alloc_data_t*list_search_space);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* closing brace for extern "C" */
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "common.h"
|
||||
#include "intrf.h"
|
||||
#include "filegen.h"
|
||||
#include "photorec.h"
|
||||
#include "sessionp.h"
|
||||
#include "log.h"
|
||||
|
||||
|
@ -66,7 +67,7 @@ int session_load(char **cmd_device, char **current_cmd, alloc_data_t *list_free_
|
|||
if(!f_session)
|
||||
{
|
||||
log_info("Can't open photorec.ses file: %s\n",strerror(errno));
|
||||
session_save(NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
session_save(NULL, NULL, NULL, NULL, 0, NULL, 0);
|
||||
return -1;
|
||||
}
|
||||
if(fstat(fileno(f_session), &stat_rec)<0)
|
||||
|
@ -157,10 +158,10 @@ int session_load(char **cmd_device, char **current_cmd, alloc_data_t *list_free_
|
|||
}
|
||||
}
|
||||
|
||||
int session_save(alloc_data_t *list_free_space, disk_t *disk_car, const partition_t *partition, const file_enable_t *files_enable, const unsigned int blocksize, const unsigned int paranoid, const unsigned int keep_corrupted_file, const unsigned int mode_ext2, const unsigned int expert, const unsigned int lowmem, const unsigned int carve_free_space_only, const int verbose)
|
||||
int session_save(alloc_data_t *list_free_space, disk_t *disk, const partition_t *partition, const file_enable_t *files_enable, const unsigned int blocksize, const struct ph_options *options, const unsigned int carve_free_space_only)
|
||||
{
|
||||
FILE *f_session;
|
||||
if(verbose>1)
|
||||
if(options->verbose>1)
|
||||
{
|
||||
log_trace("session_save\n");
|
||||
}
|
||||
|
@ -170,12 +171,12 @@ int session_save(alloc_data_t *list_free_space, disk_t *disk_car, const partitio
|
|||
log_critical("Can't create photorec.ses file: %s\n",strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if(disk_car!=NULL)
|
||||
if(disk!=NULL)
|
||||
{
|
||||
struct td_list_head *free_walker = NULL;
|
||||
unsigned int i;
|
||||
fprintf(f_session,"#%u\n%s %s,%u,blocksize,%u,fileopt,",
|
||||
(unsigned int)time(NULL), disk_car->device, disk_car->arch->part_name_option, partition->order, blocksize);
|
||||
(unsigned int)time(NULL), disk->device, disk->arch->part_name_option, partition->order, blocksize);
|
||||
for(i=0;files_enable[i].file_hint!=NULL;i++)
|
||||
{
|
||||
if(files_enable[i].file_hint->extension!=NULL && files_enable[i].file_hint->extension[0]!='\0')
|
||||
|
@ -185,22 +186,22 @@ int session_save(alloc_data_t *list_free_space, disk_t *disk_car, const partitio
|
|||
}
|
||||
/* Save options */
|
||||
fprintf(f_session, "options,");
|
||||
if(paranoid==0)
|
||||
if(options->paranoid==0)
|
||||
fprintf(f_session, "paranoid_no,");
|
||||
else if(paranoid==1)
|
||||
else if(options->paranoid==1)
|
||||
fprintf(f_session, "paranoid,");
|
||||
else
|
||||
fprintf(f_session, "paranoid_bf,");
|
||||
/* TODO: allow_partial_last_cylinder ? */
|
||||
if(keep_corrupted_file>0)
|
||||
if(options->keep_corrupted_file>0)
|
||||
fprintf(f_session, "keep_corrupted_file,");
|
||||
else
|
||||
fprintf(f_session, "keep_corrupted_file_no,");
|
||||
if(mode_ext2>0)
|
||||
if(options->mode_ext2>0)
|
||||
fprintf(f_session, "mode_ext2,");
|
||||
if(expert>0)
|
||||
if(options->expert>0)
|
||||
fprintf(f_session, "expert,");
|
||||
if(lowmem>0)
|
||||
if(options->lowmem>0)
|
||||
fprintf(f_session, "lowmem,");
|
||||
/* Save options - End */
|
||||
if(carve_free_space_only>0)
|
||||
|
@ -213,8 +214,8 @@ int session_save(alloc_data_t *list_free_space, disk_t *disk_car, const partitio
|
|||
alloc_data_t *current_free_space;
|
||||
current_free_space=td_list_entry(free_walker, alloc_data_t, list);
|
||||
fprintf(f_session,"%llu-%llu\n",
|
||||
(long long unsigned)(current_free_space->start/disk_car->sector_size),
|
||||
(long long unsigned)(current_free_space->end/disk_car->sector_size));
|
||||
(long long unsigned)(current_free_space->start/disk->sector_size),
|
||||
(long long unsigned)(current_free_space->end/disk->sector_size));
|
||||
}
|
||||
}
|
||||
{ /* Reserve some space */
|
||||
|
@ -233,5 +234,3 @@ int session_save(alloc_data_t *list_free_space, disk_t *disk_car, const partitio
|
|||
fclose(f_session);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
int session_load(char **cmd_device, char **current_cmd, alloc_data_t *list_free_space);
|
||||
int session_save(alloc_data_t *list_free_space, disk_t *disk_car, const partition_t *partition, const file_enable_t *files_enable, const unsigned int blocksize, const unsigned int paranoid, const unsigned int keep_corrupted_file, const unsigned int mode_ext2, const unsigned int expert, const unsigned int lowmem, const unsigned int carve_free_space_only, const int verbose);
|
||||
int session_save(alloc_data_t *list_free_space, disk_t *disk, const partition_t *partition, const file_enable_t *files_enable, const unsigned int blocksize, const struct ph_options *options, const unsigned int carve_free_space_only);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* closing brace for extern "C" */
|
||||
|
|
Loading…
Reference in a new issue