MCPcopy Create free account
hub / github.com/cgsecurity/testdisk / menu_disk_ncurses

Function menu_disk_ncurses

src/tdiskop.c:98–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96
97#ifdef HAVE_NCURSES
98static int menu_disk_ncurses(disk_t *disk, const int verbose,int dump_ind, const int saveheader, char **current_cmd)
99{
100 int align=1;
101 int ask_part_order=0;
102 unsigned int expert=0;
103 char options[16];
104 static const struct MenuItem menuMain[]=
105 {
106 {'A',"Analyse","Analyse current partition structure and search for lost partitions"},
107 {'T',"Advanced","Filesystem Utils"},
108 {'G',"Geometry", "Change disk geometry" },
109 {'O',"Options","Modify options"},
110 {'C',"MBR Code","Write TestDisk MBR code to first sector"},
111 {'D',"Delete","Delete all data in the partition table"},
112 {'Q',"Quit","Return to disk selection"},
113 {'E',"Editor","Basic disk editor"},
114 {0,NULL,NULL}
115 };
116 unsigned int menu=(disk->arch == &arch_none ? 1 : 0);
117 if(disk->arch == &arch_none)
118 {
119 interface_adv(disk, verbose, dump_ind, expert, current_cmd);
120 }
121 strcpy(options, "AGOPTQ");
122 if(disk->arch->write_MBR_code!=NULL)
123 strcat(options,"C");
124 if(disk->arch->erase_list_part!=NULL)
125 strcat(options,"D");
126 while(1)
127 {
128 int real_key;
129 int command;
130 aff_copy(stdscr);
131 wmove(stdscr,5,0);
132 wprintw(stdscr, "%s\n", disk->description_short(disk));
133 wmove(stdscr,6,0);
134 if(disk->geom.heads_per_cylinder == 1 && disk->geom.sectors_per_head == 1)
135 wprintw(stdscr, " %llu sectors", (long long unsigned)(disk->disk_size / disk->sector_size));
136 else
137 wprintw(stdscr, " CHS %lu %u %u",
138 disk->geom.cylinders, disk->geom.heads_per_cylinder, disk->geom.sectors_per_head);
139 wprintw(stdscr, " - sector size=%u", disk->sector_size);
140 wmove(stdscr,20,0);
141 wprintw(stdscr,"Note: Correct disk geometry is required for a successful recovery. 'Analyse'");
142 wmove(stdscr,21,0);
143 wprintw(stdscr,"process may give some warnings if it thinks the logical geometry is mismatched.");
144 command = wmenuSelect_ext(stdscr, 23, INTER_DISK_Y, INTER_DISK_X, menuMain, 10,
145 options, MENU_VERT | MENU_VERT_WARN | MENU_BUTTON | MENU_ACCEPT_OTHERS, &menu,&real_key);
146 /* e for editor will be added when the editor will be better */
147 switch(command)
148 {
149 case 'a':
150 case 'A':
151 {
152 list_part_t *list_part;
153 list_part=interface_analyse(disk, verbose, saveheader, current_cmd);
154 interface_recovery(disk, list_part, verbose, dump_ind, align, ask_part_order, expert, current_cmd);
155 part_free_list(list_part);

Callers 1

menu_diskFunction · 0.85

Calls 11

interface_advFunction · 0.85
wmenuSelect_extFunction · 0.85
interface_analyseFunction · 0.85
interface_recoveryFunction · 0.85
part_free_listFunction · 0.85
write_clean_tableFunction · 0.85
write_MBR_codeFunction · 0.85
change_geometry_ncursesFunction · 0.85
interface_optionsFunction · 0.85
interface_editorFunction · 0.85
aff_copyFunction · 0.70

Tested by

no test coverage detected