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

Unified Diff: fs/partitions/efi.c

Issue 3026039: [RFC] CHROMIUM: Two patches for comments: EFI GUID boot for dm-verity (Closed) Base URL: http://src.chromium.org/git/kernel.git
Patch Set: fix desc. dont always wait Created 10 years, 5 months 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 | « drivers/md/dm-verity.c ('k') | include/linux/efi.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fs/partitions/efi.c
diff --git a/fs/partitions/efi.c b/fs/partitions/efi.c
index 49cfd5f5423894df4c2f52ac48bac1f82a9b43a3..e9e4923707ede7161de16ab502179a8889ce5515 100644
--- a/fs/partitions/efi.c
+++ b/fs/partitions/efi.c
@@ -637,3 +637,62 @@ efi_partition(struct parsed_partitions *state, struct block_device *bdev)
printk("\n");
return 1;
}
+
+/**
+ * efi_find_partition(efi_guid_t *guid, struct block_device *bdev)
+ * @guid
+ * @bdev
+ *
+ * Returns:
+ * -1 if an error occurred
+ * 0 if there was no match (or not GPT)
+ * >=1 is the index of the partition found.
+ *
+ */
+int efi_find_partition(efi_guid_t *guid, struct block_device *bdev) {
+ gpt_header *gpt = NULL;
+ gpt_entry *ptes = NULL;
+ u32 i;
+ struct parsed_partitions *state;
+ int part = 0;
+
+ if (!bdev || !guid)
+ return -1;
+
+ state = kzalloc(sizeof(struct parsed_partitions), GFP_KERNEL);
+ if (!state)
+ return -1;
+
+ state->limit = disk_max_parts(bdev->bd_disk);
+ pr_debug(KERN_WARNING "efi_find_partition looking for gpt\n");
+
+ if (!find_valid_gpt(bdev, &gpt, &ptes) || !gpt || !ptes) {
+ pr_debug(KERN_WARNING "efi_find_partition no GPT\n");
+ kfree(gpt);
+ kfree(ptes);
+ kfree(state);
+ return 0;
+ }
+
+ pr_debug("GUID Partition Table is valid! Yea!\n");
+
+ pr_debug(KERN_WARNING "efi_find_partition: 0 -> %d (limit:%d)\n",
+ le32_to_cpu(gpt->num_partition_entries),
+ state->limit);
+ for (i = 0; i < le32_to_cpu(gpt->num_partition_entries) &&
+ i < state->limit-1; i++) {
+ if (!is_pte_valid(&ptes[i], last_lba(bdev)))
+ continue;
+
+ /* Bails on first hit so duped "unique" GUIDs will be FCFS. */
+ if (!efi_guidcmp(ptes[i].unique_partition_guid,
+ *guid)) {
+ part = i + 1;
+ break;
+ }
+ }
+ kfree(ptes);
+ kfree(gpt);
+ kfree(state);
+ return part;
+}
« no previous file with comments | « drivers/md/dm-verity.c ('k') | include/linux/efi.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698