aboutsummaryrefslogtreecommitdiffstats
path: root/fs/partitions
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2006-10-17 03:10:23 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-17 11:18:47 -0400
commiteee44cca665aa1a5663e6a00c2bdfc275739dac5 (patch)
tree86bf3f4d3d265a487d6f8e029e2e43dadf812e2c /fs/partitions
parent6b5f29675c6a1041aefc147271508bd56cf2b761 (diff)
[PATCH] fs/partitions/check: add sysfs error handling
Handle errors thrown in disk_sysfs_symlinks(), and propagate back to caller. The callers and associated functions don't do a real good job of handling kobject errors anyway (add_partition, register_disk, rescan_partitions), so this should do until something better comes along. Signed-off-by: Jeff Garzik <jeff@garzik.org> Cc: Greg KH <greg@kroah.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/partitions')
-rw-r--r--fs/partitions/check.c50
1 files changed, 42 insertions, 8 deletions
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 51c6a748df49..6fb4b6150d77 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -376,18 +376,48 @@ static char *make_block_name(struct gendisk *disk)
376 return name; 376 return name;
377} 377}
378 378
379static void disk_sysfs_symlinks(struct gendisk *disk) 379static int disk_sysfs_symlinks(struct gendisk *disk)
380{ 380{
381 struct device *target = get_device(disk->driverfs_dev); 381 struct device *target = get_device(disk->driverfs_dev);
382 int err;
383 char *disk_name = NULL;
384
382 if (target) { 385 if (target) {
383 char *disk_name = make_block_name(disk); 386 disk_name = make_block_name(disk);
384 sysfs_create_link(&disk->kobj,&target->kobj,"device"); 387 if (!disk_name) {
385 if (disk_name) { 388 err = -ENOMEM;
386 sysfs_create_link(&target->kobj,&disk->kobj,disk_name); 389 goto err_out;
387 kfree(disk_name);
388 } 390 }
391
392 err = sysfs_create_link(&disk->kobj, &target->kobj, "device");
393 if (err)
394 goto err_out_disk_name;
395
396 err = sysfs_create_link(&target->kobj, &disk->kobj, disk_name);
397 if (err)
398 goto err_out_dev_link;
389 } 399 }
390 sysfs_create_link(&disk->kobj, &block_subsys.kset.kobj, "subsystem"); 400
401 err = sysfs_create_link(&disk->kobj, &block_subsys.kset.kobj,
402 "subsystem");
403 if (err)
404 goto err_out_disk_name_lnk;
405
406 kfree(disk_name);
407
408 return 0;
409
410err_out_disk_name_lnk:
411 if (target) {
412 sysfs_remove_link(&target->kobj, disk_name);
413err_out_dev_link:
414 sysfs_remove_link(&disk->kobj, "device");
415err_out_disk_name:
416 kfree(disk_name);
417err_out:
418 put_device(target);
419 }
420 return err;
391} 421}
392 422
393/* Not exported, helper to add_disk(). */ 423/* Not exported, helper to add_disk(). */
@@ -406,7 +436,11 @@ void register_disk(struct gendisk *disk)
406 *s = '!'; 436 *s = '!';
407 if ((err = kobject_add(&disk->kobj))) 437 if ((err = kobject_add(&disk->kobj)))
408 return; 438 return;
409 disk_sysfs_symlinks(disk); 439 err = disk_sysfs_symlinks(disk);
440 if (err) {
441 kobject_del(&disk->kobj);
442 return;
443 }
410 disk_sysfs_add_subdirs(disk); 444 disk_sysfs_add_subdirs(disk);
411 445
412 /* No minors to use for partitions */ 446 /* No minors to use for partitions */