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

Function change_geometry_ncurses

src/geometryn.c:50–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48#define MAX_HEADS 255u
49
50int change_geometry_ncurses(disk_t *disk_car)
51{
52 int done = 0;
53 int default_option=4;
54 int cyl_modified=0;
55 int geo_modified=0;
56 while (done==0)
57 {
58 char def[128];
59 char response[128];
60 long int tmp_val=0;
61 int command;
62 static const struct MenuItem menuGeometry[]=
63 {
64 { 'c', "Cylinders", "Change cylinder geometry" },
65 { 'h', "Heads", "Change head geometry" },
66 { 's', "Sectors", "Change sector geometry" },
67 { 'n', "Sector Size", "Change sector size (WARNING: VERY DANGEROUS!)" },
68 { 'q', "Ok", "Done with changing geometry" },
69 { 0, NULL, NULL }
70 };
71 aff_copy(stdscr);
72 wmove(stdscr,5,0);
73 wprintw(stdscr,"%s, sector size=%u\n",disk_car->description(disk_car),disk_car->sector_size);
74 wmove(stdscr,7,0);
75 wprintw(stdscr,"Because these numbers change the way that TestDisk looks for partitions");
76 wmove(stdscr,8,0);
77 wprintw(stdscr,"and calculates their sizes, it's important to have the correct disk geometry.");
78 wmove(stdscr,9,0);
79 wprintw(stdscr,"PC partitioning programs often make partitions end on cylinder boundaries.");
80 wmove(stdscr,11,0);
81 wprintw(stdscr,"A partition's CHS values are based on disk translations which make them");
82 wmove(stdscr,12,0);
83 wprintw(stdscr,"different than its physical geometry. The most common CHS head values");
84 wmove(stdscr,13,0);
85 wprintw(stdscr,"are: 255, 240 and sometimes 16.");
86 wmove(stdscr,INTER_GEOM_Y, INTER_GEOM_X);
87 wclrtoeol(stdscr);
88 wrefresh(stdscr);
89 command=wmenuSimple(stdscr,menuGeometry, default_option);
90 switch (command) {
91 case 'c':
92 case 'C':
93 {
94 sprintf(def, "%lu", disk_car->geom.cylinders);
95 mvwaddstr(stdscr,INTER_GEOM_Y, INTER_GEOM_X, "Enter the number of cylinders: ");
96 wclrtoeol(stdscr);
97 if (get_string(stdscr, response, sizeof(response), def) > 0) {
98 tmp_val = atol(response);
99 if (tmp_val > 0) {
100 disk_car->geom.cylinders = tmp_val;
101 cyl_modified=1;
102 if(geo_modified==0)
103 geo_modified=1;
104 } else
105 wprintw(stdscr,"Illegal cylinders value");
106 }
107 }

Callers 2

menu_photorecFunction · 0.85
menu_disk_ncursesFunction · 0.85

Calls 6

wmenuSimpleFunction · 0.85
get_stringFunction · 0.85
change_sector_sizeFunction · 0.85
autoset_unitFunction · 0.85
aff_copyFunction · 0.70

Tested by

no test coverage detected