| 127 | } |
| 128 | |
| 129 | static void interface_editor_location(const disk_t *disk, uint64_t *lba) |
| 130 | { |
| 131 | const struct MenuItem menuGeometry[]= |
| 132 | { |
| 133 | { 'c', "Cylinders", "Change cylinder" }, |
| 134 | { 'h', "Heads", "Change head" }, |
| 135 | { 's', "Sectors", "Change sector" }, |
| 136 | { 'l', "Logical Sectors", "Change logical sector" }, |
| 137 | { 'd', "Done", "Done with changing" }, |
| 138 | { 0, NULL, NULL } |
| 139 | }; |
| 140 | int default_option=4; |
| 141 | while (1) |
| 142 | { |
| 143 | CHS_t location; |
| 144 | char def[128]; |
| 145 | char response[128]; |
| 146 | unsigned long int tmp_val; |
| 147 | int command; |
| 148 | wmove(stdscr,5,0); |
| 149 | wclrtoeol(stdscr); |
| 150 | wprintw(stdscr,"%lu ", (unsigned long)(*lba/disk->sector_size)); |
| 151 | aff_LBA2CHS(disk, *lba / disk->sector_size); |
| 152 | offset2CHS(disk, *lba, &location); |
| 153 | wmove(stdscr,INTER_GEOM_Y, INTER_GEOM_X); |
| 154 | wclrtoeol(stdscr); |
| 155 | wrefresh(stdscr); |
| 156 | command=wmenuSimple(stdscr, menuGeometry, default_option); |
| 157 | switch (command) { |
| 158 | case 'c': |
| 159 | case 'C': |
| 160 | sprintf(def, "%lu", location.cylinder); |
| 161 | mvwaddstr(stdscr,INTER_GEOM_Y, INTER_GEOM_X, "Enter the number of cylinders: "); |
| 162 | if (get_string(stdscr, response, sizeof(response), def) > 0) { |
| 163 | tmp_val = atol(response); |
| 164 | if (tmp_val < disk->geom.cylinders) { |
| 165 | location.cylinder = tmp_val; |
| 166 | *lba=CHS2offset(disk,&location); |
| 167 | } else |
| 168 | wprintw(stdscr,"Illegal cylinders value"); |
| 169 | } |
| 170 | default_option=1; |
| 171 | break; |
| 172 | case 'h': |
| 173 | case 'H': |
| 174 | sprintf(def, "%u", location.head); |
| 175 | mvwaddstr(stdscr,INTER_GEOM_Y, INTER_GEOM_X, "Enter the number of heads: "); |
| 176 | if (get_string(stdscr, response, sizeof(response), def) > 0) { |
| 177 | tmp_val = atoi(response); |
| 178 | if (tmp_val < disk->geom.heads_per_cylinder) { |
| 179 | location.head = tmp_val; |
| 180 | *lba=CHS2offset(disk,&location); |
| 181 | } else |
| 182 | wprintw(stdscr,"Illegal heads value"); |
| 183 | } |
| 184 | default_option=2; |
| 185 | break; |
| 186 | case 's': |
no test coverage detected