Changeset 9bda5d90 in mainline


Ignore:
Timestamp:
2013-05-03T01:20:11Z (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:
469739f, c9f61150, f6c8fca
Parents:
700f89e
Message:

libmbr final

Location:
uspace
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/hdisk/Makefile

    r700f89e r9bda5d90  
    3737SOURCES = \
    3838        hdisk.c \
     39        input.c \
     40        func_none.c \
    3941        func_mbr.c \
    40         func_gpt.c \
    41         input.c
     42        func_gpt.c
    4243
    4344include $(USPACE_PREFIX)/Makefile.common
  • uspace/app/hdisk/func_gpt.c

    r700f89e r9bda5d90  
    7171        data->gpt.gpt = gpt_alloc_gpt_header();
    7272        data->gpt.parts = gpt_alloc_partitions();
     73        return EOK;
    7374}
    7475
     
    115116int extra_gpt_funcs(tinput_t * in, service_id_t dev_handle, union table_data * data)
    116117{
     118        printf("Not implemented.\n");
    117119        return EOK;
    118120}
  • uspace/app/hdisk/func_mbr.c

    r700f89e r9bda5d90  
    6868        printf("Number of the partition to delete (counted from 0): ");
    6969        idx = get_input_size_t(in);
    70 
     70       
     71        if (idx == 0 && errno != EOK)
     72                return errno;
     73       
    7174        rc = mbr_remove_partition(data->mbr.parts, idx);
    7275        if(rc != EOK) {
     
    8184        data->mbr.mbr = mbr_alloc_mbr();
    8285        data->mbr.parts = mbr_alloc_partitions();
     86        return EOK;
    8387}
    8488
     
    103107                        printf(" ");
    104108
    105                 printf("\t%10u %10u %10u %7x\n", it->start_addr, it->start_addr + it->length, it->length, it->type);
     109                printf("\t%10u %10u %10u %7u\n", it->start_addr, it->start_addr + it->length, it->length, it->type);
    106110
    107111                ++num;
     
    109113
    110114        printf("%d partitions found.\n", num);
    111         printf("DEBUG: primary: %hhu, logical: %u\n", data->mbr.parts->n_primary, data->mbr.parts->n_logical);
    112115       
    113116        return EOK;
     
    126129int extra_mbr_funcs(tinput_t * in, service_id_t dev_handle, union table_data * data)
    127130{
     131        printf("Not implemented.\n");
    128132        return EOK;
    129133}
     
    152156        printf("Set type (0-255): ");
    153157        type = get_input_uint8(in);
     158        if (type == 0 && errno != EOK)
     159                return errno;
    154160
    155161        ///TODO: there can only be one bootable partition; let's do it just like fdisk
     
    168174        printf("Set starting address (number): ");
    169175        sa = get_input_uint32(in);
     176        if (sa == 0 && errno != EOK)
     177                return errno;
    170178
    171179        printf("Set end addres (number): ");
    172180        ea = get_input_uint32(in);
     181        if (ea == 0 && errno != EOK)
     182                return errno;
    173183       
    174184        if(ea < sa) {
  • uspace/app/hdisk/func_none.c

    r700f89e r9bda5d90  
    3434
    3535
    36 #include <loc.h>
    37 #include <tinput.h>
    38 #include <libmbr.h>
     36#include <errno.h>
    3937
    40 #include "common.h"
    4138#include "func_none.h"
    4239
    43 static void not_implemented();
     40static void not_implemented(void);
    4441
    4542int add_none_part(tinput_t * in, union table_data * data)
  • uspace/app/hdisk/func_none.h

    r700f89e r9bda5d90  
    3333 */
    3434
    35 #ifndef __FUNC_MBR_H__
    36 #define __FUNC_MBR_H__
     35#ifndef __FUNC_NONE_H__
     36#define __FUNC_NONE_H__
    3737
    3838#include <loc.h>
    3939#include <tinput.h>
    40 #include <libmbr.h>
    4140
    4241#include "common.h"
  • uspace/app/hdisk/hdisk.c

    r700f89e r9bda5d90  
    4848
    4949#include "hdisk.h"
     50#include "input.h"
     51#include "func_gpt.h"
    5052#include "func_mbr.h"
    51 #include "func_gpt.h"
     53#include "func_none.h"
    5254
    5355int interact(service_id_t dev_handle);
    5456void print_help(void);
    55 void select_table_format(void);
     57void select_table_format(tinput_t * in);
    5658void fill_table_funcs(void);
    5759void free_table(void);
     
    167169                        case 'n':
    168170                                free_table();
    169                                 table.new_table(in);
     171                                table.new_table(in, &table.data);
    170172                                break;
    171173                        case 'p':
  • uspace/app/hdisk/input.c

    r700f89e r9bda5d90  
    6666uint8_t get_input_uint8(tinput_t * in)
    6767{
     68        int rc;
    6869        uint32_t val;
    6970        /*char * str;
     
    8384        free(str);*/
    8485       
    85         convert(in, (conv_f) str_uint8_t, &val);
     86        rc = convert(in, (conv_f) str_uint8_t, &val);
     87        if (rc != EOK) {
     88                errno = rc;
     89                return 0;
     90        }
    8691       
    8792        return val;
     
    9095uint32_t get_input_uint32(tinput_t * in)
    9196{
     97        int rc;
    9298        uint32_t val;
    9399        /*char * str;
     
    107113        free(str);*/
    108114       
    109         convert(in, (conv_f) str_uint32_t, &val);
     115        rc = convert(in, (conv_f) str_uint32_t, &val);
     116        if (rc != EOK) {
     117                errno = rc;
     118                return 0;
     119        }
    110120       
    111121        return val;
     
    114124uint64_t get_input_uint64(tinput_t * in)
    115125{
     126        int rc;
    116127        uint64_t val;
    117128        /*char * str;
     
    131142        free(str);*/
    132143       
    133         convert(in, (conv_f) str_uint64_t, &val);
     144        rc = convert(in, (conv_f) str_uint64_t, &val);
     145        if (rc != EOK) {
     146                errno = rc;
     147                return 0;
     148        }
    134149       
    135150        return val;
     
    141156        size_t val;
    142157       
    143         char * str;
     158        /*char * str;
    144159        rc = get_input_line(in, &str);
    145160        if (rc != EOK) {
     
    153168                return 0;
    154169        }
    155         free(str);
    156         /*
     170        free(str);*/
     171       
    157172        rc = convert(in, (conv_f) str_size_t, &val);
    158173        if (rc != EOK) {
    159                 return -1;
    160         }
    161         */
     174                errno = rc;
     175                return 0;
     176        }
     177       
    162178        errno = EOK;
    163179        return val;
  • uspace/lib/gpt/libgpt.c

    r700f89e r9bda5d90  
    5959
    6060/** Allocate memory for gpt header */
    61 gpt_t * gpt_alloc_gpt_header()
     61gpt_t * gpt_alloc_gpt_header(void)
    6262{
    6363        return malloc(sizeof(gpt_t));
  • uspace/lib/gpt/libgpt.h

    r700f89e r9bda5d90  
    139139
    140140
    141 extern gpt_t * gpt_alloc_gpt_header();
     141extern gpt_t * gpt_alloc_gpt_header(void);
    142142extern gpt_t * gpt_read_gpt_header(service_id_t dev_handle);
    143143extern int gpt_write_gpt_header(gpt_t * header, service_id_t dev_handle);
    144144
    145 extern gpt_partitions_t *       gpt_alloc_partitions();
     145extern gpt_partitions_t *       gpt_alloc_partitions(void);
    146146extern gpt_partitions_t *       gpt_read_partitions     (gpt_t * gpt);
    147147extern int                                      gpt_write_partitions    (gpt_partitions_t * parts, gpt_t * header, service_id_t dev_handle);
  • uspace/lib/mbr/libmbr.c

    r700f89e r9bda5d90  
    5454
    5555/** Allocate memory for mbr_t */
    56 mbr_t * mbr_alloc_mbr()
    57 {
    58         return alloc_br();
     56mbr_t * mbr_alloc_mbr(void)
     57{
     58        return malloc(sizeof(mbr_t));
    5959}
    6060
     
    405405               
    406406                // if it's extended, is there any other one?
    407                 if (p->type == PT_EXTENDED && parts->l_extended != NULL) {
     407                if ((p->type == PT_EXTENDED || p->type == PT_EXTENDED_LBA) && parts->l_extended != NULL) {
    408408                        return ERR_EXTENDED_PRESENT;
    409409                }
     
    425425                }
    426426                parts->n_primary += 1;
     427               
     428                if (p->type == PT_EXTENDED || p->type == PT_EXTENDED_LBA)
     429                        parts->l_extended = &(p->link);
    427430        }
    428431
  • uspace/lib/mbr/libmbr.h

    r700f89e r9bda5d90  
    188188 * then partitions. The MBR headers' raw_data is NOT updated to follow
    189189 * partition changes. */
    190 extern mbr_t * mbr_alloc_mbr();
     190extern mbr_t * mbr_alloc_mbr(void);
    191191extern mbr_t * mbr_read_mbr(service_id_t dev_handle);
    192192extern int mbr_write_mbr(mbr_t * mbr, service_id_t dev_handle);
Note: See TracChangeset for help on using the changeset viewer.