diff options
author | Hannes Reinecke <hare@suse.de> | 2009-07-28 03:13:13 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2009-09-11 08:33:31 -0400 |
commit | e3264a4d7de147677f1995f119eba05c9abe9c1c (patch) | |
tree | 151047f3598583556194262a5b07c75ca3b4781d /block/genhd.c | |
parent | d58b85e1e891cd842d6e183f5d94d06a4fd0122c (diff) |
Send uevents for write_protect changes
Whenever a block device changes it's read-only attribute
notify the userspace about it.
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Nikanth Karthikesan <knikanth@suse.de>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block/genhd.c')
-rw-r--r-- | block/genhd.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/block/genhd.c b/block/genhd.c index f4c64c2b303a..b89328eceee2 100644 --- a/block/genhd.c +++ b/block/genhd.c | |||
@@ -1215,6 +1215,16 @@ void put_disk(struct gendisk *disk) | |||
1215 | 1215 | ||
1216 | EXPORT_SYMBOL(put_disk); | 1216 | EXPORT_SYMBOL(put_disk); |
1217 | 1217 | ||
1218 | static void set_disk_ro_uevent(struct gendisk *gd, int ro) | ||
1219 | { | ||
1220 | char event[] = "DISK_RO=1"; | ||
1221 | char *envp[] = { event, NULL }; | ||
1222 | |||
1223 | if (!ro) | ||
1224 | event[8] = '0'; | ||
1225 | kobject_uevent_env(&disk_to_dev(gd)->kobj, KOBJ_CHANGE, envp); | ||
1226 | } | ||
1227 | |||
1218 | void set_device_ro(struct block_device *bdev, int flag) | 1228 | void set_device_ro(struct block_device *bdev, int flag) |
1219 | { | 1229 | { |
1220 | bdev->bd_part->policy = flag; | 1230 | bdev->bd_part->policy = flag; |
@@ -1227,8 +1237,12 @@ void set_disk_ro(struct gendisk *disk, int flag) | |||
1227 | struct disk_part_iter piter; | 1237 | struct disk_part_iter piter; |
1228 | struct hd_struct *part; | 1238 | struct hd_struct *part; |
1229 | 1239 | ||
1230 | disk_part_iter_init(&piter, disk, | 1240 | if (disk->part0.policy != flag) { |
1231 | DISK_PITER_INCL_EMPTY | DISK_PITER_INCL_PART0); | 1241 | set_disk_ro_uevent(disk, flag); |
1242 | disk->part0.policy = flag; | ||
1243 | } | ||
1244 | |||
1245 | disk_part_iter_init(&piter, disk, DISK_PITER_INCL_EMPTY); | ||
1232 | while ((part = disk_part_iter_next(&piter))) | 1246 | while ((part = disk_part_iter_next(&piter))) |
1233 | part->policy = flag; | 1247 | part->policy = flag; |
1234 | disk_part_iter_exit(&piter); | 1248 | disk_part_iter_exit(&piter); |