2005-02-19 23:29:23

by Malcolm Rowe

[permalink] [raw]
Subject: [PATCH] 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

Signed-off-by: Malcolm Rowe <[email protected]>

diff -ur linux-2.6.11-rc4-bk7/drivers/base/class.c
linux-2.6.11-rc4-bk7-diff/drivers/base/class.c
--- linux-2.6.11-rc4-bk7/drivers/base/class.c 2005-02-19 21:34:31.000000000
+0000
+++ linux-2.6.11-rc4-bk7-diff/drivers/base/class.c 2005-02-19
21:38:31.000000000 +0000
@@ -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)
diff -ur linux-2.6.11-rc4-bk7/drivers/block/genhd.c
linux-2.6.11-rc4-bk7-diff/drivers/block/genhd.c
--- linux-2.6.11-rc4-bk7/drivers/block/genhd.c 2005-02-19 21:34:31.000000000
+0000
+++ linux-2.6.11-rc4-bk7-diff/drivers/block/genhd.c 2005-02-19
22:01:56.000000000 +0000
@@ -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);



2005-02-22 19:05:49

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Symlink /sys/class/block to /sys/block

On Sat, Feb 19, 2005 at 11:29:13PM +0000, Malcolm Rowe wrote:
> 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:

> @@ -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

2005-02-22 23:06:52

by Chris Wedgwood

[permalink] [raw]
Subject: Re: [PATCH] Symlink /sys/class/block to /sys/block

On Sat, Feb 19, 2005 at 11:29:13PM +0000, Malcolm Rowe wrote:

> 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?

2005-02-22 23:23:30

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Symlink /sys/class/block to /sys/block

On Tue, Feb 22, 2005 at 03:06:34PM -0800, Chris Wedgwood wrote:
> On Sat, Feb 19, 2005 at 11:29:13PM +0000, Malcolm Rowe wrote:
>
> > 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

2005-02-24 23:40:06

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Symlink /sys/class/block to /sys/block

On Wed, Feb 23, 2005 at 09:43:35AM +0000, Malcolm Rowe wrote:
> Greg KH writes:
>
> >>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.
>
> >But more importantly:
> >>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...

If the subsystem is never unregistered, then don't worry about undoing
the symlink.

thanks,

greg k-h

2005-02-25 01:39:45

by Kay Sievers

[permalink] [raw]
Subject: Re: [PATCH] Symlink /sys/class/block to /sys/block

Greg KH <gregkh <at> suse.de> writes:

>
> On Wed, Feb 23, 2005 at 09:43:35AM +0000, Malcolm Rowe wrote:
> > Greg KH writes:
> >
> > >>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.
> >
> > >But more importantly:
> > >>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...
>
> 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


2005-02-25 23:02:19

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Symlink /sys/class/block to /sys/block

On Fri, Feb 25, 2005 at 01:35:13AM +0000, Kay Sievers wrote:
> Greg KH <gregkh <at> suse.de> writes:
>
> >
> > On Wed, Feb 23, 2005 at 09:43:35AM +0000, Malcolm Rowe wrote:
> > > Greg KH writes:
> > >
> > > >>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.
> > >
> > > >But more importantly:
> > > >>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...
> >
> > 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 :)

> 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?

> 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

2005-02-25 23:54:15

by Kay Sievers

[permalink] [raw]
Subject: Re: [PATCH] Symlink /sys/class/block to /sys/block

On Fri, Feb 25, 2005 at 02:39:27PM -0800, Greg KH wrote:
> On Fri, Feb 25, 2005 at 01:35:13AM +0000, Kay Sievers wrote:
> > Greg KH <gregkh <at> suse.de> writes:
> >
> > >
> > > On Wed, Feb 23, 2005 at 09:43:35AM +0000, Malcolm Rowe wrote:
> > > > Greg KH writes:
> > > >
> > > > >>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.
> > > >
> > > > >But more importantly:
> > > > >>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...
> > >
> > > 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.

> > 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?

> > 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

2005-02-25 23:58:55

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Symlink /sys/class/block to /sys/block

On Sat, Feb 26, 2005 at 12:53:49AM +0100, Kay Sievers wrote:
> On Fri, Feb 25, 2005 at 02:39:27PM -0800, Greg KH wrote:
> > > 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