block: extends name_to_dev_t() syntax for specifying e.g. root=.
Subsystems (3)
PATCH 1/1 block: extends name_to_dev_t() syntax for specifying e.g. root=.
Enables use of GPT partition labels, APM partition labels, and MBR disk signatures to specify block devices during early boot. Traditional device names and GPT partition UUIDs are still supported. This is useful on systems with nondeterministic device ordering.
Signed-off-by Andy Getzendanner <[email protected]>
---
Tested with an MBR disk, an APM disk, and a GPT disk on ppc32 and amd64 using qemu.
block/genhd.c | 18 +++--- block/partition-generic.c | 3 +- block/partitions/check.h | 1 - block/partitions/efi.c | 10 +++- block/partitions/mac.c | 20 +++++- block/partitions/msdos.c | 97 ++++++++++++++++++++++------ include/linux/genhd.h | 2 + init/do_mounts.c | 153 +++++++++++++++++++++++++++++++++++++++++++-- 8 files changed, 260 insertions(+), 44 deletions(-)
block/genhd.c +9 -9
@@ -743,7 +743,6 @@ void __init printk_all_partitions(void)struct hd_struct *part;char name_buf[BDEVNAME_SIZE ];char devt_buf[BDEVT_SIZE ]; -char uuid_buf[PARTITION_META_INFO_UUIDLTH *2 +5 ];/* * Don't show empty devices or things that have been
@@ -762,16 +761,17 @@ void __init printk_all_partitions(void)while ((part =disk_part_iter_next (&piter))) {bool is_part0 = part == &disk->part0; - uuid_buf[0 ] ='\0' ; -if (part->info) -snprintf (uuid_buf,sizeof (uuid_buf),"%pU" , - part->info->uuid); - -printk ("%s%s %10llu %s %s" , is_part0 ?"" :" " , +printk ("%s%s %10llu %s" , is_part0 ?"" :" " ,bdevt_str (part_devt (part), devt_buf), (unsigned long long )part->nr_sects >>1 , -disk_name (disk, part->partno, name_buf), - uuid_buf); +disk_name (disk, part->partno, name_buf)); +if (part->info && part->info->has_uuid) +printk (" PARTUUID=%pUb" , part->info->uuid); +if (part->info && part->info->has_volname) +printk (" PARTLABEL=%s" , part->info->volname); +if (part->info && part->info->has_diskid) +printk (" DISKID=%08x/PARTNR=%d" , + part->info->diskid, part->partno);if (is_part0) {if (disk->driverfs_dev !=NULL && disk->driverfs_dev->driver !=NULL )
block/partition-generic.c +1 -2
@@ -508,8 +508,7 @@ rescan: } } -if (state->parts[p].has_info) - info = &state->parts[p].info; + info = &state->parts[p].info; part =add_partition (disk, p, from, size, state->parts[p].flags, &state->parts[p].info);
block/partitions/check.h +0 -1
@@ -13,7 +13,6 @@ struct parsed_partitions {sector_t from;sector_t size;int flags; -bool has_info;struct partition_meta_info info; } parts[DISK_MAX_PARTS ];int next;
block/partitions/efi.c +8 -2
@@ -25,6 +25,9 @@* TODO: * * Changelog: +* Sun Jul 22 2012 Andy Getzendanner <[email protected]> +* - generalized partition_meta_info and populated volname field from GPT +* * Mon Nov 09 2004 Matt Domsch <[email protected]> * - test for valid PMBR and valid PGPT before ever reading * AGPT, allow override with 'gpt' kernel command line option.
@@ -95,6 +98,7 @@************************************************************/ #include <linux/crc32.h> #include <linux/ctype.h> +#include <linux/genhd.h> #include <linux/math64.h> #include <linux/slab.h> #include "check.h"
@@ -654,19 +658,21 @@ int efi_partition(struct parsed_partitions *state)*/ efi_guid_unparse (&ptes[i].unique_partition_guid, unparsed_guid);part_pack_uuid (unparsed_guid, info->uuid); + info->has_uuid = true;/* Naively convert UTF16-LE to 7 bits. */ label_max =min (sizeof (info->volname) -1 ,sizeof (ptes[i].partition_name)); info->volname[label_max] =0 ;while (label_count < label_max) { -u8 c = ptes[i].partition_name[label_count] &0xff ; +u8 c =le16_to_cpu ( + ptes[i].partition_name[label_count]) &0xff ;if (c && !isprint (c)) c ='!' ; info->volname[label_count] = c; label_count++; } - state->parts[i +1 ].has_info = true; + info->has_volname = true; }kfree (ptes);kfree (gpt);
block/partitions/mac.c +16 -4
@@ -7,6 +7,8 @@*/ #include <linux/ctype.h> +#include <linux/genhd.h> +#include <linux/string.h> #include "check.h" #include "mac.h"
@@ -66,6 +68,9 @@ int mac_partition(struct parsed_partitions *state)strlcat (state->pp_buf," [mac]" ,PAGE_SIZE );for (slot =1 ; slot <= blocks_in_map; ++slot) {int pos = slot * secsize; +unsigned volname_max; +struct partition_meta_info *info; +put_dev_sector (sect); data =read_part_sector (state, pos/512 , §);if (!data)
@@ -79,6 +84,13 @@ int mac_partition(struct parsed_partitions *state)if (!strnicmp (part->type,"Linux_RAID" ,10 )) state->parts[slot].flags =ADDPART_FLAG_RAID ; + +mac_fix_string (part->name,sizeof (part->name)); + info = &state->parts[slot].info; + volname_max =min (sizeof (info->volname),sizeof (part->name)); +strlcpy (info->volname, part->name, volname_max); + info->has_volname = true; +#ifdef CONFIG_PPC_PMAC /* * If this is the first bootable partition, tell the
@@ -87,10 +99,10 @@ int mac_partition(struct parsed_partitions *state)if (machine_is (powermac)) {int goodness =0 ; -mac_fix_string (part->processor,16 ); -mac_fix_string (part->name,32 ); -mac_fix_string (part->type,32 ); - +mac_fix_string (part->processor, +sizeof (part->processor)); +mac_fix_string (part->type,sizeof (part->type)); +if ((be32_to_cpu (part->status) &MAC_STATUS_BOOTABLE ) &&strcasecmp (part->processor,"powerpc" ) ==0 ) goodness++;
block/partitions/msdos.c +76 -21
249 lines not on this page · raw message
include/linux/genhd.h +2 -0
@@ -91,7 +91,9 @@ struct disk_stats {#define PARTITION_META_INFO_UUIDLTH 16struct partition_meta_info { +bool has_uuid, has_diskid, has_volname;u8 uuid[PARTITION_META_INFO_UUIDLTH ];/* always big endian */ +u32 diskid;u8 volname[PARTITION_META_INFO_VOLNAMELTH ]; };
init/do_mounts.c +148 -5
191 lines not on this page · raw message
Signature · 1 line
1.7.8.6