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