List the number of sectors when head per cylinder and sector per head are 1

TestDisk: Display the sector size
This commit is contained in:
Christophe Grenier 2012-08-09 13:03:40 +02:00
parent a904c5a049
commit 5c5f3c6845
2 changed files with 36 additions and 23 deletions

View file

@ -149,8 +149,6 @@ struct info_file_struct
};
static void autoset_geometry(disk_t * disk_car, const unsigned char *buffer, const int verbose);
static const char *file_description(disk_t *disk_car);
static const char *file_description_short(disk_t *disk_car);
static int file_clean(disk_t *disk_car);
static int file_pread(disk_t *disk_car, void *buf, const unsigned int count, const uint64_t offset);
static void *file_pread_fast(disk_t *disk, void *buf, const unsigned int count, const uint64_t offset);
@ -1057,16 +1055,24 @@ static uint64_t compute_device_size(const int hd_h, const char *device, const in
}
#endif
static const char *file_description(disk_t *disk_car)
static const char *file_description(disk_t *disk)
{
const struct info_file_struct *data=(const struct info_file_struct *)disk_car->data;
const struct info_file_struct *data=(const struct info_file_struct *)disk->data;
char buffer_disk_size[100];
size_to_unit(disk_car->disk_size, buffer_disk_size);
snprintf(disk_car->description_txt, sizeof(disk_car->description_txt),"Disk %s - %s - CHS %lu %u %u%s",
disk_car->device, buffer_disk_size,
disk_car->geom.cylinders, disk_car->geom.heads_per_cylinder, disk_car->geom.sectors_per_head,
((data->mode&O_RDWR)==O_RDWR?"":" (RO)"));
return disk_car->description_txt;
size_to_unit(disk->disk_size, buffer_disk_size);
if(disk->geom.heads_per_cylinder == 1 && disk->geom.sectors_per_head == 1)
snprintf(disk->description_txt, sizeof(disk->description_txt),
"Disk %s - %s - %lu sectors%s",
disk->device, buffer_disk_size,
disk->geom.cylinders,
((data->mode&O_RDWR)==O_RDWR?"":" (RO)"));
else
snprintf(disk->description_txt, sizeof(disk->description_txt),
"Disk %s - %s - CHS %lu %u %u%s",
disk->device, buffer_disk_size,
disk->geom.cylinders, disk->geom.heads_per_cylinder, disk->geom.sectors_per_head,
((data->mode&O_RDWR)==O_RDWR?"":" (RO)"));
return disk->description_txt;
}
static const char *file_description_short(disk_t *disk_car)

View file

@ -49,7 +49,7 @@
extern const arch_fnct_t arch_i386;
extern const arch_fnct_t arch_none;
#define INTER_DISK_X 0
#define INTER_DISK_Y 7
#define INTER_DISK_Y 8
static int menu_disk_cli(disk_t *disk_car, const int verbose,int dump_ind, const int saveheader, char **current_cmd)
@ -106,7 +106,7 @@ static int menu_disk_cli(disk_t *disk_car, const int verbose,int dump_ind, const
}
#ifdef HAVE_NCURSES
static int menu_disk_ncurses(disk_t *disk_car, const int verbose,int dump_ind, const int saveheader, char **current_cmd)
static int menu_disk_ncurses(disk_t *disk, const int verbose,int dump_ind, const int saveheader, char **current_cmd)
{
int align=1;
int ask_part_order=0;
@ -126,17 +126,24 @@ static int menu_disk_ncurses(disk_t *disk_car, const int verbose,int dump_ind, c
{'E',"Editor","Basic disk editor"},
{0,NULL,NULL}
};
unsigned int menu=(disk_car->arch == &arch_none ? 1 : 0);
unsigned int menu=(disk->arch == &arch_none ? 1 : 0);
strcpy(options, "AGOPTQ");
if(disk_car->arch->write_MBR_code!=NULL)
if(disk->arch->write_MBR_code!=NULL)
strcat(options,"C");
if(disk_car->arch->erase_list_part!=NULL)
if(disk->arch->erase_list_part!=NULL)
strcat(options,"D");
while(1)
{
aff_copy(stdscr);
wmove(stdscr,5,0);
wprintw(stdscr,"%s\n",disk_car->description(disk_car));
wprintw(stdscr, "%s\n", disk->description_short(disk));
wmove(stdscr,6,0);
if(disk->geom.heads_per_cylinder == 1 && disk->geom.sectors_per_head == 1)
wprintw(stdscr, " %lu sectors", disk->geom.cylinders);
else
wprintw(stdscr, " CHS %lu %u %u",
disk->geom.cylinders, disk->geom.heads_per_cylinder, disk->geom.sectors_per_head);
wprintw(stdscr, " - sector size=%u", disk->sector_size);
wmove(stdscr,20,0);
wprintw(stdscr,"Note: Correct disk geometry is required for a successful recovery. 'Analyse'");
wmove(stdscr,21,0);
@ -150,22 +157,22 @@ static int menu_disk_ncurses(disk_t *disk_car, const int verbose,int dump_ind, c
case 'A':
{
list_part_t *list_part;
list_part=interface_analyse(disk_car, verbose, saveheader, current_cmd);
interface_recovery(disk_car, list_part, verbose, dump_ind, align, ask_part_order, expert, current_cmd);
list_part=interface_analyse(disk, verbose, saveheader, current_cmd);
interface_recovery(disk, list_part, verbose, dump_ind, align, ask_part_order, expert, current_cmd);
part_free_list(list_part);
}
break;
case 'd':
case 'D':
write_clean_table(disk_car);
write_clean_table(disk);
break;
case 'c':
case 'C':
write_MBR_code(disk_car);
write_MBR_code(disk);
break;
case 'g':
case 'G':
change_geometry(disk_car, current_cmd);
change_geometry(disk, current_cmd);
break;
case 'o':
case 'O':
@ -175,11 +182,11 @@ static int menu_disk_ncurses(disk_t *disk_car, const int verbose,int dump_ind, c
break;
case 't':
case 'T':
interface_adv(disk_car, verbose, dump_ind, expert, current_cmd);
interface_adv(disk, verbose, dump_ind, expert, current_cmd);
break;
case 'e':
case 'E':
interface_editor(disk_car);
interface_editor(disk);
break;
case 'q':
case 'Q':