OLD | NEW |
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
4 * | 4 * |
5 * Utility for ChromeOS-specific GPT partitions, Please see corresponding .c | 5 * Utility for ChromeOS-specific GPT partitions, Please see corresponding .c |
6 * files for more details. | 6 * files for more details. |
7 */ | 7 */ |
8 | 8 |
9 #include "cgpt.h" | 9 #include "cgpt.h" |
10 | 10 |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 } | 515 } |
516 | 516 |
517 return (GptEntry*)(&entries[stride * entry_index]); | 517 return (GptEntry*)(&entries[stride * entry_index]); |
518 } | 518 } |
519 | 519 |
520 void SetPriority(GptData *gpt, int secondary, int entry_index, int priority) { | 520 void SetPriority(GptData *gpt, int secondary, int entry_index, int priority) { |
521 GptEntry *entry; | 521 GptEntry *entry; |
522 entry = GetEntry(gpt, secondary, entry_index); | 522 entry = GetEntry(gpt, secondary, entry_index); |
523 | 523 |
524 assert(priority >= 0 && priority <= CGPT_ATTRIBUTE_MAX_PRIORITY); | 524 assert(priority >= 0 && priority <= CGPT_ATTRIBUTE_MAX_PRIORITY); |
525 entry->attributes &= ~CGPT_ATTRIBUTE_PRIORITY_MASK; | 525 entry->attrs.fields.gpt_att &= ~CGPT_ATTRIBUTE_PRIORITY_MASK; |
526 entry->attributes |= (uint64_t)priority << CGPT_ATTRIBUTE_PRIORITY_OFFSET; | 526 entry->attrs.fields.gpt_att |= priority << CGPT_ATTRIBUTE_PRIORITY_OFFSET; |
527 } | 527 } |
528 | 528 |
529 int GetPriority(GptData *gpt, int secondary, int entry_index) { | 529 int GetPriority(GptData *gpt, int secondary, int entry_index) { |
530 GptEntry *entry; | 530 GptEntry *entry; |
531 entry = GetEntry(gpt, secondary, entry_index); | 531 entry = GetEntry(gpt, secondary, entry_index); |
532 return (entry->attributes & CGPT_ATTRIBUTE_PRIORITY_MASK) >> | 532 return (entry->attrs.fields.gpt_att & CGPT_ATTRIBUTE_PRIORITY_MASK) >> |
533 CGPT_ATTRIBUTE_PRIORITY_OFFSET; | 533 CGPT_ATTRIBUTE_PRIORITY_OFFSET; |
534 } | 534 } |
535 | 535 |
536 void SetTries(GptData *gpt, int secondary, int entry_index, int tries) { | 536 void SetTries(GptData *gpt, int secondary, int entry_index, int tries) { |
537 GptEntry *entry; | 537 GptEntry *entry; |
538 entry = GetEntry(gpt, secondary, entry_index); | 538 entry = GetEntry(gpt, secondary, entry_index); |
539 | 539 |
540 assert(tries >= 0 && tries <= CGPT_ATTRIBUTE_MAX_TRIES); | 540 assert(tries >= 0 && tries <= CGPT_ATTRIBUTE_MAX_TRIES); |
541 entry->attributes &= ~CGPT_ATTRIBUTE_TRIES_MASK; | 541 entry->attrs.fields.gpt_att &= ~CGPT_ATTRIBUTE_TRIES_MASK; |
542 entry->attributes |= (uint64_t)tries << CGPT_ATTRIBUTE_TRIES_OFFSET; | 542 entry->attrs.fields.gpt_att |= tries << CGPT_ATTRIBUTE_TRIES_OFFSET; |
543 } | 543 } |
544 | 544 |
545 int GetTries(GptData *gpt, int secondary, int entry_index) { | 545 int GetTries(GptData *gpt, int secondary, int entry_index) { |
546 GptEntry *entry; | 546 GptEntry *entry; |
547 entry = GetEntry(gpt, secondary, entry_index); | 547 entry = GetEntry(gpt, secondary, entry_index); |
548 return (entry->attributes & CGPT_ATTRIBUTE_TRIES_MASK) >> | 548 return (entry->attrs.fields.gpt_att & CGPT_ATTRIBUTE_TRIES_MASK) >> |
549 CGPT_ATTRIBUTE_TRIES_OFFSET; | 549 CGPT_ATTRIBUTE_TRIES_OFFSET; |
550 } | 550 } |
551 | 551 |
552 void SetSuccessful(GptData *gpt, int secondary, int entry_index, int success) { | 552 void SetSuccessful(GptData *gpt, int secondary, int entry_index, int success) { |
553 GptEntry *entry; | 553 GptEntry *entry; |
554 entry = GetEntry(gpt, secondary, entry_index); | 554 entry = GetEntry(gpt, secondary, entry_index); |
555 | 555 |
556 assert(success >= 0 && success <= CGPT_ATTRIBUTE_MAX_SUCCESSFUL); | 556 assert(success >= 0 && success <= CGPT_ATTRIBUTE_MAX_SUCCESSFUL); |
557 entry->attributes &= ~CGPT_ATTRIBUTE_SUCCESSFUL_MASK; | 557 entry->attrs.fields.gpt_att &= ~CGPT_ATTRIBUTE_SUCCESSFUL_MASK; |
558 entry->attributes |= (uint64_t)success << CGPT_ATTRIBUTE_SUCCESSFUL_OFFSET; | 558 entry->attrs.fields.gpt_att |= success << CGPT_ATTRIBUTE_SUCCESSFUL_OFFSET; |
559 } | 559 } |
560 | 560 |
561 int GetSuccessful(GptData *gpt, int secondary, int entry_index) { | 561 int GetSuccessful(GptData *gpt, int secondary, int entry_index) { |
562 GptEntry *entry; | 562 GptEntry *entry; |
563 entry = GetEntry(gpt, secondary, entry_index); | 563 entry = GetEntry(gpt, secondary, entry_index); |
564 return (entry->attributes & CGPT_ATTRIBUTE_SUCCESSFUL_MASK) >> | 564 return (entry->attrs.fields.gpt_att & CGPT_ATTRIBUTE_SUCCESSFUL_MASK) >> |
565 CGPT_ATTRIBUTE_SUCCESSFUL_OFFSET; | 565 CGPT_ATTRIBUTE_SUCCESSFUL_OFFSET; |
566 } | 566 } |
567 | 567 |
568 | 568 |
569 #define TOSTRING(A) #A | 569 #define TOSTRING(A) #A |
570 const char *GptError(int errnum) { | 570 const char *GptError(int errnum) { |
571 const char *error_string[] = { | 571 const char *error_string[] = { |
572 TOSTRING(GPT_SUCCESS), | 572 TOSTRING(GPT_SUCCESS), |
573 TOSTRING(GPT_ERROR_NO_VALID_KERNEL), | 573 TOSTRING(GPT_ERROR_NO_VALID_KERNEL), |
574 TOSTRING(GPT_ERROR_INVALID_HEADERS), | 574 TOSTRING(GPT_ERROR_INVALID_HEADERS), |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 void PMBRToStr(struct pmbr *pmbr, char *str) { | 717 void PMBRToStr(struct pmbr *pmbr, char *str) { |
718 char buf[256]; | 718 char buf[256]; |
719 if (IsZero(&pmbr->boot_guid)) { | 719 if (IsZero(&pmbr->boot_guid)) { |
720 sprintf(str, "PMBR"); | 720 sprintf(str, "PMBR"); |
721 } else { | 721 } else { |
722 GuidToStr(&pmbr->boot_guid, buf); | 722 GuidToStr(&pmbr->boot_guid, buf); |
723 sprintf(str, "PMBR (Boot GUID: %s)", buf); | 723 sprintf(str, "PMBR (Boot GUID: %s)", buf); |
724 } | 724 } |
725 } | 725 } |
726 | 726 |
OLD | NEW |