Changeset 8c95dff in mainline


Ignore:
Timestamp:
2013-11-30T17:49:09Z (10 years ago)
Author:
Dominik Taborsky (AT DOT) <brembyseznamcz>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f4a47e52
Parents:
802898f
Message:

various bugfixes

Location:
uspace
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/hdisk/common.h

    r802898f r8c95dff  
    5454struct label {
    5555        layouts_t layout;
     56        aoff64_t nblocks;
     57        service_id_t device;
    5658        union label_data data;
    5759        unsigned int alignment;
     
    6163        int (* new_label)    (label_t *);
    6264        int (* print_parts)  (label_t *);
    63         int (* read_parts)   (label_t *, service_id_t);
    64         int (* write_parts)  (label_t *, service_id_t);
    65         int (* extra_funcs)  (label_t *, tinput_t *, service_id_t);
     65        int (* read_parts)   (label_t *);
     66        int (* write_parts)  (label_t *);
     67        int (* extra_funcs)  (label_t *, tinput_t *);
    6668};
    6769
  • uspace/app/hdisk/func_gpt.c

    r802898f r8c95dff  
    4343#include "input.h"
    4444
    45 static int set_gpt_partition(tinput_t *, gpt_part_t *, unsigned int);
     45static void print_part_types(void);
     46static int set_gpt_partition(tinput_t *, gpt_part_t *, label_t *);
    4647
    4748int construct_gpt_label(label_t *this)
     
    6970        }
    7071       
    71         return set_gpt_partition(in, p, this->alignment);
     72        return set_gpt_partition(in, p, this);
    7273}
    7374
     
    106107int print_gpt_parts(label_t *this)
    107108{
    108         printf("Current partition scheme (GPT):\n");
     109        printf("Current partition scheme (GPT)(number of blocks: %" PRIu64 "):\n", this->nblocks);
    109110        printf("%15s %10s %10s Type: Name:\n", "Start:", "End:", "Length:");
    110111       
     
    131132}
    132133
    133 int read_gpt_parts(label_t *this, service_id_t dev_handle)
    134 {
    135         int rc;
    136        
    137         rc = gpt_read_header(this->data.gpt, dev_handle);
     134int read_gpt_parts(label_t *this)
     135{
     136        int rc;
     137       
     138        rc = gpt_read_header(this->data.gpt, this->device);
    138139        if (rc != EOK) {
    139140                printf("Error: Reading header failed: %d (%s)\n", rc, str_error(rc));
     
    150151}
    151152
    152 int write_gpt_parts(label_t *this, service_id_t dev_handle)
    153 {
    154         int rc;
    155        
    156         rc = gpt_write_partitions(this->data.gpt, dev_handle);
     153int write_gpt_parts(label_t *this)
     154{
     155        int rc;
     156        printf("test1\n");
     157        rc = gpt_write_partitions(this->data.gpt, this->device);
    157158        if (rc != EOK) {
    158159                printf("Error: Writing partitions failed: %d (%s)\n", rc, str_error(rc));
    159160                return rc;
    160161        }
    161        
    162         rc = gpt_write_header(this->data.gpt, dev_handle);
    163         if (rc != EOK) {
    164                 printf("Error: Writing header failed: %d (%s)\n", rc, str_error(rc));
    165                 return rc;
    166         }
    167        
    168         return EOK;
    169 }
    170 
    171 int extra_gpt_funcs(label_t *this, tinput_t *in, service_id_t dev_handle)
     162        printf("test2\n");
     163        return EOK;
     164}
     165
     166int extra_gpt_funcs(label_t *this, tinput_t *in)
    172167{
    173168        printf("Not implemented.\n");
     
    175170}
    176171
    177 static int set_gpt_partition(tinput_t *in, gpt_part_t *p, unsigned int alignment)
     172static int set_gpt_partition(tinput_t *in, gpt_part_t *p, label_t * this)
    178173{
    179174        int rc;
     
    181176        uint64_t sa, ea;
    182177       
    183         printf("Set starting address (number): ");
     178        printf("Set starting address: ");
    184179        sa = get_input_uint64(in);
    185         if (sa % alignment != 0)
    186                 sa = gpt_get_next_aligned(sa, alignment);
    187        
    188         printf("Set end address (number): ");
     180        if (this->alignment != 0 && this->alignment != 1 && sa % this->alignment != 0)
     181                sa = gpt_get_next_aligned(sa, this->alignment);
     182       
     183        printf("Set end address (max: %" PRIu64 "): ", this->nblocks);
    189184        ea = get_input_uint64(in);
    190185       
     
    198193       
    199194        /* See global.c from libgpt for all partition types. */
     195        printf("Choose type: ");
     196        print_part_types();
    200197        printf("Set type (1 for HelenOS System): ");
    201198        size_t idx = get_input_size_t(in);
    202199        gpt_set_part_type(p, idx);
    203200       
    204         gpt_set_random_uuid(p->part_type);
    205201        gpt_set_random_uuid(p->part_id);
    206202       
     
    218214}
    219215
     216static void print_part_types(void)
     217{
     218        int c;
     219        int count = 0;
     220        const struct partition_type * ptype = gpt_ptypes;
     221       
     222        do {
     223                if (count % 10 == 0) {
     224                        printf("Print (more) partition types? (y/n)\n");
     225                        c = getchar();
     226                        if (c == 'n')
     227                                return;
     228                }
     229               
     230                printf("%d: %s\n", count, ptype->desc);
     231                ++count;
     232                ++ptype;
     233        } while (ptype->guid != NULL);
     234}
     235
  • uspace/app/hdisk/func_gpt.h

    r802898f r8c95dff  
    4848extern int new_gpt_label    (label_t *);
    4949extern int print_gpt_parts  (label_t *);
    50 extern int read_gpt_parts   (label_t *, service_id_t);
    51 extern int write_gpt_parts  (label_t *, service_id_t);
    52 extern int extra_gpt_funcs  (label_t *, tinput_t *, service_id_t);
     50extern int read_gpt_parts   (label_t *);
     51extern int write_gpt_parts  (label_t *);
     52extern int extra_gpt_funcs  (label_t *, tinput_t *);
    5353
    5454#endif
  • uspace/app/hdisk/func_mbr.c

    r802898f r8c95dff  
    4141#include "input.h"
    4242
    43 static int set_mbr_partition(tinput_t *in, mbr_part_t *p, unsigned int alignment);
     43static int set_mbr_partition(tinput_t *, mbr_part_t *, label_t *);
    4444
    4545int construct_mbr_label(label_t *this)
     
    6666        mbr_part_t *part = mbr_alloc_partition();
    6767       
    68         set_mbr_partition(in, part, this->alignment);
     68        rc = set_mbr_partition(in, part, this);
     69        if (rc != EOK)
     70                return rc;
    6971       
    7072        rc = mbr_add_partition(this->data.mbr, part);
     
    8991        rc = mbr_remove_partition(this->data.mbr, idx);
    9092        if (rc != EOK) {
    91                 printf("Error: something.\n");
     93                printf("Error: partition does not exist?\n");
    9294        }
    9395       
     
    106108        if (this->data.mbr == NULL)
    107109                return ENOMEM;
    108         else
    109                 return EOK;
     110       
     111        mbr_set_device(this->data.mbr, this->device);
     112        return EOK;
    110113}
    111114
     
    115118        int num = 0;
    116119       
    117         printf("Current partition scheme (MBR):\n");
     120        printf("Current partition scheme (MBR)(number of blocks: %" PRIu64 "):\n", this->nblocks);
    118121        printf("\t\t%10s  %10s %10s %10s %7s\n", "Bootable:", "Start:", "End:", "Length:", "Type:");
    119122       
     
    121124       
    122125        for (it = mbr_get_first_partition(this->data.mbr); it != NULL;
    123              it = mbr_get_next_partition(this->data.mbr, it), ++num) {
     126             it = mbr_get_next_partition(this->data.mbr, it)) {
    124127                if (it->type == PT_UNUSED)
    125128                        continue;
     
    133136                printf("\t%10u %10u %10u %7u\n", it->start_addr, it->start_addr + it->length, it->length, it->type);
    134137               
     138                num++;
    135139        }
    136140       
     
    140144}
    141145
    142 int read_mbr_parts(label_t *this, service_id_t dev_handle)
     146int read_mbr_parts(label_t *this)
    143147{
    144148        int rc;
    145         rc = mbr_read_mbr(this->data.mbr, dev_handle);
     149        rc = mbr_read_mbr(this->data.mbr, this->device);
    146150        if (rc != EOK)
    147151                return rc;
     
    157161}
    158162
    159 int write_mbr_parts(label_t *this, service_id_t dev_handle)
    160 {
    161         int rc = mbr_write_partitions(this->data.mbr, dev_handle);
     163int write_mbr_parts(label_t *this)
     164{
     165        int rc = mbr_write_partitions(this->data.mbr, this->device);
    162166        if (rc != EOK) {
    163167                printf("Error occured during writing: ERR: %d: %s\n", rc, str_error(rc));
     
    167171}
    168172
    169 int extra_mbr_funcs(label_t *this, tinput_t *in, service_id_t dev_handle)
     173int extra_mbr_funcs(label_t *this, tinput_t *in)
    170174{
    171175        printf("Not implemented.\n");
     
    173177}
    174178
    175 static int set_mbr_partition(tinput_t *in, mbr_part_t *p, unsigned int alignment)
     179static int set_mbr_partition(tinput_t *in, mbr_part_t *p, label_t * this)
    176180{
    177181        int c;
     
    214218        uint32_t sa, ea;
    215219
    216         printf("Set starting address (number): ");
     220        printf("Set starting address: ");
    217221        sa = get_input_uint32(in);
    218222        if (sa == 0 && errno != EOK)
    219223                return errno;
    220224       
    221         if (alignment != 0 && alignment != 1) {
    222                 sa = mbr_get_next_aligned(sa, alignment);
     225        if (this->alignment != 0 && this->alignment != 1 && sa % this->alignment != 0) {
     226                sa = mbr_get_next_aligned(sa, this->alignment);
    223227                printf("Starting address was aligned to %u.\n", sa);
    224228        }
    225 
    226         printf("Set end addres (number): ");
     229       
     230        printf("Set end addres (max: %" PRIu64 "): ", this->nblocks);
    227231        ea = get_input_uint32(in);
    228232        if (ea == 0 && errno != EOK)
     
    233237                return EINVAL;
    234238        }
    235 
     239       
    236240        p->type = type;
    237241        p->start_addr = sa;
  • uspace/app/hdisk/func_mbr.h

    r802898f r8c95dff  
    4848extern int new_mbr_label    (label_t *);
    4949extern int print_mbr_parts  (label_t *);
    50 extern int read_mbr_parts   (label_t *, service_id_t);
    51 extern int write_mbr_parts  (label_t *, service_id_t);
    52 extern int extra_mbr_funcs  (label_t *, tinput_t *, service_id_t);
     50extern int read_mbr_parts   (label_t *);
     51extern int write_mbr_parts  (label_t *);
     52extern int extra_mbr_funcs  (label_t *, tinput_t *);
    5353
    5454#endif
  • uspace/app/hdisk/func_none.c

    r802898f r8c95dff  
    8686}
    8787
    88 int read_none_parts(label_t *this, service_id_t dev_handle)
     88int read_none_parts(label_t *this)
    8989{
    9090        not_implemented();
     
    9292}
    9393
    94 int write_none_parts(label_t *this, service_id_t dev_handle)
     94int write_none_parts(label_t *this)
    9595{
    9696        not_implemented();
     
    9898}
    9999
    100 int extra_none_funcs(label_t *this, tinput_t * in, service_id_t dev_handle)
     100int extra_none_funcs(label_t *this, tinput_t * in)
    101101{
    102102        not_implemented();
  • uspace/app/hdisk/func_none.h

    r802898f r8c95dff  
    4747extern int new_none_label    (label_t *);
    4848extern int print_none_parts  (label_t *);
    49 extern int read_none_parts   (label_t *, service_id_t);
    50 extern int write_none_parts  (label_t *, service_id_t);
    51 extern int extra_none_funcs  (label_t *, tinput_t *, service_id_t);
     49extern int read_none_parts   (label_t *);
     50extern int write_none_parts  (label_t *);
     51extern int extra_none_funcs  (label_t *, tinput_t *);
    5252
    5353#endif
  • uspace/app/hdisk/hdisk.c

    r802898f r8c95dff  
    4646#include <libgpt.h>
    4747#include <tinput.h>
     48#include <str_error.h>
    4849
    4950#include "hdisk.h"
     
    5354#include "func_none.h"
    5455
    55 int interact(service_id_t);
     56int interact(void);
    5657void print_help(void);
    5758void select_label_format(tinput_t *);
    5859void construct_label(layouts_t);
    5960void free_label(void);
    60 int try_read(service_id_t);
    61 int try_read_mbr(service_id_t);
    62 int try_read_gpt(service_id_t);
     61int try_read(void);
     62int try_read_mbr(void);
     63int try_read_gpt(void);
    6364void set_alignment(tinput_t *);
    6465
     
    8384       
    8485        init_label();
    85        
    86         rc = try_read_mbr(dev_handle);
     86        label.device = dev_handle;
     87       
     88        rc = block_init(EXCHANGE_ATOMIC, dev_handle, 512);
     89        if (rc != EOK) {
     90                printf("Error during libblock init: %d - %s.\n", rc, str_error(rc));
     91                return -1;
     92        }
     93       
     94        aoff64_t nblocks;
     95        rc = block_get_nblocks(dev_handle, &nblocks);
     96        block_fini(dev_handle);
     97        if (rc != EOK) {
     98                printf(LIBMBR_NAME ": Error while getting number of blocks: %d - %s.\n", rc, str_error(rc));
     99                return -1;
     100        }
     101       
     102        label.nblocks = nblocks;
     103       
     104        rc = try_read_mbr();
    87105        if (rc == EOK)
    88106                goto interact;
    89107       
    90         rc = try_read_gpt(dev_handle);
     108        free_label();
     109       
     110        rc = try_read_gpt();
    91111        if (rc == EOK)
    92112                goto interact;
    93113       
    94114        printf("No label recognized. Create a new one.\n");
    95         label.layout = LYT_NONE;
     115        construct_label(LYT_NONE);
    96116       
    97117interact:
    98118       
    99         rc = interact(dev_handle);
     119        rc = interact();
    100120       
    101121        return rc;
     
    103123
    104124/** Interact with user */
    105 int interact(service_id_t dev_handle)
     125int interact()
    106126{
    107127        int input;
     
    130150                        break;
    131151                case 'e':
    132                         label.extra_funcs(&label, in, dev_handle);
     152                        label.extra_funcs(&label, in);
    133153                        break;
    134154                case 'f':
     155                        free_label();
    135156                        select_label_format(in);
    136157                        break;
     
    154175                        goto end;
    155176                case 'r':
    156                         label.read_parts(&label, dev_handle);
     177                        label.read_parts(&label);
    157178                case 'w':
    158                         label.write_parts(&label, dev_handle);
     179                        label.write_parts(&label);
    159180                        break;
    160181                default:
     
    197218        uint8_t val = get_input_uint8(in);
    198219        switch (val) {
    199         case 0:
    200                 free_label();
     220        case 1:
     221                construct_label(LYT_MBR);
     222                break;
     223        case 2:
     224                construct_label(LYT_GPT);
     225                break;
     226        default:
    201227                construct_label(LYT_NONE);
    202                 break;
    203         case 1:
    204                 free_label();
    205                 construct_label(LYT_MBR);
    206                 break;
    207         case 2:
    208                 free_label();
    209                 construct_label(LYT_GPT);
    210228                break;
    211229        }
     
    235253}
    236254
    237 int try_read(service_id_t dev_handle)
    238 {
    239         return label.read_parts(&label, dev_handle);
    240 }
    241 
    242 int try_read_mbr(service_id_t dev_handle)
     255int try_read()
     256{
     257       
     258        return label.read_parts(&label);
     259}
     260
     261int try_read_mbr()
    243262{
    244263        construct_label(LYT_MBR);
    245         return try_read(dev_handle);
    246 }
    247 
    248 int try_read_gpt(service_id_t dev_handle)
     264        return try_read();
     265}
     266
     267int try_read_gpt()
    249268{
    250269        construct_label(LYT_GPT);
    251         return try_read(dev_handle);
     270        return try_read();
    252271}
    253272
  • uspace/lib/gpt/Makefile

    r802898f r8c95dff  
    2828
    2929USPACE_PREFIX = ../..
    30 EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX)
     30EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I$(LIBMBR_PREFIX)
    3131LIBRARY = libgpt
    3232
  • uspace/lib/gpt/global.c

    r802898f r8c95dff  
    4040};
    4141
     42const uint8_t revision[4] = {
     43        00, 00, 01, 00
     44};
     45
    4246const struct partition_type gpt_ptypes[] = {
    4347        { "Unused entry",                                       "00000000" "0000" "0000" "0000000000000000" }, /* 0 */
     
    5559        { "HP-UX Data",                                         "75894C1E" "3AEB" "11D3" "B7C17B03A0000000" },
    5660        { "HP-UX Service",                                      "E2A1E728" "32E3" "11D6" "A6827B03A0000000" },
    57         { "Linux filesystem data",                      "EBD0A0A2" "B9E5" "4433" "87C068B6B72699C7" },
    5861        { "Linux filesystem data",                      "0FC63DAF" "8483" "4772" "8E793D69D8477DE4" },
    5962        { "Linux RAID",                                         "A19D880F" "05FC" "4D3B" "A006743F0F84911E" },
    6063        { "Linux Swap",                                         "0657FD6D" "A4AB" "43C4" "84E50933C84B4F4F" },
    6164        { "Linux LVM",                                          "E6D6D379" "F507" "44C2" "A23C238F2A3DF928" },
     65        { "Linux filesystem data",                      "933AC7E1" "2EB4" "4F13" "B8440E14E2AEF915" },
    6266        { "Linux Reserved",                                     "8DA63339" "0007" "60C0" "C436083AC8230908" },
    6367        { "FreeBSD Boot",                                       "83BD6B9D" "7F41" "11DC" "BE0B001560B84F0F" }, /* 20 */
  • uspace/lib/gpt/gpt.h

    r802898f r8c95dff  
    5050typedef struct {
    5151        uint8_t  efi_signature[8];
    52         uint32_t revision;
     52        uint8_t  revision[4];
    5353        uint32_t header_size;
    5454        uint32_t header_crc32;
  • uspace/lib/gpt/libgpt.c

    r802898f r8c95dff  
    4949#include <mem.h>
    5050#include <sys/typefmt.h>
     51#include <mbr.h>
    5152
    5253
     
    112113        }
    113114       
     115        /* Enter some sane defaults. */
    114116        memset(gpt->header, 0, final_size);
     117        memcpy(gpt->header->efi_signature, efi_signature, 8);
     118        memcpy(gpt->header->revision, revision, 4);
     119        gpt->header->header_size = host2uint32_t_le(final_size);
     120        gpt->header->entry_lba = host2uint64_t_le((uint64_t) 2);
     121        gpt->header->entry_size = host2uint32_t_le(sizeof(gpt_entry_t));
     122       
    115123       
    116124        return gpt;
     
    207215        uint64_t tmp;
    208216       
     217        gpt_set_random_uuid(label->gpt->header->disk_guid);
     218       
    209219        /* Prepare the backup header */
    210220        label->gpt->header->alternate_lba = label->gpt->header->my_lba;
     
    243253        /* Write to main GPT header location */
    244254        rc = block_write_direct(dev_handle, GPT_HDR_BA, GPT_HDR_BS, label->gpt->header);
     255        if (rc != EOK)
     256                return rc;
     257       
     258        /* Write Protective MBR */
     259        br_block_t mbr;
     260        memset(&mbr, 0, 512);
     261        memset(mbr.pte[0].first_chs, 1, 3);
     262        mbr.pte[0].ptype = 0xEE;
     263        memset(mbr.pte[0].last_chs, 0xFF, 3);
     264        mbr.pte[0].first_lba = host2uint32_t_le(1);
     265        mbr.pte[0].length = 0xFFFFFFFF;
     266        mbr.signature = host2uint16_t_le(BR_SIGNATURE);
     267       
     268        rc = block_write_direct(dev_handle, 0, 1, &mbr);
    245269        block_fini(dev_handle);
    246270        if (rc != EOK)
    247271                return rc;
    248        
    249272       
    250273        return 0;
     
    343366        int rc;
    344367        size_t b_size;
    345         uint32_t e_size = uint32_t_le2host(label->gpt->header->entry_size);
    346         size_t fillries = label->parts->fill > GPT_MIN_PART_NUM ? label->parts->fill : GPT_MIN_PART_NUM;
    347        
    348         if (e_size != sizeof(gpt_entry_t))
    349                 return ENOTSUP;
    350368       
    351369        /* comm_size of 4096 is ignored */
     
    363381                goto fail;
    364382       
     383        /* When we're creating a new label from scratch, we need to fill
     384         * the header with sensible defaults. */
     385        if (label->gpt == NULL) {
     386                label->gpt = gpt_alloc_header(b_size);
     387        }
     388       
     389        printf("test1.0\n");
     390        uint32_t e_size = uint32_t_le2host(label->gpt->header->entry_size);
     391        printf("test1.025\n");
     392        size_t fillries = label->parts->fill > GPT_MIN_PART_NUM ? label->parts->fill : GPT_MIN_PART_NUM;
     393        printf("test1.05\n");
     394        if (e_size != sizeof(gpt_entry_t))
     395                return ENOTSUP;
     396
    365397        label->gpt->header->fillries = host2uint32_t_le(fillries);
    366398        uint64_t arr_blocks = (fillries * sizeof(gpt_entry_t)) / b_size;
     
    368400        label->gpt->header->first_usable_lba = host2uint64_t_le(gpt_space);
    369401        label->gpt->header->last_usable_lba = host2uint64_t_le(n_blocks - gpt_space - 1);
    370        
     402        printf("test1.5\n");
    371403        /* Perform checks */
    372404        gpt_part_foreach (label, p) {
     
    395427                }
    396428        }
    397        
     429        printf("test1.6\n");
    398430        label->gpt->header->pe_array_crc32 = host2uint32_t_le(compute_crc32(
    399431                                       (uint8_t *) label->parts->part_array,
    400432                                       fillries * e_size));
    401433       
    402        
     434        printf("test1.7\n");
    403435        /* Write to backup GPT partition array location */
    404436        rc = block_write_direct(dev_handle, n_blocks - arr_blocks - 1,
     
    406438        if (rc != EOK)
    407439                goto fail;
    408        
     440        printf("test1.8\n");
    409441        /* Write to main GPT partition array location */
    410442        rc = block_write_direct(dev_handle, uint64_t_le2host(label->gpt->header->entry_lba),
     
    412444        if (rc != EOK)
    413445                goto fail;
    414        
     446        printf("test1.9\n");
    415447        return gpt_write_header(label, dev_handle);
    416448       
     
    594626       
    595627        for (i = 0; gpt_ptypes[i].guid != NULL; i++) {
     628                //printf("%x =?= %x\n", p->part_type[3], get_byte(gpt_ptypes[i].guid +0));
     629                //printf("%x =?= %x\n", p->part_type[2], get_byte(gpt_ptypes[i].guid +2));
     630                //printf("%x =?= %x\n", p->part_type[1], get_byte(gpt_ptypes[i].guid +4));
     631                //printf("%x =?= %x\n", p->part_type[0], get_byte(gpt_ptypes[i].guid +6));
     632                //getchar();
    596633                if (p->part_type[3] == get_byte(gpt_ptypes[i].guid +0) &&
    597634                        p->part_type[2] == get_byte(gpt_ptypes[i].guid +2) &&
     
    627664{
    628665        /* Beware: first 3 blocks are byteswapped! */
    629         p->part_type[3] = gpt_ptypes[type].guid[0];
    630         p->part_type[2] = gpt_ptypes[type].guid[1];
    631         p->part_type[1] = gpt_ptypes[type].guid[2];
    632         p->part_type[0] = gpt_ptypes[type].guid[3];
    633 
    634         p->part_type[5] = gpt_ptypes[type].guid[4];
    635         p->part_type[4] = gpt_ptypes[type].guid[5];
    636 
    637         p->part_type[7] = gpt_ptypes[type].guid[6];
    638         p->part_type[6] = gpt_ptypes[type].guid[7];
    639 
    640         p->part_type[8] = gpt_ptypes[type].guid[8];
    641         p->part_type[9] = gpt_ptypes[type].guid[9];
    642         p->part_type[10] = gpt_ptypes[type].guid[10];
    643         p->part_type[11] = gpt_ptypes[type].guid[11];
    644         p->part_type[12] = gpt_ptypes[type].guid[12];
    645         p->part_type[13] = gpt_ptypes[type].guid[13];
    646         p->part_type[14] = gpt_ptypes[type].guid[14];
    647         p->part_type[15] = gpt_ptypes[type].guid[15];
     666        p->part_type[3] = get_byte(gpt_ptypes[type].guid +0);
     667        p->part_type[2] = get_byte(gpt_ptypes[type].guid +2);
     668        p->part_type[1] = get_byte(gpt_ptypes[type].guid +4);
     669        p->part_type[0] = get_byte(gpt_ptypes[type].guid +6);
     670                       
     671        p->part_type[5] = get_byte(gpt_ptypes[type].guid +8);
     672        p->part_type[4] = get_byte(gpt_ptypes[type].guid +10);
     673                       
     674        p->part_type[7] = get_byte(gpt_ptypes[type].guid +12);
     675        p->part_type[6] = get_byte(gpt_ptypes[type].guid +14);
     676                       
     677        p->part_type[8] = get_byte(gpt_ptypes[type].guid +16);
     678        p->part_type[9] = get_byte(gpt_ptypes[type].guid +18);
     679        p->part_type[10] = get_byte(gpt_ptypes[type].guid +20);
     680        p->part_type[11] = get_byte(gpt_ptypes[type].guid +22);
     681        p->part_type[12] = get_byte(gpt_ptypes[type].guid +24);
     682        p->part_type[13] = get_byte(gpt_ptypes[type].guid +26);
     683        p->part_type[14] = get_byte(gpt_ptypes[type].guid +28);
     684        p->part_type[15] = get_byte(gpt_ptypes[type].guid +30);
    648685}
    649686
  • uspace/lib/gpt/libgpt.h

    r802898f r8c95dff  
    6060/** GPT header signature ("EFI PART" in ASCII) */
    6161extern const uint8_t efi_signature[8];
     62extern const uint8_t revision[4];
    6263
    6364typedef struct {
  • uspace/lib/mbr/libmbr.c

    r802898f r8c95dff  
    7070}
    7171
     72void mbr_set_device(mbr_label_t *label, service_id_t dev_handle)
     73{
     74        label->device = dev_handle;
     75}
     76
    7277/** Free mbr_label_t structure */
    7378void mbr_free_label(mbr_label_t *label)
     
    253258        }
    254259       
     260        label->mbr->raw_data.signature = host2uint16_t_le(BR_SIGNATURE);
     261       
    255262        /* Writing MBR */
    256263        rc = block_write_direct(dev_handle, 0, 1, &(label->mbr->raw_data));
     
    271278         * and implementation. If you don't have to change it, don't. Other
    272279         * designs have been tried, this came out as the least horror with
    273          * as much power over it as you can get. Thanks. */
     280         * as much power over it as you can get. */
    274281       
    275282        /* Encoding and writing first logical partition */
  • uspace/lib/mbr/libmbr.h

    r802898f r8c95dff  
    120120/* Alloc complete label structure */
    121121extern mbr_label_t * mbr_alloc_label(void);
     122extern void mbr_set_device(mbr_label_t *, service_id_t);
    122123
    123124/* Read/Write MBR header.
Note: See TracChangeset for help on using the changeset viewer.