aboutsummaryrefslogtreecommitdiffstats
path: root/block/genhd.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/genhd.c')
-rw-r--r--block/genhd.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/block/genhd.c b/block/genhd.c
index 653919d50cd4..457fdac4c17d 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -417,6 +417,34 @@ static struct disk_attribute disk_attr_stat = {
417 .show = disk_stats_read 417 .show = disk_stats_read
418}; 418};
419 419
420#ifdef CONFIG_FAIL_MAKE_REQUEST
421
422static ssize_t disk_fail_store(struct gendisk * disk,
423 const char *buf, size_t count)
424{
425 int i;
426
427 if (count > 0 && sscanf(buf, "%d", &i) > 0) {
428 if (i == 0)
429 disk->flags &= ~GENHD_FL_FAIL;
430 else
431 disk->flags |= GENHD_FL_FAIL;
432 }
433
434 return count;
435}
436static ssize_t disk_fail_read(struct gendisk * disk, char *page)
437{
438 return sprintf(page, "%d\n", disk->flags & GENHD_FL_FAIL ? 1 : 0);
439}
440static struct disk_attribute disk_attr_fail = {
441 .attr = {.name = "make-it-fail", .mode = S_IRUGO | S_IWUSR },
442 .store = disk_fail_store,
443 .show = disk_fail_read
444};
445
446#endif
447
420static struct attribute * default_attrs[] = { 448static struct attribute * default_attrs[] = {
421 &disk_attr_uevent.attr, 449 &disk_attr_uevent.attr,
422 &disk_attr_dev.attr, 450 &disk_attr_dev.attr,
@@ -424,6 +452,9 @@ static struct attribute * default_attrs[] = {
424 &disk_attr_removable.attr, 452 &disk_attr_removable.attr,
425 &disk_attr_size.attr, 453 &disk_attr_size.attr,
426 &disk_attr_stat.attr, 454 &disk_attr_stat.attr,
455#ifdef CONFIG_FAIL_MAKE_REQUEST
456 &disk_attr_fail.attr,
457#endif
427 NULL, 458 NULL,
428}; 459};
429 460