mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Will Drewry <wad@chromium.org>
To: linux-kernel@vger.kernel.org
Cc: Kay Sievers <kay.sievers@vrfy.org>, Jens Axboe <axboe@kernel.dk>,
	Karel Zak <kzak@redhat.com>, Tejun Heo <tj@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Andrew Morton <akpm@linux-foundation.org>,
	Joe Perches <joe@perches.com>, Jan Blunck <jblunck@suse.de>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	Will Drewry <wad@chromium.org>
Subject: [PATCH v2 2/3] genhd, efi: add efi partition metadata to hd_structs
Date: Tue,  3 Aug 2010 21:04:42 -0500	[thread overview]
Message-ID: <1280887483-2979-2-git-send-email-wad@chromium.org> (raw)
In-Reply-To: <AANLkTim6Bn++JaspY0cbpLLvi=MYBLNgUhARwKQkoYpE@mail.gmail.com>

This change extends the partition_meta_info structure to
support EFI GPT-specific metadata and ensures that data
is copied in on partition scanning.

Signed-off-by: Will Drewry <wad@chromium.org>

v2: move info assignment after memcpy()s
    adds _MAX to the enum after EFI
---
 fs/partitions/efi.c   |   16 ++++++++++++++++
 include/linux/genhd.h |   14 ++++++++++++++
 2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/fs/partitions/efi.c b/fs/partitions/efi.c
index 9efb2cf..fac527d 100644
--- a/fs/partitions/efi.c
+++ b/fs/partitions/efi.c
@@ -614,6 +614,7 @@ int efi_partition(struct parsed_partitions *state)
 	pr_debug("GUID Partition Table is valid!  Yea!\n");
 
 	for (i = 0; i < le32_to_cpu(gpt->num_partition_entries) && i < state->limit-1; i++) {
+		struct partition_meta_info *info;
 		u64 start = le64_to_cpu(ptes[i].starting_lba);
 		u64 size = le64_to_cpu(ptes[i].ending_lba) -
 			   le64_to_cpu(ptes[i].starting_lba) + 1ULL;
@@ -627,6 +628,21 @@ int efi_partition(struct parsed_partitions *state)
 		if (!efi_guidcmp(ptes[i].partition_type_guid,
 				 PARTITION_LINUX_RAID_GUID))
 			state->parts[i + 1].flags = ADDPART_FLAG_RAID;
+
+		info = alloc_part_info(NULL);
+		if (!info) {
+			printk(KERN_WARNING
+			       "unable to allocate memory for part->info\n");
+			continue;
+		}
+		info->format = PARTITION_META_INFO_FORMAT_EFI;
+		memcpy(info->efi.uuid.b, ptes[i].unique_partition_guid.b,
+			sizeof(info->efi.uuid.b));
+		memcpy(info->efi.type.b, ptes[i].partition_type_guid.b,
+			sizeof(info->efi.type.b));
+		memcpy(info->efi.label, ptes[i].partition_name,
+			sizeof(info->efi.label));
+		state->parts[i + 1].info = info;
 	}
 	kfree(ptes);
 	kfree(gpt);
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 7b6644a..beb98e3 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -91,11 +91,25 @@ struct disk_stats {
 enum partition_meta_info_format_t {
 	/* Partition info format */
 	PARTITION_META_INFO_FORMAT_NONE = 0,
+	PARTITION_META_INFO_FORMAT_EFI,
+	/* Place additional formats here. */
+	PARTITION_META_INFO_FORMAT_MAX,
 };
 
+#ifdef CONFIG_EFI_PARTITION
+#include <linux/efi.h>
+#endif
+
 struct partition_meta_info {
 	enum partition_meta_info_format_t format;
 	union {
+#ifdef CONFIG_EFI_PARTITION
+		struct {
+			efi_guid_t uuid;
+			efi_guid_t type;
+			efi_char16_t label[72 / sizeof(efi_char16_t)];
+		} efi;
+#endif
 	};
 };
 
-- 
1.7.0.4


  parent reply	other threads:[~2010-08-04  2:06 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-02 19:17 [PATCH RFC] efi: add and expose efi_partition_by_guid Will Drewry
2010-08-02 23:00 ` David Miller
2010-08-03  2:44   ` Will Drewry
2010-08-03  2:52   ` [PATCH v2 " Will Drewry
2010-08-03 18:50     ` Randy Dunlap
2010-08-03 18:52       ` Will Drewry
2010-08-03  2:48 ` [PATCH RFC (alt)] efi: add efi_partition_walk and expose for kernel access Will Drewry
2010-08-03 16:08 ` [PATCH RFC] efi: add and expose efi_partition_by_guid Tejun Heo
2010-08-03 17:17   ` Kay Sievers
2010-08-03 17:55     ` Will Drewry
2010-08-03 18:23       ` Kay Sievers
2010-08-03 18:52         ` Will Drewry
2010-08-03 21:35           ` [PATCH 1/2] block, partition: add partition_meta_info to hd_struct Will Drewry
2010-08-03 21:35           ` [PATCH 2/2] genhd, efi: add efi partition metadata to hd_structs Will Drewry
2010-08-03 21:54             ` Kay Sievers
2010-08-03 22:27               ` Will Drewry
2010-08-03 23:13                 ` Kay Sievers
2010-08-04  2:04                   ` [PATCH v2 1/3] block, partition: add partition_meta_info to hd_struct Will Drewry
2010-08-04  7:57                     ` Tejun Heo
2010-08-04 14:46                       ` Will Drewry
2010-08-04  2:04                   ` Will Drewry [this message]
2010-08-04  7:59                     ` [PATCH v2 2/3] genhd, efi: add efi partition metadata to hd_structs Tejun Heo
2010-08-04  9:00                     ` Karel Zak
2010-08-04 10:14                       ` Kay Sievers
2010-08-04 14:44                         ` Will Drewry
2010-08-04 15:28                           ` Kay Sievers
2010-08-04 15:56                             ` Will Drewry
2010-08-04 18:22                               ` [PATCH v3 1/3] block, partition: add partition_meta_info to hd_struct Will Drewry
2010-08-04 18:22                               ` [PATCH v3 2/3] genhd, efi: add efi partition metadata to hd_structs Will Drewry
2010-08-04 18:22                               ` [PATCH v3 3/3] init: add support for root devices specified by partition UUID Will Drewry
2010-08-05 10:55                                 ` Tejun Heo
2010-08-05 14:26                                   ` Will Drewry
2010-08-05 14:29                                     ` Tejun Heo
2010-08-05 19:19                                       ` Will Drewry
2010-08-05 19:29                                 ` Kay Sievers
2010-08-31 20:47                                 ` [PATCH v4 1/3] block, partition: add partition_meta_info to hd_struct Will Drewry
2010-09-15 14:22                                   ` Jens Axboe
2010-08-31 20:47                                 ` [PATCH v4 2/3] genhd, efi: add efi partition metadata to hd_structs Will Drewry
2010-08-31 20:47                                 ` [PATCH v4 3/3] init: add support for root devices specified by partition UUID Will Drewry
2010-08-04 14:44                       ` [PATCH v2 2/3] genhd, efi: add efi partition metadata to hd_structs Will Drewry
2010-08-04  2:04                   ` [PATCH 3/3] init: add support for root devices specified by partition UUID Will Drewry
2010-08-04 14:27                   ` [PATCH 2/2] genhd, efi: add efi partition metadata to hd_structs John Stoffel
2010-08-04 14:45                     ` Will Drewry
2010-08-04 15:25                       ` Kay Sievers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1280887483-2979-2-git-send-email-wad@chromium.org \
    --to=wad@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=davem@davemloft.net \
    --cc=gregkh@suse.de \
    --cc=jblunck@suse.de \
    --cc=joe@perches.com \
    --cc=kay.sievers@vrfy.org \
    --cc=kzak@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®