Changeset 30440ed in mainline for uspace/app/hdisk
- Timestamp:
- 2013-04-08T23:15:42Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 256cbfe
- Parents:
- 271e24a
- Location:
- uspace/app/hdisk
- Files:
-
- 1 added
- 5 edited
-
func_gpt.c (modified) (2 diffs)
-
func_gpt.h (modified) (1 diff)
-
func_mbr.c (modified) (6 diffs)
-
func_mbr.h (modified) (1 diff)
-
hdisk.c (modified) (5 diffs)
-
hdisk.h (added)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/hdisk/func_gpt.c
r271e24a r30440ed 35 35 #include <stdio.h> 36 36 #include <errno.h> 37 #include <str_error.h> 37 38 #include <sys/types.h> 38 39 39 40 #include "func_gpt.h" 41 #include "input.h" 42 43 static int set_gpt_partition(tinput_t *, gpt_part_t *); 40 44 41 45 int add_gpt_part(tinput_t * in, union table_data * data) 42 46 { 43 int rc = EOK; 47 gpt_part_t * p = gpt_alloc_partition(data->gpt.parts); 48 if (p == NULL) { 49 return ENOMEM; 50 } 44 51 45 return rc;52 return set_gpt_partition(in, p); 46 53 } 47 54 48 55 int delete_gpt_part(tinput_t * in, union table_data * data) 49 56 { 50 int rc = EOK; 57 size_t idx; 58 59 printf("Number of the partition to delete (counted from 0): "); 60 idx = get_input_size_t(in); 51 61 52 return rc; 62 if (gpt_remove_partition(data->gpt.parts, idx) == -1) { 63 printf("Warning: running low on memory, not resizing...\n"); 64 } 65 66 return EOK; 53 67 } 54 68 55 69 int print_gpt_parts(union table_data * data) 56 70 { 57 int rc = EOK; 71 printf("Current partition scheme (GPT):\n"); 72 printf("\t\tStart:\tEnd:\tLength:\tType:\tName:\n"); 73 74 gpt_foreach(data->gpt.parts, i, iter) { 75 printf("\t%10u %10u %10u %3d\n", iter->start_addr, iter->start_addr + iter->length, 76 iter->length, gpt_get_part_type(iter), gpt_get_part_name(iter)); 77 } 58 78 59 79 return rc; … … 62 82 int write_gpt_parts(service_id_t dev_handle, union table_data * data) 63 83 { 64 int rc = EOK;84 int rc; 65 85 66 return rc; 86 rc = gpt_write_partitions(data->gpt.parts, data->gpt.gpt, dev_handle); 87 if (rc != EOK) { 88 printf("Error: Writing partitions failed: %d (%s)\n", rc, str_error(rc)); 89 return rc; 90 } 91 92 rc = gpt_write_gpt_header(data->gpt.gpt, dev_handle); 93 if (rc != EOK) { 94 printf("Error: Writing partitions failed: %d (%s)\n", rc, str_error(rc)); 95 return rc; 96 } 97 98 return EOK; 67 99 } 68 100 101 int extra_gpt_funcs(tinput_t * in, service_id_t dev_handle, union table_data * data) 102 { 103 return EOK; 104 } 105 106 static int set_gpt_partition(tinput_t * in, gpt_part_t * p) 107 { 108 int rc; 109 110 uint64_t sa, ea; 111 112 printf("Set starting address (number): "); 113 sa = get_input_uint64(in); 114 115 printf("Set end addres (number): "); 116 ea = get_input_uint64(in); 117 118 if (ea <= sa) { 119 printf("Invalid value.\n"); 120 return EINVAL; 121 } 122 123 124 p->start_addr = sa; 125 p->length = ea - sa; 126 127 return EOK; 128 } 129 -
uspace/app/hdisk/func_gpt.h
r271e24a r30440ed 46 46 extern int print_gpt_parts(union table_data * data); 47 47 extern int write_gpt_parts(service_id_t dev_handle, union table_data * data); 48 extern int extra_gpt_funcs(tinput_t * in, service_id_t dev_handle, union table_data * data); 48 49 49 50 #endif -
uspace/app/hdisk/func_mbr.c
r271e24a r30440ed 35 35 #include <stdio.h> 36 36 #include <errno.h> 37 #include <str_error.h> 37 38 #include <sys/types.h> 38 39 … … 94 95 printf(" "); 95 96 96 printf("\t \t%u\t%u\t%u\t%d\n", it->start_addr, it->start_addr + it->length, it->length, it->type);97 printf("\t%10u %10u %10u %3d\n", it->start_addr, it->start_addr + it->length, it->length, it->type); 97 98 98 99 ++num; … … 108 109 int rc = mbr_write_partitions(data->mbr.parts, data->mbr.mbr, dev_handle); 109 110 if (rc != EOK) { 110 printf("Error occured during writing . (ERR: %d)\n", rc);111 printf("Error occured during writing: ERR: %d: %s\n", rc, str_error(rc)); 111 112 } 112 113 … … 114 115 } 115 116 116 117 int extra_mbr_funcs(tinput_t * in, service_id_t dev_handle, union table_data * data) 118 { 119 return EOK; 120 } 117 121 118 122 static int set_mbr_partition(tinput_t * in, mbr_part_t * p) … … 123 127 printf("Primary (p) or logical (l): "); 124 128 c = getchar(); 129 printf("%c\n", c); 125 130 126 131 switch(c) { 127 132 case 'p': 128 133 mbr_set_flag(p, ST_LOGIC, false); 134 break; 129 135 case 'l': 130 136 mbr_set_flag(p, ST_LOGIC, true); 137 break; 131 138 default: 132 139 printf("Invalid type. Cancelled."); … … 144 151 return EINVAL; 145 152 } 146 153 printf("%c\n", c); 147 154 mbr_set_flag(p, ST_BOOT, (c == 'y' || c == 'Y') ? true : false); 148 155 -
uspace/app/hdisk/func_mbr.h
r271e24a r30440ed 46 46 extern int print_mbr_parts(union table_data * data); 47 47 extern int write_mbr_parts(service_id_t dev_handle, union table_data * data); 48 extern int extra_mbr_funcs(tinput_t * in, service_id_t dev_handle, union table_data * data); 48 49 49 50 #endif -
uspace/app/hdisk/hdisk.c
r271e24a r30440ed 175 175 return ENOMEM; 176 176 } 177 tinput_set_prompt(in, ""); 177 178 178 179 printf("Welcome to hdisk.\nType 'h' for help.\n"); … … 184 185 while (1) { 185 186 186 //printf("# ");187 printf("# "); 187 188 input = getchar(); 188 //printf("%c\n", input);189 printf("%c\n", input); 189 190 190 191 … … 210 211 table.delete_part(in, &table.data); 211 212 break; 213 case 'e': 214 table.extra_funcs(in, dev_handle, &table.data); 215 break; 212 216 case 'h': 213 217 print_help(); … … 259 263 table.print_parts = print_mbr_parts; 260 264 table.write_parts = write_mbr_parts; 265 table.extra_funcs = extra_mbr_funcs; 261 266 break; 262 267 case LYT_GPT: … … 265 270 table.print_parts = print_gpt_parts; 266 271 table.write_parts = write_gpt_parts; 272 table.extra_funcs = extra_gpt_funcs; 267 273 break; 268 274 default:
Note:
See TracChangeset
for help on using the changeset viewer.
