diff options
Diffstat (limited to 'block/genhd.c')
-rw-r--r-- | block/genhd.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/block/genhd.c b/block/genhd.c index 7efa8bb25da9..863a8c0623ed 100644 --- a/block/genhd.c +++ b/block/genhd.c | |||
@@ -696,6 +696,27 @@ struct seq_operations diskstats_op = { | |||
696 | .show = diskstats_show | 696 | .show = diskstats_show |
697 | }; | 697 | }; |
698 | 698 | ||
699 | static void media_change_notify_thread(struct work_struct *work) | ||
700 | { | ||
701 | struct gendisk *gd = container_of(work, struct gendisk, async_notify); | ||
702 | char event[] = "MEDIA_CHANGE=1"; | ||
703 | char *envp[] = { event, NULL }; | ||
704 | |||
705 | /* | ||
706 | * set enviroment vars to indicate which event this is for | ||
707 | * so that user space will know to go check the media status. | ||
708 | */ | ||
709 | kobject_uevent_env(&gd->kobj, KOBJ_CHANGE, envp); | ||
710 | put_device(gd->driverfs_dev); | ||
711 | } | ||
712 | |||
713 | void genhd_media_change_notify(struct gendisk *disk) | ||
714 | { | ||
715 | get_device(disk->driverfs_dev); | ||
716 | schedule_work(&disk->async_notify); | ||
717 | } | ||
718 | EXPORT_SYMBOL_GPL(genhd_media_change_notify); | ||
719 | |||
699 | struct gendisk *alloc_disk(int minors) | 720 | struct gendisk *alloc_disk(int minors) |
700 | { | 721 | { |
701 | return alloc_disk_node(minors, -1); | 722 | return alloc_disk_node(minors, -1); |
@@ -725,6 +746,8 @@ struct gendisk *alloc_disk_node(int minors, int node_id) | |||
725 | kobj_set_kset_s(disk,block_subsys); | 746 | kobj_set_kset_s(disk,block_subsys); |
726 | kobject_init(&disk->kobj); | 747 | kobject_init(&disk->kobj); |
727 | rand_initialize_disk(disk); | 748 | rand_initialize_disk(disk); |
749 | INIT_WORK(&disk->async_notify, | ||
750 | media_change_notify_thread); | ||
728 | } | 751 | } |
729 | return disk; | 752 | return disk; |
730 | } | 753 | } |