diff options
Diffstat (limited to 'cgpt')
-rw-r--r-- | cgpt/cgpt_common.c | 22 | ||||
-rw-r--r-- | cgpt/cmd_add.c | 4 | ||||
-rw-r--r-- | cgpt/cmd_show.c | 19 |
3 files changed, 24 insertions, 21 deletions
diff --git a/cgpt/cgpt_common.c b/cgpt/cgpt_common.c index f165f7a7..8e8196b4 100644 --- a/cgpt/cgpt_common.c +++ b/cgpt/cgpt_common.c @@ -522,15 +522,15 @@ void SetPriority(GptData *gpt, int secondary, int entry_index, int priority) { entry = GetEntry(gpt, secondary, entry_index); assert(priority >= 0 && priority <= CGPT_ATTRIBUTE_MAX_PRIORITY); - entry->attributes &= ~CGPT_ATTRIBUTE_PRIORITY_MASK; - entry->attributes |= (uint64_t)priority << CGPT_ATTRIBUTE_PRIORITY_OFFSET; + entry->attrs.fields.gpt_att &= ~CGPT_ATTRIBUTE_PRIORITY_MASK; + entry->attrs.fields.gpt_att |= priority << CGPT_ATTRIBUTE_PRIORITY_OFFSET; } int GetPriority(GptData *gpt, int secondary, int entry_index) { GptEntry *entry; entry = GetEntry(gpt, secondary, entry_index); - return (entry->attributes & CGPT_ATTRIBUTE_PRIORITY_MASK) >> - CGPT_ATTRIBUTE_PRIORITY_OFFSET; + return (entry->attrs.fields.gpt_att & CGPT_ATTRIBUTE_PRIORITY_MASK) >> + CGPT_ATTRIBUTE_PRIORITY_OFFSET; } void SetTries(GptData *gpt, int secondary, int entry_index, int tries) { @@ -538,15 +538,15 @@ void SetTries(GptData *gpt, int secondary, int entry_index, int tries) { entry = GetEntry(gpt, secondary, entry_index); assert(tries >= 0 && tries <= CGPT_ATTRIBUTE_MAX_TRIES); - entry->attributes &= ~CGPT_ATTRIBUTE_TRIES_MASK; - entry->attributes |= (uint64_t)tries << CGPT_ATTRIBUTE_TRIES_OFFSET; + entry->attrs.fields.gpt_att &= ~CGPT_ATTRIBUTE_TRIES_MASK; + entry->attrs.fields.gpt_att |= tries << CGPT_ATTRIBUTE_TRIES_OFFSET; } int GetTries(GptData *gpt, int secondary, int entry_index) { GptEntry *entry; entry = GetEntry(gpt, secondary, entry_index); - return (entry->attributes & CGPT_ATTRIBUTE_TRIES_MASK) >> - CGPT_ATTRIBUTE_TRIES_OFFSET; + return (entry->attrs.fields.gpt_att & CGPT_ATTRIBUTE_TRIES_MASK) >> + CGPT_ATTRIBUTE_TRIES_OFFSET; } void SetSuccessful(GptData *gpt, int secondary, int entry_index, int success) { @@ -554,14 +554,14 @@ void SetSuccessful(GptData *gpt, int secondary, int entry_index, int success) { entry = GetEntry(gpt, secondary, entry_index); assert(success >= 0 && success <= CGPT_ATTRIBUTE_MAX_SUCCESSFUL); - entry->attributes &= ~CGPT_ATTRIBUTE_SUCCESSFUL_MASK; - entry->attributes |= (uint64_t)success << CGPT_ATTRIBUTE_SUCCESSFUL_OFFSET; + entry->attrs.fields.gpt_att &= ~CGPT_ATTRIBUTE_SUCCESSFUL_MASK; + entry->attrs.fields.gpt_att |= success << CGPT_ATTRIBUTE_SUCCESSFUL_OFFSET; } int GetSuccessful(GptData *gpt, int secondary, int entry_index) { GptEntry *entry; entry = GetEntry(gpt, secondary, entry_index); - return (entry->attributes & CGPT_ATTRIBUTE_SUCCESSFUL_MASK) >> + return (entry->attrs.fields.gpt_att & CGPT_ATTRIBUTE_SUCCESSFUL_MASK) >> CGPT_ATTRIBUTE_SUCCESSFUL_OFFSET; } diff --git a/cgpt/cmd_add.c b/cgpt/cmd_add.c index 18a0285e..12ae57c9 100644 --- a/cgpt/cmd_add.c +++ b/cgpt/cmd_add.c @@ -45,7 +45,7 @@ int cmd_add(int argc, char *argv[]) { int successful = 0; int tries = 0; int priority = 0; - uint64_t raw_value = 0; + uint16_t raw_value = 0; int set_begin = 0; int set_size = 0; int set_type = 0; @@ -249,7 +249,7 @@ int cmd_add(int argc, char *argv[]) { memcpy(entry->name, buf, sizeof(entry->name)); } if (set_raw) { - entry->attributes = raw_value; + entry->attrs.fields.gpt_att = raw_value; } else { if (set_successful) SetSuccessful(&drive.gpt, PRIMARY, index, successful); diff --git a/cgpt/cmd_show.c b/cgpt/cmd_show.c index 91461490..6ab537dc 100644 --- a/cgpt/cmd_show.c +++ b/cgpt/cmd_show.c @@ -132,12 +132,15 @@ void EntryDetails(GptEntry *entry, int index, int raw) { GuidToStr(&entry->unique, unique); printf(PARTITION_MORE, "UUID: ", unique); if (!memcmp(&guid_chromeos_kernel, &entry->type, sizeof(Guid))) { - int tries = (entry->attributes & CGPT_ATTRIBUTE_TRIES_MASK) >> - CGPT_ATTRIBUTE_TRIES_OFFSET; - int successful = (entry->attributes & CGPT_ATTRIBUTE_SUCCESSFUL_MASK) >> - CGPT_ATTRIBUTE_SUCCESSFUL_OFFSET; - int priority = (entry->attributes & CGPT_ATTRIBUTE_PRIORITY_MASK) >> - CGPT_ATTRIBUTE_PRIORITY_OFFSET; + int tries = (entry->attrs.fields.gpt_att & + CGPT_ATTRIBUTE_TRIES_MASK) >> + CGPT_ATTRIBUTE_TRIES_OFFSET; + int successful = (entry->attrs.fields.gpt_att & + CGPT_ATTRIBUTE_SUCCESSFUL_MASK) >> + CGPT_ATTRIBUTE_SUCCESSFUL_OFFSET; + int priority = (entry->attrs.fields.gpt_att & + CGPT_ATTRIBUTE_PRIORITY_MASK) >> + CGPT_ATTRIBUTE_PRIORITY_OFFSET; snprintf(contents, sizeof(contents), "priority=%d tries=%d successful=%d", priority, tries, successful); @@ -155,7 +158,7 @@ void EntryDetails(GptEntry *entry, int index, int raw) { printf(PARTITION_MORE, "Type: ", type); GuidToStr(&entry->unique, unique); printf(PARTITION_MORE, "UUID: ", unique); - snprintf(contents, sizeof(contents), "[%" PRIx64 "]", entry->attributes); + snprintf(contents, sizeof(contents), "[%x]", entry->attrs.fields.gpt_att); printf(PARTITION_MORE, "Attr: ", contents); } } @@ -299,7 +302,7 @@ int cmd_show(int argc, char *argv[]) { printf("%d\n", GetPriority(&drive.gpt, PRIMARY, index)); break; case 'A': - printf("0x%" PRIx64 "\n", entry->attributes); + printf("0x%x\n", entry->attrs.fields.gpt_att); break; } } else { |