Symlink /sys/class/block to /sys/block
Subsystems (2)
PATCH 1/1 Symlink /sys/class/block to /sys/block
Greg,
Following the discussion in [1], the attached patch creates /sys/class/block as a symlink to /sys/block. The patch applies to 2.6.11-rc4-bk7.
Please cc: me on any replies - I'm not subscribed to the mailing list.
[1] http://marc.theaimsgroup.com/?m=110506536315986
Regards,
Malcolm
drivers/base/class.c +0 -0
@@ -69,7 +69,7 @@
};
/* Hotplug events for classes go to the class_obj subsys */ -static decl_subsys(class, &ktype_class, NULL); +decl_subsys(class, &ktype_class, NULL);
int class_create_file(struct class * cls, const struct class_attribute * attr)
drivers/block/genhd.c +0 -0
@@ -14,6 +14,7 @@
#include <linux/slab.h>
#include <linux/kmod.h>
#include <linux/kobj_map.h>
+#include <linux/sysfs.h>
#define MAX_PROBE_HASH 255 /* random */
@@ -300,11 +301,24 @@
return NULL; }
+extern struct subsystem class_subsys;
+
static int __init genhd_device_init(void)
{
bdev_map = kobj_map_init(base_probe, &block_subsys);
blk_dev_init();- subsystem_register(&block_subsys);
+ if (!subsystem_register(&block_subsys)) {
+ /*
+ * /sys/block should really live under /sys/class, but for
+ * the moment, we can only have class devices, not
+ * sub-classes-devices. Until we can move /sys/block into
+ * the right place, create a symlink from /sys/class/block to
+ * /sys/block, so that userspace doesn't need to know about
+ * the difference.
+ */
+ sysfs_create_link(&class_subsys.kset.kobj,
+ &block_subsys.kset.kobj, "block");
+ }
return 0; }
@@ -406,6 +420,7 @@
static void disk_release(struct kobject * kobj)
{
struct gendisk *disk = to_disk(kobj);
+ sysfs_remove_link(&class_subsys.kset.kobj, "block");
kfree(disk->random);
kfree(disk->part);
free_disk_stats(disk); Quoted 6 lines · Malcolm Rowe
Greg,
Following the discussion in [1], the attached patch creates
/sys/class/blockas a symlink to/sys/block. The patch applies to 2.6.11-rc4-bk7.Please cc: me on any replies - I'm not subscribed to the mailing list.
Hm, your patch is linewrapped, and can't be applied :(
But more importantly:
Review line 426
Quoted 8 lines
(quoted diff) +1
-0@@ -406,6 +420,7 @@ static void disk_release(struct kobject * kobj) { struct gendisk *disk = to_disk(kobj); + sysfs_remove_link(&class_subsys.kset.kobj, "block"); kfree(disk->random); kfree(disk->part); free_disk_stats(disk);
Did you try to remove a disk (like a usb device) and see what happens here? Hint, this isn't the proper place to remove the symlink...
thanks,
greg k-h
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 18 lines · Malcolm Rowe
Quoted 6 lines · Greg KH
Quoted 5 lines
Following the discussion in [1], the attached patch creates
/sys/class/block
as a symlink to/sys/block. The patch applies to 2.6.11-rc4-bk7.Please cc: me on any replies - I'm not subscribed to the mailing list.
Hm, your patch is linewrapped, and can't be applied :(
Bah, and I did send it to myself first, but I guess my mailer un-flowed it for me :-(. I'll try to find a better mailer.
Quoted 5 lines
But more importantly:
Quoted 1 line
static void
disk_release(struct kobject * kobj)Did you try to remove a disk (like a usb device) and see what happens here? Hint, this isn't the proper place to remove the symlink...
Quoted 6 lines
Er, yeah. Oops.
*Is* there a sensible place to remove the symlink from, though? Nobody seems to call
subsystem_unregister(&block_subsys), which is the place I'd expect to add a call to, and I can't see anything that's otherwise obvious...
If the subsystem is never unregistered, then don't worry about undoing the symlink.
thanks,
greg k-h
Quoted 22 lines · Greg KH <gregkh <at> suse.de> writes:
Quoted 20 lines · Malcolm Rowe
Quoted 6 lines · Greg KH
Quoted 5 lines
Following the discussion in [1], the attached patch creates
/sys/class/block
as a symlink to/sys/block. The patch applies to 2.6.11-rc4-bk7.Please cc: me on any replies - I'm not subscribed to the mailing list.
Hm, your patch is linewrapped, and can't be applied :(
Bah, and I did send it to myself first, but I guess my mailer un-flowed it for me . I'll try to find a better mailer.
Quoted 5 lines
But more importantly:
Quoted 1 line
static void
disk_release(struct kobject * kobj)Did you try to remove a disk (like a usb device) and see what happens here? Hint, this isn't the proper place to remove the symlink...
Er, yeah. Oops.
Quoted 7 lines
Quoted 4 lines
*Is* there a sensible place to remove the symlink from, though? Nobody seems to call
subsystem_unregister(&block_subsys), which is the place I'd expect to add a call to, and I can't see anything that's otherwise obvious...If the subsystem is never unregistered, then don't worry about undoing the symlink.
This symlink will break a lot of applications out there. If there is not a _very_ good reason for it, we should not do that.
The "dev" file unfortunately does not tell you if it's a char or block device node and that should be solved by something better than matching a magic string somewhere in the middle of a devpath.
The hotplug events will still have the /block/* devpath, so this symlink will give us nothing than problems.
Thanks,
Kay
Quoted 29 lines · Kay Sievers
Quoted 27 lines · Greg KH <gregkh <at> suse.de> writes:
Quoted 24 lines · Malcolm Rowe
Quoted 6 lines · Greg KH
Quoted 5 lines
Following the discussion in [1], the attached patch creates
/sys/class/block
as a symlink to/sys/block. The patch applies to 2.6.11-rc4-bk7.Please cc: me on any replies - I'm not subscribed to the mailing list.
Hm, your patch is linewrapped, and can't be applied :(
Bah, and I did send it to myself first, but I guess my mailer un-flowed it for me . I'll try to find a better mailer.
Quoted 5 lines
But more importantly:
Quoted 1 line
static void
disk_release(struct kobject * kobj)Did you try to remove a disk (like a usb device) and see what happens here? Hint, this isn't the proper place to remove the symlink...
Er, yeah. Oops.
*Is* there a sensible place to remove the symlink from, though? Nobody seems to call
subsystem_unregister(&block_subsys), which is the place I'd expect to add a call to, and I can't see anything that's otherwise obvious...
Quoted 5 lines
Quoted 2 lines
If the subsystem is never unregistered, then don't worry about undoing the symlink.
This symlink will break a lot of applications out there. If there is not a _very_ good reason for it, we should not do that.
People seem to want it for some odd reason, I haven't seen a good reason yet though, let alone a working patch :)
Quoted 3 lines
The "dev" file unfortunately does not tell you if it's a char or block device node and that should be solved by something better than matching a magic string somewhere in the middle of a devpath.
Use the subsystem value. If it's "block", it's a block device, otherwise it's a char device. Don't we already do this in udev today?
Quoted 2 lines
The hotplug events will still have the /block/* devpath, so this symlink will give us nothing than problems.
It will not give hotplug programs issues, as the block devpath still remains the same.
thanks,
greg k-h
Quoted 30 lines · Greg KH
Quoted 29 lines · Kay Sievers
Quoted 27 lines · Greg KH <gregkh <at> suse.de> writes:
Quoted 24 lines · Malcolm Rowe
Quoted 6 lines · Greg KH
Quoted 5 lines
Following the discussion in [1], the attached patch creates
/sys/class/block
as a symlink to/sys/block. The patch applies to 2.6.11-rc4-bk7.Please cc: me on any replies - I'm not subscribed to the mailing list.
Hm, your patch is linewrapped, and can't be applied :(
Bah, and I did send it to myself first, but I guess my mailer un-flowed it for me . I'll try to find a better mailer.
Quoted 5 lines
But more importantly:
Quoted 1 line
static void
disk_release(struct kobject * kobj)Did you try to remove a disk (like a usb device) and see what happens here? Hint, this isn't the proper place to remove the symlink...
Er, yeah. Oops.
*Is* there a sensible place to remove the symlink from, though? Nobody seems to call
subsystem_unregister(&block_subsys), which is the place I'd expect to add a call to, and I can't see anything that's otherwise obvious...
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
If the subsystem is never unregistered, then don't worry about undoing the symlink.
This symlink will break a lot of applications out there. If there is not a _very_ good reason for it, we should not do that.
People seem to want it for some odd reason, I haven't seen a good reason yet though, let alone a working patch :)
Good.
Quoted 6 lines
Quoted 3 lines
The "dev" file unfortunately does not tell you if it's a char or block device node and that should be solved by something better than matching a magic string somewhere in the middle of a devpath.
Use the subsystem value. If it's "block", it's a block device, otherwise it's a char device. Don't we already do this in udev today?
You don't have any subsystem value if you get a device list from sysfs, right?
Quoted 5 lines
Quoted 2 lines
The hotplug events will still have the /block/* devpath, so this symlink will give us nothing than problems.
It will not give hotplug programs issues, as the block devpath still remains the same.
No, but anything like udevstart or HAL coldplugging will have a problem with that inconsistency.
Thanks,
Kay
Quoted 9 lines · Kay Sievers
Quoted 5 lines · Greg KH
Quoted 2 lines
The hotplug events will still have the /block/* devpath, so this symlink will give us nothing than problems.
It will not give hotplug programs issues, as the block devpath still remains the same.
No, but anything like udevstart or HAL coldplugging will have a problem with that inconsistency.
Damm, forgot about that, good point :)
Ok, forget the symlink. Or, for that matter, ever moving from /sys/block/...
thanks,
greg k-h
Quoted 3 lines · Malcolm Rowe
Following the discussion in [1], the attached patch creates
/sys/class/blockas a symlink to/sys/block. The patch applies to 2.6.11-rc4-bk7.
Shouldn't we really move /sys/block to /sys/class/block and put the symlink from there to /sys/block with the hope of removing it one day?
Quoted 8 lines · Chris Wedgwood
Quoted 3 lines · Malcolm Rowe
Following the discussion in [1], the attached patch creates
/sys/class/blockas a symlink to/sys/block. The patch applies to 2.6.11-rc4-bk7.Shouldn't we really move
/sys/blockto/sys/class/blockand put the symlink from there to/sys/blockwith the hope of removing it one day?
When struct class_device can support children, we can do just that. But that support has not been added, yet...
thanks,
greg k-h