Commit 34db1d595ef6f183fbc1e42cda45a3dfa0035258
Committed by
Jens Axboe
1 parent
2b9408a459
Exists in
master
and in
4 other branches
block: export 'ro' sysfs attribute for partitions
We already export 'ro' for the disk. This adds the same attribute for partitions. Cc: Karel Zak <kzak@redhat.com> Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Showing 1 changed file with 9 additions and 0 deletions Side-by-side Diff
fs/partitions/check.c
... | ... | @@ -237,6 +237,13 @@ |
237 | 237 | return sprintf(buf, "%llu\n",(unsigned long long)p->nr_sects); |
238 | 238 | } |
239 | 239 | |
240 | +ssize_t part_ro_show(struct device *dev, | |
241 | + struct device_attribute *attr, char *buf) | |
242 | +{ | |
243 | + struct hd_struct *p = dev_to_part(dev); | |
244 | + return sprintf(buf, "%d\n", p->policy ? 1 : 0); | |
245 | +} | |
246 | + | |
240 | 247 | ssize_t part_alignment_offset_show(struct device *dev, |
241 | 248 | struct device_attribute *attr, char *buf) |
242 | 249 | { |
... | ... | @@ -312,6 +319,7 @@ |
312 | 319 | static DEVICE_ATTR(partition, S_IRUGO, part_partition_show, NULL); |
313 | 320 | static DEVICE_ATTR(start, S_IRUGO, part_start_show, NULL); |
314 | 321 | static DEVICE_ATTR(size, S_IRUGO, part_size_show, NULL); |
322 | +static DEVICE_ATTR(ro, S_IRUGO, part_ro_show, NULL); | |
315 | 323 | static DEVICE_ATTR(alignment_offset, S_IRUGO, part_alignment_offset_show, NULL); |
316 | 324 | static DEVICE_ATTR(discard_alignment, S_IRUGO, part_discard_alignment_show, |
317 | 325 | NULL); |
... | ... | @@ -326,6 +334,7 @@ |
326 | 334 | &dev_attr_partition.attr, |
327 | 335 | &dev_attr_start.attr, |
328 | 336 | &dev_attr_size.attr, |
337 | + &dev_attr_ro.attr, | |
329 | 338 | &dev_attr_alignment_offset.attr, |
330 | 339 | &dev_attr_discard_alignment.attr, |
331 | 340 | &dev_attr_stat.attr, |