Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/fdisk/fdisk.c

    r6c4eedf r4627314  
    3535 */
    3636
    37 #include <cap.h>
    3837#include <errno.h>
    3938#include <nchoice.h>
     
    4241#include <stdlib.h>
    4342#include <fdisk.h>
    44 
    45 #define NO_LABEL_CAPTION "(No name)"
    4643
    4744static bool quit = false;
     
    152149        nchoice_t *choice = NULL;
    153150        char *svcname = NULL;
    154         cap_spec_t cap;
     151        fdisk_cap_t cap;
    155152        fdisk_dev_info_t *sdev;
    156153        char *scap = NULL;
     
    201198                }
    202199
    203                 cap_simplify(&cap);
    204 
    205                 rc = cap_format(&cap, &scap);
     200                fdisk_cap_simplify(&cap);
     201
     202                rc = fdisk_cap_format(&cap, &scap);
    206203                if (rc != EOK) {
    207204                        assert(rc == ENOMEM);
     
    446443        int rc;
    447444        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;
    451447        vol_fstype_t fstype = 0;
    452448        tinput_t *tinput = NULL;
     
    454450        char *scap;
    455451        char *smcap = NULL;
    456         char *label = NULL;
    457452
    458453        if (pkind == lpk_logical)
     
    467462        }
    468463
    469         cap_simplify(&mcap);
    470 
    471         rc = cap_format(&mcap, &smcap);
     464        fdisk_cap_simplify(&mcap);
     465
     466        rc = fdisk_cap_format(&mcap, &smcap);
    472467        if (rc != EOK) {
    473468                rc = ENOMEM;
     
    491486                        goto error;
    492487
    493                 rc = cap_parse(scap, &cap);
     488                rc = fdisk_cap_parse(scap, &cap);
    494489                if (rc == EOK)
    495490                        break;
     
    507502        }
    508503
    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 
    531504        fdisk_pspec_init(&pspec);
    532505        pspec.capacity = cap;
    533506        pspec.pkind = pkind;
    534507        pspec.fstype = fstype;
    535         pspec.label = label;
    536508
    537509        rc = fdisk_part_create(dev, &pspec, NULL);
     
    541513        }
    542514
    543         free(label);
    544515        return EOK;
    545516error:
    546517        free(smcap);
    547         free(label);
    548518        if (tinput != NULL)
    549519                tinput_destroy(tinput);
     
    560530        char *sfstype = NULL;
    561531        char *sdesc = NULL;
    562         const char *label;
    563532        bool confirm;
    564533        void *sel;
     
    587556                }
    588557
    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);
    592561                if (rc != EOK) {
    593562                        printf("Out of memory.\n");
     
    608577                        }
    609578
    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);
    617580                        if (rc < 0) {
    618581                                rc = ENOMEM;
     
    704667        fdisk_part_t *part;
    705668        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;
    708671        fdisk_dev_flags_t dflags;
    709672        char *sltype = NULL;
     
    714677        char *svcname = NULL;
    715678        char *spkind;
    716         const char *label;
    717679        int rc;
    718680        int npart;
     
    739701        }
    740702
    741         cap_simplify(&cap);
    742 
    743         rc = cap_format(&cap, &sdcap);
     703        fdisk_cap_simplify(&cap);
     704
     705        rc = fdisk_cap_format(&cap, &sdcap);
    744706        if (rc != EOK) {
    745707                printf("Out of memory.\n");
     
    755717        fdisk_dev_get_flags(dev, &dflags);
    756718
    757         printf("Device: %s (%s)\n", svcname, sdcap);
     719        printf("Device: %s, %s\n", sdcap, svcname);
    758720        free(sdcap);
    759721        sdcap = NULL;
     
    793755                }
    794756
    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);
    798760                if (rc != EOK) {
    799761                        printf("Out of memory.\n");
     
    807769                }
    808770
    809                 if (str_size(pinfo.label) > 0)
    810                         label = pinfo.label;
     771                if (linfo.ltype == lt_none)
     772                        printf("Entire disk: %s", scap);
    811773                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);
    818775
    819776                if ((linfo.flags & lf_ext_supp) != 0) {
     
    850807                }
    851808
    852                 cap_simplify(&mcap);
    853 
    854                 rc = cap_format(&mcap, &smcap);
     809                fdisk_cap_simplify(&mcap);
     810
     811                rc = fdisk_cap_format(&mcap, &smcap);
    855812                if (rc != EOK) {
    856813                        rc = ENOMEM;
     
    872829                }
    873830
    874                 cap_simplify(&mcap);
    875 
    876                 rc = cap_format(&mcap, &smcap);
     831                fdisk_cap_simplify(&mcap);
     832
     833                rc = fdisk_cap_format(&mcap, &smcap);
    877834                if (rc != EOK) {
    878835                        rc = ENOMEM;
     
    897854                }
    898855
    899                 cap_simplify(&mcap);
    900 
    901                 rc = cap_format(&mcap, &smcap);
     856                fdisk_cap_simplify(&mcap);
     857
     858                rc = fdisk_cap_format(&mcap, &smcap);
    902859                if (rc != EOK) {
    903860                        rc = ENOMEM;
     
    915872                }
    916873
    917                 cap_simplify(&mcap);
    918 
    919                 rc = cap_format(&mcap, &smcap);
     874                fdisk_cap_simplify(&mcap);
     875
     876                rc = fdisk_cap_format(&mcap, &smcap);
    920877                if (rc != EOK) {
    921878                        rc = ENOMEM;
Note: See TracChangeset for help on using the changeset viewer.