Changeset 493b881 in mainline
- Timestamp:
- 2013-07-30T11:54:19Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0435fe41
- Parents:
- 2b55edb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/gpt/libgpt.c
r2b55edb r493b881 364 364 label->gpt->header->fillries = host2uint32_t_le(fillries); 365 365 uint64_t arr_blocks = (fillries * sizeof(gpt_entry_t)) / b_size; 366 label->gpt->header->first_usable_lba = host2uint64_t_le(arr_blocks + 1);367 uint64_t first_lba = n_blocks - arr_blocks - 2;368 label->gpt->header->last_usable_lba = host2uint64_t_le( first_lba);366 uint64_t gpt_space = arr_blocks + GPT_HDR_BS + 1; /* +1 for Protective MBR */ 367 label->gpt->header->first_usable_lba = host2uint64_t_le(gpt_space); 368 label->gpt->header->last_usable_lba = host2uint64_t_le(n_blocks - gpt_space - 1); 369 369 370 370 /* Perform checks */ … … 373 373 continue; 374 374 375 if (!check_encaps(p, n_blocks, first_lba)) {375 if (!check_encaps(p, n_blocks, gpt_space)) { 376 376 rc = ERANGE; 377 printf("encaps with: %llu, %llu, %llu\n", n_blocks, gpt_space, gpt_get_end_lba(p)); 377 378 goto fail; 378 379 } … … 384 385 if (gpt_get_part_type(p) != GPT_PTE_UNUSED) { 385 386 if (check_overlap(p, q)) { 387 printf("overlap with: %llu, %llu\n", gpt_get_start_lba(p), gpt_get_start_lba(q)); 386 388 rc = ERANGE; 387 389 goto fail; … … 838 840 static bool check_overlap(gpt_part_t * p1, gpt_part_t * p2) 839 841 { 840 if (gpt_get_start_lba(p1) < gpt_get_start_lba(p2) && gpt_get_end_lba(p1) < =gpt_get_start_lba(p2)) {842 if (gpt_get_start_lba(p1) < gpt_get_start_lba(p2) && gpt_get_end_lba(p1) < gpt_get_start_lba(p2)) { 841 843 return false; 842 } else if (gpt_get_start_lba(p1) > gpt_get_start_lba(p2) && gpt_get_end_lba(p2) < =gpt_get_start_lba(p1)) {844 } else if (gpt_get_start_lba(p1) > gpt_get_start_lba(p2) && gpt_get_end_lba(p2) < gpt_get_start_lba(p1)) { 843 845 return false; 844 846 } … … 849 851 static bool check_encaps(gpt_part_t *p, uint64_t n_blocks, uint64_t first_lba) 850 852 { 851 uint64_t start = uint64_t_le2host(p->start_lba); 852 uint64_t end = uint64_t_le2host(p->end_lba); 853 854 if (start >= first_lba && end < n_blocks - first_lba) 853 /* 854 * We allow "<=" in the second expression because it lacks MBR so 855 * it's by 1 block smaller. 856 */ 857 if (gpt_get_start_lba(p) >= first_lba && gpt_get_end_lba(p) <= n_blocks - first_lba) 855 858 return true; 856 859
Note:
See TracChangeset
for help on using the changeset viewer.