diff options
Diffstat (limited to 'block')
-rw-r--r-- | block/genhd.c | 17 | ||||
-rw-r--r-- | block/partition-generic.c | 11 | ||||
-rw-r--r-- | block/partitions/efi.c | 16 |
3 files changed, 42 insertions, 2 deletions
diff --git a/block/genhd.c b/block/genhd.c index cdeb5277dfd4..6f612a747810 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1107,6 +1107,22 @@ static void disk_release(struct device *dev) blk_put_queue(disk->queue); kfree(disk); } + +static int disk_uevent(struct device *dev, struct kobj_uevent_env *env) +{ + struct gendisk *disk = dev_to_disk(dev); + struct disk_part_iter piter; + struct hd_struct *part; + int cnt = 0; + + disk_part_iter_init(&piter, disk, 0); + while((part = disk_part_iter_next(&piter))) + cnt++; + disk_part_iter_exit(&piter); + add_uevent_var(env, "NPARTS=%u", cnt); + return 0; +} + struct class block_class = { .name = "block", }; @@ -1126,6 +1142,7 @@ static struct device_type disk_type = { .groups = disk_attr_groups, .release = disk_release, .devnode = block_devnode, + .uevent = disk_uevent, }; #ifdef CONFIG_PROC_FS diff --git a/block/partition-generic.c b/block/partition-generic.c index 789cdea05893..c7942acf1379 100644 --- a/block/partition-generic.c +++ b/block/partition-generic.c @@ -216,10 +216,21 @@ static void part_release(struct device *dev) kfree(p); } +static int part_uevent(struct device *dev, struct kobj_uevent_env *env) +{ + struct hd_struct *part = dev_to_part(dev); + + add_uevent_var(env, "PARTN=%u", part->partno); + if (part->info && part->info->volname[0]) + add_uevent_var(env, "PARTNAME=%s", part->info->volname); + return 0; +} + struct device_type part_type = { .name = "partition", .groups = part_attr_groups, .release = part_release, + .uevent = part_uevent, }; static void delete_partition_rcu_cb(struct rcu_head *head) diff --git a/block/partitions/efi.c b/block/partitions/efi.c index c85fc895ecdb..894174ca6773 100644 --- a/block/partitions/efi.c +++ b/block/partitions/efi.c @@ -93,6 +93,7 @@ * - Code works, detects all the partitions. * ************************************************************/ +#include <linux/kernel.h> #include <linux/crc32.h> #include <linux/ctype.h> #include <linux/math64.h> @@ -105,6 +106,7 @@ * the partition tables happens after init too. */ static int force_gpt; +static u64 force_gpt_sector; static int __init force_gpt_fn(char *str) { @@ -113,6 +115,13 @@ force_gpt_fn(char *str) } __setup("gpt", force_gpt_fn); +static int __init force_gpt_sector_fn(char *str) +{ + force_gpt_sector = simple_strtoull(str, NULL, 0); + return 1; +} +__setup("gpt_sector=", force_gpt_sector_fn); + /** * efi_crc32() - EFI version of crc32 function @@ -564,6 +573,9 @@ static int find_valid_gpt(struct parsed_partitions *state, gpt_header **gpt, if (!good_agpt && force_gpt) good_agpt = is_gpt_valid(state, lastlba, &agpt, &aptes); + if (!good_agpt && force_gpt && force_gpt_sector) + good_agpt = is_gpt_valid(state, force_gpt_sector, &agpt, &aptes); + /* The obviously unsuccessful case */ if (!good_pgpt && !good_agpt) goto fail; @@ -659,8 +671,8 @@ int efi_partition(struct parsed_partitions *state) efi_guid_unparse(&ptes[i].unique_partition_guid, info->uuid); /* Naively convert UTF16-LE to 7 bits. */ - label_max = min(sizeof(info->volname) - 1, - sizeof(ptes[i].partition_name)); + label_max = min(ARRAY_SIZE(info->volname) - 1, + ARRAY_SIZE(ptes[i].partition_name)); info->volname[label_max] = 0; while (label_count < label_max) { u8 c = ptes[i].partition_name[label_count] & 0xff; |