Changeset 283ea3d in mainline for uspace/app/hdisk/func_gpt.c


Ignore:
Timestamp:
2013-07-28T22:52:16Z (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:
e3bc355
Parents:
8559fa0 (diff), 675de6d (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:

libmbr, libgpt and hdisk fixes and polishing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/hdisk/func_gpt.c

    r8559fa0 r283ea3d  
    4242#include "input.h"
    4343
    44 static int set_gpt_partition(tinput_t *, gpt_part_t *);
    45 
     44static int set_gpt_partition(tinput_t *, gpt_part_t *, unsigned int);
    4645
    4746int construct_gpt_label(label_t *this)
     
    5049        this->alignment = 1;
    5150       
    52         this->add_part    = add_gpt_part;
    53         this->delete_part = delete_gpt_part;
    54         this->new_label   = new_gpt_label;
    55         this->print_parts = print_gpt_parts;
    56         this->read_parts  = read_gpt_parts;
    57         this->write_parts = write_gpt_parts;
    58         this->extra_funcs = extra_gpt_funcs;
     51        this->add_part      = add_gpt_part;
     52        this->delete_part   = delete_gpt_part;
     53        this->destroy_label = destroy_gpt_label;
     54        this->new_label     = new_gpt_label;
     55        this->print_parts   = print_gpt_parts;
     56        this->read_parts    = read_gpt_parts;
     57        this->write_parts   = write_gpt_parts;
     58        this->extra_funcs   = extra_gpt_funcs;
    5959       
    6060        return this->new_label(this);
     
    6868        }
    6969       
    70         return set_gpt_partition(in, p);
     70        return set_gpt_partition(in, p, this->alignment);
    7171}
    7272
     
    8080       
    8181        rc = gpt_remove_partition(this->data.gpt, idx);
    82         if (rc != EOK) {
     82        if (rc == ENOMEM) {
    8383                printf("Warning: running low on memory, not resizing...\n");
    8484                return rc;
     85        } else if (rc == EINVAL) {
     86                printf("Invalid index.\n");
     87                return rc;
    8588        }
    8689       
     
    102105int print_gpt_parts(label_t *this)
    103106{
    104         //int rc;
    105107        printf("Current partition scheme (GPT):\n");
    106         printf("\t\tStart:\tEnd:\tLength:\tType:\tName:\n");
     108        printf("%15s %10s %10s Type: Name:\n", "Start:", "End:", "Length:");
    107109       
    108110        size_t i = 0;
     
    110112        gpt_part_foreach(this->data.gpt, iter) {
    111113                i++;
    112                 //FIXMEE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     114               
    113115                if (gpt_get_part_type(iter) == GPT_PTE_UNUSED)
    114116                        continue;
     
    117119                        printf("%15s %10s %10s Type: Name:\n", "Start:", "End:", "Length:");
    118120               
    119                 //printf("\t%10u %10u %10u %3d\n", iter->start_addr, iter->start_addr + iter->length,
    120                 //              iter->length, gpt_get_part_type(iter), gpt_get_part_name(iter));
     121               
    121122                printf("%3u  %10llu %10llu %10llu    %3d %s\n", i-1, gpt_get_start_lba(iter), gpt_get_end_lba(iter),
    122123                                gpt_get_end_lba(iter) - gpt_get_start_lba(iter), gpt_get_part_type(iter),
    123124                                gpt_get_part_name(iter));
    124         }
    125        
    126         //return rc;
     125               
     126        }
     127       
    127128        return EOK;
    128129}
     
    172173}
    173174
    174 static int set_gpt_partition(tinput_t *in, gpt_part_t *p)
     175static int set_gpt_partition(tinput_t *in, gpt_part_t *p, unsigned int alignment)
    175176{
    176177        int rc;
     
    180181        printf("Set starting address (number): ");
    181182        sa = get_input_uint64(in);
     183        if (sa % alignment != 0)
     184                sa = gpt_get_next_aligned(sa, alignment);
    182185       
    183186        printf("Set end addres (number): ");
     
    192195        gpt_set_end_lba(p, ea);
    193196       
     197        //printf("Set type : ");
     198        //size_t idx = get_input_size_t(in);
     199        //gpt_set_part_type(p, idx);
     200       
     201        gpt_set_random_uuid(p->part_type);
     202        gpt_set_random_uuid(p->part_id);
    194203       
    195204        char *name;
     
    201210        }
    202211       
    203         printf("name: %s, len: %d\n", name, str_size(name));
    204212        gpt_set_part_name(p, name, str_size(name));
    205213       
Note: See TracChangeset for help on using the changeset viewer.