aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2008-06-13 03:41:00 -0400
committerJens Axboe <jens.axboe@oracle.com>2008-07-03 07:21:12 -0400
commit1c9ce5276324ae566ca409491b99a2cc8d5986fa (patch)
treeeca8ad1317880de5da3f7126e746d366f699348d /block
parent02c62304e6af60f1963695c6bc1bbffe619aa585 (diff)
block: export "ro" attribute
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block')
-rw-r--r--block/genhd.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/block/genhd.c b/block/genhd.c
index b922d4801c87..43e468ee5993 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -400,6 +400,14 @@ static ssize_t disk_removable_show(struct device *dev,
400 (disk->flags & GENHD_FL_REMOVABLE ? 1 : 0)); 400 (disk->flags & GENHD_FL_REMOVABLE ? 1 : 0));
401} 401}
402 402
403static ssize_t disk_ro_show(struct device *dev,
404 struct device_attribute *attr, char *buf)
405{
406 struct gendisk *disk = dev_to_disk(dev);
407
408 return sprintf(buf, "%d\n", disk->policy ? 1 : 0);
409}
410
403static ssize_t disk_size_show(struct device *dev, 411static ssize_t disk_size_show(struct device *dev,
404 struct device_attribute *attr, char *buf) 412 struct device_attribute *attr, char *buf)
405{ 413{
@@ -472,6 +480,7 @@ static ssize_t disk_fail_store(struct device *dev,
472 480
473static DEVICE_ATTR(range, S_IRUGO, disk_range_show, NULL); 481static DEVICE_ATTR(range, S_IRUGO, disk_range_show, NULL);
474static DEVICE_ATTR(removable, S_IRUGO, disk_removable_show, NULL); 482static DEVICE_ATTR(removable, S_IRUGO, disk_removable_show, NULL);
483static DEVICE_ATTR(ro, S_IRUGO, disk_ro_show, NULL);
475static DEVICE_ATTR(size, S_IRUGO, disk_size_show, NULL); 484static DEVICE_ATTR(size, S_IRUGO, disk_size_show, NULL);
476static DEVICE_ATTR(capability, S_IRUGO, disk_capability_show, NULL); 485static DEVICE_ATTR(capability, S_IRUGO, disk_capability_show, NULL);
477static DEVICE_ATTR(stat, S_IRUGO, disk_stat_show, NULL); 486static DEVICE_ATTR(stat, S_IRUGO, disk_stat_show, NULL);
@@ -483,6 +492,7 @@ static struct device_attribute dev_attr_fail =
483static struct attribute *disk_attrs[] = { 492static struct attribute *disk_attrs[] = {
484 &dev_attr_range.attr, 493 &dev_attr_range.attr,
485 &dev_attr_removable.attr, 494 &dev_attr_removable.attr,
495 &dev_attr_ro.attr,
486 &dev_attr_size.attr, 496 &dev_attr_size.attr,
487 &dev_attr_capability.attr, 497 &dev_attr_capability.attr,
488 &dev_attr_stat.attr, 498 &dev_attr_stat.attr,