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


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

File:
1 edited

Legend:

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