Changeset b7a4d06 in mainline for uspace/app/fdisk/fdisk.c
- Timestamp:
- 2015-07-18T12:55:12Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c43db5f
- Parents:
- 70815a24
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/fdisk/fdisk.c
r70815a24 rb7a4d06 51 51 /** Delete label */ 52 52 devac_delete_label, 53 /** Create partition */ 54 devac_create_part, 53 /** Create (primary) partition */ 54 devac_create_pri_part, 55 /** Create extended partition */ 56 devac_create_ext_part, 57 /** Create logical partition */ 58 devac_create_log_part, 55 59 /** Delete partition */ 56 60 devac_delete_part, … … 312 316 } 313 317 314 static int fdsk_create_part(fdisk_dev_t *dev )318 static int fdsk_create_part(fdisk_dev_t *dev, label_pkind_t pkind) 315 319 { 316 320 int rc; 317 321 fdisk_part_spec_t pspec; 318 322 fdisk_cap_t cap; 319 fdisk_fstype_t fstype ;323 fdisk_fstype_t fstype = fdfs_none; 320 324 tinput_t *tinput = NULL; 321 325 char *scap; … … 345 349 tinput = NULL; 346 350 347 rc = fdsk_select_fstype(&fstype); 348 if (rc != EOK) 349 goto error; 351 if (pkind != lpk_extended) { 352 rc = fdsk_select_fstype(&fstype); 353 if (rc != EOK) 354 goto error; 355 } 350 356 351 357 fdisk_pspec_init(&pspec); 352 358 pspec.capacity = cap; 359 pspec.pkind = pkind; 353 360 pspec.fstype = fstype; 354 361 … … 471 478 char *sfstype = NULL; 472 479 char *svcname = NULL; 480 char *spkind; 473 481 int rc; 474 482 int npart; … … 563 571 } 564 572 565 printf("Partition %d: %s, %s\n", npart, scap, sfstype); 573 printf("Partition %d: %s", npart, scap); 574 if ((linfo.flags & lf_ext_supp) != 0) { 575 rc = fdisk_pkind_format(pinfo.pkind, &spkind); 576 if (rc != EOK) { 577 printf("\nOut of memory.\n"); 578 goto error; 579 } 580 581 printf(", %s", spkind); 582 free(spkind); 583 } 584 585 if (pinfo.pkind != lpk_extended) 586 printf(", %s", sfstype); 587 printf("\n"); 588 566 589 free(scap); 567 590 scap = NULL; … … 580 603 581 604 if (linfo.dcnt == dc_label) { 582 rc = nchoice_add(choice, "Create partition", 583 (void *)devac_create_part); 584 if (rc != EOK) { 585 assert(rc == ENOMEM); 586 printf("Out of memory.\n"); 587 goto error; 605 if ((linfo.flags & lf_ext_supp) != 0) { 606 if ((linfo.flags & lf_can_create_pri) != 0) { 607 rc = nchoice_add(choice, "Create primary " 608 "partition", 609 (void *)devac_create_pri_part); 610 if (rc != EOK) { 611 assert(rc == ENOMEM); 612 printf("Out of memory.\n"); 613 goto error; 614 } 615 } 616 617 if ((linfo.flags & lf_can_create_ext) != 0) { 618 rc = nchoice_add(choice, "Create extended " 619 "partition", 620 (void *)devac_create_ext_part); 621 if (rc != EOK) { 622 assert(rc == ENOMEM); 623 printf("Out of memory.\n"); 624 goto error; 625 } 626 } 627 628 if ((linfo.flags & lf_can_create_log) != 0) { 629 rc = nchoice_add(choice, "Create logical " 630 "partition", 631 (void *)devac_create_log_part); 632 if (rc != EOK) { 633 assert(rc == ENOMEM); 634 printf("Out of memory.\n"); 635 goto error; 636 } 637 } 638 } else { /* (linfo.flags & lf_ext_supp) == 0 */ 639 if ((linfo.flags & lf_can_create_pri) != 0) { 640 rc = nchoice_add(choice, "Create partition", 641 (void *)devac_create_pri_part); 642 if (rc != EOK) { 643 assert(rc == ENOMEM); 644 printf("Out of memory.\n"); 645 goto error; 646 } 647 } 588 648 } 589 649 } … … 637 697 (void) fdsk_delete_label(dev); 638 698 break; 639 case devac_create_part: 640 (void) fdsk_create_part(dev); 699 case devac_create_pri_part: 700 (void) fdsk_create_part(dev, lpk_primary); 701 break; 702 case devac_create_ext_part: 703 (void) fdsk_create_part(dev, lpk_extended); 704 break; 705 case devac_create_log_part: 706 (void) fdsk_create_part(dev, lpk_logical); 641 707 break; 642 708 case devac_delete_part:
Note:
See TracChangeset
for help on using the changeset viewer.