Changeset 9bda5d90 in mainline
- Timestamp:
- 2013-05-03T01:20:11Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 469739f, c9f61150, f6c8fca
- Parents:
- 700f89e
- Location:
- uspace
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/hdisk/Makefile
r700f89e r9bda5d90 37 37 SOURCES = \ 38 38 hdisk.c \ 39 input.c \ 40 func_none.c \ 39 41 func_mbr.c \ 40 func_gpt.c \ 41 input.c 42 func_gpt.c 42 43 43 44 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/hdisk/func_gpt.c
r700f89e r9bda5d90 71 71 data->gpt.gpt = gpt_alloc_gpt_header(); 72 72 data->gpt.parts = gpt_alloc_partitions(); 73 return EOK; 73 74 } 74 75 … … 115 116 int extra_gpt_funcs(tinput_t * in, service_id_t dev_handle, union table_data * data) 116 117 { 118 printf("Not implemented.\n"); 117 119 return EOK; 118 120 } -
uspace/app/hdisk/func_mbr.c
r700f89e r9bda5d90 68 68 printf("Number of the partition to delete (counted from 0): "); 69 69 idx = get_input_size_t(in); 70 70 71 if (idx == 0 && errno != EOK) 72 return errno; 73 71 74 rc = mbr_remove_partition(data->mbr.parts, idx); 72 75 if(rc != EOK) { … … 81 84 data->mbr.mbr = mbr_alloc_mbr(); 82 85 data->mbr.parts = mbr_alloc_partitions(); 86 return EOK; 83 87 } 84 88 … … 103 107 printf(" "); 104 108 105 printf("\t%10u %10u %10u %7 x\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); 106 110 107 111 ++num; … … 109 113 110 114 printf("%d partitions found.\n", num); 111 printf("DEBUG: primary: %hhu, logical: %u\n", data->mbr.parts->n_primary, data->mbr.parts->n_logical);112 115 113 116 return EOK; … … 126 129 int extra_mbr_funcs(tinput_t * in, service_id_t dev_handle, union table_data * data) 127 130 { 131 printf("Not implemented.\n"); 128 132 return EOK; 129 133 } … … 152 156 printf("Set type (0-255): "); 153 157 type = get_input_uint8(in); 158 if (type == 0 && errno != EOK) 159 return errno; 154 160 155 161 ///TODO: there can only be one bootable partition; let's do it just like fdisk … … 168 174 printf("Set starting address (number): "); 169 175 sa = get_input_uint32(in); 176 if (sa == 0 && errno != EOK) 177 return errno; 170 178 171 179 printf("Set end addres (number): "); 172 180 ea = get_input_uint32(in); 181 if (ea == 0 && errno != EOK) 182 return errno; 173 183 174 184 if(ea < sa) { -
uspace/app/hdisk/func_none.c
r700f89e r9bda5d90 34 34 35 35 36 #include <loc.h> 37 #include <tinput.h> 38 #include <libmbr.h> 36 #include <errno.h> 39 37 40 #include "common.h"41 38 #include "func_none.h" 42 39 43 static void not_implemented( );40 static void not_implemented(void); 44 41 45 42 int add_none_part(tinput_t * in, union table_data * data) -
uspace/app/hdisk/func_none.h
r700f89e r9bda5d90 33 33 */ 34 34 35 #ifndef __FUNC_ MBR_H__36 #define __FUNC_ MBR_H__35 #ifndef __FUNC_NONE_H__ 36 #define __FUNC_NONE_H__ 37 37 38 38 #include <loc.h> 39 39 #include <tinput.h> 40 #include <libmbr.h>41 40 42 41 #include "common.h" -
uspace/app/hdisk/hdisk.c
r700f89e r9bda5d90 48 48 49 49 #include "hdisk.h" 50 #include "input.h" 51 #include "func_gpt.h" 50 52 #include "func_mbr.h" 51 #include "func_ gpt.h"53 #include "func_none.h" 52 54 53 55 int interact(service_id_t dev_handle); 54 56 void print_help(void); 55 void select_table_format( void);57 void select_table_format(tinput_t * in); 56 58 void fill_table_funcs(void); 57 59 void free_table(void); … … 167 169 case 'n': 168 170 free_table(); 169 table.new_table(in );171 table.new_table(in, &table.data); 170 172 break; 171 173 case 'p': -
uspace/app/hdisk/input.c
r700f89e r9bda5d90 66 66 uint8_t get_input_uint8(tinput_t * in) 67 67 { 68 int rc; 68 69 uint32_t val; 69 70 /*char * str; … … 83 84 free(str);*/ 84 85 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 } 86 91 87 92 return val; … … 90 95 uint32_t get_input_uint32(tinput_t * in) 91 96 { 97 int rc; 92 98 uint32_t val; 93 99 /*char * str; … … 107 113 free(str);*/ 108 114 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 } 110 120 111 121 return val; … … 114 124 uint64_t get_input_uint64(tinput_t * in) 115 125 { 126 int rc; 116 127 uint64_t val; 117 128 /*char * str; … … 131 142 free(str);*/ 132 143 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 } 134 149 135 150 return val; … … 141 156 size_t val; 142 157 143 char * str;158 /*char * str; 144 159 rc = get_input_line(in, &str); 145 160 if (rc != EOK) { … … 153 168 return 0; 154 169 } 155 free(str); 156 /*170 free(str);*/ 171 157 172 rc = convert(in, (conv_f) str_size_t, &val); 158 173 if (rc != EOK) { 159 return -1; 160 } 161 */ 174 errno = rc; 175 return 0; 176 } 177 162 178 errno = EOK; 163 179 return val; -
uspace/lib/gpt/libgpt.c
r700f89e r9bda5d90 59 59 60 60 /** Allocate memory for gpt header */ 61 gpt_t * gpt_alloc_gpt_header( )61 gpt_t * gpt_alloc_gpt_header(void) 62 62 { 63 63 return malloc(sizeof(gpt_t)); -
uspace/lib/gpt/libgpt.h
r700f89e r9bda5d90 139 139 140 140 141 extern gpt_t * gpt_alloc_gpt_header( );141 extern gpt_t * gpt_alloc_gpt_header(void); 142 142 extern gpt_t * gpt_read_gpt_header(service_id_t dev_handle); 143 143 extern int gpt_write_gpt_header(gpt_t * header, service_id_t dev_handle); 144 144 145 extern gpt_partitions_t * gpt_alloc_partitions( );145 extern gpt_partitions_t * gpt_alloc_partitions(void); 146 146 extern gpt_partitions_t * gpt_read_partitions (gpt_t * gpt); 147 147 extern int gpt_write_partitions (gpt_partitions_t * parts, gpt_t * header, service_id_t dev_handle); -
uspace/lib/mbr/libmbr.c
r700f89e r9bda5d90 54 54 55 55 /** Allocate memory for mbr_t */ 56 mbr_t * mbr_alloc_mbr( )57 { 58 return alloc_br();56 mbr_t * mbr_alloc_mbr(void) 57 { 58 return malloc(sizeof(mbr_t)); 59 59 } 60 60 … … 405 405 406 406 // 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) { 408 408 return ERR_EXTENDED_PRESENT; 409 409 } … … 425 425 } 426 426 parts->n_primary += 1; 427 428 if (p->type == PT_EXTENDED || p->type == PT_EXTENDED_LBA) 429 parts->l_extended = &(p->link); 427 430 } 428 431 -
uspace/lib/mbr/libmbr.h
r700f89e r9bda5d90 188 188 * then partitions. The MBR headers' raw_data is NOT updated to follow 189 189 * partition changes. */ 190 extern mbr_t * mbr_alloc_mbr( );190 extern mbr_t * mbr_alloc_mbr(void); 191 191 extern mbr_t * mbr_read_mbr(service_id_t dev_handle); 192 192 extern int mbr_write_mbr(mbr_t * mbr, service_id_t dev_handle);
Note:
See TracChangeset
for help on using the changeset viewer.