Changeset b7a4d06 in mainline for uspace/lib/fdisk


Ignore:
Timestamp:
2015-07-18T12:55:12Z (10 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/lib/fdisk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.