aboutsummaryrefslogtreecommitdiffstats
path: root/block/genhd.c
diff options
context:
space:
mode:
authorKristen Carlson Accardi <kristen.c.accardi@intel.com>2007-05-23 16:57:38 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-23 23:14:12 -0400
commit8ce7ad7b2d11fae2c3d285a6a0caea9322c0b8fc (patch)
tree87d7423635821dae9f26d14c62f3314ec7bb3b17 /block/genhd.c
parent86ce18d7b7925bfd6b64c061828ca2a857ee83b8 (diff)
genhd: send async notification on media change
Send an uevent to user space to indicate that a media change event has occurred. Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'block/genhd.c')
-rw-r--r--block/genhd.c23
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
699static 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
713void genhd_media_change_notify(struct gendisk *disk)
714{
715 get_device(disk->driverfs_dev);
716 schedule_work(&disk->async_notify);
717}
718EXPORT_SYMBOL_GPL(genhd_media_change_notify);
719
699struct gendisk *alloc_disk(int minors) 720struct 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}