aboutsummaryrefslogtreecommitdiffstats
path: root/fs/partitions/check.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2008-10-13 07:27:59 -0400
committerJens Axboe <jens.axboe@oracle.com>2008-10-17 02:46:56 -0400
commit0fc71e3d6520ba7abad5cfbc9a33db0190e4d5b8 (patch)
tree4793789ea94ffec2c5169378fd6ed7228fb31eeb /fs/partitions/check.c
parent0e11e342bac31f51ea055b147d20f77b59b9dd2c (diff)
block: add partition attribute for partition number
With extended devt, finding out the partition number becomes a bit more challenging as subtracting the minor number from that of the parent device doesn't work anymore. The only thing left is parsing the partition name which is brittle and not exactly universal (some have '-' between the device name and partition number while others don't). This patch introduced partition attribute which contains the partition number of the device. This should make finding partitions and its index easier. This problem and solution were suggested by H. Peter Anvin. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'fs/partitions/check.c')
-rw-r--r--fs/partitions/check.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index fbeb2f372a93..cfb0c80690aa 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -195,6 +195,14 @@ check_partition(struct gendisk *hd, struct block_device *bdev)
195 return ERR_PTR(res); 195 return ERR_PTR(res);
196} 196}
197 197
198static ssize_t part_partition_show(struct device *dev,
199 struct device_attribute *attr, char *buf)
200{
201 struct hd_struct *p = dev_to_part(dev);
202
203 return sprintf(buf, "%d\n", p->partno);
204}
205
198static ssize_t part_start_show(struct device *dev, 206static ssize_t part_start_show(struct device *dev,
199 struct device_attribute *attr, char *buf) 207 struct device_attribute *attr, char *buf)
200{ 208{
@@ -260,6 +268,7 @@ ssize_t part_fail_store(struct device *dev,
260} 268}
261#endif 269#endif
262 270
271static DEVICE_ATTR(partition, S_IRUGO, part_partition_show, NULL);
263static DEVICE_ATTR(start, S_IRUGO, part_start_show, NULL); 272static DEVICE_ATTR(start, S_IRUGO, part_start_show, NULL);
264static DEVICE_ATTR(size, S_IRUGO, part_size_show, NULL); 273static DEVICE_ATTR(size, S_IRUGO, part_size_show, NULL);
265static DEVICE_ATTR(stat, S_IRUGO, part_stat_show, NULL); 274static DEVICE_ATTR(stat, S_IRUGO, part_stat_show, NULL);
@@ -269,6 +278,7 @@ static struct device_attribute dev_attr_fail =
269#endif 278#endif
270 279
271static struct attribute *part_attrs[] = { 280static struct attribute *part_attrs[] = {
281 &dev_attr_partition.attr,
272 &dev_attr_start.attr, 282 &dev_attr_start.attr,
273 &dev_attr_size.attr, 283 &dev_attr_size.attr,
274 &dev_attr_stat.attr, 284 &dev_attr_stat.attr,