diff options
author | Kristen Carlson Accardi <kristen.c.accardi@intel.com> | 2007-05-23 13:57:38 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-23 20:14:12 -0700 |
commit | 8ce7ad7b2d11fae2c3d285a6a0caea9322c0b8fc (patch) | |
tree | 87d7423635821dae9f26d14c62f3314ec7bb3b17 /block | |
parent | 86ce18d7b7925bfd6b64c061828ca2a857ee83b8 (diff) | |
download | kernel_goldelico_gta04-8ce7ad7b2d11fae2c3d285a6a0caea9322c0b8fc.zip kernel_goldelico_gta04-8ce7ad7b2d11fae2c3d285a6a0caea9322c0b8fc.tar.gz kernel_goldelico_gta04-8ce7ad7b2d11fae2c3d285a6a0caea9322c0b8fc.tar.bz2 |
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')
-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 7efa8bb..863a8c0 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -696,6 +696,27 @@ struct seq_operations diskstats_op = { .show = diskstats_show }; +static void media_change_notify_thread(struct work_struct *work) +{ + struct gendisk *gd = container_of(work, struct gendisk, async_notify); + char event[] = "MEDIA_CHANGE=1"; + char *envp[] = { event, NULL }; + + /* + * set enviroment vars to indicate which event this is for + * so that user space will know to go check the media status. + */ + kobject_uevent_env(&gd->kobj, KOBJ_CHANGE, envp); + put_device(gd->driverfs_dev); +} + +void genhd_media_change_notify(struct gendisk *disk) +{ + get_device(disk->driverfs_dev); + schedule_work(&disk->async_notify); +} +EXPORT_SYMBOL_GPL(genhd_media_change_notify); + struct gendisk *alloc_disk(int minors) { return alloc_disk_node(minors, -1); @@ -725,6 +746,8 @@ struct gendisk *alloc_disk_node(int minors, int node_id) kobj_set_kset_s(disk,block_subsys); kobject_init(&disk->kobj); rand_initialize_disk(disk); + INIT_WORK(&disk->async_notify, + media_change_notify_thread); } return disk; } |