Changeset c3cbbb2 in mainline
- Timestamp:
- 2013-07-26T21:48:22Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 903a897, dc76f4a
- Parents:
- 9f4650c
- Location:
- uspace
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/hdisk/func_gpt.c
r9f4650c rc3cbbb2 44 44 static int set_gpt_partition(tinput_t *, gpt_part_t *); 45 45 46 47 46 int construct_gpt_label(label_t *this) 48 47 { … … 50 49 this->alignment = 1; 51 50 52 this->add_part = add_gpt_part; 53 this->delete_part = delete_gpt_part; 54 this->new_label = new_gpt_label; 55 this->print_parts = print_gpt_parts; 56 this->read_parts = read_gpt_parts; 57 this->write_parts = write_gpt_parts; 58 this->extra_funcs = extra_gpt_funcs; 51 this->add_part = add_gpt_part; 52 this->delete_part = delete_gpt_part; 53 this->destroy_label = destroy_gpt_label; 54 this->new_label = new_gpt_label; 55 this->print_parts = print_gpt_parts; 56 this->read_parts = read_gpt_parts; 57 this->write_parts = write_gpt_parts; 58 this->extra_funcs = extra_gpt_funcs; 59 59 60 60 return this->new_label(this); … … 110 110 gpt_part_foreach(this->data.gpt, iter) { 111 111 i++; 112 //FIXMEE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!112 113 113 if (gpt_get_part_type(iter) == GPT_PTE_UNUSED) 114 114 continue; … … 122 122 gpt_get_end_lba(iter) - gpt_get_start_lba(iter), gpt_get_part_type(iter), 123 123 gpt_get_part_name(iter)); 124 124 125 } 125 126 … … 192 193 gpt_set_end_lba(p, ea); 193 194 195 //printf("Set type : "); 196 //size_t idx = get_input_size_t(in); 197 //gpt_set_part_type(p, idx); 198 199 gpt_set_random_uuid(p->part_type); 200 gpt_set_random_uuid(p->part_id); 194 201 195 202 char *name; … … 201 208 } 202 209 203 printf("name: %s, len: %d\n", name, str_size(name));204 210 gpt_set_part_name(p, name, str_size(name)); 205 211 -
uspace/app/hdisk/hdisk.c
r9f4650c rc3cbbb2 144 144 rc = interact(dev_handle); 145 145 146 free_label();147 148 146 return rc; 149 147 } -
uspace/lib/gpt/libgpt.c
r9f4650c rc3cbbb2 230 230 int rc; 231 231 unsigned int i; 232 uint32_t fill = uint32_t_le2host(label->gpt->header->fillries);232 uint32_t fillries = uint32_t_le2host(label->gpt->header->fillries); 233 233 uint32_t ent_size = uint32_t_le2host(label->gpt->header->entry_size); 234 234 uint64_t ent_lba = uint64_t_le2host(label->gpt->header->entry_lba); 235 235 236 236 if (label->parts == NULL) { 237 label->parts = alloc_part_array(fill );237 label->parts = alloc_part_array(fillries); 238 238 if (label->parts == NULL) { 239 239 return ENOMEM; … … 263 263 * will always read just sizeof(gpt_entry_t) bytes - hopefully they 264 264 * don't break backward compatibility) */ 265 for (i = 0; i < fill ; ++i) {265 for (i = 0; i < fillries; ++i) { 266 266 //FIXME: this does bypass cache... 267 267 rc = block_read_bytes_direct(label->device, pos, sizeof(gpt_entry_t), label->parts->part_array + i); … … 280 280 */ 281 281 uint32_t crc = compute_crc32((uint8_t *) label->parts->part_array, 282 label->parts->fill* sizeof(gpt_entry_t));282 fillries * sizeof(gpt_entry_t)); 283 283 284 284 if(uint32_t_le2host(label->gpt->header->pe_array_crc32) != crc) … … 312 312 size_t b_size; 313 313 uint32_t e_size = uint32_t_le2host(label->gpt->header->entry_size); 314 size_t fill = label->parts->fill > GPT_MIN_PART_NUM ? label->parts->fill : GPT_MIN_PART_NUM; 315 316 label->gpt->header->pe_array_crc32 = compute_crc32( 314 size_t fillries = label->parts->fill > GPT_MIN_PART_NUM ? label->parts->fill : GPT_MIN_PART_NUM; 315 316 label->gpt->header->fillries = host2uint32_t_le(fillries); 317 label->gpt->header->pe_array_crc32 = host2uint32_t_le(compute_crc32( 317 318 (uint8_t *) label->parts->part_array, 318 fill * e_size);319 fillries * e_size)); 319 320 320 321 /* comm_size of 4096 is ignored */ … … 339 340 /* Write to main GPT partition array location */ 340 341 rc = block_write_direct(dev_handle, uint64_t_le2host(label->gpt->header->entry_lba), 341 nearest_larger_int((uint64_t_le2host(label->gpt->header->entry_size) * label->parts->fill) / b_size),342 342 nearest_larger_int((uint64_t_le2host(label->gpt->header->entry_size) * fillries) / b_size), 343 label->parts->part_array); 343 344 if (rc != EOK) 344 345 goto fail; … … 385 386 { 386 387 gpt_part_t *p; 388 387 389 388 390 /* Find the first empty entry */ … … 482 484 memset(label->parts->part_array + idx, 0, sizeof(gpt_entry_t)); 483 485 484 label->parts->fill -= 1;486 label->parts->fill = idx; 485 487 486 488 /* FIXME! HOPEFULLY FIXED. … … 633 635 } 634 636 637 void gpt_set_random_uuid(uint8_t * uuid) 638 { 639 srandom((unsigned int) uuid); 640 641 unsigned int i; 642 for (i = 0; i < 16/sizeof(long int); ++i) 643 ((long int *)uuid)[i] = random(); 644 645 } 646 635 647 // Internal functions follow // 636 648 … … 683 695 } 684 696 685 res->fill = num;686 res->arr_size = size;697 res->fill = 0; 698 res->arr_size = num; 687 699 688 700 return res; … … 691 703 static int extend_part_array(gpt_partitions_t * p) 692 704 { 693 unsigned int nsize = p->arr_size * 2;705 size_t nsize = p->arr_size * 2; 694 706 gpt_entry_t * tmp = malloc(nsize * sizeof(gpt_entry_t)); 695 707 if(tmp == NULL) { … … 697 709 return -1; 698 710 } 699 700 memcpy(tmp, p->part_array, p->fill );711 712 memcpy(tmp, p->part_array, p->fill * sizeof(gpt_entry_t)); 701 713 free(p->part_array); 702 714 p->part_array = tmp; -
uspace/lib/gpt/libgpt.h
r9f4650c rc3cbbb2 167 167 extern void gpt_set_flag (gpt_part_t *, GPT_ATTR, bool); 168 168 169 extern void gpt_set_random_uuid(uint8_t *); 169 170 170 171 171 172 #define gpt_part_foreach(label, iterator) \ 172 173 for(gpt_part_t * iterator = (label)->parts->part_array; \ 173 iterator < (label)->parts->part_array + (label)->parts-> fill; ++iterator)174 iterator < (label)->parts->part_array + (label)->parts->arr_size; ++iterator) 174 175 175 176 extern void gpt_free_gpt(gpt_t *);
Note:
See TracChangeset
for help on using the changeset viewer.