Skip to contentSkip to conversation

Symlink /sys/class/block to /sys/block

PATCH In review Malcolm Rowe 5 participants 9 messages Feb 19, 2005 – Feb 25, 2005 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
diff -ur linux-2.6.11-rc4-bk7/drivers/base/class.c linux-2.6.11-rc4-bk7-diff/drivers/base/class.c
@@ -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
diff -ur linux-2.6.11-rc4-bk7/drivers/block/genhd.c linux-2.6.11-rc4-bk7-diff/drivers/block/genhd.c
@@ -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); 
#1 lore raw
Quoted 6 lines · Malcolm Rowe

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.

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]

#3 lore raw
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

#4 lore raw
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

#5 lore raw
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

#6 lore raw
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

#7 lore raw
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

#8 lore raw
In reply to Malcolm Rowe
Quoted 3 lines · Malcolm Rowe

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.

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?

#9 lore raw
Quoted 8 lines · Chris Wedgwood
Quoted 3 lines · Malcolm Rowe

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.

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?

When struct class_device can support children, we can do just that. But that support has not been added, yet...

thanks,

greg k-h