summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2011-12-08 09:00:52 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2011-12-08 09:00:52 +0100
commit7943d695f9470e39fd2ff75c83941ec6f47f577d (patch)
tree90cb489b3ff5a00f09addb2b7a54f2e8c54203b5 /src
parent01fc5101b70cba8e095f36809488b11e361a8412 (diff)
Remove "Allow partial last cylinder" option
Diffstat (limited to 'src')
-rw-r--r--src/chgtypen.c2
-rw-r--r--src/godmode.c6
-rw-r--r--src/hdaccess.c43
-rw-r--r--src/hdaccess.h4
-rw-r--r--src/phmain.c3
-rw-r--r--src/photorec.h1
-rw-r--r--src/phrecn.c22
-rw-r--r--src/ppartsel.c6
-rw-r--r--src/sessionp.c1
-rw-r--r--src/tdiskop.c24
-rw-r--r--src/testdisk.c4
-rw-r--r--src/toptions.c28
-rw-r--r--src/toptions.h2
13 files changed, 31 insertions, 115 deletions
diff --git a/src/chgtypen.c b/src/chgtypen.c
index d5ff4d6..95bdece 100644
--- a/src/chgtypen.c
+++ b/src/chgtypen.c
@@ -437,6 +437,6 @@ int interface_partition_type(disk_t *disk_car, const int verbose, char**current_
}
log_info("%s\n",disk_car->description_short(disk_car));
log_info("Partition table type: %s\n",disk_car->arch->part_name);
- hd_update_geometry(disk_car, 0,verbose);
+ hd_update_geometry(disk_car, verbose);
return 0;
}
diff --git a/src/godmode.c b/src/godmode.c
index eff5d8b..0da8d32 100644
--- a/src/godmode.c
+++ b/src/godmode.c
@@ -389,8 +389,6 @@ static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_o
((uint64_t) disk_car->geom.heads_per_cylinder * disk_car->geom.sectors_per_head * disk_car->sector_size) + 1 ) *
((uint64_t) disk_car->geom.heads_per_cylinder * disk_car->geom.sectors_per_head * disk_car->sector_size),
disk_car->disk_real_size);
- const uint64_t max_disk_size_for_partition=td_max(disk_car->disk_size,
- (uint64_t)disk_car->geom.cylinders*disk_car->geom.heads_per_cylinder * disk_car->geom.sectors_per_head * disk_car->sector_size);
partition=partition_new(disk_car->arch);
buffer_disk=(unsigned char*)MALLOC(16*DEFAULT_SECTOR_SIZE);
buffer_disk0=(unsigned char*)MALLOC(16*DEFAULT_SECTOR_SIZE);
@@ -766,7 +764,7 @@ static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_o
/* TODO: Detect Linux md 1.0 software raid */
}
/* */
- if(pos_fin <= max_disk_size_for_partition)
+ if(pos_fin <= search_location_max)
{
{
int insert_error=0;
@@ -868,7 +866,7 @@ static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_o
partition->status=STATUS_DELETED;
if(disk_car->arch->is_part_known(partition)!=0 && partition->part_size>1 &&
partition->part_offset >= min_location &&
- partition->part_offset+partition->part_size-1 <= max_disk_size_for_partition)
+ partition->part_offset+partition->part_size-1 <= search_location_max)
{
int insert_error=0;
partition_t *new_partition=partition_new(NULL);
diff --git a/src/hdaccess.c b/src/hdaccess.c
index 19ef443..d3fd9ba 100644
--- a/src/hdaccess.c
+++ b/src/hdaccess.c
@@ -1594,7 +1594,7 @@ disk_t *file_test_availability(const char *device, const int verbose, const arch
return NULL;
}
-void hd_update_geometry(disk_t *disk, const int allow_partial_last_cylinder, const int verbose)
+void hd_update_geometry(disk_t *disk, const int verbose)
{
if(disk->autodetect!=0)
{
@@ -1609,43 +1609,6 @@ void hd_update_geometry(disk_t *disk, const int allow_partial_last_cylinder, con
}
free(buffer);
}
- if((unsigned int)(disk->geom.cylinders+1)!=0) /* Avoid to wrap */
- {
- uint64_t pos;
- CHS_t pos_CHS;
- pos_CHS.cylinder=disk->geom.cylinders-1+1;
- if(allow_partial_last_cylinder)
- {
- pos_CHS.head=0;
- pos_CHS.sector=1;
- }
- else
- {
- pos_CHS.head=disk->geom.heads_per_cylinder-1;
- pos_CHS.sector=disk->geom.sectors_per_head;
- }
- pos=CHS2offset(disk,&pos_CHS);
-#ifdef DJGPP
- if(disk->description==disk_description)
- {
- struct info_disk_struct*data=disk->data;
- data->geo_phys.cylinders=0;
- }
-#endif
- {
- unsigned char *buffer=(unsigned char *)MALLOC(disk->sector_size);
- if((unsigned)disk->pread(disk, buffer, disk->sector_size, pos) == disk->sector_size)
- {
- disk->geom.cylinders++;
- if(disk->disk_size < (uint64_t)disk->geom.cylinders * disk->geom.heads_per_cylinder * disk->geom.sectors_per_head * disk->sector_size)
- {
- disk->disk_size = (uint64_t)disk->geom.cylinders * disk->geom.heads_per_cylinder * disk->geom.sectors_per_head * disk->sector_size;
- log_info("Computes LBA from CHS for %s\n",disk->description(disk));
- }
- }
- free(buffer);
- }
- }
#ifdef DJGPP
if(disk->description==disk_description)
{
@@ -1655,7 +1618,7 @@ void hd_update_geometry(disk_t *disk, const int allow_partial_last_cylinder, con
#endif
}
-void hd_update_all_geometry(const list_disk_t * list_disk, const int allow_partial_last_cylinder, const int verbose)
+void hd_update_all_geometry(const list_disk_t * list_disk, const int verbose)
{
const list_disk_t *element_disk;
if(verbose>1)
@@ -1663,7 +1626,7 @@ void hd_update_all_geometry(const list_disk_t * list_disk, const int allow_parti
log_trace("hd_update_all_geometry\n");
}
for(element_disk=list_disk;element_disk!=NULL;element_disk=element_disk->next)
- hd_update_geometry(element_disk->disk,allow_partial_last_cylinder,verbose);
+ hd_update_geometry(element_disk->disk, verbose);
}
void init_disk(disk_t *disk)
diff --git a/src/hdaccess.h b/src/hdaccess.h
index 31851d5..f1d01bb 100644
--- a/src/hdaccess.h
+++ b/src/hdaccess.h
@@ -24,8 +24,8 @@ extern "C" {
#endif
-void hd_update_geometry(disk_t *disk_car, const int allow_partial_last_cylinder, const int verbose);
-void hd_update_all_geometry(const list_disk_t * list_disk, const int allow_partial_last_cylinder, const int verbose);
+void hd_update_geometry(disk_t *disk_car, const int verbose);
+void hd_update_all_geometry(const list_disk_t * list_disk, const int verbose);
list_disk_t *hd_parse(list_disk_t *list_disk, const int verbose, const arch_fnct_t *arch, const int testdisk_mode);
disk_t *file_test_availability(const char *device, const int verbose, const arch_fnct_t *arch, const int testdisk_mode);
void update_disk_car_fields(disk_t *disk_car);
diff --git a/src/phmain.c b/src/phmain.c
index e8d8665..9cb9dc4 100644
--- a/src/phmain.c
+++ b/src/phmain.c
@@ -113,7 +113,6 @@ int main( int argc, char **argv )
FILE *log_handle=NULL;
struct ph_options options={
.paranoid=1,
- .allow_partial_last_cylinder=0,
.keep_corrupted_file=0,
.mode_ext2=0,
.expert=0,
@@ -327,7 +326,7 @@ int main( int argc, char **argv )
/* 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, options.verbose, arch, testdisk_mode);
- hd_update_all_geometry(list_disk, 0, options.verbose);
+ hd_update_all_geometry(list_disk, options.verbose);
/* Activate the cache, even if photorec has its own */
for(element_disk=list_disk;element_disk!=NULL;element_disk=element_disk->next)
{
diff --git a/src/photorec.h b/src/photorec.h
index 217d059..db5d12a 100644
--- a/src/photorec.h
+++ b/src/photorec.h
@@ -30,7 +30,6 @@ 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;
diff --git a/src/phrecn.c b/src/phrecn.c
index 852a8a2..fd0dc74 100644
--- a/src/phrecn.c
+++ b/src/phrecn.c
@@ -1060,11 +1060,10 @@ int photorec(struct ph_param *params, const struct ph_options *options, alloc_da
#ifdef HAVE_NCURSES
static void interface_options_photorec_ncurses(struct ph_options *options)
{
- unsigned int menu = 6;
+ unsigned int menu = 5;
struct MenuItem menuOptions[]=
{
{ 'P', NULL, "Check JPG files" },
- { 'A',NULL,"" },
{ 'K',NULL,"Keep corrupted files"},
{ 'S',NULL,"Try to skip indirect block"},
{ 'E',NULL,"Provide additional controls"},
@@ -1088,13 +1087,12 @@ static void interface_options_photorec_ncurses(struct ph_options *options)
menuOptions[0].name="Paranoid : Yes (Brute force enabled)";
break;
}
- 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";
+ menuOptions[1].name=options->keep_corrupted_file?"Keep corrupted files : Yes":"Keep corrupted files : No";
+ menuOptions[2].name=options->mode_ext2?"ext2/ext3 mode: Yes":"ext2/ext3 mode : No";
+ menuOptions[3].name=options->expert?"Expert mode : Yes":"Expert mode : No";
+ menuOptions[4].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);
+ car=wmenuSelect_ext(stdscr, 23, INTER_OPTION_Y, INTER_OPTION_X, menuOptions, 0, "PKELQ", MENU_VERT|MENU_VERT_ARROW2VALID, &menu,&real_key);
switch(car)
{
case 'p':
@@ -1104,10 +1102,6 @@ static void interface_options_photorec_ncurses(struct ph_options *options)
else
options->paranoid=0;
break;
- case 'a':
- case 'A':
- options->allow_partial_last_cylinder=!options->allow_partial_last_cylinder;
- break;
case 'k':
case 'K':
options->keep_corrupted_file=!options->keep_corrupted_file;
@@ -1158,7 +1152,6 @@ void interface_options_photorec(struct ph_options *options, char **current_cmd)
(*current_cmd)+=8;
options->paranoid=1;
}
- /* TODO: allow_partial_last_cylinder */
/* keep_corrupted_file */
else if(strncmp(*current_cmd,"keep_corrupted_file_no",22)==0)
{
@@ -1201,8 +1194,7 @@ void interface_options_photorec(struct ph_options *options, char **current_cmd)
/* write new options to log file */
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",
- options->allow_partial_last_cylinder?"Yes":"No",
+ log_info(" Keep corrupted files : %s\n ext2/ext3 mode : %s\n Expert mode : %s\n Low memory : %s\n",
options->keep_corrupted_file?"Yes":"No",
options->mode_ext2?"Yes":"No",
options->expert?"Yes":"No",
diff --git a/src/ppartsel.c b/src/ppartsel.c
index d2f7332..eb914af 100644
--- a/src/ppartsel.c
+++ b/src/ppartsel.c
@@ -186,11 +186,8 @@ void menu_photorec(struct ph_param *params, struct ph_options *options, alloc_da
}
else if(strncmp(params->cmd_run,"options",7)==0)
{
- const int old_allow_partial_last_cylinder=options->allow_partial_last_cylinder;
params->cmd_run+=7;
interface_options_photorec(options, &params->cmd_run);
- if(old_allow_partial_last_cylinder!=options->allow_partial_last_cylinder)
- hd_update_geometry(params->disk, options->allow_partial_last_cylinder, options->verbose);
}
else if(strncmp(params->cmd_run,"fileopt",7)==0)
{
@@ -426,10 +423,7 @@ void menu_photorec(struct ph_param *params, struct ph_options *options, alloc_da
case 'o':
case 'O':
{
- const int old_allow_partial_last_cylinder=options->allow_partial_last_cylinder;
interface_options_photorec(options, &params->cmd_run);
- if(old_allow_partial_last_cylinder!=options->allow_partial_last_cylinder)
- hd_update_geometry(params->disk, options->allow_partial_last_cylinder, options->verbose);
menu=1;
}
break;
diff --git a/src/sessionp.c b/src/sessionp.c
index 69ae8a8..4d8f75e 100644
--- a/src/sessionp.c
+++ b/src/sessionp.c
@@ -193,7 +193,6 @@ int session_save(alloc_data_t *list_free_space, struct ph_param *params, const
fprintf(f_session, "paranoid,");
else
fprintf(f_session, "paranoid_bf,");
- /* TODO: allow_partial_last_cylinder ? */
if(options->keep_corrupted_file>0)
fprintf(f_session, "keep_corrupted_file,");
else
diff --git a/src/tdiskop.c b/src/tdiskop.c
index 9919177..d17e8b9 100644
--- a/src/tdiskop.c
+++ b/src/tdiskop.c
@@ -55,7 +55,6 @@ extern const arch_fnct_t arch_none;
static int menu_disk_cli(disk_t *disk_car, const int verbose,int dump_ind, const int saveheader, char **current_cmd)
{
int align=2;
- int allow_partial_last_cylinder=0;
int ask_part_order=0;
unsigned int expert=0;
char options[16];
@@ -73,7 +72,6 @@ static int menu_disk_cli(disk_t *disk_car, const int verbose,int dump_ind, const
list_part=interface_analyse(disk_car, verbose, saveheader, current_cmd);
if(disk_car->arch==&arch_i386)
{
- const int old_allow_partial_last_cylinder=allow_partial_last_cylinder;
const list_part_t *element;
for(element=list_part;element!=NULL;element=element->next)
{
@@ -87,11 +85,6 @@ static int menu_disk_cli(disk_t *disk_car, const int verbose,int dump_ind, const
(*current_cmd)+=10;
search_vista_part=1;
}
- if(search_vista_part==1)
- allow_partial_last_cylinder=1;
- if(old_allow_partial_last_cylinder!=allow_partial_last_cylinder)
- hd_update_geometry(disk_car,allow_partial_last_cylinder,verbose);
- log_info("Allow partial last cylinder : %s\n", allow_partial_last_cylinder>0?"Yes":"No");
log_info("search_vista_part: %d\n", search_vista_part);
}
interface_recovery(disk_car, list_part, verbose, dump_ind, align, ask_part_order, expert, search_vista_part, current_cmd);
@@ -110,11 +103,8 @@ static int menu_disk_cli(disk_t *disk_car, const int verbose,int dump_ind, const
}
else if(strncmp(*current_cmd,"options,",8)==0)
{
- const int old_allow_partial_last_cylinder=allow_partial_last_cylinder;
(*current_cmd)+=8;
- interface_options(&dump_ind, &align,&allow_partial_last_cylinder,&expert,current_cmd);
- if(old_allow_partial_last_cylinder!=allow_partial_last_cylinder)
- hd_update_geometry(disk_car,allow_partial_last_cylinder,verbose);
+ interface_options(&dump_ind, &align, &expert,current_cmd);
}
else if(strncmp(*current_cmd,"delete",6)==0)
{
@@ -137,7 +127,6 @@ static int menu_disk_cli(disk_t *disk_car, const int verbose,int dump_ind, const
static int menu_disk_ncurses(disk_t *disk_car, const int verbose,int dump_ind, const int saveheader, char **current_cmd)
{
int align=2;
- int allow_partial_last_cylinder=0;
int ask_part_order=0;
int command;
int real_key;
@@ -183,7 +172,6 @@ static int menu_disk_ncurses(disk_t *disk_car, const int verbose,int dump_ind, c
list_part=interface_analyse(disk_car, verbose, saveheader, current_cmd);
if(disk_car->arch==&arch_i386)
{
- const int old_allow_partial_last_cylinder=allow_partial_last_cylinder;
const list_part_t *element;
for(element=list_part;element!=NULL;element=element->next)
{
@@ -196,11 +184,6 @@ static int menu_disk_ncurses(disk_t *disk_car, const int verbose,int dump_ind, c
if(ask_confirmation("Should TestDisk search for partition created under Vista or later ? [Y/N] (answer Yes if unsure)")!=0)
search_vista_part=1;
}
- if(search_vista_part==1)
- allow_partial_last_cylinder=1;
- if(old_allow_partial_last_cylinder!=allow_partial_last_cylinder)
- hd_update_geometry(disk_car,allow_partial_last_cylinder,verbose);
- log_info("Allow partial last cylinder : %s\n", allow_partial_last_cylinder>0?"Yes":"No");
log_info("search_vista_part: %d\n", search_vista_part);
}
interface_recovery(disk_car, list_part, verbose, dump_ind, align, ask_part_order, expert, search_vista_part, current_cmd);
@@ -222,10 +205,7 @@ static int menu_disk_ncurses(disk_t *disk_car, const int verbose,int dump_ind, c
case 'o':
case 'O':
{
- const int old_allow_partial_last_cylinder=allow_partial_last_cylinder;
- interface_options(&dump_ind, &align,&allow_partial_last_cylinder,&expert, current_cmd);
- if(old_allow_partial_last_cylinder!=allow_partial_last_cylinder)
- hd_update_geometry(disk_car,allow_partial_last_cylinder,verbose);
+ interface_options(&dump_ind, &align, &expert, current_cmd);
}
break;
case 't':
diff --git a/src/testdisk.c b/src/testdisk.c
index 7acf8d9..c5feca2 100644
--- a/src/testdisk.c
+++ b/src/testdisk.c
@@ -270,7 +270,7 @@ int main( int argc, char **argv )
}
#endif
if(safe==0)
- hd_update_all_geometry(list_disk,0,verbose);
+ hd_update_all_geometry(list_disk, verbose);
for(element_disk=list_disk;element_disk!=NULL;element_disk=element_disk->next)
{
printf("%s, sector size=%u\n",element_disk->disk->description(element_disk->disk),element_disk->disk->sector_size);
@@ -379,7 +379,7 @@ int main( int argc, char **argv )
wrefresh(stdscr);
#endif
if(safe==0)
- hd_update_all_geometry(list_disk,0,verbose);
+ hd_update_all_geometry(list_disk, verbose);
/* save disk parameters to rapport */
log_info("Hard disk list\n");
for(element_disk=list_disk;element_disk!=NULL;element_disk=element_disk->next)
diff --git a/src/toptions.c b/src/toptions.c
index 00de51f..1864880 100644
--- a/src/toptions.c
+++ b/src/toptions.c
@@ -34,9 +34,9 @@
#include "toptions.h"
#ifdef HAVE_NCURSES
-static void interface_options_ncurses(int *dump_ind, int *align, int *allow_partial_last_cylinder, unsigned int *expert)
+static void interface_options_ncurses(int *dump_ind, int *align, unsigned int *expert)
{
- unsigned int menu = 4;
+ unsigned int menu = 3;
/* ncurses interface */
while (1)
{
@@ -46,7 +46,6 @@ static void interface_options_ncurses(int *dump_ind, int *align, int *allow_part
{
{ 'E',NULL,"Expert mode adds some functionalities"},
{ 'C',NULL,"Partitions are aligned on cylinder/head boundaries" },
- { 'A',NULL,""},
{ 'D',NULL,"Dump essential sectors" },
{ 'Q',"[ Ok ]","Done with changing options"},
{ 0, NULL, NULL }
@@ -64,10 +63,9 @@ static void interface_options_ncurses(int *dump_ind, int *align, int *allow_part
menuOptions[1].name="Cylinder boundary : Yes";
break;
}
- menuOptions[2].name=*allow_partial_last_cylinder?"Allow partial last cylinder : Yes":"Allow partial last cylinder : No";
- menuOptions[3].name=*dump_ind?"Dump : Yes":"Dump : No";
+ menuOptions[2].name=*dump_ind?"Dump : Yes":"Dump : No";
aff_copy(stdscr);
- car=wmenuSelect_ext(stdscr, 23, INTER_OPTION_Y, INTER_OPTION_X, menuOptions, 0, "ECADQ", MENU_VERT|MENU_VERT_ARROW2VALID, &menu,&real_key);
+ car=wmenuSelect_ext(stdscr, 23, INTER_OPTION_Y, INTER_OPTION_X, menuOptions, 0, "ECDQ", MENU_VERT|MENU_VERT_ARROW2VALID, &menu,&real_key);
switch(car)
{
case 'd':
@@ -81,10 +79,6 @@ static void interface_options_ncurses(int *dump_ind, int *align, int *allow_part
else
*align=0;
break;
- case 'a':
- case 'A':
- *allow_partial_last_cylinder=!*allow_partial_last_cylinder;
- break;
case 'e':
case 'E':
*expert=!*expert;
@@ -98,12 +92,12 @@ static void interface_options_ncurses(int *dump_ind, int *align, int *allow_part
}
#endif
-void interface_options(int *dump_ind, int *align, int *allow_partial_last_cylinder, unsigned int *expert, char**current_cmd)
+void interface_options(int *dump_ind, int *align, unsigned int *expert, char**current_cmd)
{
if(*current_cmd==NULL)
{
#ifdef HAVE_NCURSES
- interface_options_ncurses(dump_ind, align, allow_partial_last_cylinder, expert);
+ interface_options_ncurses(dump_ind, align, expert);
#endif
}
/* write new options to log file */
@@ -111,16 +105,14 @@ void interface_options(int *dump_ind, int *align, int *allow_partial_last_cylind
switch(*align)
{
case 0:
- log_info("Cylinder boundary : No");
+ log_info("Cylinder boundary : No\n");
break;
case 1:
- log_info("Cylinder boundary : Head boundary only");
+ log_info("Cylinder boundary : Head boundary only\n");
break;
case 2:
- log_info("Cylinder boundary : Yes");
+ log_info("Cylinder boundary : Yes\n");
break;
}
- log_info("\n Allow partial last cylinder : %s\n Expert mode : %s\n",
- *allow_partial_last_cylinder?"Yes":"No",
- *expert?"Yes":"No");
+ log_info(" Expert mode : %s\n", *expert?"Yes":"No");
}
diff --git a/src/toptions.h b/src/toptions.h
index b043b44..6c87492 100644
--- a/src/toptions.h
+++ b/src/toptions.h
@@ -23,7 +23,7 @@
extern "C" {
#endif
-void interface_options(int *dump_ind, int *align, int *allow_partial_last_cylinder, unsigned int *expert, char**current_cmd);
+void interface_options(int *dump_ind, int *align, unsigned int *expert, char**current_cmd);
#ifdef __cplusplus
} /* closing brace for extern "C" */