Changeset 8c95dff in mainline for uspace/app/hdisk/func_gpt.c
- Timestamp:
- 2013-11-30T17:49:09Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f4a47e52
- Parents:
- 802898f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/hdisk/func_gpt.c
r802898f r8c95dff 43 43 #include "input.h" 44 44 45 static int set_gpt_partition(tinput_t *, gpt_part_t *, unsigned int); 45 static void print_part_types(void); 46 static int set_gpt_partition(tinput_t *, gpt_part_t *, label_t *); 46 47 47 48 int construct_gpt_label(label_t *this) … … 69 70 } 70 71 71 return set_gpt_partition(in, p, this ->alignment);72 return set_gpt_partition(in, p, this); 72 73 } 73 74 … … 106 107 int print_gpt_parts(label_t *this) 107 108 { 108 printf("Current partition scheme (GPT) :\n");109 printf("Current partition scheme (GPT)(number of blocks: %" PRIu64 "):\n", this->nblocks); 109 110 printf("%15s %10s %10s Type: Name:\n", "Start:", "End:", "Length:"); 110 111 … … 131 132 } 132 133 133 int read_gpt_parts(label_t *this , service_id_t dev_handle)134 { 135 int rc; 136 137 rc = gpt_read_header(this->data.gpt, dev_handle);134 int read_gpt_parts(label_t *this) 135 { 136 int rc; 137 138 rc = gpt_read_header(this->data.gpt, this->device); 138 139 if (rc != EOK) { 139 140 printf("Error: Reading header failed: %d (%s)\n", rc, str_error(rc)); … … 150 151 } 151 152 152 int write_gpt_parts(label_t *this , service_id_t dev_handle)153 { 154 int rc; 155 156 rc = gpt_write_partitions(this->data.gpt, dev_handle);153 int write_gpt_parts(label_t *this) 154 { 155 int rc; 156 printf("test1\n"); 157 rc = gpt_write_partitions(this->data.gpt, this->device); 157 158 if (rc != EOK) { 158 159 printf("Error: Writing partitions failed: %d (%s)\n", rc, str_error(rc)); 159 160 return rc; 160 161 } 161 162 rc = gpt_write_header(this->data.gpt, dev_handle); 163 if (rc != EOK) { 164 printf("Error: Writing header failed: %d (%s)\n", rc, str_error(rc)); 165 return rc; 166 } 167 168 return EOK; 169 } 170 171 int extra_gpt_funcs(label_t *this, tinput_t *in, service_id_t dev_handle) 162 printf("test2\n"); 163 return EOK; 164 } 165 166 int extra_gpt_funcs(label_t *this, tinput_t *in) 172 167 { 173 168 printf("Not implemented.\n"); … … 175 170 } 176 171 177 static int set_gpt_partition(tinput_t *in, gpt_part_t *p, unsigned int alignment)172 static int set_gpt_partition(tinput_t *in, gpt_part_t *p, label_t * this) 178 173 { 179 174 int rc; … … 181 176 uint64_t sa, ea; 182 177 183 printf("Set starting address (number): ");178 printf("Set starting address: "); 184 179 sa = get_input_uint64(in); 185 if ( sa %alignment != 0)186 sa = gpt_get_next_aligned(sa, alignment);187 188 printf("Set end address ( number): ");180 if (this->alignment != 0 && this->alignment != 1 && sa % this->alignment != 0) 181 sa = gpt_get_next_aligned(sa, this->alignment); 182 183 printf("Set end address (max: %" PRIu64 "): ", this->nblocks); 189 184 ea = get_input_uint64(in); 190 185 … … 198 193 199 194 /* See global.c from libgpt for all partition types. */ 195 printf("Choose type: "); 196 print_part_types(); 200 197 printf("Set type (1 for HelenOS System): "); 201 198 size_t idx = get_input_size_t(in); 202 199 gpt_set_part_type(p, idx); 203 200 204 gpt_set_random_uuid(p->part_type);205 201 gpt_set_random_uuid(p->part_id); 206 202 … … 218 214 } 219 215 216 static void print_part_types(void) 217 { 218 int c; 219 int count = 0; 220 const struct partition_type * ptype = gpt_ptypes; 221 222 do { 223 if (count % 10 == 0) { 224 printf("Print (more) partition types? (y/n)\n"); 225 c = getchar(); 226 if (c == 'n') 227 return; 228 } 229 230 printf("%d: %s\n", count, ptype->desc); 231 ++count; 232 ++ptype; 233 } while (ptype->guid != NULL); 234 } 235
Note:
See TracChangeset
for help on using the changeset viewer.