Changeset 8c95dff in mainline for uspace/app/hdisk/func_mbr.c


Ignore:
Timestamp:
2013-11-30T17:49:09Z (11 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

File:
1 edited

Legend:

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