diff options
author | Jens Axboe <jaxboe@fusionio.com> | 2010-11-16 04:09:42 -0500 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2010-11-16 04:09:42 -0500 |
commit | a02056349cdea2252cd2b21643ebf025e83a29f2 (patch) | |
tree | b7c889d6cbe8e7188d07d99a5c9da858c53a5b6c /fs/partitions | |
parent | 34db1d595ef6f183fbc1e42cda45a3dfa0035258 (diff) | |
parent | e53beacd23d9cb47590da6a7a7f6d417b941a994 (diff) |
Merge branch 'v2.6.37-rc2' into for-2.6.38/core
Diffstat (limited to 'fs/partitions')
-rw-r--r-- | fs/partitions/check.c | 42 | ||||
-rw-r--r-- | fs/partitions/check.h | 3 | ||||
-rw-r--r-- | fs/partitions/efi.c | 25 | ||||
-rw-r--r-- | fs/partitions/ldm.c | 2 | ||||
-rw-r--r-- | fs/partitions/ldm.h | 2 |
5 files changed, 59 insertions, 15 deletions
diff --git a/fs/partitions/check.c b/fs/partitions/check.c index 861ae84fcee5..12213f7ce7a2 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c | |||
@@ -361,6 +361,7 @@ static void part_release(struct device *dev) | |||
361 | { | 361 | { |
362 | struct hd_struct *p = dev_to_part(dev); | 362 | struct hd_struct *p = dev_to_part(dev); |
363 | free_part_stats(p); | 363 | free_part_stats(p); |
364 | free_part_info(p); | ||
364 | kfree(p); | 365 | kfree(p); |
365 | } | 366 | } |
366 | 367 | ||
@@ -410,7 +411,8 @@ static DEVICE_ATTR(whole_disk, S_IRUSR | S_IRGRP | S_IROTH, | |||
410 | whole_disk_show, NULL); | 411 | whole_disk_show, NULL); |
411 | 412 | ||
412 | struct hd_struct *add_partition(struct gendisk *disk, int partno, | 413 | struct hd_struct *add_partition(struct gendisk *disk, int partno, |
413 | sector_t start, sector_t len, int flags) | 414 | sector_t start, sector_t len, int flags, |
415 | struct partition_meta_info *info) | ||
414 | { | 416 | { |
415 | struct hd_struct *p; | 417 | struct hd_struct *p; |
416 | dev_t devt = MKDEV(0, 0); | 418 | dev_t devt = MKDEV(0, 0); |
@@ -447,6 +449,14 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno, | |||
447 | p->partno = partno; | 449 | p->partno = partno; |
448 | p->policy = get_disk_ro(disk); | 450 | p->policy = get_disk_ro(disk); |
449 | 451 | ||
452 | if (info) { | ||
453 | struct partition_meta_info *pinfo = alloc_part_info(disk); | ||
454 | if (!pinfo) | ||
455 | goto out_free_stats; | ||
456 | memcpy(pinfo, info, sizeof(*info)); | ||
457 | p->info = pinfo; | ||
458 | } | ||
459 | |||
450 | dname = dev_name(ddev); | 460 | dname = dev_name(ddev); |
451 | if (isdigit(dname[strlen(dname) - 1])) | 461 | if (isdigit(dname[strlen(dname) - 1])) |
452 | dev_set_name(pdev, "%sp%d", dname, partno); | 462 | dev_set_name(pdev, "%sp%d", dname, partno); |
@@ -460,7 +470,7 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno, | |||
460 | 470 | ||
461 | err = blk_alloc_devt(p, &devt); | 471 | err = blk_alloc_devt(p, &devt); |
462 | if (err) | 472 | if (err) |
463 | goto out_free_stats; | 473 | goto out_free_info; |
464 | pdev->devt = devt; | 474 | pdev->devt = devt; |
465 | 475 | ||
466 | /* delay uevent until 'holders' subdir is created */ | 476 | /* delay uevent until 'holders' subdir is created */ |
@@ -490,6 +500,8 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno, | |||
490 | 500 | ||
491 | return p; | 501 | return p; |
492 | 502 | ||
503 | out_free_info: | ||
504 | free_part_info(p); | ||
493 | out_free_stats: | 505 | out_free_stats: |
494 | free_part_stats(p); | 506 | free_part_stats(p); |
495 | out_free: | 507 | out_free: |
@@ -522,14 +534,14 @@ void register_disk(struct gendisk *disk) | |||
522 | 534 | ||
523 | if (device_add(ddev)) | 535 | if (device_add(ddev)) |
524 | return; | 536 | return; |
525 | #ifndef CONFIG_SYSFS_DEPRECATED | 537 | if (!sysfs_deprecated) { |
526 | err = sysfs_create_link(block_depr, &ddev->kobj, | 538 | err = sysfs_create_link(block_depr, &ddev->kobj, |
527 | kobject_name(&ddev->kobj)); | 539 | kobject_name(&ddev->kobj)); |
528 | if (err) { | 540 | if (err) { |
529 | device_del(ddev); | 541 | device_del(ddev); |
530 | return; | 542 | return; |
543 | } | ||
531 | } | 544 | } |
532 | #endif | ||
533 | disk->part0.holder_dir = kobject_create_and_add("holders", &ddev->kobj); | 545 | disk->part0.holder_dir = kobject_create_and_add("holders", &ddev->kobj); |
534 | disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj); | 546 | disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj); |
535 | 547 | ||
@@ -651,6 +663,7 @@ rescan: | |||
651 | /* add partitions */ | 663 | /* add partitions */ |
652 | for (p = 1; p < state->limit; p++) { | 664 | for (p = 1; p < state->limit; p++) { |
653 | sector_t size, from; | 665 | sector_t size, from; |
666 | struct partition_meta_info *info = NULL; | ||
654 | 667 | ||
655 | size = state->parts[p].size; | 668 | size = state->parts[p].size; |
656 | if (!size) | 669 | if (!size) |
@@ -684,8 +697,12 @@ rescan: | |||
684 | size = get_capacity(disk) - from; | 697 | size = get_capacity(disk) - from; |
685 | } | 698 | } |
686 | } | 699 | } |
700 | |||
701 | if (state->parts[p].has_info) | ||
702 | info = &state->parts[p].info; | ||
687 | part = add_partition(disk, p, from, size, | 703 | part = add_partition(disk, p, from, size, |
688 | state->parts[p].flags); | 704 | state->parts[p].flags, |
705 | &state->parts[p].info); | ||
689 | if (IS_ERR(part)) { | 706 | if (IS_ERR(part)) { |
690 | printk(KERN_ERR " %s: p%d could not be added: %ld\n", | 707 | printk(KERN_ERR " %s: p%d could not be added: %ld\n", |
691 | disk->disk_name, p, -PTR_ERR(part)); | 708 | disk->disk_name, p, -PTR_ERR(part)); |
@@ -746,8 +763,7 @@ void del_gendisk(struct gendisk *disk) | |||
746 | kobject_put(disk->part0.holder_dir); | 763 | kobject_put(disk->part0.holder_dir); |
747 | kobject_put(disk->slave_dir); | 764 | kobject_put(disk->slave_dir); |
748 | disk->driverfs_dev = NULL; | 765 | disk->driverfs_dev = NULL; |
749 | #ifndef CONFIG_SYSFS_DEPRECATED | 766 | if (!sysfs_deprecated) |
750 | sysfs_remove_link(block_depr, dev_name(disk_to_dev(disk))); | 767 | sysfs_remove_link(block_depr, dev_name(disk_to_dev(disk))); |
751 | #endif | ||
752 | device_del(disk_to_dev(disk)); | 768 | device_del(disk_to_dev(disk)); |
753 | } | 769 | } |
diff --git a/fs/partitions/check.h b/fs/partitions/check.h index 8e4e103ba216..d68bf4dc3bc2 100644 --- a/fs/partitions/check.h +++ b/fs/partitions/check.h | |||
@@ -1,5 +1,6 @@ | |||
1 | #include <linux/pagemap.h> | 1 | #include <linux/pagemap.h> |
2 | #include <linux/blkdev.h> | 2 | #include <linux/blkdev.h> |
3 | #include <linux/genhd.h> | ||
3 | 4 | ||
4 | /* | 5 | /* |
5 | * add_gd_partition adds a partitions details to the devices partition | 6 | * add_gd_partition adds a partitions details to the devices partition |
@@ -12,6 +13,8 @@ struct parsed_partitions { | |||
12 | sector_t from; | 13 | sector_t from; |
13 | sector_t size; | 14 | sector_t size; |
14 | int flags; | 15 | int flags; |
16 | bool has_info; | ||
17 | struct partition_meta_info info; | ||
15 | } parts[DISK_MAX_PARTS]; | 18 | } parts[DISK_MAX_PARTS]; |
16 | int next; | 19 | int next; |
17 | int limit; | 20 | int limit; |
diff --git a/fs/partitions/efi.c b/fs/partitions/efi.c index dbb44d4bb8a7..ac0ccb5026a2 100644 --- a/fs/partitions/efi.c +++ b/fs/partitions/efi.c | |||
@@ -94,6 +94,7 @@ | |||
94 | * | 94 | * |
95 | ************************************************************/ | 95 | ************************************************************/ |
96 | #include <linux/crc32.h> | 96 | #include <linux/crc32.h> |
97 | #include <linux/ctype.h> | ||
97 | #include <linux/math64.h> | 98 | #include <linux/math64.h> |
98 | #include <linux/slab.h> | 99 | #include <linux/slab.h> |
99 | #include "check.h" | 100 | #include "check.h" |
@@ -604,6 +605,7 @@ int efi_partition(struct parsed_partitions *state) | |||
604 | gpt_entry *ptes = NULL; | 605 | gpt_entry *ptes = NULL; |
605 | u32 i; | 606 | u32 i; |
606 | unsigned ssz = bdev_logical_block_size(state->bdev) / 512; | 607 | unsigned ssz = bdev_logical_block_size(state->bdev) / 512; |
608 | u8 unparsed_guid[37]; | ||
607 | 609 | ||
608 | if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) { | 610 | if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) { |
609 | kfree(gpt); | 611 | kfree(gpt); |
@@ -614,6 +616,9 @@ int efi_partition(struct parsed_partitions *state) | |||
614 | pr_debug("GUID Partition Table is valid! Yea!\n"); | 616 | pr_debug("GUID Partition Table is valid! Yea!\n"); |
615 | 617 | ||
616 | for (i = 0; i < le32_to_cpu(gpt->num_partition_entries) && i < state->limit-1; i++) { | 618 | for (i = 0; i < le32_to_cpu(gpt->num_partition_entries) && i < state->limit-1; i++) { |
619 | struct partition_meta_info *info; | ||
620 | unsigned label_count = 0; | ||
621 | unsigned label_max; | ||
617 | u64 start = le64_to_cpu(ptes[i].starting_lba); | 622 | u64 start = le64_to_cpu(ptes[i].starting_lba); |
618 | u64 size = le64_to_cpu(ptes[i].ending_lba) - | 623 | u64 size = le64_to_cpu(ptes[i].ending_lba) - |
619 | le64_to_cpu(ptes[i].starting_lba) + 1ULL; | 624 | le64_to_cpu(ptes[i].starting_lba) + 1ULL; |
@@ -627,6 +632,26 @@ int efi_partition(struct parsed_partitions *state) | |||
627 | if (!efi_guidcmp(ptes[i].partition_type_guid, | 632 | if (!efi_guidcmp(ptes[i].partition_type_guid, |
628 | PARTITION_LINUX_RAID_GUID)) | 633 | PARTITION_LINUX_RAID_GUID)) |
629 | state->parts[i + 1].flags = ADDPART_FLAG_RAID; | 634 | state->parts[i + 1].flags = ADDPART_FLAG_RAID; |
635 | |||
636 | info = &state->parts[i + 1].info; | ||
637 | /* Instead of doing a manual swap to big endian, reuse the | ||
638 | * common ASCII hex format as the interim. | ||
639 | */ | ||
640 | efi_guid_unparse(&ptes[i].unique_partition_guid, unparsed_guid); | ||
641 | part_pack_uuid(unparsed_guid, info->uuid); | ||
642 | |||
643 | /* Naively convert UTF16-LE to 7 bits. */ | ||
644 | label_max = min(sizeof(info->volname) - 1, | ||
645 | sizeof(ptes[i].partition_name)); | ||
646 | info->volname[label_max] = 0; | ||
647 | while (label_count < label_max) { | ||
648 | u8 c = ptes[i].partition_name[label_count] & 0xff; | ||
649 | if (c && !isprint(c)) | ||
650 | c = '!'; | ||
651 | info->volname[label_count] = c; | ||
652 | label_count++; | ||
653 | } | ||
654 | state->parts[i + 1].has_info = true; | ||
630 | } | 655 | } |
631 | kfree(ptes); | 656 | kfree(ptes); |
632 | kfree(gpt); | 657 | kfree(gpt); |
diff --git a/fs/partitions/ldm.c b/fs/partitions/ldm.c index 5bf8a04b5d9b..789c625c7aa5 100644 --- a/fs/partitions/ldm.c +++ b/fs/partitions/ldm.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * Copyright (c) 2001-2007 Anton Altaparmakov | 5 | * Copyright (c) 2001-2007 Anton Altaparmakov |
6 | * Copyright (C) 2001,2002 Jakob Kemi <jakob.kemi@telia.com> | 6 | * Copyright (C) 2001,2002 Jakob Kemi <jakob.kemi@telia.com> |
7 | * | 7 | * |
8 | * Documentation is available at http://www.linux-ntfs.org/content/view/19/37/ | 8 | * Documentation is available at http://www.linux-ntfs.org/doku.php?id=downloads |
9 | * | 9 | * |
10 | * This program is free software; you can redistribute it and/or modify it under | 10 | * This program is free software; you can redistribute it and/or modify it under |
11 | * the terms of the GNU General Public License as published by the Free Software | 11 | * the terms of the GNU General Public License as published by the Free Software |
diff --git a/fs/partitions/ldm.h b/fs/partitions/ldm.h index d1fb50b28d86..374242c0971a 100644 --- a/fs/partitions/ldm.h +++ b/fs/partitions/ldm.h | |||
@@ -5,7 +5,7 @@ | |||
5 | * Copyright (c) 2001-2007 Anton Altaparmakov | 5 | * Copyright (c) 2001-2007 Anton Altaparmakov |
6 | * Copyright (C) 2001,2002 Jakob Kemi <jakob.kemi@telia.com> | 6 | * Copyright (C) 2001,2002 Jakob Kemi <jakob.kemi@telia.com> |
7 | * | 7 | * |
8 | * Documentation is available at http://www.linux-ntfs.org/content/view/19/37/ | 8 | * Documentation is available at http://www.linux-ntfs.org/doku.php?id=downloads |
9 | * | 9 | * |
10 | * This program is free software; you can redistribute it and/or modify it | 10 | * This program is free software; you can redistribute it and/or modify it |
11 | * under the terms of the GNU General Public License as published by the Free | 11 | * under the terms of the GNU General Public License as published by the Free |