block, partition: add partition_meta_info to hd_struct
[pandora-kernel.git] / fs / partitions / check.c
index 72c5265..6dfbee0 100644 (file)
@@ -164,10 +164,16 @@ check_partition(struct gendisk *hd, struct block_device *bdev)
        state = kzalloc(sizeof(struct parsed_partitions), GFP_KERNEL);
        if (!state)
                return NULL;
+       state->pp_buf = (char *)__get_free_page(GFP_KERNEL);
+       if (!state->pp_buf) {
+               kfree(state);
+               return NULL;
+       }
+       state->pp_buf[0] = '\0';
 
        state->bdev = bdev;
        disk_name(hd, 0, state->name);
-       printk(KERN_INFO " %s:", state->name);
+       snprintf(state->pp_buf, PAGE_SIZE, " %s:", state->name);
        if (isdigit(state->name[strlen(state->name)-1]))
                sprintf(state->name, "p");
 
@@ -185,17 +191,25 @@ check_partition(struct gendisk *hd, struct block_device *bdev)
                }
 
        }
-       if (res > 0)
+       if (res > 0) {
+               printk(KERN_INFO "%s", state->pp_buf);
+
+               free_page((unsigned long)state->pp_buf);
                return state;
+       }
        if (state->access_beyond_eod)
                err = -ENOSPC;
        if (err)
        /* The partition is unrecognized. So report I/O errors if there were any */
                res = err;
        if (!res)
-               printk(" unknown partition table\n");
+               strlcat(state->pp_buf, " unknown partition table\n", PAGE_SIZE);
        else if (warn_no_part)
-               printk(" unable to read partition table\n");
+               strlcat(state->pp_buf, " unable to read partition table\n", PAGE_SIZE);
+
+       printk(KERN_INFO "%s", state->pp_buf);
+
+       free_page((unsigned long)state->pp_buf);
        kfree(state);
        return ERR_PTR(res);
 }
@@ -338,6 +352,7 @@ static void part_release(struct device *dev)
 {
        struct hd_struct *p = dev_to_part(dev);
        free_part_stats(p);
+       free_part_info(p);
        kfree(p);
 }
 
@@ -387,7 +402,8 @@ static DEVICE_ATTR(whole_disk, S_IRUSR | S_IRGRP | S_IROTH,
                   whole_disk_show, NULL);
 
 struct hd_struct *add_partition(struct gendisk *disk, int partno,
-                               sector_t start, sector_t len, int flags)
+                               sector_t start, sector_t len, int flags,
+                               struct partition_meta_info *info)
 {
        struct hd_struct *p;
        dev_t devt = MKDEV(0, 0);
@@ -424,6 +440,14 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
        p->partno = partno;
        p->policy = get_disk_ro(disk);
 
+       if (info) {
+               struct partition_meta_info *pinfo = alloc_part_info(disk);
+               if (!pinfo)
+                       goto out_free_stats;
+               memcpy(pinfo, info, sizeof(*info));
+               p->info = pinfo;
+       }
+
        dname = dev_name(ddev);
        if (isdigit(dname[strlen(dname) - 1]))
                dev_set_name(pdev, "%sp%d", dname, partno);
@@ -437,7 +461,7 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
 
        err = blk_alloc_devt(p, &devt);
        if (err)
-               goto out_free_stats;
+               goto out_free_info;
        pdev->devt = devt;
 
        /* delay uevent until 'holders' subdir is created */
@@ -467,6 +491,8 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
 
        return p;
 
+out_free_info:
+       free_part_info(p);
 out_free_stats:
        free_part_stats(p);
 out_free:
@@ -628,6 +654,7 @@ rescan:
        /* add partitions */
        for (p = 1; p < state->limit; p++) {
                sector_t size, from;
+               struct partition_meta_info *info = NULL;
 
                size = state->parts[p].size;
                if (!size)
@@ -661,8 +688,12 @@ rescan:
                                size = get_capacity(disk) - from;
                        }
                }
+
+               if (state->parts[p].has_info)
+                       info = &state->parts[p].info;
                part = add_partition(disk, p, from, size,
-                                    state->parts[p].flags);
+                                    state->parts[p].flags,
+                                    &state->parts[p].info);
                if (IS_ERR(part)) {
                        printk(KERN_ERR " %s: p%d could not be added: %ld\n",
                               disk->disk_name, p, -PTR_ERR(part));