Changeset b7a4d06 in mainline


Ignore:
Timestamp:
2015-07-18T12:55:12Z (9 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c43db5f
Parents:
70815a24
Message:

Most of extended (but not logical) partition support.

Location:
uspace
Files:
19 edited

Legend:

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

    r70815a24 rb7a4d06  
    5151        /** Delete label */
    5252        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,
    5559        /** Delete partition */
    5660        devac_delete_part,
     
    312316}
    313317
    314 static int fdsk_create_part(fdisk_dev_t *dev)
     318static int fdsk_create_part(fdisk_dev_t *dev, label_pkind_t pkind)
    315319{
    316320        int rc;
    317321        fdisk_part_spec_t pspec;
    318322        fdisk_cap_t cap;
    319         fdisk_fstype_t fstype;
     323        fdisk_fstype_t fstype = fdfs_none;
    320324        tinput_t *tinput = NULL;
    321325        char *scap;
     
    345349        tinput = NULL;
    346350
    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        }
    350356
    351357        fdisk_pspec_init(&pspec);
    352358        pspec.capacity = cap;
     359        pspec.pkind = pkind;
    353360        pspec.fstype = fstype;
    354361
     
    471478        char *sfstype = NULL;
    472479        char *svcname = NULL;
     480        char *spkind;
    473481        int rc;
    474482        int npart;
     
    563571                }
    564572
    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
    566589                free(scap);
    567590                scap = NULL;
     
    580603
    581604        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                        }
    588648                }
    589649        }
     
    637697                (void) fdsk_delete_label(dev);
    638698                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);
    641707                break;
    642708        case devac_delete_part:
  • uspace/lib/c/generic/vbd.c

    r70815a24 rb7a4d06  
    264264{
    265265        async_exch_t *exch;
    266         sysarg_t index;
    267         sysarg_t b0_lo, b0_hi;
    268         sysarg_t nb_lo, nb_hi;
    269         int retval;
    270 
    271         exch = async_exchange_begin(vbd->sess);
    272         retval = async_req_1_5(exch, VBD_PART_GET_INFO, part, &index,
    273             &b0_lo, &b0_hi, &nb_lo, &nb_hi);
    274         async_exchange_end(exch);
    275 
    276         if (retval != EOK)
    277                 return EIO;
    278 
    279         pinfo->index = index;
    280         pinfo->block0 = MERGE_LOUP32(b0_lo, b0_hi);
    281         pinfo->nblocks = MERGE_LOUP32(nb_lo, nb_hi);
     266        sysarg_t retval;
     267        ipc_call_t answer;
     268
     269        exch = async_exchange_begin(vbd->sess);
     270        aid_t req = async_send_1(exch, VBD_PART_GET_INFO, part, &answer);
     271        int rc = async_data_read_start(exch, pinfo, sizeof(vbd_part_info_t));
     272        async_exchange_end(exch);
     273
     274        if (rc != EOK) {
     275                async_forget(req);
     276                return EIO;
     277        }
     278
     279        async_wait_for(req, &retval);
     280        if (retval != EOK)
     281                return EIO;
     282
    282283        return EOK;
    283284}
  • uspace/lib/c/generic/vol.c

    r70815a24 rb7a4d06  
    192192{
    193193        async_exch_t *exch;
    194         sysarg_t dcnt, ltype;
     194        sysarg_t dcnt, ltype, flags;
    195195        int retval;
    196196
    197197        exch = async_exchange_begin(vol->sess);
    198         retval = async_req_1_2(exch, VOL_DISK_INFO, sid, &dcnt, &ltype);
     198        retval = async_req_1_3(exch, VOL_DISK_INFO, sid, &dcnt, &ltype,
     199            &flags);
    199200        async_exchange_end(exch);
    200201
     
    204205        vinfo->dcnt = (label_disk_cnt_t)dcnt;
    205206        vinfo->ltype = (label_type_t)ltype;
     207        vinfo->flags = (label_flags_t)flags;
    206208        return EOK;
    207209}
  • uspace/lib/c/include/types/label.h

    r70815a24 rb7a4d06  
    5858#define LT_LIMIT (lt_gpt + 1)
    5959
     60/** Partition kind */
     61typedef enum {
     62        /** Primary partition */
     63        lpk_primary,
     64        /** Extended partition */
     65        lpk_extended,
     66        /** Logical partition */
     67        lpk_logical
     68} label_pkind_t;
     69
     70/** Label flags */
     71typedef enum {
     72        /** Label supports extended (and logical) partitions */
     73        lf_ext_supp = 0x1,
     74        /** Currently it is possible to create a primary partition */
     75        lf_can_create_pri = 0x2,
     76        /** Currently it is possible to create an extended partition */
     77        lf_can_create_ext = 0x4,
     78        /** Currrently it is possible to create a logical partition */
     79        lf_can_create_log = 0x8
     80} label_flags_t;
    6081
    6182#endif
  • uspace/lib/c/include/vbd.h

    r70815a24 rb7a4d06  
    5151        /** Label type */
    5252        label_type_t ltype;
     53        /** Label flags */
     54        label_flags_t flags;
    5355        /** First block that can be allocated */
    5456        aoff64_t ablock0;
     
    6769        /** Number of blocks */
    6870        aoff64_t nblocks;
     71        /** Partition kind */
     72        label_pkind_t pkind;
    6973        /** Partition type */
    7074        uint64_t ptype;
     
    7579        /** Partition index */
    7680        int index;
     81        /** Partition kind */
     82        label_pkind_t pkind;
    7783        /** First block */
    7884        aoff64_t block0;
  • uspace/lib/c/include/vol.h

    r70815a24 rb7a4d06  
    5353        /** Label type, if disk contents is label */
    5454        label_type_t ltype;
     55        /** Label flags */
     56        label_flags_t flags;
    5557} vol_disk_info_t;
    5658
  • uspace/lib/fdisk/include/fdisk.h

    r70815a24 rb7a4d06  
    7272extern int fdisk_ltype_format(label_type_t, char **);
    7373extern int fdisk_fstype_format(fdisk_fstype_t, char **);
     74extern int fdisk_pkind_format(label_pkind_t, char **);
    7475
    7576#endif
  • uspace/lib/fdisk/include/types/fdisk.h

    r70815a24 rb7a4d06  
    119119        /** Label type */
    120120        label_type_t ltype;
     121        /** Label flags */
     122        label_flags_t flags;
    121123} fdisk_label_info_t;
    122124
     
    131133        /** Capacity */
    132134        fdisk_cap_t capacity;
     135        /** Partition kind */
     136        label_pkind_t pkind;
    133137        /** File system type */
    134138        fdisk_fstype_t fstype;
     
    147151        /** Desired capacity */
    148152        fdisk_cap_t capacity;
     153        /** Partition kind */
     154        label_pkind_t pkind;
    149155        /** File system type */
    150156        fdisk_fstype_t fstype;
     
    153159/** Partition info */
    154160typedef struct {
     161        /** Capacity */
    155162        fdisk_cap_t capacity;
     163        /** Partition kind */
     164        label_pkind_t pkind;
    156165        /** File system type */
    157166        fdisk_fstype_t fstype;
  • uspace/lib/fdisk/src/fdisk.c

    r70815a24 rb7a4d06  
    271271        part->block0 = pinfo.block0;
    272272        part->nblocks = pinfo.nblocks;
     273        part->pkind = pinfo.pkind;
    273274
    274275        /* Insert to list by block address */
     
    442443        info->dcnt = vinfo.dcnt;
    443444        info->ltype = vinfo.ltype;
     445        info->flags = vinfo.flags;
    444446        return EOK;
    445447error:
     
    497499        info->capacity = part->capacity;
    498500        info->fstype = part->fstype;
     501        info->pkind = part->pkind;
    499502        return EOK;
    500503}
     
    671674}
    672675
     676int fdisk_pkind_format(label_pkind_t pkind, char **rstr)
     677{
     678        const char *spkind;
     679        char *s;
     680
     681        spkind = NULL;
     682        switch (pkind) {
     683        case lpk_primary:
     684                spkind = "Primary";
     685                break;
     686        case lpk_extended:
     687                spkind = "Extended";
     688                break;
     689        case lpk_logical:
     690                spkind = "Logical";
     691                break;
     692        }
     693
     694        s = str_dup(spkind);
     695        if (s == NULL)
     696                return ENOMEM;
     697
     698        *rstr = s;
     699        return EOK;
     700}
     701
    673702/** Get free partition index. */
    674703static int fdisk_part_get_free_idx(fdisk_dev_t *dev, int *rindex)
     
    765794                return EIO;
    766795
     796        memset(vpspec, 0, sizeof(vbd_part_spec_t));
    767797        vpspec->index = index;
    768798        vpspec->block0 = fblock0;
    769799        vpspec->nblocks = req_blocks;
    770         vpspec->ptype = 42;
     800        vpspec->pkind = pspec->pkind;
     801        if (pspec->pkind != lpk_extended)
     802                vpspec->ptype = 42;
     803
    771804        return EOK;
    772805}
  • uspace/lib/label/include/types/liblabel.h

    r70815a24 rb7a4d06  
    6868        /** Label type */
    6969        label_type_t ltype;
     70        /** Label flags */
     71        label_flags_t flags;
    7072        /** First block that can be allocated */
    7173        aoff64_t ablock0;
     
    7779        /** Partition index */
    7880        int index;
     81        /** Partition kind */
     82        label_pkind_t pkind;
    7983        /** Address of first block */
    8084        aoff64_t block0;
     
    8892        struct label *label;
    8993        /** Link to label_t.parts */
    90         link_t llabel;
     94        link_t lparts;
     95        /** Link to label_t.pri_parts */
     96        link_t lpri;
     97        /** Link to label_t.log_parts */
     98        link_t llog;
    9199        /** Index */
    92100        int index;
     
    109117        /** Number of blocks */
    110118        aoff64_t nblocks;
     119        /** Partition kind */
     120        label_pkind_t pkind;
    111121        /** Partition type */
    112122        uint64_t ptype;
     
    135145        /** Partitions */
    136146        list_t parts; /* of label_part_t */
     147        /** Primary partitions */
     148        list_t pri_parts; /* of label_part_t */
     149        /** Logical partitions */
     150        list_t log_parts; /* of label_part_t */
    137151        /** First block that can be allocated */
    138152        aoff64_t ablock0;
     
    141155        /** Number of primary partition entries */
    142156        int pri_entries;
     157        /** Index of extended partition or -1 if there is none */
     158        int ext_part_idx;
    143159        /** Block size */
    144160        size_t block_size;
  • uspace/lib/label/src/gpt.c

    r70815a24 rb7a4d06  
    150150
    151151        list_initialize(&label->parts);
     152        list_initialize(&label->pri_parts);
     153        list_initialize(&label->log_parts);
    152154
    153155        for (j = 0; j < 2; j++) {
     
    300302        label->pri_entries = num_entries;
    301303        label->block_size = bsize;
     304        label->ext_part_idx = -1;
    302305
    303306        label->lt.gpt.hdr_ba[0] = gpt_hdr_ba;
     
    436439
    437440        list_initialize(&label->parts);
     441        list_initialize(&label->pri_parts);
     442        list_initialize(&label->log_parts);
    438443
    439444        label->ops = &gpt_label_ops;
     
    444449        label->pri_entries = num_entries;
    445450        label->block_size = bsize;
     451        label->ext_part_idx = -1;
    446452
    447453        label->lt.gpt.hdr_ba[0] = hdr_ba[0];
     
    468474        part = gpt_part_first(label);
    469475        while (part != NULL) {
    470                 list_remove(&part->llabel);
     476                list_remove(&part->lparts);
     477                list_remove(&part->lpri);
    471478                free(part);
    472479                part = gpt_part_first(label);
     
    532539}
    533540
     541static bool gpt_can_create_pri(label_t *label)
     542{
     543        return list_count(&label->parts) < (size_t)label->pri_entries;
     544}
     545
    534546static int gpt_get_info(label_t *label, label_info_t *linfo)
    535547{
     
    537549        linfo->dcnt = dc_label;
    538550        linfo->ltype = lt_gpt;
     551        linfo->flags = 0;
     552        if (gpt_can_create_pri(label))
     553                linfo->flags = linfo->flags | lf_can_create_pri;
    539554        linfo->ablock0 = label->ablock0;
    540555        linfo->anblocks = label->anblocks;
     
    550565                return NULL;
    551566
    552         return list_get_instance(link, label_part_t, llabel);
     567        return list_get_instance(link, label_part_t, lparts);
    553568}
    554569
     
    557572        link_t *link;
    558573
    559         link = list_next(&part->llabel, &part->label->parts);
     574        link = list_next(&part->lparts, &part->label->parts);
    560575        if (link == NULL)
    561576                return NULL;
    562577
    563         return list_get_instance(link, label_part_t, llabel);
     578        return list_get_instance(link, label_part_t, lparts);
    564579}
    565580
     
    567582{
    568583        pinfo->index = part->index;
     584        pinfo->pkind = lpk_primary;
    569585        pinfo->block0 = part->block0;
    570586        pinfo->nblocks = part->nblocks;
     
    587603
    588604        if (pspec->index < 1 || pspec->index > label->pri_entries) {
     605                rc = EINVAL;
     606                goto error;
     607        }
     608
     609        /* GPT only has primary partitions */
     610        if (pspec->pkind != lpk_primary) {
    589611                rc = EINVAL;
    590612                goto error;
     
    614636        }
    615637
    616         list_append(&part->llabel, &label->parts);
     638        list_append(&part->lparts, &label->parts);
     639        list_append(&part->lpri, &label->pri_parts);
    617640
    618641        *rpart = part;
     
    636659                return EIO;
    637660
    638         list_remove(&part->llabel);
     661        list_remove(&part->lparts);
     662        list_remove(&part->lpri);
    639663        free(part);
    640664        return EOK;
     
    694718
    695719        part->label = label;
    696         list_append(&part->llabel, &label->parts);
     720        list_append(&part->lparts, &label->parts);
     721        list_append(&part->lpri, &label->pri_parts);
    697722        return EOK;
    698723}
  • uspace/lib/label/src/mbr.c

    r70815a24 rb7a4d06  
    122122
    123123        list_initialize(&label->parts);
     124        list_initialize(&label->pri_parts);
     125        list_initialize(&label->log_parts);
    124126
    125127        /* Verify boot record signature */
     
    130132        }
    131133
     134        label->ext_part_idx = -1;
    132135        for (entry = 0; entry < mbr_nprimary; entry++) {
    133136                eptr = &mbr->pte[entry];
     
    187190
    188191        list_initialize(&label->parts);
     192        list_initialize(&label->pri_parts);
     193        list_initialize(&label->log_parts);
    189194
    190195        mbr->media_id = 0;
     
    210215        label->anblocks = nblocks - mbr_ablock0;
    211216        label->pri_entries = mbr_nprimary;
     217        label->ext_part_idx = -1;
    212218
    213219        *rlabel = label;
     
    225231        part = mbr_part_first(label);
    226232        while (part != NULL) {
    227                 list_remove(&part->llabel);
     233                list_remove(&part->lparts);
     234                if (link_used(&part->lpri))
     235                        list_remove(&part->lpri);
     236                if (link_used(&part->llog))
     237                        list_remove(&part->llog);
    228238                free(part);
    229239
     
    273283        linfo->dcnt = dc_label;
    274284        linfo->ltype = lt_mbr;
     285
     286        /* We support extended partitions */
     287        linfo->flags = lf_ext_supp;
     288
     289        /** Can create primary if there is a free slot */
     290        if (list_count(&label->pri_parts) < mbr_nprimary)
     291                linfo->flags |= lf_can_create_pri;
     292        /* Can create extended if there is a free slot and no extended */
     293        if ((linfo->flags & lf_can_create_pri) != 0 && label->ext_part_idx < 0)
     294                linfo->flags |= lf_can_create_ext;
     295        /* Can create logical if there is an extended partition */
     296        if (label->ext_part_idx >= 0)
     297                linfo->flags |= lf_can_create_log;
     298
    275299        linfo->ablock0 = label->ablock0;
    276300        linfo->anblocks = label->anblocks;
     301
    277302        return EOK;
    278303}
     
    286311                return NULL;
    287312
    288         return list_get_instance(link, label_part_t, llabel);
     313        return list_get_instance(link, label_part_t, lparts);
    289314}
    290315
     
    293318        link_t *link;
    294319
    295         link = list_next(&part->llabel, &part->label->parts);
     320        link = list_next(&part->lparts, &part->label->parts);
    296321        if (link == NULL)
    297322                return NULL;
    298323
    299         return list_get_instance(link, label_part_t, llabel);
    300 }
    301 
     324        return list_get_instance(link, label_part_t, lparts);
     325}
     326
     327#include <io/log.h>
    302328static void mbr_part_get_info(label_part_t *part, label_part_info_t *pinfo)
    303329{
     
    305331        pinfo->block0 = part->block0;
    306332        pinfo->nblocks = part->nblocks;
     333
     334        log_msg(LOG_DEFAULT, LVL_NOTE, "mbr_part_get_info: index=%d ptype=%d",
     335            (int)part->index, (int)part->ptype);
     336        if (link_used(&part->llog))
     337                pinfo->pkind = lpk_logical;
     338        else if (part->ptype == mbr_pt_extended)
     339                pinfo->pkind = lpk_extended;
     340        else
     341                pinfo->pkind = lpk_primary;
    307342}
    308343
     
    318353                return ENOMEM;
    319354
    320         /* XXX Verify index, block0, nblocks */
    321 
    322         if (pspec->index < 1 || pspec->index > label->pri_entries) {
    323                 rc = EINVAL;
    324                 goto error;
    325         }
    326355
    327356        /* XXX Check if index is used */
     
    331360        part->block0 = pspec->block0;
    332361        part->nblocks = pspec->nblocks;
    333         part->ptype = pspec->ptype;
    334 
    335         rc = mbr_part_to_pte(part, &pte);
    336         if (rc != EOK) {
    337                 rc = EINVAL;
    338                 goto error;
    339         }
    340 
    341         rc = mbr_pte_update(label, &pte, pspec->index - 1);
    342         if (rc != EOK) {
    343                 rc = EIO;
    344                 goto error;
    345         }
    346 
    347         list_append(&part->llabel, &label->parts);
     362
     363        switch (pspec->pkind) {
     364        case lpk_primary:
     365                part->ptype = pspec->ptype;
     366                break;
     367        case lpk_extended:
     368                part->ptype = mbr_pt_extended;
     369                if (pspec->ptype != 0) {
     370                        rc = EINVAL;
     371                        goto error;
     372                }
     373                if (label->ext_part_idx >= 0) {
     374                        rc = EEXISTS;
     375                        goto error;
     376                }
     377                break;
     378        case lpk_logical:
     379                part->ptype = pspec->ptype;
     380                if (pspec->index != 0) {
     381                        rc = EINVAL;
     382                        goto error;
     383                }
     384                break;
     385        }
     386
     387        if (pspec->pkind != lpk_logical) {
     388                /* Primary or extended partition */
     389                /* XXX Verify index, block0, nblocks */
     390
     391                if (pspec->index < 1 || pspec->index > label->pri_entries) {
     392                        rc = EINVAL;
     393                        goto error;
     394                }
     395
     396                rc = mbr_part_to_pte(part, &pte);
     397                if (rc != EOK) {
     398                        rc = EINVAL;
     399                        goto error;
     400                }
     401
     402                rc = mbr_pte_update(label, &pte, pspec->index - 1);
     403                if (rc != EOK) {
     404                        rc = EIO;
     405                        goto error;
     406                }
     407
     408                list_append(&part->lparts, &label->parts);
     409                list_append(&part->lpri, &label->pri_parts);
     410
     411                if (pspec->pkind == lpk_extended)
     412                        label->ext_part_idx = pspec->index - 1;
     413        } else {
     414                /* Logical partition */
     415                rc = ENOTSUP;
     416                goto error;
     417        }
    348418
    349419        *rpart = part;
     
    367437                return EIO;
    368438
    369         list_remove(&part->llabel);
     439        /* If it was the extended partition, clear ext. part. index */
     440        if (part->index - 1 == part->label->ext_part_idx)
     441                part->label->ext_part_idx = -1;
     442
     443        list_remove(&part->lparts);
     444        if (link_used(&part->lpri))
     445                list_remove(&part->lpri);
     446        if (link_used(&part->llog))
     447                list_remove(&part->llog);
    370448        free(part);
    371449        return EOK;
     
    386464                return EINVAL;
    387465
     466        log_msg(LOG_DEFAULT, LVL_NOTE, "mbr_part_to_pte: a0=%" PRIu64
     467            " len=%" PRIu64 " ptype=%d", part->block0, part->nblocks,
     468            (int)part->ptype);
    388469        memset(pte, 0, sizeof(mbr_pte_t));
    389470        pte->ptype = part->ptype;
     
    403484
    404485        /* See UEFI specification 2.0 section 5.2.1 Legacy Master Boot Record */
    405         if (pte->ptype == mbr_pt_unused || pte->ptype == mbr_pt_extended ||
    406             nblocks == 0)
     486        if (pte->ptype == mbr_pt_unused || nblocks == 0)
    407487                return EOK;
    408488
     
    411491                return ENOMEM;
    412492
     493        part->ptype = pte->ptype;
    413494        part->index = index;
    414495        part->block0 = block0;
     
    422503
    423504        part->label = label;
    424         list_append(&part->llabel, &label->parts);
     505        list_append(&part->lparts, &label->parts);
     506        list_append(&part->lpri, &label->pri_parts);
     507
     508        if (pte->ptype == mbr_pt_extended)
     509                label->ext_part_idx = index - 1;
    425510        return EOK;
    426511}
  • uspace/srv/bd/vbd/disk.c

    r70815a24 rb7a4d06  
    125125            disk->svc_name, lpart);
    126126
     127        label_part_get_info(lpart, &lpinfo);
     128
    127129        part = calloc(1, sizeof(vbds_part_t));
    128130        if (part == NULL) {
     
    148150
    149151        free(name);
    150         label_part_get_info(lpart, &lpinfo);
    151152
    152153        part->lpart = lpart;
     
    302303}
    303304
    304 int vbds_disk_info(service_id_t sid, vbds_disk_info_t *info)
     305int vbds_disk_info(service_id_t sid, vbd_disk_info_t *info)
    305306{
    306307        vbds_disk_t *disk;
     
    317318
    318319        info->ltype = linfo.ltype;
     320        info->flags = linfo.flags;
    319321        info->ablock0 = linfo.ablock0;
    320322        info->anblocks = linfo.anblocks;
     
    467469
    468470        pinfo->index = lpinfo.index;
     471        pinfo->pkind = lpinfo.pkind;
    469472        pinfo->block0 = lpinfo.block0;
    470473        pinfo->nblocks = lpinfo.nblocks;
     
    492495        lpspec.block0 = pspec->block0;
    493496        lpspec.nblocks = pspec->nblocks;
     497        lpspec.pkind = pspec->pkind;
    494498        lpspec.ptype = pspec->ptype;
    495499
  • uspace/srv/bd/vbd/disk.h

    r70815a24 rb7a4d06  
    4545extern int vbds_disk_add(service_id_t);
    4646extern int vbds_disk_remove(service_id_t);
    47 extern int vbds_disk_info(service_id_t, vbds_disk_info_t *);
     47extern int vbds_disk_info(service_id_t, vbd_disk_info_t *);
    4848extern int vbds_get_parts(service_id_t, service_id_t *, size_t, size_t *);
    4949extern int vbds_label_create(service_id_t, label_type_t);
  • uspace/srv/bd/vbd/types/vbd.h

    r70815a24 rb7a4d06  
    4747typedef sysarg_t vbds_part_id_t;
    4848
    49 /** Disk info */
    50 typedef struct {
    51         /** Label type */
    52         label_type_t ltype;
    53         /** First block that can be allocated */
    54         aoff64_t ablock0;
    55         /** Number of blocks that can be allocated */
    56         aoff64_t anblocks;
    57         /** Block size */
    58         size_t block_size;
    59 } vbds_disk_info_t;
    60 
    6149/** Partition */
    6250typedef struct {
  • uspace/srv/bd/vbd/vbd.c

    r70815a24 rb7a4d06  
    107107{
    108108        service_id_t disk_sid;
    109         vbds_disk_info_t dinfo;
     109        vbd_disk_info_t dinfo;
    110110        int rc;
    111111
     
    127127        }
    128128
    129         if (size != sizeof(vbds_disk_info_t)) {
     129        if (size != sizeof(vbd_disk_info_t)) {
    130130                async_answer_0(callid, EINVAL);
    131131                async_answer_0(iid, EINVAL);
     
    219219        part = IPC_GET_ARG1(*icall);
    220220        rc = vbds_part_get_info(part, &pinfo);
    221         async_answer_5(iid, (sysarg_t)rc, pinfo.index,
    222             LOWER32(pinfo.block0), UPPER32(pinfo.block0),
    223             LOWER32(pinfo.nblocks), UPPER32(pinfo.nblocks));
     221        if (rc != EOK) {
     222                async_answer_0(iid, rc);
     223                return;
     224        }
     225
     226        ipc_callid_t callid;
     227        size_t size;
     228        if (!async_data_read_receive(&callid, &size)) {
     229                async_answer_0(callid, EREFUSED);
     230                async_answer_0(iid, EREFUSED);
     231                return;
     232        }
     233
     234        if (size != sizeof(vbd_part_info_t)) {
     235                async_answer_0(callid, EINVAL);
     236                async_answer_0(iid, EINVAL);
     237                return;
     238        }
     239
     240        rc = async_data_read_finalize(callid, &pinfo,
     241            min(size, sizeof(pinfo)));
     242        if (rc != EOK) {
     243                async_answer_0(callid, rc);
     244                async_answer_0(iid, rc);
     245                return;
     246        }
     247
     248        async_answer_0(iid, EOK);
    224249}
    225250
  • uspace/srv/volsrv/disk.c

    r70815a24 rb7a4d06  
    271271}
    272272
    273 int vol_disk_empty(vol_disk_t *disk)
     273int vol_disk_empty_disk(vol_disk_t *disk)
    274274{
    275275        int rc;
     
    286286}
    287287
     288int vol_disk_get_info(vol_disk_t *disk, vol_disk_info_t *dinfo)
     289{
     290        vbd_disk_info_t vdinfo;
     291        int rc;
     292
     293        dinfo->dcnt = disk->dcnt;
     294
     295        if (disk->dcnt == dc_label) {
     296                rc = vbd_disk_info(vbd, disk->svc_id, &vdinfo);
     297                if (rc != EOK)
     298                        return rc;
     299
     300                dinfo->ltype = vdinfo.ltype;
     301                dinfo->flags = vdinfo.flags;
     302        }
     303
     304        return EOK;
     305}
     306
    288307
    289308/** @}
  • uspace/srv/volsrv/disk.h

    r70815a24 rb7a4d06  
    3939
    4040#include <sys/types.h>
     41#include <vol.h>
    4142#include "types/disk.h"
    4243
     
    4647extern int vol_disk_find_by_id(service_id_t, vol_disk_t **);
    4748extern int vol_disk_label_create(vol_disk_t *, label_type_t);
    48 extern int vol_disk_empty(vol_disk_t *);
     49extern int vol_disk_empty_disk(vol_disk_t *);
     50extern int vol_disk_get_info(vol_disk_t *, vol_disk_info_t *);
    4951
    5052#endif
  • uspace/srv/volsrv/volsrv.c

    r70815a24 rb7a4d06  
    4343#include <stdlib.h>
    4444#include <task.h>
     45#include <vol.h>
    4546
    4647#include "disk.h"
     
    118119        service_id_t sid;
    119120        vol_disk_t *disk;
     121        vol_disk_info_t dinfo;
    120122        int rc;
    121123
     
    127129        }
    128130
    129         async_answer_2(iid, rc, disk->dcnt, disk->ltype);
     131        rc = vol_disk_get_info(disk, &dinfo);
     132        if (rc != EOK) {
     133                async_answer_0(iid, EIO);
     134                return;
     135        }
     136
     137        async_answer_3(iid, rc, dinfo.dcnt, dinfo.ltype, dinfo.flags);
    130138}
    131139
     
    169177        }
    170178
    171         rc = vol_disk_empty(disk);
     179        rc = vol_disk_empty_disk(disk);
    172180        if (rc != EOK) {
    173181                async_answer_0(iid, EIO);
Note: See TracChangeset for help on using the changeset viewer.