| 274 | } |
| 275 | |
| 276 | list_part_t *add_partition_mac_cli(disk_t *disk_car,list_part_t *list_part, char **current_cmd) |
| 277 | { |
| 278 | partition_t *new_partition=partition_new(&arch_mac); |
| 279 | assert(current_cmd!=NULL); |
| 280 | new_partition->part_offset=disk_car->sector_size; |
| 281 | new_partition->part_size=disk_car->disk_size-disk_car->sector_size; |
| 282 | /*@ |
| 283 | @ loop invariant valid_list_part(list_part); |
| 284 | @ loop invariant valid_read_string(*current_cmd); |
| 285 | @ */ |
| 286 | while(1) |
| 287 | { |
| 288 | skip_comma_in_command(current_cmd); |
| 289 | if(check_command(current_cmd,"s,",2)==0) |
| 290 | { |
| 291 | uint64_t part_offset; |
| 292 | part_offset=new_partition->part_offset; |
| 293 | new_partition->part_offset=(uint64_t)ask_number_cli( |
| 294 | current_cmd, |
| 295 | new_partition->part_offset/disk_car->sector_size, |
| 296 | 4096/disk_car->sector_size, |
| 297 | (disk_car->disk_size-1)/disk_car->sector_size, |
| 298 | "Enter the starting sector ") * |
| 299 | (uint64_t)disk_car->sector_size; |
| 300 | new_partition->part_size=new_partition->part_size + part_offset - new_partition->part_offset; |
| 301 | } |
| 302 | else if(check_command(current_cmd,"S,",2)==0) |
| 303 | { |
| 304 | new_partition->part_size=(uint64_t)ask_number_cli( |
| 305 | current_cmd, |
| 306 | (new_partition->part_offset+new_partition->part_size-1)/disk_car->sector_size, |
| 307 | new_partition->part_offset/disk_car->sector_size, |
| 308 | (disk_car->disk_size-1)/disk_car->sector_size, |
| 309 | "Enter the ending sector ") * |
| 310 | (uint64_t)disk_car->sector_size + |
| 311 | disk_car->sector_size - new_partition->part_offset; |
| 312 | } |
| 313 | else if(check_command(current_cmd,"T,",2)==0) |
| 314 | { |
| 315 | change_part_type_cli(disk_car,new_partition,current_cmd); |
| 316 | } |
| 317 | else if(new_partition->part_size>0 && new_partition->part_type_mac>0) |
| 318 | { |
| 319 | int insert_error=0; |
| 320 | list_part_t *new_list_part=insert_new_partition(list_part, new_partition, 0, &insert_error); |
| 321 | /*@ assert valid_list_part(new_list_part); */ |
| 322 | if(insert_error>0) |
| 323 | { |
| 324 | free(new_partition); |
| 325 | /*@ assert valid_list_part(new_list_part); */ |
| 326 | return new_list_part; |
| 327 | } |
| 328 | new_partition->status=STATUS_PRIM; |
| 329 | if(test_structure_mac(list_part)!=0) |
| 330 | new_partition->status=STATUS_DELETED; |
| 331 | /*@ assert valid_list_part(new_list_part); */ |
| 332 | return new_list_part; |
| 333 | } |
no test coverage detected