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

Function change_geometry_cli

src/geometry.c:74–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74int change_geometry_cli(disk_t *disk_car, char ** current_cmd)
75{
76 int done = 0;
77 int tmp_val=0;
78 int cyl_modified=0;
79 int geo_modified=0;
80 if(*current_cmd==NULL)
81 return 0;
82#ifndef DISABLED_FOR_FRAMAC
83 log_info("Current geometry\n%s sector_size=%u\n", disk_car->description(disk_car), disk_car->sector_size);
84#endif
85 /*@ loop invariant valid_read_string(*current_cmd); */
86 while (done==0)
87 {
88 skip_comma_in_command(current_cmd);
89 if(check_command(current_cmd,"C,",2)==0)
90 {
91 tmp_val = get_int_from_command(current_cmd);
92 if (tmp_val > 0)
93 {
94 disk_car->geom.cylinders = tmp_val;
95 cyl_modified=1;
96 if(geo_modified==0)
97 geo_modified=1;
98 }
99#ifndef DISABLED_FOR_FRAMAC
100 else
101 log_error("Illegal cylinders value\n");
102#endif
103 }
104 else if(check_command(current_cmd,"H,",2)==0)
105 {
106 tmp_val = get_int_from_command(current_cmd);
107 if (tmp_val > 0 && tmp_val <= MAX_HEADS)
108 {
109 disk_car->geom.heads_per_cylinder = tmp_val;
110 if(geo_modified==0)
111 geo_modified=1;
112 if(cyl_modified==0)
113 set_cylinders_from_size_up(disk_car);
114 }
115#ifndef DISABLED_FOR_FRAMAC
116 else
117 log_error("Illegal heads value\n");
118#endif
119 }
120 else if(check_command(current_cmd,"S,",2)==0)
121 {
122 tmp_val = get_int_from_command(current_cmd);
123 /* SUN partition can have more than 63 sectors */
124 if (tmp_val > 0) {
125 disk_car->geom.sectors_per_head = tmp_val;
126 if(geo_modified==0)
127 geo_modified=1;
128 if(cyl_modified==0)
129 set_cylinders_from_size_up(disk_car);
130 }
131#ifndef DISABLED_FOR_FRAMAC

Callers 2

menu_photorec_cliFunction · 0.85
menu_disk_cliFunction · 0.85

Calls 6

skip_comma_in_commandFunction · 0.85
check_commandFunction · 0.85
get_int_from_commandFunction · 0.85
change_sector_sizeFunction · 0.85
autoset_unitFunction · 0.85

Tested by

no test coverage detected