aboutsummaryrefslogtreecommitdiffstats
path: root/fs/partitions
diff options
context:
space:
mode:
authorJun'ichi Nomura <j-nomura@ce.jp.nec.com>2006-03-27 04:17:55 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-27 11:44:59 -0500
commit6a4d44c1f1108d6c9e8850e8cf166aaba0e56eae (patch)
tree4e0b59ca2b4959e1593cbcdec4b90ec0d9041126 /fs/partitions
parent3ac51e741a46af7a20f55e79d3e3aeaa93c6c544 (diff)
[PATCH] dm/md dependency tree in sysfs: holders/slaves subdirectory
Creating "slaves" and "holders" directories in /sys/block/<disk> and creating "holders" directory under /sys/block/<disk>/<partition> Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com> Cc: Alasdair G Kergon <agk@redhat.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.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index f924f459bdb..60523cea713 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -297,6 +297,30 @@ struct kobj_type ktype_part = {
297 .sysfs_ops = &part_sysfs_ops, 297 .sysfs_ops = &part_sysfs_ops,
298}; 298};
299 299
300#ifdef CONFIG_SYSFS
301static inline void partition_sysfs_add_subdir(struct hd_struct *p)
302{
303 struct kobject *k;
304
305 k = kobject_get(&p->kobj);
306 p->holder_dir = kobject_add_dir(k, "holders");
307 kobject_put(k);
308}
309
310static inline void disk_sysfs_add_subdirs(struct gendisk *disk)
311{
312 struct kobject *k;
313
314 k = kobject_get(&disk->kobj);
315 disk->holder_dir = kobject_add_dir(k, "holders");
316 disk->slave_dir = kobject_add_dir(k, "slaves");
317 kobject_put(k);
318}
319#else
320#define partition_sysfs_add_subdir(x) do { } while (0)
321#define disk_sysfs_add_subdirs(x) do { } while (0)
322#endif
323
300void delete_partition(struct gendisk *disk, int part) 324void delete_partition(struct gendisk *disk, int part)
301{ 325{
302 struct hd_struct *p = disk->part[part-1]; 326 struct hd_struct *p = disk->part[part-1];
@@ -310,6 +334,10 @@ void delete_partition(struct gendisk *disk, int part)
310 p->ios[0] = p->ios[1] = 0; 334 p->ios[0] = p->ios[1] = 0;
311 p->sectors[0] = p->sectors[1] = 0; 335 p->sectors[0] = p->sectors[1] = 0;
312 devfs_remove("%s/part%d", disk->devfs_name, part); 336 devfs_remove("%s/part%d", disk->devfs_name, part);
337#ifdef CONFIG_SYSFS
338 if (p->holder_dir)
339 kobject_unregister(p->holder_dir);
340#endif
313 kobject_unregister(&p->kobj); 341 kobject_unregister(&p->kobj);
314} 342}
315 343
@@ -337,6 +365,7 @@ void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len)
337 p->kobj.parent = &disk->kobj; 365 p->kobj.parent = &disk->kobj;
338 p->kobj.ktype = &ktype_part; 366 p->kobj.ktype = &ktype_part;
339 kobject_register(&p->kobj); 367 kobject_register(&p->kobj);
368 partition_sysfs_add_subdir(p);
340 disk->part[part-1] = p; 369 disk->part[part-1] = p;
341} 370}
342 371
@@ -383,6 +412,7 @@ void register_disk(struct gendisk *disk)
383 if ((err = kobject_add(&disk->kobj))) 412 if ((err = kobject_add(&disk->kobj)))
384 return; 413 return;
385 disk_sysfs_symlinks(disk); 414 disk_sysfs_symlinks(disk);
415 disk_sysfs_add_subdirs(disk);
386 kobject_uevent(&disk->kobj, KOBJ_ADD); 416 kobject_uevent(&disk->kobj, KOBJ_ADD);
387 417
388 /* No minors to use for partitions */ 418 /* No minors to use for partitions */
@@ -483,6 +513,12 @@ void del_gendisk(struct gendisk *disk)
483 513
484 devfs_remove_disk(disk); 514 devfs_remove_disk(disk);
485 515
516#ifdef CONFIG_SYSFS
517 if (disk->holder_dir)
518 kobject_unregister(disk->holder_dir);
519 if (disk->slave_dir)
520 kobject_unregister(disk->slave_dir);
521#endif
486 if (disk->driverfs_dev) { 522 if (disk->driverfs_dev) {
487 char *disk_name = make_block_name(disk); 523 char *disk_name = make_block_name(disk);
488 sysfs_remove_link(&disk->kobj, "device"); 524 sysfs_remove_link(&disk->kobj, "device");