Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1074)

Unified Diff: cgpt/cgpt_common.c

Issue 5352005: Add 'prioritize' command to cgpt tool. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@master
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cgpt/cgpt.c ('k') | cgpt/cmd_find.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cgpt/cgpt_common.c
diff --git a/cgpt/cgpt_common.c b/cgpt/cgpt_common.c
index eafc661c2d77f96bb229561c35865cc5492b259b..90cd8b6025a103a7c68781ceca4b7fd816f6c271 100644
--- a/cgpt/cgpt_common.c
+++ b/cgpt/cgpt_common.c
@@ -557,17 +557,25 @@ int UTF8ToUTF16(const uint8_t *utf8, uint16_t *utf16, unsigned int maxoutput)
return retval;
}
-struct {
- Guid type;
+/* global types to compare against */
+const Guid guid_chromeos_kernel = GPT_ENT_TYPE_CHROMEOS_KERNEL;
+const Guid guid_chromeos_rootfs = GPT_ENT_TYPE_CHROMEOS_ROOTFS;
+const Guid guid_linux_data = GPT_ENT_TYPE_LINUX_DATA;
+const Guid guid_chromeos_reserved = GPT_ENT_TYPE_CHROMEOS_RESERVED;
+const Guid guid_efi = GPT_ENT_TYPE_EFI;
+const Guid guid_unused = GPT_ENT_TYPE_UNUSED;
+
+static struct {
+ const Guid *type;
char *name;
char *description;
} supported_types[] = {
- {GPT_ENT_TYPE_CHROMEOS_KERNEL, "kernel", "ChromeOS kernel"},
- {GPT_ENT_TYPE_CHROMEOS_ROOTFS, "rootfs", "ChromeOS rootfs"},
- {GPT_ENT_TYPE_LINUX_DATA, "data", "Linux data"},
- {GPT_ENT_TYPE_CHROMEOS_RESERVED, "reserved", "ChromeOS reserved"},
- {GPT_ENT_TYPE_EFI, "efi", "EFI System Partition"},
- {GPT_ENT_TYPE_UNUSED, "unused", "Unused (nonexistent) partition"},
+ {&guid_chromeos_kernel, "kernel", "ChromeOS kernel"},
+ {&guid_chromeos_rootfs, "rootfs", "ChromeOS rootfs"},
+ {&guid_linux_data, "data", "Linux data"},
+ {&guid_chromeos_reserved, "reserved", "ChromeOS reserved"},
+ {&guid_efi, "efi", "EFI System Partition"},
+ {&guid_unused, "unused", "Unused (nonexistent) partition"},
};
/* Resolves human-readable GPT type.
@@ -576,7 +584,7 @@ struct {
int ResolveType(const Guid *type, char *buf) {
int i;
for (i = 0; i < ARRAY_COUNT(supported_types); ++i) {
- if (!memcmp(type, &supported_types[i].type, sizeof(Guid))) {
+ if (!memcmp(type, supported_types[i].type, sizeof(Guid))) {
strcpy(buf, supported_types[i].description);
return CGPT_OK;
}
@@ -588,7 +596,7 @@ int SupportedType(const char *name, Guid *type) {
int i;
for (i = 0; i < ARRAY_COUNT(supported_types); ++i) {
if (!strcmp(name, supported_types[i].name)) {
- memcpy(type, &supported_types[i].type, sizeof(Guid));
+ memcpy(type, supported_types[i].type, sizeof(Guid));
return CGPT_OK;
}
}
@@ -842,9 +850,12 @@ uint8_t RepairHeader(GptData *gpt, const uint32_t valid_headers) {
return 0;
}
+int GuidEqual(const Guid *guid1, const Guid *guid2) {
+ return (0 == memcmp(guid1, guid2, sizeof(Guid)));
+}
int IsZero(const Guid *gp) {
- return (0 == memcmp(gp, &guid_unused, sizeof(Guid)));
+ return GuidEqual(gp, &guid_unused);
}
void PMBRToStr(struct pmbr *pmbr, char *str, unsigned int buflen) {
« no previous file with comments | « cgpt/cgpt.c ('k') | cgpt/cmd_find.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698