aboutsummaryrefslogtreecommitdiffstats
path: root/fs/partitions/check.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/partitions/check.c')
-rw-r--r--fs/partitions/check.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 8dc1822a7022..7881ce05daef 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -226,7 +226,7 @@ static struct sysfs_ops part_sysfs_ops = {
226static ssize_t part_uevent_store(struct hd_struct * p, 226static ssize_t part_uevent_store(struct hd_struct * p,
227 const char *page, size_t count) 227 const char *page, size_t count)
228{ 228{
229 kobject_hotplug(&p->kobj, KOBJ_ADD); 229 kobject_uevent(&p->kobj, KOBJ_ADD);
230 return count; 230 return count;
231} 231}
232static ssize_t part_dev_read(struct hd_struct * p, char *page) 232static ssize_t part_dev_read(struct hd_struct * p, char *page)
@@ -336,12 +336,31 @@ void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len)
336 disk->part[part-1] = p; 336 disk->part[part-1] = p;
337} 337}
338 338
339static char *make_block_name(struct gendisk *disk)
340{
341 char *name;
342 static char *block_str = "block:";
343 int size;
344
345 size = strlen(block_str) + strlen(disk->disk_name) + 1;
346 name = kmalloc(size, GFP_KERNEL);
347 if (!name)
348 return NULL;
349 strcpy(name, block_str);
350 strcat(name, disk->disk_name);
351 return name;
352}
353
339static void disk_sysfs_symlinks(struct gendisk *disk) 354static void disk_sysfs_symlinks(struct gendisk *disk)
340{ 355{
341 struct device *target = get_device(disk->driverfs_dev); 356 struct device *target = get_device(disk->driverfs_dev);
342 if (target) { 357 if (target) {
358 char *disk_name = make_block_name(disk);
343 sysfs_create_link(&disk->kobj,&target->kobj,"device"); 359 sysfs_create_link(&disk->kobj,&target->kobj,"device");
344 sysfs_create_link(&target->kobj,&disk->kobj,"block"); 360 if (disk_name) {
361 sysfs_create_link(&target->kobj,&disk->kobj,disk_name);
362 kfree(disk_name);
363 }
345 } 364 }
346} 365}
347 366
@@ -360,7 +379,7 @@ void register_disk(struct gendisk *disk)
360 if ((err = kobject_add(&disk->kobj))) 379 if ((err = kobject_add(&disk->kobj)))
361 return; 380 return;
362 disk_sysfs_symlinks(disk); 381 disk_sysfs_symlinks(disk);
363 kobject_hotplug(&disk->kobj, KOBJ_ADD); 382 kobject_uevent(&disk->kobj, KOBJ_ADD);
364 383
365 /* No minors to use for partitions */ 384 /* No minors to use for partitions */
366 if (disk->minors == 1) { 385 if (disk->minors == 1) {
@@ -461,10 +480,14 @@ void del_gendisk(struct gendisk *disk)
461 devfs_remove_disk(disk); 480 devfs_remove_disk(disk);
462 481
463 if (disk->driverfs_dev) { 482 if (disk->driverfs_dev) {
483 char *disk_name = make_block_name(disk);
464 sysfs_remove_link(&disk->kobj, "device"); 484 sysfs_remove_link(&disk->kobj, "device");
465 sysfs_remove_link(&disk->driverfs_dev->kobj, "block"); 485 if (disk_name) {
486 sysfs_remove_link(&disk->driverfs_dev->kobj, disk_name);
487 kfree(disk_name);
488 }
466 put_device(disk->driverfs_dev); 489 put_device(disk->driverfs_dev);
467 } 490 }
468 kobject_hotplug(&disk->kobj, KOBJ_REMOVE); 491 kobject_uevent(&disk->kobj, KOBJ_REMOVE);
469 kobject_del(&disk->kobj); 492 kobject_del(&disk->kobj);
470} 493}