Changeset 0435fe41 in mainline for uspace/app/hdisk/hdisk.c


Ignore:
Timestamp:
2013-08-27T00:32:08Z (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:
61ab4a9, 802898f
Parents:
493b881
Message:

polishing libmbr, libgpt, hdisk

File:
1 edited

Legend:

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

    r493b881 r0435fe41  
    8484        init_label();
    8585       
    86         /*
    87         mbr_t * mbr = mbr_read_mbr(dev_handle);
    88         if(mbr == NULL) {
    89                 printf("Failed to read the Master Boot Record.\n"       \
    90                            "Either memory allocation or disk access failed. Exiting.\n");
    91                 return -1;
    92         }
    93 
    94         if(mbr_is_mbr(mbr)) {
    95                 label.layout = LYT_MBR;
    96                 set_label_mbr(mbr);
    97                 mbr_partitions_t * parts = mbr_read_partitions(mbr);
    98                 if(parts == NULL) {
    99                         printf("Failed to read and parse partitions.\n" \
    100                                    "Creating new partition table.");
    101                         parts = mbr_alloc_partitions();
    102                 }
    103                 set_label_mbr_parts(parts);
    104                 fill_label_funcs();
    105                 goto interact;
    106         }
    107        
    108        
    109         mbr_free_mbr(mbr);*/
    110        
    11186        rc = try_read_mbr(dev_handle);
    11287        if (rc == EOK)
    11388                goto interact;
    114        
    115         /*
    116         gpt_t * gpt = gpt_read_gpt_header(dev_handle);
    117        
    118         if(gpt != NULL) {
    119                 label.layout = LYT_GPT;
    120                 set_label_gpt(gpt);
    121                
    122                 gpt_partitions_t * parts = gpt_read_partitions(gpt);
    123                
    124                 if(parts == NULL) {
    125                         printf("Failed to read and parse partitions.\n" \
    126                                    "Creating new partition table.");
    127                         parts = gpt_alloc_partitions();
    128                 }
    129                 set_label_gpt_parts(parts);
    130                 fill_label_funcs();
    131                 goto interact;
    132         }
    133         */
    13489       
    13590        rc = try_read_gpt(dev_handle);
     
    167122                printf("%c\n", input);
    168123               
    169                 switch(input) {
    170                         case 'a':
    171                                 label.add_part(&label, in);
    172                                 break;
    173                         case 'd':
    174                                 label.delete_part(&label, in);
    175                                 break;
    176                         case 'e':
    177                                 label.extra_funcs(&label, in, dev_handle);
    178                                 break;
    179                         case 'f':
    180                                 select_label_format(in);
    181                                 break;
    182                         case 'h':
    183                                 print_help();
    184                                 break;
    185                         case 'l':
    186                                 set_alignment(in);
    187                                 break;
    188                         case 'n':
    189                                 printf("Discarding label...\n");
    190                                 free_label();
    191                                 label.new_label(&label);
    192                                 break;
    193                         case 'p':
    194                                 label.print_parts(&label);
    195                                 break;
    196                         case 'q':
    197                                 putchar('\n');
    198                                 free_label();
    199                                 goto end;
    200                         case 'r':
    201                                 label.read_parts(&label, dev_handle);
    202                         case 'w':
    203                                 label.write_parts(&label, dev_handle);
    204                                 break;
    205                         default:
    206                                 printf("Unknown command. Try 'h' for help.\n");
    207                                 break;
     124                switch (input) {
     125                case 'a':
     126                        label.add_part(&label, in);
     127                        break;
     128                case 'd':
     129                        label.delete_part(&label, in);
     130                        break;
     131                case 'e':
     132                        label.extra_funcs(&label, in, dev_handle);
     133                        break;
     134                case 'f':
     135                        select_label_format(in);
     136                        break;
     137                case 'h':
     138                        print_help();
     139                        break;
     140                case 'l':
     141                        set_alignment(in);
     142                        break;
     143                case 'n':
     144                        printf("Discarding label...\n");
     145                        free_label();
     146                        label.new_label(&label);
     147                        break;
     148                case 'p':
     149                        label.print_parts(&label);
     150                        break;
     151                case 'q':
     152                        putchar('\n');
     153                        free_label();
     154                        goto end;
     155                case 'r':
     156                        label.read_parts(&label, dev_handle);
     157                case 'w':
     158                        label.write_parts(&label, dev_handle);
     159                        break;
     160                default:
     161                        printf("Unknown command. Try 'h' for help.\n");
     162                        break;
    208163                }
    209164        }
     
    241196       
    242197        uint8_t val = get_input_uint8(in);
    243         switch(val) {
    244                 case 0:
    245                         free_label();
    246                         construct_label(LYT_NONE);
    247                         break;
    248                 case 1:
    249                         free_label();
    250                         construct_label(LYT_MBR);
    251                         break;
    252                 case 2:
    253                         free_label();
    254                         construct_label(LYT_GPT);
    255                         break;
     198        switch (val) {
     199        case 0:
     200                free_label();
     201                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);
     210                break;
    256211        }
    257212}
     
    259214void construct_label(layouts_t layout)
    260215{
    261         switch(layout) {
    262                 case LYT_MBR:
    263                         label.layout = LYT_MBR;
    264                         construct_mbr_label(&label);
    265                         break;
    266                 case LYT_GPT:
    267                         label.layout = LYT_GPT;
    268                         construct_gpt_label(&label);
    269                         break;
    270                 default:
    271                         label.layout = LYT_NONE;
    272                         construct_none_label(&label);
    273                         break;
     216        switch (layout) {
     217        case LYT_MBR:
     218                label.layout = LYT_MBR;
     219                construct_mbr_label(&label);
     220                break;
     221        case LYT_GPT:
     222                label.layout = LYT_GPT;
     223                construct_gpt_label(&label);
     224                break;
     225        default:
     226                label.layout = LYT_NONE;
     227                construct_none_label(&label);
     228                break;
    274229        }
    275230}
     
    306261
    307262
    308 
    309 
    310 
    311 
    312 
    313 
    314 
Note: See TracChangeset for help on using the changeset viewer.