Ignore:
File:
1 edited

Legend:

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

    r4627314 r6c4eedf  
    3535 */
    3636
     37#include <cap.h>
    3738#include <errno.h>
    3839#include <nchoice.h>
     
    4142#include <stdlib.h>
    4243#include <fdisk.h>
     44
     45#define NO_LABEL_CAPTION "(No name)"
    4346
    4447static bool quit = false;
     
    149152        nchoice_t *choice = NULL;
    150153        char *svcname = NULL;
    151         fdisk_cap_t cap;
     154        cap_spec_t cap;
    152155        fdisk_dev_info_t *sdev;
    153156        char *scap = NULL;
     
    198201                }
    199202
    200                 fdisk_cap_simplify(&cap);
    201 
    202                 rc = fdisk_cap_format(&cap, &scap);
     203                cap_simplify(&cap);
     204
     205                rc = cap_format(&cap, &scap);
    203206                if (rc != EOK) {
    204207                        assert(rc == ENOMEM);
     
    443446        int rc;
    444447        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;
    447451        vol_fstype_t fstype = 0;
    448452        tinput_t *tinput = NULL;
     
    450454        char *scap;
    451455        char *smcap = NULL;
     456        char *label = NULL;
    452457
    453458        if (pkind == lpk_logical)
     
    462467        }
    463468
    464         fdisk_cap_simplify(&mcap);
    465 
    466         rc = fdisk_cap_format(&mcap, &smcap);
     469        cap_simplify(&mcap);
     470
     471        rc = cap_format(&mcap, &smcap);
    467472        if (rc != EOK) {
    468473                rc = ENOMEM;
     
    486491                        goto error;
    487492
    488                 rc = fdisk_cap_parse(scap, &cap);
     493                rc = cap_parse(scap, &cap);
    489494                if (rc == EOK)
    490495                        break;
     
    502507        }
    503508
     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
    504531        fdisk_pspec_init(&pspec);
    505532        pspec.capacity = cap;
    506533        pspec.pkind = pkind;
    507534        pspec.fstype = fstype;
     535        pspec.label = label;
    508536
    509537        rc = fdisk_part_create(dev, &pspec, NULL);
     
    513541        }
    514542
     543        free(label);
    515544        return EOK;
    516545error:
    517546        free(smcap);
     547        free(label);
    518548        if (tinput != NULL)
    519549                tinput_destroy(tinput);
     
    530560        char *sfstype = NULL;
    531561        char *sdesc = NULL;
     562        const char *label;
    532563        bool confirm;
    533564        void *sel;
     
    556587                }
    557588
    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);
    561592                if (rc != EOK) {
    562593                        printf("Out of memory.\n");
     
    577608                        }
    578609
    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);
    580617                        if (rc < 0) {
    581618                                rc = ENOMEM;
     
    667704        fdisk_part_t *part;
    668705        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;
    671708        fdisk_dev_flags_t dflags;
    672709        char *sltype = NULL;
     
    677714        char *svcname = NULL;
    678715        char *spkind;
     716        const char *label;
    679717        int rc;
    680718        int npart;
     
    701739        }
    702740
    703         fdisk_cap_simplify(&cap);
    704 
    705         rc = fdisk_cap_format(&cap, &sdcap);
     741        cap_simplify(&cap);
     742
     743        rc = cap_format(&cap, &sdcap);
    706744        if (rc != EOK) {
    707745                printf("Out of memory.\n");
     
    717755        fdisk_dev_get_flags(dev, &dflags);
    718756
    719         printf("Device: %s, %s\n", sdcap, svcname);
     757        printf("Device: %s (%s)\n", svcname, sdcap);
    720758        free(sdcap);
    721759        sdcap = NULL;
     
    755793                }
    756794
    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);
    760798                if (rc != EOK) {
    761799                        printf("Out of memory.\n");
     
    769807                }
    770808
     809                if (str_size(pinfo.label) > 0)
     810                        label = pinfo.label;
     811                else
     812                        label = "(No name)";
     813
    771814                if (linfo.ltype == lt_none)
    772                         printf("Entire disk: %s", scap);
     815                        printf("Entire disk: %s %s", label, scap);
    773816                else
    774                         printf("Partition %d: %s", npart, scap);
     817                        printf("Partition %d: %s %s", npart, label, scap);
    775818
    776819                if ((linfo.flags & lf_ext_supp) != 0) {
     
    807850                }
    808851
    809                 fdisk_cap_simplify(&mcap);
    810 
    811                 rc = fdisk_cap_format(&mcap, &smcap);
     852                cap_simplify(&mcap);
     853
     854                rc = cap_format(&mcap, &smcap);
    812855                if (rc != EOK) {
    813856                        rc = ENOMEM;
     
    829872                }
    830873
    831                 fdisk_cap_simplify(&mcap);
    832 
    833                 rc = fdisk_cap_format(&mcap, &smcap);
     874                cap_simplify(&mcap);
     875
     876                rc = cap_format(&mcap, &smcap);
    834877                if (rc != EOK) {
    835878                        rc = ENOMEM;
     
    854897                }
    855898
    856                 fdisk_cap_simplify(&mcap);
    857 
    858                 rc = fdisk_cap_format(&mcap, &smcap);
     899                cap_simplify(&mcap);
     900
     901                rc = cap_format(&mcap, &smcap);
    859902                if (rc != EOK) {
    860903                        rc = ENOMEM;
     
    872915                }
    873916
    874                 fdisk_cap_simplify(&mcap);
    875 
    876                 rc = fdisk_cap_format(&mcap, &smcap);
     917                cap_simplify(&mcap);
     918
     919                rc = cap_format(&mcap, &smcap);
    877920                if (rc != EOK) {
    878921                        rc = ENOMEM;
Note: See TracChangeset for help on using the changeset viewer.