Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=d18d7682c18b617f523df6beea5ea0bd396ed0bd
Commit:     d18d7682c18b617f523df6beea5ea0bd396ed0bd
Parent:     66efc5a7e3061c3597ac43a8bb1026488d57e66b
Author:     Fabio Massimo Di Nitto <[EMAIL PROTECTED]>
AuthorDate: Sat Feb 10 23:50:00 2007 -0800
Committer:  David S. Miller <[EMAIL PROTECTED]>
CommitDate: Sat Feb 10 23:50:00 2007 -0800

    [PARTITION]: Add whole_disk attribute.
    
    Some partitioning systems create special partitions that
    span the entire disk.  One example are Sun partitions, and
    this whole-disk partition exists to tell the firmware the
    extent of the entire device so it can load the boot block
    and do other things.
    
    Such partitions should not be treated as normal partitions,
    because all the other partitions overlap this whole-disk one.
    So we'd see multiple instances of the same UUID etc. which
    we do not want.  udev and friends can thus search for this
    'whole_disk' attribute and use it to decide to ignore the
    partition.
    
    Signed-off-by: Fabio Massimo Di Nitto <[EMAIL PROTECTED]>
    Signed-off-by: David S. Miller <[EMAIL PROTECTED]>
---
 block/ioctl.c         |    2 +-
 fs/partitions/check.c |   15 ++++++++++++---
 fs/partitions/msdos.c |    2 +-
 fs/partitions/sgi.c   |    2 +-
 fs/partitions/sun.c   |    5 ++++-
 include/linux/genhd.h |    8 +++++++-
 6 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/block/ioctl.c b/block/ioctl.c
index f6962b6..e3f5eb9 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -61,7 +61,7 @@ static int blkpg_ioctl(struct block_device *bdev, struct 
blkpg_ioctl_arg __user
                                }
                        }
                        /* all seems OK */
-                       add_partition(disk, part, start, length);
+                       add_partition(disk, part, start, length, 
ADDPART_FLAG_NONE);
                        mutex_unlock(&bdev->bd_mutex);
                        return 0;
                case BLKPG_DEL_PARTITION:
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 3d73d94..ac32a2e 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -365,7 +365,7 @@ void delete_partition(struct gendisk *disk, int part)
        kobject_put(&p->kobj);
 }
 
-void add_partition(struct gendisk *disk, int part, sector_t start, sector_t 
len)
+void add_partition(struct gendisk *disk, int part, sector_t start, sector_t 
len, int flags)
 {
        struct hd_struct *p;
 
@@ -390,6 +390,15 @@ void add_partition(struct gendisk *disk, int part, 
sector_t start, sector_t len)
        if (!disk->part_uevent_suppress)
                kobject_uevent(&p->kobj, KOBJ_ADD);
        sysfs_create_link(&p->kobj, &block_subsys.kset.kobj, "subsystem");
+       if (flags & ADDPART_FLAG_WHOLEDISK) {
+               static struct attribute addpartattr = {
+                       .name = "whole_disk",
+                       .mode = S_IRUSR | S_IRGRP | S_IROTH,
+                       .owner = THIS_MODULE,
+               };
+
+               sysfs_create_file(&p->kobj, &addpartattr);
+       }
        partition_sysfs_add_subdir(p);
        disk->part[part-1] = p;
 }
@@ -543,9 +552,9 @@ int rescan_partitions(struct gendisk *disk, struct 
block_device *bdev)
                        printk(" %s: p%d exceeds device capacity\n",
                                disk->disk_name, p);
                }
-               add_partition(disk, p, from, size);
+               add_partition(disk, p, from, size, state->parts[p].flags);
 #ifdef CONFIG_BLK_DEV_MD
-               if (state->parts[p].flags)
+               if (state->parts[p].flags & ADDPART_FLAG_RAID)
                        md_autodetect_dev(bdev->bd_dev+p);
 #endif
        }
diff --git a/fs/partitions/msdos.c b/fs/partitions/msdos.c
index 8c7af17..d964d1f 100644
--- a/fs/partitions/msdos.c
+++ b/fs/partitions/msdos.c
@@ -155,7 +155,7 @@ parse_extended(struct parsed_partitions *state, struct 
block_device *bdev,
 
                        put_partition(state, state->next, next, size);
                        if (SYS_IND(p) == LINUX_RAID_PARTITION)
-                               state->parts[state->next].flags = 1;
+                               state->parts[state->next].flags = 
ADDPART_FLAG_RAID;
                        loopct = 0;
                        if (++state->next == state->limit)
                                goto done;
diff --git a/fs/partitions/sgi.c b/fs/partitions/sgi.c
index 6fa4ff8..ed5ac83 100644
--- a/fs/partitions/sgi.c
+++ b/fs/partitions/sgi.c
@@ -72,7 +72,7 @@ int sgi_partition(struct parsed_partitions *state, struct 
block_device *bdev)
                if (blocks) {
                        put_partition(state, slot, start, blocks);
                        if (be32_to_cpu(p->type) == LINUX_RAID_PARTITION)
-                               state->parts[slot].flags = 1;
+                               state->parts[slot].flags = ADDPART_FLAG_RAID;
                }
                slot++;
        }
diff --git a/fs/partitions/sun.c b/fs/partitions/sun.c
index 0a5927c..123f8b4 100644
--- a/fs/partitions/sun.c
+++ b/fs/partitions/sun.c
@@ -80,8 +80,11 @@ int sun_partition(struct parsed_partitions *state, struct 
block_device *bdev)
                num_sectors = be32_to_cpu(p->num_sectors);
                if (num_sectors) {
                        put_partition(state, slot, st_sector, num_sectors);
+                       state->parts[slot].flags = 0;
                        if (label->infos[i].id == LINUX_RAID_PARTITION)
-                               state->parts[slot].flags = 1;
+                               state->parts[slot].flags |= ADDPART_FLAG_RAID;
+                       if (label->infos[i].id == SUN_WHOLE_DISK)
+                               state->parts[slot].flags |= 
ADDPART_FLAG_WHOLEDISK;
                }
                slot++;
        }
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 0a022b2..247734f 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -20,6 +20,8 @@ enum {
        LINUX_EXTENDED_PARTITION = 0x85,
        WIN98_EXTENDED_PARTITION = 0x0f,
 
+       SUN_WHOLE_DISK = DOS_EXTENDED_PARTITION,
+
        LINUX_SWAP_PARTITION = 0x82,
        LINUX_RAID_PARTITION = 0xfd,    /* autodetect RAID partition */
 
@@ -400,10 +402,14 @@ struct unixware_disklabel {
 
 #ifdef __KERNEL__
 
+#define ADDPART_FLAG_NONE      0
+#define ADDPART_FLAG_RAID      1
+#define ADDPART_FLAG_WHOLEDISK 2
+
 char *disk_name (struct gendisk *hd, int part, char *buf);
 
 extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev);
-extern void add_partition(struct gendisk *, int, sector_t, sector_t);
+extern void add_partition(struct gendisk *, int, sector_t, sector_t, int);
 extern void delete_partition(struct gendisk *, int);
 
 extern struct gendisk *alloc_disk_node(int minors, int node_id);
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to