Changeset 1c8bfe8 in mainline for uspace/app/hdisk/func_gpt.c
- Timestamp:
- 2013-06-25T00:27:47Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6317b33, 9256d093
- Parents:
- 6e8e4e19 (diff), cb328ab (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/hdisk/func_gpt.c
r6e8e4e19 r1c8bfe8 34 34 35 35 #include <stdio.h> 36 #include <str.h> 36 37 #include <errno.h> 37 38 #include <str_error.h> … … 60 61 } 61 62 62 int add_gpt_part(label_t *this, tinput_t * 63 { 64 gpt_part_t * p = gpt_ alloc_partition(this->data.gpt->parts);63 int add_gpt_part(label_t *this, tinput_t *in) 64 { 65 gpt_part_t * p = gpt_get_partition(this->data.gpt); 65 66 if (p == NULL) { 66 67 return ENOMEM; 67 68 } 68 69 69 70 return set_gpt_partition(in, p); 70 71 } 71 72 72 int delete_gpt_part(label_t *this, tinput_t * in) 73 { 73 int delete_gpt_part(label_t *this, tinput_t *in) 74 { 75 int rc; 74 76 size_t idx; 75 77 76 78 printf("Number of the partition to delete (counted from 0): "); 77 79 idx = get_input_size_t(in); 78 79 if (gpt_remove_partition(this->data.gpt->parts, idx) == -1) { 80 81 rc = gpt_remove_partition(this->data.gpt, idx); 82 if (rc != EOK) { 80 83 printf("Warning: running low on memory, not resizing...\n"); 81 } 82 84 return rc; 85 } 86 83 87 return EOK; 84 88 } … … 86 90 int destroy_gpt_label(label_t *this) 87 91 { 92 gpt_free_label(this->data.gpt); 88 93 return EOK; 89 94 } … … 91 96 int new_gpt_label(label_t *this) 92 97 { 93 this->data.gpt->gpt = gpt_alloc_gpt_header(); 94 this->data.gpt->parts = gpt_alloc_partitions(); 98 this->data.gpt = gpt_alloc_label(); 95 99 return EOK; 96 100 } … … 104 108 size_t i = 0; 105 109 106 gpt_part_foreach(this->data.gpt->parts, iter) { 110 gpt_part_foreach(this->data.gpt, iter) { 111 i++; 107 112 //FIXMEE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 108 if (gpt_get_part_type(iter) == 62)113 if (gpt_get_part_type(iter) == GPT_PTE_UNUSED) 109 114 continue; 115 116 if (i % 20 == 0) 117 printf("%15s %10s %10s Type: Name:\n", "Start:", "End:", "Length:"); 110 118 111 119 //printf("\t%10u %10u %10u %3d\n", iter->start_addr, iter->start_addr + iter->length, 112 120 // iter->length, gpt_get_part_type(iter), gpt_get_part_name(iter)); 113 printf("%3u \t%10llu %10llu %10llu %3d %s\n", i, gpt_get_start_lba(iter), gpt_get_end_lba(iter),121 printf("%3u %10llu %10llu %10llu %3d %s\n", i-1, gpt_get_start_lba(iter), gpt_get_end_lba(iter), 114 122 gpt_get_end_lba(iter) - gpt_get_start_lba(iter), gpt_get_part_type(iter), 115 123 gpt_get_part_name(iter)); 116 i++; 117 } 118 124 } 125 119 126 //return rc; 120 127 return EOK; … … 123 130 int read_gpt_parts(label_t *this, service_id_t dev_handle) 124 131 { 132 int rc; 133 134 rc = gpt_read_header(this->data.gpt, dev_handle); 135 if (rc != EOK) { 136 printf("Error: Reading header failed: %d (%s)\n", rc, str_error(rc)); 137 return rc; 138 } 139 140 rc = gpt_read_partitions(this->data.gpt); 141 if (rc != EOK) { 142 printf("Error: Reading partitions failed: %d (%s)\n", rc, str_error(rc)); 143 return rc; 144 } 145 125 146 return EOK; 126 147 } … … 129 150 { 130 151 int rc; 131 132 rc = gpt_write_partitions(this->data.gpt ->parts, this->data.gpt->gpt, dev_handle);152 153 rc = gpt_write_partitions(this->data.gpt, dev_handle); 133 154 if (rc != EOK) { 134 155 printf("Error: Writing partitions failed: %d (%s)\n", rc, str_error(rc)); 135 156 return rc; 136 157 } 137 138 rc = gpt_write_ gpt_header(this->data.gpt->gpt, dev_handle);139 if (rc != EOK) { 140 printf("Error: Writing partitionsfailed: %d (%s)\n", rc, str_error(rc));141 return rc; 142 } 143 144 return EOK; 145 } 146 147 int extra_gpt_funcs(label_t *this, tinput_t * 158 159 rc = gpt_write_header(this->data.gpt, dev_handle); 160 if (rc != EOK) { 161 printf("Error: Writing header failed: %d (%s)\n", rc, str_error(rc)); 162 return rc; 163 } 164 165 return EOK; 166 } 167 168 int extra_gpt_funcs(label_t *this, tinput_t *in, service_id_t dev_handle) 148 169 { 149 170 printf("Not implemented.\n"); … … 151 172 } 152 173 153 static int set_gpt_partition(tinput_t * in, gpt_part_t *p)154 { 155 //int rc;156 174 static int set_gpt_partition(tinput_t *in, gpt_part_t *p) 175 { 176 int rc; 177 157 178 uint64_t sa, ea; 158 179 159 180 printf("Set starting address (number): "); 160 181 sa = get_input_uint64(in); 161 182 162 183 printf("Set end addres (number): "); 163 184 ea = get_input_uint64(in); 164 185 165 186 if (ea <= sa) { 166 187 printf("Invalid value.\n"); 167 188 return EINVAL; 168 189 } 169 170 171 //p->start_addr = sa; 190 172 191 gpt_set_start_lba(p, sa); 173 //p->length = ea - sa;174 192 gpt_set_end_lba(p, ea); 175 176 return EOK; 177 } 178 193 194 195 char *name; 196 rc = get_input_line(in, &name); 197 if (rc != EOK) { 198 printf("Error reading name: %d (%s)\n", rc, str_error(rc)); 199 return rc; 200 } 201 202 gpt_set_part_name(p, name, str_size(name)); 203 204 return EOK; 205 } 206
Note:
See TracChangeset
for help on using the changeset viewer.