Changeset 52f2c89 in mainline for uspace/lib/gpt


Ignore:
Timestamp:
2013-06-24T22:29:44Z (12 years ago)
Author:
Dominik Taborsky (AT DOT) <brembyseznamcz>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9bdfde73
Parents:
44c4886 (diff), 6317b33 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

hdisk, libmbr and libgpt updates

Location:
uspace/lib/gpt
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/gpt/global.c

    r44c4886 r52f2c89  
    4141
    4242const struct partition_type gpt_ptypes[] = {
    43         { "Unused entry",                                       "00000000-0000-0000-0000-000000000000" },
    44         { "MBR partition scheme",                       "024DEE41-33E7-11D3-9D69-0008C781F39F" },
    45         { "EFI System",                                         "C12A7328-F81F-11D2-BA4B-00A0C93EC93B" },
    46         { "BIOS Boot",                                          "21686148-6449-6E6F-744E-656564454649" },
    47         { "Windows Reserved",                           "E3C9E316-0B5C-4DB8-817D-F92DF00215AE" },
    48         { "Windows Basic data",                         "EBD0A0A2-B9E5-4433-87C0-68B6B72699C7" },
    49         { "Windows LDM metadata",                       "5808C8AA-7E8F-42E0-85D2-E1E90434CFB3" },
    50         { "Windows LDM data",                           "AF9B60A0-1431-4F62-BC68-3311714A69AD" },
    51         { "Windows Recovery Environment",       "DE94BBA4-06D1-4D40-A16A-BFD50179D6AC" },
    52         { "Windows IBM GPFS",                           "37AFFC90-EF7D-4E96-91C3-2D7AE055B174" },
    53         { "Windows Cluster metadata",           "DB97DBA9-0840-4BAE-97F0-FFB9A327C7E1" },
    54         { "HP-UX Data",                                         "75894C1E-3AEB-11D3-B7C1-7B03A0000000" },
    55         { "HP-UX Service",                                      "E2A1E728-32E3-11D6-A682-7B03A0000000" },
    56         { "Linux filesystem data",                      "EBD0A0A2-B9E5-4433-87C0-68B6B72699C7" },
    57         { "Linux filesystem data",                      "0FC63DAF-8483-4772-8E79-3D69D8477DE4" },
    58         { "Linux RAID",                                         "A19D880F-05FC-4D3B-A006-743F0F84911E" },
    59         { "Linux Swap",                                         "0657FD6D-A4AB-43C4-84E5-0933C84B4F4F" },
    60         { "Linux LVM",                                          "E6D6D379-F507-44C2-A23C-238F2A3DF928" },
    61         { "Linux Reserved",                                     "8DA63339-0007-60C0-C436-083AC8230908" },
    62         { "FreeBSD Boot",                                       "83BD6B9D-7F41-11DC-BE0B-001560B84F0F" },
    63         { "FreeBSD Data",                                       "516E7CB4-6ECF-11D6-8FF8-00022D09712B" },
    64         { "FreeBSD Swap",                                       "516E7CB5-6ECF-11D6-8FF8-00022D09712B" },
    65         { "FreeBSD UFS",                                        "516E7CB6-6ECF-11D6-8FF8-00022D09712B" },
    66         { "FreeBSD Vinum VM",                           "516E7CB8-6ECF-11D6-8FF8-00022D09712B" },
    67         { "FreeBSD ZFS",                                        "516E7CBA-6ECF-11D6-8FF8-00022D09712B" },
    68         { "Mac OS X HFS+",                                      "48465300-0000-11AA-AA11-00306543ECAC" },
    69         { "Mac OS X UFS",                                       "55465300-0000-11AA-AA11-00306543ECAC" },
    70         { "Mac OS X ZFS",                                       "6A898CC3-1DD2-11B2-99A6-080020736631" },
    71         { "Mac OS X RAID",                                      "52414944-0000-11AA-AA11-00306543ECAC" },
    72         { "Mac OS X RAID, offline",                     "52414944-5F4F-11AA-AA11-00306543ECAC" },
    73         { "Mac OS X Boot",                                      "426F6F74-0000-11AA-AA11-00306543ECAC" },
    74         { "Mac OS X Label",                                     "4C616265-6C00-11AA-AA11-00306543ECAC" },
    75         { "Mac OS X TV Recovery",                       "5265636F-7665-11AA-AA11-00306543ECAC" },
    76         { "Mac OS X Core Storage",                      "53746F72-6167-11AA-AA11-00306543ECAC" },
    77         { "Solaris Boot",                                       "6A82CB45-1DD2-11B2-99A6-080020736631" },
    78         { "Solaris Root",                                       "6A85CF4D-1DD2-11B2-99A6-080020736631" },
    79         { "Solaris Swap",                                       "6A87C46F-1DD2-11B2-99A6-080020736631" },
    80         { "Solaris Backup",                                     "6A8B642B-1DD2-11B2-99A6-080020736631" },
    81         { "Solaris /usr",                                       "6A898CC3-1DD2-11B2-99A6-080020736631" },
    82         { "Solaris /var",                                       "6A8EF2E9-1DD2-11B2-99A6-080020736631" },
    83         { "Solaris /home",                                      "6A90BA39-1DD2-11B2-99A6-080020736631" },
    84         { "Solaris Alternate sector",           "6A9283A5-1DD2-11B2-99A6-080020736631" },
    85         { "Solaris Reserved",                           "6A945A3B-1DD2-11B2-99A6-080020736631" },
    86         { "Solaris Reserved",                           "6A9630D1-1DD2-11B2-99A6-080020736631" },
    87         { "Solaris Reserved",                           "6A980767-1DD2-11B2-99A6-080020736631" },
    88         { "Solaris Reserved",                           "6A96237F-1DD2-11B2-99A6-080020736631" },
    89         { "Solaris Reserved",                           "6A8D2AC7-1DD2-11B2-99A6-080020736631" },
    90         { "NetBSD Swap",                                        "49F48D32-B10E-11DC-B99B-0019D1879648" },
    91         { "NetBSD FFS",                                         "49F48D5A-B10E-11DC-B99B-0019D1879648" },
    92         { "NetBSD LFS",                                         "49F48D82-B10E-11DC-B99B-0019D1879648" },
    93         { "NetBSD RAID",                                        "49F48DAA-B10E-11DC-B99B-0019D1879648" },
    94         { "NetBSD Concatenated",                        "2DB519C4-B10F-11DC-B99B-0019D1879648" },
    95         { "NetBSD Encrypted",                           "2DB519EC-B10F-11DC-B99B-0019D1879648" },
    96         { "ChromeOS ChromeOS kernel",           "FE3A2A5D-4F32-41A7-B725-ACCC3285A309" },
    97         { "ChromeOS rootfs",                            "3CB8E202-3B7E-47DD-8A3C-7FF2A13CFCEC" },
    98         { "ChromeOS future use",                        "2E0A753D-9E48-43B0-8337-B15192CB1B5E" },
    99         { "MidnightBSD Boot",                           "85D5E45E-237C-11E1-B4B3-E89A8F7FC3A7" },
    100         { "MidnightBSD Data",                           "85D5E45A-237C-11E1-B4B3-E89A8F7FC3A7" },
    101         { "MidnightBSD Swap",                           "85D5E45B-237C-11E1-B4B3-E89A8F7FC3A7" },
    102         { "MidnightBSD UFS",                            "0394Ef8B-237E-11E1-B4B3-E89A8F7FC3A7" },
    103         { "MidnightBSD Vinum VM",                       "85D5E45C-237C-11E1-B4B3-E89A8F7FC3A7" },
    104         { "MidnightBSD ZFS",                            "85D5E45D-237C-11E1-B4B3-E89A8F7FC3A7" },
    105         { "Uknown", NULL}       // keep this as the last one! gpt_get_part_type depends on it!
     43        { "Unused entry",                                       "00000000" "0000" "0000" "0000" "000000000000" },
     44        { "MBR partition scheme",                       "024DEE41" "33E7" "11D3" "9D69" "0008C781F39F" },
     45        { "EFI System",                                         "C12A7328" "F81F" "11D2" "BA4B" "00A0C93EC93B" },
     46        { "BIOS Boot",                                          "21686148" "6449" "6E6F" "744E" "656564454649" },
     47        { "Windows Reserved",                           "E3C9E316" "0B5C" "4DB8" "817D" "F92DF00215AE" },
     48        { "Windows Basic data",                         "EBD0A0A2" "B9E5" "4433" "87C0" "68B6B72699C7" },
     49        { "Windows LDM metadata",                       "5808C8AA" "7E8F" "42E0" "85D2" "E1E90434CFB3" },
     50        { "Windows LDM data",                           "AF9B60A0" "1431" "4F62" "BC68" "3311714A69AD" },
     51        { "Windows Recovery Environment",       "DE94BBA4" "06D1" "4D40" "A16A" "BFD50179D6AC" },
     52        { "Windows IBM GPFS",                           "37AFFC90" "EF7D" "4E96" "91C3" "2D7AE055B174" },
     53        { "Windows Cluster metadata",           "DB97DBA9" "0840" "4BAE" "97F0" "FFB9A327C7E1" },
     54        { "HP-UX Data",                                         "75894C1E" "3AEB" "11D3" "B7C1" "7B03A0000000" },
     55        { "HP-UX Service",                                      "E2A1E728" "32E3" "11D6" "A682" "7B03A0000000" },
     56        { "Linux filesystem data",                      "EBD0A0A2" "B9E5" "4433" "87C0" "68B6B72699C7" },
     57        { "Linux filesystem data",                      "0FC63DAF" "8483" "4772" "8E79" "3D69D8477DE4" },
     58        { "Linux RAID",                                         "A19D880F" "05FC" "4D3B" "A006" "743F0F84911E" },
     59        { "Linux Swap",                                         "0657FD6D" "A4AB" "43C4" "84E5" "0933C84B4F4F" },
     60        { "Linux LVM",                                          "E6D6D379" "F507" "44C2" "A23C" "238F2A3DF928" },
     61        { "Linux Reserved",                                     "8DA63339" "0007" "60C0" "C436" "083AC8230908" },
     62        { "FreeBSD Boot",                                       "83BD6B9D" "7F41" "11DC" "BE0B" "001560B84F0F" },
     63        { "FreeBSD Data",                                       "516E7CB4" "6ECF" "11D6" "8FF8" "00022D09712B" },
     64        { "FreeBSD Swap",                                       "516E7CB5" "6ECF" "11D6" "8FF8" "00022D09712B" },
     65        { "FreeBSD UFS",                                        "516E7CB6" "6ECF" "11D6" "8FF8" "00022D09712B" },
     66        { "FreeBSD Vinum VM",                           "516E7CB8" "6ECF" "11D6" "8FF8" "00022D09712B" },
     67        { "FreeBSD ZFS",                                        "516E7CBA" "6ECF" "11D6" "8FF8" "00022D09712B" },
     68        { "Mac OS X HFS+",                                      "48465300" "0000" "11AA" "AA11" "00306543ECAC" },
     69        { "Mac OS X UFS",                                       "55465300" "0000" "11AA" "AA11" "00306543ECAC" },
     70        { "Mac OS X ZFS",                                       "6A898CC3" "1DD2" "11B2" "99A6" "080020736631" },
     71        { "Mac OS X RAID",                                      "52414944" "0000" "11AA" "AA11" "00306543ECAC" },
     72        { "Mac OS X RAID, offline",                     "52414944" "5F4F" "11AA" "AA11" "00306543ECAC" },
     73        { "Mac OS X Boot",                                      "426F6F74" "0000" "11AA" "AA11" "00306543ECAC" },
     74        { "Mac OS X Label",                                     "4C616265" "6C00" "11AA" "AA11" "00306543ECAC" },
     75        { "Mac OS X TV Recovery",                       "5265636F" "7665" "11AA" "AA11" "00306543ECAC" },
     76        { "Mac OS X Core Storage",                      "53746F72" "6167" "11AA" "AA11" "00306543ECAC" },
     77        { "Solaris Boot",                                       "6A82CB45" "1DD2" "11B2" "99A6" "080020736631" },
     78        { "Solaris Root",                                       "6A85CF4D" "1DD2" "11B2" "99A6" "080020736631" },
     79        { "Solaris Swap",                                       "6A87C46F" "1DD2" "11B2" "99A6" "080020736631" },
     80        { "Solaris Backup",                                     "6A8B642B" "1DD2" "11B2" "99A6" "080020736631" },
     81        { "Solaris /usr",                                       "6A898CC3" "1DD2" "11B2" "99A6" "080020736631" },
     82        { "Solaris /var",                                       "6A8EF2E9" "1DD2" "11B2" "99A6" "080020736631" },
     83        { "Solaris /home",                                      "6A90BA39" "1DD2" "11B2" "99A6" "080020736631" },
     84        { "Solaris Alternate sector",           "6A9283A5" "1DD2" "11B2" "99A6" "080020736631" },
     85        { "Solaris Reserved",                           "6A945A3B" "1DD2" "11B2" "99A6" "080020736631" },
     86        { "Solaris Reserved",                           "6A9630D1" "1DD2" "11B2" "99A6" "080020736631" },
     87        { "Solaris Reserved",                           "6A980767" "1DD2" "11B2" "99A6" "080020736631" },
     88        { "Solaris Reserved",                           "6A96237F" "1DD2" "11B2" "99A6" "080020736631" },
     89        { "Solaris Reserved",                           "6A8D2AC7" "1DD2" "11B2" "99A6" "080020736631" },
     90        { "NetBSD Swap",                                        "49F48D32" "B10E" "11DC" "B99B" "0019D1879648" },
     91        { "NetBSD FFS",                                         "49F48D5A" "B10E" "11DC" "B99B" "0019D1879648" },
     92        { "NetBSD LFS",                                         "49F48D82" "B10E" "11DC" "B99B" "0019D1879648" },
     93        { "NetBSD RAID",                                        "49F48DAA" "B10E" "11DC" "B99B" "0019D1879648" },
     94        { "NetBSD Concatenated",                        "2DB519C4" "B10F" "11DC" "B99B" "0019D1879648" },
     95        { "NetBSD Encrypted",                           "2DB519EC" "B10F" "11DC" "B99B" "0019D1879648" },
     96        { "ChromeOS ChromeOS kernel",           "FE3A2A5D" "4F32" "41A7" "B725" "ACCC3285A309" },
     97        { "ChromeOS rootfs",                            "3CB8E202" "3B7E" "47DD" "8A3C" "7FF2A13CFCEC" },
     98        { "ChromeOS future use",                        "2E0A753D" "9E48" "43B0" "8337" "B15192CB1B5E" },
     99        { "MidnightBSD Boot",                           "85D5E45E" "237C" "11E1" "B4B3" "E89A8F7FC3A7" },
     100        { "MidnightBSD Data",                           "85D5E45A" "237C" "11E1" "B4B3" "E89A8F7FC3A7" },
     101        { "MidnightBSD Swap",                           "85D5E45B" "237C" "11E1" "B4B3" "E89A8F7FC3A7" },
     102        { "MidnightBSD UFS",                            "0394Ef8B" "237E" "11E1" "B4B3" "E89A8F7FC3A7" },
     103        { "MidnightBSD Vinum VM",                       "85D5E45C" "237C" "11E1" "B4B3" "E89A8F7FC3A7" },
     104        { "MidnightBSD ZFS",                            "85D5E45D" "237C" "11E1" "B4B3" "E89A8F7FC3A7" },
     105        { "Uknown", NULL} /* keep this as the last one! gpt_get_part_type depends on it! */
    106106};
     107
     108
     109
  • uspace/lib/gpt/libgpt.c

    r44c4886 r52f2c89  
    5151#include "libgpt.h"
    5252
    53 static int load_and_check_header(service_id_t handle, aoff64_t addr, size_t b_size, gpt_header_t * header);
     53static int load_and_check_header(service_id_t handle, aoff64_t addr, size_t b_size, gpt_header_t *header);
    5454static gpt_partitions_t * alloc_part_array(uint32_t num);
    55 static int extend_part_array(gpt_partitions_t * p);
    56 static int reduce_part_array(gpt_partitions_t * p);
     55static int extend_part_array(gpt_partitions_t *);
     56static int reduce_part_array(gpt_partitions_t *);
    5757static long long nearest_larger_int(double a);
    58 
     58static uint8_t get_byte(const char *);
    5959
    6060/** Allocate memory for gpt label */
     
    179179
    180180        rc = block_init(EXCHANGE_ATOMIC, dev_handle, b_size);
    181         if (rc != EOK)
     181        if (rc != EOK && rc != EEXIST)
    182182                return rc;
    183183
     
    300300        size_t b_size;
    301301        uint32_t e_size = uint32_t_le2host(label->gpt->header->entry_size);
    302 
     302        size_t fill = label->parts->fill > GPT_MIN_PART_NUM ? label->parts->fill : GPT_MIN_PART_NUM;
     303       
    303304        label->gpt->header->pe_array_crc32 = compute_crc32(
    304305                                       (uint8_t *) label->parts->part_array,
    305                                        label->parts->fill * e_size);
     306                                       fill * e_size);
    306307       
    307308        /* comm_size of 4096 is ignored */
    308309        rc = block_init(EXCHANGE_ATOMIC, dev_handle, 4096);
    309         if (rc != EOK)
    310                 return rc;
    311 
     310        if (rc != EOK && rc != EEXIST)
     311                return rc;
     312       
    312313        rc = block_get_bsize(dev_handle, &b_size);
    313314        if (rc != EOK)
    314315                goto fail;
    315 
     316       
     317        aoff64_t n_blocks;
     318        rc = block_get_nblocks(dev_handle, &n_blocks);
     319        if (rc != EOK)
     320                goto fail;
     321       
     322        /* Write to backup GPT partition array location */
     323        //rc = block_write_direct(dev_handle, n_blocks - 1, GPT_HDR_BS, header->raw_data);
     324        if (rc != EOK)
     325                goto fail;
     326       
    316327        /* Write to main GPT partition array location */
    317328        rc = block_write_direct(dev_handle, uint64_t_le2host(label->gpt->header->entry_lba),
     
    320331        if (rc != EOK)
    321332                goto fail;
    322 
    323         aoff64_t n_blocks;
    324         rc = block_get_nblocks(dev_handle, &n_blocks);
    325         if (rc != EOK)
    326                 goto fail;
    327 
    328         /* Write to backup GPT partition array location */
    329         //rc = block_write_direct(dev_handle, n_blocks - 1, GPT_HDR_BS, header->raw_data);
    330         block_fini(dev_handle);
    331         if (rc != EOK)
    332                 goto fail;
    333 
    334 
     333       
    335334        return gpt_write_header(label, dev_handle);
    336335       
     
    347346 * This returns a memory block (zero-filled) and needs gpt_add_partition()
    348347 * to be called to insert it into a partition array.
    349  * Requires you to call gpt_free_partition after use.
     348 * Requires you to call gpt_free_partition afterwards.
    350349 */
    351350gpt_part_t * gpt_alloc_partition(void)
     
    367366 *
    368367 * Note: use either gpt_alloc_partition or gpt_get_partition.
    369  * This one return a pointer to a structure already inside the array, so
    370  * there's no need to call gpt_add_partition().
     368 * This one returns a pointer to the first empty structure already
     369 * inside the array, so don't call gpt_add_partition() afterwards.
    371370 * This is the one you will usually want.
    372371 */
    373372gpt_part_t * gpt_get_partition(gpt_label_t *label)
    374373{
    375         if (label->parts->fill == label->parts->arr_size) {
    376                 if (extend_part_array(label->parts) == -1)
    377                         return NULL;
    378         }
    379 
    380         return label->parts->part_array + label->parts->fill++;
     374        gpt_part_t *p;
     375       
     376        /* Find the first empty entry */
     377        do {
     378                if (label->parts->fill == label->parts->arr_size) {
     379                        if (extend_part_array(label->parts) == -1)
     380                                return NULL;
     381                }
     382               
     383                p = label->parts->part_array + label->parts->fill++;
     384               
     385        } while (gpt_get_part_type(p) != GPT_PTE_UNUSED);
     386       
     387        return p;
     388}
     389
     390/** Get partition already inside the label
     391 *
     392 * @param label   label to carrying the partition
     393 * @param idx     index of the partition
     394 *
     395 * @return        returns pointer to the partition
     396 *                or NULL when out of range
     397 *
     398 * Note: For new partitions use either gpt_alloc_partition or
     399 * gpt_get_partition unless you want a partition at a specific place.
     400 * This returns a pointer to a structure already inside the array,
     401 * so don't call gpt_add_partition() afterwards.
     402 * This function is handy when you want to change already existing
     403 * partition or to simply write somewhere in the middle. This works only
     404 * for indexes smaller than either 128 or the actual number of filled
     405 * entries.
     406 */
     407gpt_part_t * gpt_get_partition_at(gpt_label_t *label, size_t idx)
     408{
     409        return NULL;
     410       
     411        if (idx >= GPT_MIN_PART_NUM && idx >= label->parts->fill)
     412                return NULL;
     413       
     414        return label->parts->part_array + idx;
    381415}
    382416
     
    415449int gpt_remove_partition(gpt_label_t *label, size_t idx)
    416450{
    417         if (idx != label->parts->fill - 1) {
    418                 memmove(label->parts->part_array + idx,
    419                         label->parts->part_array + idx + 1,
    420                         (label->parts->fill - 1) * sizeof(gpt_entry_t));
    421                 label->parts->fill -= 1;
    422         }
    423        
    424         /* FIXME: This probably shouldn't be here, but instead
    425          * in reduce_part_array() or similar */
     451        if (idx >= label->parts->fill)
     452                return EINVAL;
     453       
     454        /* FIXME!
     455         * If we allow blank spots, we break the array. If we have more than
     456         * 128 partitions in the array and then remove something from
     457         * the first 128 partitions, we would forget to write the last one.*/
     458        memset(label->parts->part_array + idx, 0, sizeof(gpt_entry_t));
     459       
     460        label->parts->fill -= 1;
     461       
     462        /* FIXME!
     463         * We cannot reduce the array so simply. We may have some partitions
     464         * there since we allow blank spots.*/
    426465        if (label->parts->fill < (label->parts->arr_size / 2) - GPT_IGNORE_FILL_NUM) {
    427466                if (reduce_part_array(label->parts) == ENOMEM)
     
    448487{
    449488        size_t i;
     489       
    450490        for (i = 0; gpt_ptypes[i].guid != NULL; i++) {
    451                 if (bcmp(p->part_type, gpt_ptypes[i].guid, 16) == 0) {
    452                         break;
    453                 }
    454         }
     491                if (p->part_type[3] == get_byte(gpt_ptypes[i].guid +0) &&
     492                        p->part_type[2] == get_byte(gpt_ptypes[i].guid +2) &&
     493                        p->part_type[1] == get_byte(gpt_ptypes[i].guid +4) &&
     494                        p->part_type[0] == get_byte(gpt_ptypes[i].guid +6) &&
     495                       
     496                        p->part_type[5] == get_byte(gpt_ptypes[i].guid +8) &&
     497                        p->part_type[4] == get_byte(gpt_ptypes[i].guid +10) &&
     498                       
     499                        p->part_type[7] == get_byte(gpt_ptypes[i].guid +12) &&
     500                        p->part_type[6] == get_byte(gpt_ptypes[i].guid +14) &&
     501                       
     502                        p->part_type[8] == get_byte(gpt_ptypes[i].guid +16) &&
     503                        p->part_type[9] == get_byte(gpt_ptypes[i].guid +18) &&
     504                        p->part_type[10] == get_byte(gpt_ptypes[i].guid +20) &&
     505                        p->part_type[11] == get_byte(gpt_ptypes[i].guid +22) &&
     506                        p->part_type[12] == get_byte(gpt_ptypes[i].guid +24) &&
     507                        p->part_type[13] == get_byte(gpt_ptypes[i].guid +26) &&
     508                        p->part_type[14] == get_byte(gpt_ptypes[i].guid +28) &&
     509                        p->part_type[15] == get_byte(gpt_ptypes[i].guid +30))
     510                                break;
     511        }
     512       
    455513        return i;
    456514}
     
    516574
    517575/** Copy partition name */
    518 void gpt_set_part_name(gpt_part_t * p, char * name[], size_t length)
     576void gpt_set_part_name(gpt_part_t *p, char *name, size_t length)
    519577{
    520578        if (length >= 72)
     
    645703}
    646704
    647 
    648 
    649 
    650 
    651 
     705static uint8_t get_byte(const char * c)
     706{
     707        uint8_t val = 0;
     708        char hex[3] = {*c, *(c+1), 0};
     709       
     710        errno = str_uint8_t(hex, NULL, 16, false, &val);
     711        return val;
     712}
     713
     714
     715
     716
  • uspace/lib/gpt/libgpt.h

    r44c4886 r52f2c89  
    5252/** How much fill we ignore before resizing partition array */
    5353#define GPT_IGNORE_FILL_NUM 10
     54
     55/** Unused partition entry */
     56#define GPT_PTE_UNUSED 0
    5457
    5558/** GPT header signature ("EFI PART" in ASCII) */
     
    149152extern gpt_part_t *    gpt_alloc_partition (void);
    150153extern gpt_part_t *    gpt_get_partition   (gpt_label_t *);
     154extern gpt_part_t *    gpt_get_partition_at(gpt_label_t *, size_t);
    151155extern int             gpt_add_partition   (gpt_label_t *, gpt_part_t *);
    152156extern int             gpt_remove_partition(gpt_label_t *, size_t);
     
    159163extern uint64_t        gpt_get_end_lba  (gpt_part_t *);
    160164extern unsigned char * gpt_get_part_name(gpt_part_t *);
    161 extern void            gpt_set_part_name(gpt_part_t *, char *[], size_t);
     165extern void            gpt_set_part_name(gpt_part_t *, char *, size_t);
    162166extern bool            gpt_get_flag     (gpt_part_t *, GPT_ATTR);
    163167extern void            gpt_set_flag     (gpt_part_t *, GPT_ATTR, bool);
     
    165169
    166170
    167 #define gpt_part_foreach(parts, iterator) \
    168                 for(gpt_part_t * iterator = (parts)->part_array; \
    169                     iterator < (parts)->part_array + (parts)->fill; ++iterator)
     171#define gpt_part_foreach(label, iterator) \
     172                for(gpt_part_t * iterator = (label)->parts->part_array; \
     173                    iterator < (label)->parts->part_array + (label)->parts->fill; ++iterator)
    170174
    171175extern void gpt_free_gpt(gpt_t *);
Note: See TracChangeset for help on using the changeset viewer.