return sprintf(buf, "%8u %8u\n", p->in_flight[0], p->in_flight[1]);
}
+ssize_t part_partition_name_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct hd_struct *p = dev_to_part(dev);
+ return sprintf(buf, "%s\n", p->partition_name);
+}
+
#ifdef CONFIG_FAIL_MAKE_REQUEST
ssize_t part_fail_show(struct device *dev,
struct device_attribute *attr, char *buf)
NULL);
static DEVICE_ATTR(stat, S_IRUGO, part_stat_show, NULL);
static DEVICE_ATTR(inflight, S_IRUGO, part_inflight_show, NULL);
+static DEVICE_ATTR(partition_name, S_IRUGO, part_partition_name_show, NULL);
+
#ifdef CONFIG_FAIL_MAKE_REQUEST
static struct device_attribute dev_attr_fail =
__ATTR(make-it-fail, S_IRUGO|S_IWUSR, part_fail_show, part_fail_store);
&dev_attr_discard_alignment.attr,
&dev_attr_stat.attr,
&dev_attr_inflight.attr,
+ &dev_attr_partition_name.attr,
#ifdef CONFIG_FAIL_MAKE_REQUEST
&dev_attr_fail.attr,
#endif
static DEVICE_ATTR(whole_disk, S_IRUSR | S_IRGRP | S_IROTH,
whole_disk_show, NULL);
+static void name_partition(struct hd_struct *p, const char *name)
+{
+ strlcpy(p->partition_name, name, GENHD_PART_NAME_SIZE);
+}
+
struct hd_struct *add_partition(struct gendisk *disk, int partno,
sector_t start, sector_t len, int flags)
{
disk->disk_name, p, -PTR_ERR(part));
continue;
}
+ name_partition(part, state->parts[p].name);
#ifdef CONFIG_BLK_DEV_MD
if (state->parts[p].flags & ADDPART_FLAG_RAID)
md_autodetect_dev(part_to_dev(part)->devt);
#include <linux/pagemap.h>
#include <linux/blkdev.h>
+#define PART_NAME_SIZE 128
+
/*
* add_gd_partition adds a partitions details to the devices partition
* description.
sector_t from;
sector_t size;
int flags;
+ char name[PART_NAME_SIZE];
} parts[DISK_MAX_PARTS];
int next;
int limit;
}
static inline void
-put_partition(struct parsed_partitions *p, int n, sector_t from, sector_t size)
+put_named_partition(struct parsed_partitions *p, int n, sector_t from,
+ sector_t size, const char *name, size_t name_size)
{
if (n < p->limit) {
char tmp[1 + BDEVNAME_SIZE + 10 + 1];
p->parts[n].size = size;
snprintf(tmp, sizeof(tmp), " %s%d", p->name, n);
strlcat(p->pp_buf, tmp, PAGE_SIZE);
+ if (name) {
+ if (name_size > PART_NAME_SIZE - 1)
+ name_size = PART_NAME_SIZE - 1;
+ memcpy(p->parts[n].name, name, name_size);
+ p->parts[n].name[name_size] = 0;
+ snprintf(tmp, sizeof(tmp), " (%s)", p->parts[n].name);
+ strlcat(p->pp_buf, tmp, PAGE_SIZE);
+ }
}
}
+static inline void
+put_partition(struct parsed_partitions *p, int n, sector_t from, sector_t size)
+{
+ put_named_partition(p, n, from, size, NULL, 0);
+}
+
extern int warn_no_part;
#define disk_to_dev(disk) (&(disk)->part0.__dev)
#define part_to_dev(part) (&((part)->__dev))
+#define GENHD_PART_NAME_SIZE 128
+
extern struct device_type part_type;
extern struct kobject *block_depr;
extern struct class block_class;
struct disk_stats dkstats;
#endif
struct rcu_head rcu_head;
+ char partition_name[GENHD_PART_NAME_SIZE];
};
#define GENHD_FL_REMOVABLE 1