hack(cgpt): use Root instead of the Kernel partitions hack up the code a bit to set priorities on root partitions: $ cgpt show -i 4 -P /dev/sda 1 $ cgpt show -i 5 -P /dev/sda 2 $ cgpt prioritize -i 4 /dev/sda $ cgpt show -i 4 -P /dev/sda 2
diff --git a/cgpt/cgpt.h b/cgpt/cgpt.h index e55c32f..e871765 100644 --- a/cgpt/cgpt.h +++ b/cgpt/cgpt.h
@@ -116,6 +116,7 @@ int IsUnused(struct drive *drive, int secondary, uint32_t index); int IsKernel(struct drive *drive, int secondary, uint32_t index); +int IsRoot(struct drive *drive, int secondary, uint32_t index); // For usage and error messages. extern const char* progname;
diff --git a/cgpt/cgpt_common.c b/cgpt/cgpt_common.c index 13ea522..0055135 100644 --- a/cgpt/cgpt_common.c +++ b/cgpt/cgpt_common.c
@@ -737,6 +737,12 @@ return GuidEqual(&entry->type, &guid_chromeos_kernel); } +int IsRoot(struct drive *drive, int secondary, uint32_t index) { + GptEntry *entry; + entry = GetEntry(&drive->gpt, secondary, index); + return GuidEqual(&entry->type, &guid_chromeos_rootfs); +} + #define TOSTRING(A) #A const char *GptError(int errnum) {
diff --git a/cgpt/cgpt_prioritize.c b/cgpt/cgpt_prioritize.c index 4502306..5edf968 100644 --- a/cgpt/cgpt_prioritize.c +++ b/cgpt/cgpt_prioritize.c
@@ -99,7 +99,7 @@ int gpt_retval; uint32_t index; uint32_t max_part; - int num_kernels; + int num_root; int i,j; group_list_t *groups; @@ -125,24 +125,24 @@ } index = params->set_partition - 1; // it must be a kernel - if (!IsKernel(&drive, PRIMARY, index)) { + if (!IsRoot(&drive, PRIMARY, index)) { Error("partition %d is not a ChromeOS kernel\n", params->set_partition); goto bad; } } // How many kernel partitions do I have? - num_kernels = 0; + num_root = 0; for (i = 0; i < max_part; i++) { - if (IsKernel(&drive, PRIMARY, i)) - num_kernels++; + if (IsRoot(&drive, PRIMARY, i)) + num_root++; } - if (num_kernels) { + if (num_root) { // Determine the current priority groups - groups = NewGroupList(num_kernels); + groups = NewGroupList(num_root); for (i = 0; i < max_part; i++) { - if (!IsKernel(&drive, PRIMARY, i)) + if (!IsRoot(&drive, PRIMARY, i)) continue; priority = GetPriority(&drive, PRIMARY, i);
diff --git a/firmware/lib/cgptlib/cgptlib.c b/firmware/lib/cgptlib/cgptlib.c index 53b6992..293c69c 100644 --- a/firmware/lib/cgptlib/cgptlib.c +++ b/firmware/lib/cgptlib/cgptlib.c
@@ -48,7 +48,7 @@ for (i = gpt->current_kernel + 1; i < header->number_of_entries; i++) { e = entries + i; - if (!IsKernelEntry(e)) + if (!IsRoot(e)) continue; VBDEBUG(("GptNextKernelEntry looking at same prio " "partition %d\n", i+1));