diff options
author | Bill Richardson <wfrichar@chromium.org> | 2010-11-29 14:24:51 -0800 |
---|---|---|
committer | Bill Richardson <wfrichar@chromium.org> | 2010-11-29 14:24:51 -0800 |
commit | 3430b32667937a75c7a3afc83f8f7a601a8187f7 (patch) | |
tree | af0492bff6b8493080d0ae959baa015434c3e3a7 /cgpt/cgpt_common.c | |
parent | 5f500b19ba0cdc174a47a68e40f939a4ed69861c (diff) | |
download | vboot-3430b32667937a75c7a3afc83f8f7a601a8187f7.tar.gz |
Add 'prioritize' command to cgpt tool.
This lets us reorder the priority of all the kernel partitions with a single
command, instead of a bunch of complicated and error-prone shell script
logic.
Change-Id: I21d39763ec5a748488d5319a987bcfe7c34ce4d0
BUG=chromium-os:9167
TEST=manual
In the chroot, do this:
cd ~/trunk/src/platform/vboot_reference
make
make runtests
make clean
Everything should pass.
Review URL: http://codereview.chromium.org/5352005
Diffstat (limited to 'cgpt/cgpt_common.c')
-rw-r--r-- | cgpt/cgpt_common.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/cgpt/cgpt_common.c b/cgpt/cgpt_common.c index eafc661c..90cd8b60 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) { |