| 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 #include "cgpt.h" | 5 #include "cgpt.h" |
| 6 | 6 |
| 7 #define __STDC_FORMAT_MACROS | 7 #define __STDC_FORMAT_MACROS |
| 8 #include <getopt.h> | 8 #include <getopt.h> |
| 9 #include <inttypes.h> | 9 #include <inttypes.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 index+1, contents); | 125 index+1, contents); |
| 126 if (CGPT_OK == ResolveType(&entry->type, type)) { | 126 if (CGPT_OK == ResolveType(&entry->type, type)) { |
| 127 printf(PARTITION_MORE, "Type: ", type); | 127 printf(PARTITION_MORE, "Type: ", type); |
| 128 } else { | 128 } else { |
| 129 GuidToStr(&entry->type, type); | 129 GuidToStr(&entry->type, type); |
| 130 printf(PARTITION_MORE, "Type: ", type); | 130 printf(PARTITION_MORE, "Type: ", type); |
| 131 } | 131 } |
| 132 GuidToStr(&entry->unique, unique); | 132 GuidToStr(&entry->unique, unique); |
| 133 printf(PARTITION_MORE, "UUID: ", unique); | 133 printf(PARTITION_MORE, "UUID: ", unique); |
| 134 if (!memcmp(&guid_chromeos_kernel, &entry->type, sizeof(Guid))) { | 134 if (!memcmp(&guid_chromeos_kernel, &entry->type, sizeof(Guid))) { |
| 135 int tries = (entry->attributes & CGPT_ATTRIBUTE_TRIES_MASK) >> | 135 int tries = (entry->attrs.fields.gpt_att & |
| 136 CGPT_ATTRIBUTE_TRIES_OFFSET; | 136 CGPT_ATTRIBUTE_TRIES_MASK) >> |
| 137 int successful = (entry->attributes & CGPT_ATTRIBUTE_SUCCESSFUL_MASK) >> | 137 CGPT_ATTRIBUTE_TRIES_OFFSET; |
| 138 CGPT_ATTRIBUTE_SUCCESSFUL_OFFSET; | 138 int successful = (entry->attrs.fields.gpt_att & |
| 139 int priority = (entry->attributes & CGPT_ATTRIBUTE_PRIORITY_MASK) >> | 139 CGPT_ATTRIBUTE_SUCCESSFUL_MASK) >> |
| 140 CGPT_ATTRIBUTE_PRIORITY_OFFSET; | 140 CGPT_ATTRIBUTE_SUCCESSFUL_OFFSET; |
| 141 int priority = (entry->attrs.fields.gpt_att & |
| 142 CGPT_ATTRIBUTE_PRIORITY_MASK) >> |
| 143 CGPT_ATTRIBUTE_PRIORITY_OFFSET; |
| 141 snprintf(contents, sizeof(contents), | 144 snprintf(contents, sizeof(contents), |
| 142 "priority=%d tries=%d successful=%d", | 145 "priority=%d tries=%d successful=%d", |
| 143 priority, tries, successful); | 146 priority, tries, successful); |
| 144 printf(PARTITION_MORE, "Attr: ", contents); | 147 printf(PARTITION_MORE, "Attr: ", contents); |
| 145 } | 148 } |
| 146 } else { | 149 } else { |
| 147 char type[GUID_STRLEN], unique[GUID_STRLEN]; | 150 char type[GUID_STRLEN], unique[GUID_STRLEN]; |
| 148 | 151 |
| 149 UTF16ToUTF8(entry->name, label); | 152 UTF16ToUTF8(entry->name, label); |
| 150 snprintf(contents, sizeof(contents), "Label: \"%s\"", label); | 153 snprintf(contents, sizeof(contents), "Label: \"%s\"", label); |
| 151 printf(PARTITION_FMT, (int)entry->starting_lba, | 154 printf(PARTITION_FMT, (int)entry->starting_lba, |
| 152 (int)(entry->ending_lba - entry->starting_lba + 1), | 155 (int)(entry->ending_lba - entry->starting_lba + 1), |
| 153 index+1, contents); | 156 index+1, contents); |
| 154 GuidToStr(&entry->type, type); | 157 GuidToStr(&entry->type, type); |
| 155 printf(PARTITION_MORE, "Type: ", type); | 158 printf(PARTITION_MORE, "Type: ", type); |
| 156 GuidToStr(&entry->unique, unique); | 159 GuidToStr(&entry->unique, unique); |
| 157 printf(PARTITION_MORE, "UUID: ", unique); | 160 printf(PARTITION_MORE, "UUID: ", unique); |
| 158 snprintf(contents, sizeof(contents), "[%" PRIx64 "]", entry->attributes); | 161 snprintf(contents, sizeof(contents), "[%x]", entry->attrs.fields.gpt_att); |
| 159 printf(PARTITION_MORE, "Attr: ", contents); | 162 printf(PARTITION_MORE, "Attr: ", contents); |
| 160 } | 163 } |
| 161 } | 164 } |
| 162 | 165 |
| 163 | 166 |
| 164 void EntriesDetails(GptData *gpt, const int secondary, int raw) { | 167 void EntriesDetails(GptData *gpt, const int secondary, int raw) { |
| 165 int i; | 168 int i; |
| 166 | 169 |
| 167 for (i = 0; i < GetNumberOfEntries(gpt); ++i) { | 170 for (i = 0; i < GetNumberOfEntries(gpt); ++i) { |
| 168 GptEntry *entry; | 171 GptEntry *entry; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 case 'S': | 295 case 'S': |
| 293 printf("%d\n", GetSuccessful(&drive.gpt, PRIMARY, index)); | 296 printf("%d\n", GetSuccessful(&drive.gpt, PRIMARY, index)); |
| 294 break; | 297 break; |
| 295 case 'T': | 298 case 'T': |
| 296 printf("%d\n", GetTries(&drive.gpt, PRIMARY, index)); | 299 printf("%d\n", GetTries(&drive.gpt, PRIMARY, index)); |
| 297 break; | 300 break; |
| 298 case 'P': | 301 case 'P': |
| 299 printf("%d\n", GetPriority(&drive.gpt, PRIMARY, index)); | 302 printf("%d\n", GetPriority(&drive.gpt, PRIMARY, index)); |
| 300 break; | 303 break; |
| 301 case 'A': | 304 case 'A': |
| 302 printf("0x%" PRIx64 "\n", entry->attributes); | 305 printf("0x%x\n", entry->attrs.fields.gpt_att); |
| 303 break; | 306 break; |
| 304 } | 307 } |
| 305 } else { | 308 } else { |
| 306 printf(TITLE_FMT, "start", "size", "part", "contents"); | 309 printf(TITLE_FMT, "start", "size", "part", "contents"); |
| 307 EntryDetails(entry, index, numeric); | 310 EntryDetails(entry, index, numeric); |
| 308 } | 311 } |
| 309 | 312 |
| 310 } else if (quick) { // show all partitions, quickly | 313 } else if (quick) { // show all partitions, quickly |
| 311 int i; | 314 int i; |
| 312 GptEntry *entry; | 315 GptEntry *entry; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 } | 408 } |
| 406 | 409 |
| 407 (void) CheckValid(&drive); | 410 (void) CheckValid(&drive); |
| 408 (void) DriveClose(&drive, 0); | 411 (void) DriveClose(&drive, 0); |
| 409 | 412 |
| 410 return CGPT_OK; | 413 return CGPT_OK; |
| 411 } | 414 } |
| 412 | 415 |
| 413 | 416 |
| 414 | 417 |
| OLD | NEW |