Changes in uspace/app/fdisk/fdisk.c [4627314:6c4eedf] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/fdisk/fdisk.c
r4627314 r6c4eedf 35 35 */ 36 36 37 #include <cap.h> 37 38 #include <errno.h> 38 39 #include <nchoice.h> … … 41 42 #include <stdlib.h> 42 43 #include <fdisk.h> 44 45 #define NO_LABEL_CAPTION "(No name)" 43 46 44 47 static bool quit = false; … … 149 152 nchoice_t *choice = NULL; 150 153 char *svcname = NULL; 151 fdisk_cap_t cap;154 cap_spec_t cap; 152 155 fdisk_dev_info_t *sdev; 153 156 char *scap = NULL; … … 198 201 } 199 202 200 fdisk_cap_simplify(&cap);201 202 rc = fdisk_cap_format(&cap, &scap);203 cap_simplify(&cap); 204 205 rc = cap_format(&cap, &scap); 203 206 if (rc != EOK) { 204 207 assert(rc == ENOMEM); … … 443 446 int rc; 444 447 fdisk_part_spec_t pspec; 445 fdisk_cap_t cap; 446 fdisk_cap_t mcap; 448 cap_spec_t cap; 449 cap_spec_t mcap; 450 vol_label_supp_t vlsupp; 447 451 vol_fstype_t fstype = 0; 448 452 tinput_t *tinput = NULL; … … 450 454 char *scap; 451 455 char *smcap = NULL; 456 char *label = NULL; 452 457 453 458 if (pkind == lpk_logical) … … 462 467 } 463 468 464 fdisk_cap_simplify(&mcap);465 466 rc = fdisk_cap_format(&mcap, &smcap);469 cap_simplify(&mcap); 470 471 rc = cap_format(&mcap, &smcap); 467 472 if (rc != EOK) { 468 473 rc = ENOMEM; … … 486 491 goto error; 487 492 488 rc = fdisk_cap_parse(scap, &cap);493 rc = cap_parse(scap, &cap); 489 494 if (rc == EOK) 490 495 break; … … 502 507 } 503 508 509 fdisk_get_vollabel_support(dev, fstype, &vlsupp); 510 if (vlsupp.supported) { 511 tinput = tinput_new(); 512 if (tinput == NULL) { 513 rc = ENOMEM; 514 goto error; 515 } 516 517 rc = tinput_set_prompt(tinput, "?> "); 518 if (rc != EOK) 519 goto error; 520 521 /* Ask for volume label */ 522 printf("Enter volume label for new partition.\n"); 523 rc = tinput_read_i(tinput, "New volume", &label); 524 if (rc != EOK) 525 goto error; 526 527 tinput_destroy(tinput); 528 tinput = NULL; 529 } 530 504 531 fdisk_pspec_init(&pspec); 505 532 pspec.capacity = cap; 506 533 pspec.pkind = pkind; 507 534 pspec.fstype = fstype; 535 pspec.label = label; 508 536 509 537 rc = fdisk_part_create(dev, &pspec, NULL); … … 513 541 } 514 542 543 free(label); 515 544 return EOK; 516 545 error: 517 546 free(smcap); 547 free(label); 518 548 if (tinput != NULL) 519 549 tinput_destroy(tinput); … … 530 560 char *sfstype = NULL; 531 561 char *sdesc = NULL; 562 const char *label; 532 563 bool confirm; 533 564 void *sel; … … 556 587 } 557 588 558 fdisk_cap_simplify(&pinfo.capacity);559 560 rc = fdisk_cap_format(&pinfo.capacity, &scap);589 cap_simplify(&pinfo.capacity); 590 591 rc = cap_format(&pinfo.capacity, &scap); 561 592 if (rc != EOK) { 562 593 printf("Out of memory.\n"); … … 577 608 } 578 609 579 rc = asprintf(&sdesc, "%s, %s, %s", scap, spkind, sfstype); 610 if (str_size(pinfo.label) > 0) 611 label = pinfo.label; 612 else 613 label = "(No name)"; 614 615 rc = asprintf(&sdesc, "%s %s, %s, %s", label, 616 scap, spkind, sfstype); 580 617 if (rc < 0) { 581 618 rc = ENOMEM; … … 667 704 fdisk_part_t *part; 668 705 fdisk_part_info_t pinfo; 669 fdisk_cap_t cap;670 fdisk_cap_t mcap;706 cap_spec_t cap; 707 cap_spec_t mcap; 671 708 fdisk_dev_flags_t dflags; 672 709 char *sltype = NULL; … … 677 714 char *svcname = NULL; 678 715 char *spkind; 716 const char *label; 679 717 int rc; 680 718 int npart; … … 701 739 } 702 740 703 fdisk_cap_simplify(&cap);704 705 rc = fdisk_cap_format(&cap, &sdcap);741 cap_simplify(&cap); 742 743 rc = cap_format(&cap, &sdcap); 706 744 if (rc != EOK) { 707 745 printf("Out of memory.\n"); … … 717 755 fdisk_dev_get_flags(dev, &dflags); 718 756 719 printf("Device: %s , %s\n", sdcap, svcname);757 printf("Device: %s (%s)\n", svcname, sdcap); 720 758 free(sdcap); 721 759 sdcap = NULL; … … 755 793 } 756 794 757 fdisk_cap_simplify(&pinfo.capacity);758 759 rc = fdisk_cap_format(&pinfo.capacity, &scap);795 cap_simplify(&pinfo.capacity); 796 797 rc = cap_format(&pinfo.capacity, &scap); 760 798 if (rc != EOK) { 761 799 printf("Out of memory.\n"); … … 769 807 } 770 808 809 if (str_size(pinfo.label) > 0) 810 label = pinfo.label; 811 else 812 label = "(No name)"; 813 771 814 if (linfo.ltype == lt_none) 772 printf("Entire disk: %s ", scap);815 printf("Entire disk: %s %s", label, scap); 773 816 else 774 printf("Partition %d: %s ", npart, scap);817 printf("Partition %d: %s %s", npart, label, scap); 775 818 776 819 if ((linfo.flags & lf_ext_supp) != 0) { … … 807 850 } 808 851 809 fdisk_cap_simplify(&mcap);810 811 rc = fdisk_cap_format(&mcap, &smcap);852 cap_simplify(&mcap); 853 854 rc = cap_format(&mcap, &smcap); 812 855 if (rc != EOK) { 813 856 rc = ENOMEM; … … 829 872 } 830 873 831 fdisk_cap_simplify(&mcap);832 833 rc = fdisk_cap_format(&mcap, &smcap);874 cap_simplify(&mcap); 875 876 rc = cap_format(&mcap, &smcap); 834 877 if (rc != EOK) { 835 878 rc = ENOMEM; … … 854 897 } 855 898 856 fdisk_cap_simplify(&mcap);857 858 rc = fdisk_cap_format(&mcap, &smcap);899 cap_simplify(&mcap); 900 901 rc = cap_format(&mcap, &smcap); 859 902 if (rc != EOK) { 860 903 rc = ENOMEM; … … 872 915 } 873 916 874 fdisk_cap_simplify(&mcap);875 876 rc = fdisk_cap_format(&mcap, &smcap);917 cap_simplify(&mcap); 918 919 rc = cap_format(&mcap, &smcap); 877 920 if (rc != EOK) { 878 921 rc = ENOMEM;
Note:
See TracChangeset
for help on using the changeset viewer.