Changeset 9256d093 in mainline
- Timestamp:
- 2013-07-22T19:17:25Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9f4650c
- Parents:
- 1c8bfe8 (diff), 9bdfde73 (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. - Location:
- uspace/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/gpt/libgpt.c
r1c8bfe8 r9256d093 57 57 static long long nearest_larger_int(double a); 58 58 static uint8_t get_byte(const char *); 59 static int check_overlap(gpt_part_t * p1, gpt_part_t * p2); 59 60 60 61 /** Allocate memory for gpt label */ … … 290 291 291 292 /** Write GPT and partitions to device 293 * Note: also writes the header. 292 294 * @param label label to write 293 295 * @param dev_handle device to write the data to … … 424 426 * Note: for use with gpt_alloc_partition() only. You will get 425 427 * duplicates with gpt_get_partition(). 428 * Note: does not call gpt_free_partition()! 426 429 */ 427 430 int gpt_add_partition(gpt_label_t *label, gpt_part_t *partition) … … 432 435 } 433 436 437 /*FIXME: 438 * Check dimensions and stuff! */ 439 gpt_part_foreach(label, p) { 440 if (gpt_get_part_type(p) != GPT_PTE_UNUSED) { 441 if (check_overlap(partition, p)) 442 return EINVAL; 443 } 444 } 445 434 446 memcpy(label->parts->part_array + label->parts->fill++, 435 447 partition, sizeof(gpt_part_t)); 448 449 436 450 437 451 return EOK; … … 460 474 label->parts->fill -= 1; 461 475 462 /* FIXME! 476 /* FIXME! HOPEFULLY FIXED. 463 477 * We cannot reduce the array so simply. We may have some partitions 464 * there since we allow blank spots.*/ 478 * there since we allow blank spots. */ 479 gpt_part_t * p; 465 480 if (label->parts->fill < (label->parts->arr_size / 2) - GPT_IGNORE_FILL_NUM) { 481 for (p = gpt_get_partition_at(label, label->parts->arr_size / 2); 482 p < label->parts->part_array + label->parts->arr_size; ++p) { 483 if (gpt_get_part_type(p) != GPT_PTE_UNUSED) 484 return EOK; 485 } 486 466 487 if (reduce_part_array(label->parts) == ENOMEM) 467 488 return ENOMEM; … … 712 733 } 713 734 714 715 716 735 static int check_overlap(gpt_part_t * p1, gpt_part_t * p2) 736 { 737 if (gpt_get_start_lba(p1) < gpt_get_start_lba(p2) && gpt_get_end_lba(p1) <= gpt_get_start_lba(p2)) { 738 return 0; 739 } else if (gpt_get_start_lba(p1) > gpt_get_start_lba(p2) && gpt_get_end_lba(p2) <= gpt_get_start_lba(p1)) { 740 return 0; 741 } 742 743 return 1; 744 } 745 746 -
uspace/lib/mbr/libmbr.h
r1c8bfe8 r9256d093 204 204 /* Read/Write/Set MBR partitions. 205 205 * NOTE: Writing partitions writes the complete header as well. */ 206 extern int mbr_read_partitions(mbr_label_t *);206 extern int mbr_read_partitions(mbr_label_t *); 207 207 extern int mbr_write_partitions(mbr_label_t *, service_id_t); 208 208 extern mbr_part_t * mbr_alloc_partition(void);
Note:
See TracChangeset
for help on using the changeset viewer.