linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Symlink /sys/class/block to /sys/block
@ 2005-02-19 23:29 Malcolm Rowe
  2005-02-22 19:04 ` Greg KH
  2005-02-22 23:06 ` Chris Wedgwood
  0 siblings, 2 replies; 9+ messages in thread
From: Malcolm Rowe @ 2005-02-19 23:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel

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 <malcolm-linux@farside.org.uk> 

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



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Symlink /sys/class/block to /sys/block
  2005-02-19 23:29 [PATCH] Symlink /sys/class/block to /sys/block Malcolm Rowe
@ 2005-02-22 19:04 ` Greg KH
       [not found]   ` <courier.421C5047.00003EBA@mail.farside.org.uk>
  2005-02-22 23:06 ` Chris Wedgwood
  1 sibling, 1 reply; 9+ messages in thread
From: Greg KH @ 2005-02-22 19:04 UTC (permalink / raw)
  To: Malcolm Rowe; +Cc: linux-kernel

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Symlink /sys/class/block to /sys/block
  2005-02-19 23:29 [PATCH] Symlink /sys/class/block to /sys/block Malcolm Rowe
  2005-02-22 19:04 ` Greg KH
@ 2005-02-22 23:06 ` Chris Wedgwood
  2005-02-22 23:21   ` Greg KH
  1 sibling, 1 reply; 9+ messages in thread
From: Chris Wedgwood @ 2005-02-22 23:06 UTC (permalink / raw)
  To: Malcolm Rowe; +Cc: Greg Kroah-Hartman, linux-kernel

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?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Symlink /sys/class/block to /sys/block
  2005-02-22 23:06 ` Chris Wedgwood
@ 2005-02-22 23:21   ` Greg KH
  0 siblings, 0 replies; 9+ messages in thread
From: Greg KH @ 2005-02-22 23:21 UTC (permalink / raw)
  To: Chris Wedgwood; +Cc: Malcolm Rowe, linux-kernel

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Symlink /sys/class/block to /sys/block
       [not found]   ` <courier.421C5047.00003EBA@mail.farside.org.uk>
@ 2005-02-24 23:34     ` Greg KH
  2005-02-25  1:35       ` Kay Sievers
  0 siblings, 1 reply; 9+ messages in thread
From: Greg KH @ 2005-02-24 23:34 UTC (permalink / raw)
  To: Malcolm Rowe; +Cc: linux-kernel

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Symlink /sys/class/block to /sys/block
  2005-02-24 23:34     ` Greg KH
@ 2005-02-25  1:35       ` Kay Sievers
  2005-02-25 22:39         ` Greg KH
  0 siblings, 1 reply; 9+ messages in thread
From: Kay Sievers @ 2005-02-25  1:35 UTC (permalink / raw)
  To: linux-kernel

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



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Symlink /sys/class/block to /sys/block
  2005-02-25  1:35       ` Kay Sievers
@ 2005-02-25 22:39         ` Greg KH
  2005-02-25 23:53           ` Kay Sievers
  0 siblings, 1 reply; 9+ messages in thread
From: Greg KH @ 2005-02-25 22:39 UTC (permalink / raw)
  To: Kay Sievers; +Cc: linux-kernel

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Symlink /sys/class/block to /sys/block
  2005-02-25 22:39         ` Greg KH
@ 2005-02-25 23:53           ` Kay Sievers
  2005-02-25 23:58             ` Greg KH
  0 siblings, 1 reply; 9+ messages in thread
From: Kay Sievers @ 2005-02-25 23:53 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Symlink /sys/class/block to /sys/block
  2005-02-25 23:53           ` Kay Sievers
@ 2005-02-25 23:58             ` Greg KH
  0 siblings, 0 replies; 9+ messages in thread
From: Greg KH @ 2005-02-25 23:58 UTC (permalink / raw)
  To: Kay Sievers; +Cc: linux-kernel

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2005-02-25 23:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-19 23:29 [PATCH] Symlink /sys/class/block to /sys/block Malcolm Rowe
2005-02-22 19:04 ` Greg KH
     [not found]   ` <courier.421C5047.00003EBA@mail.farside.org.uk>
2005-02-24 23:34     ` Greg KH
2005-02-25  1:35       ` Kay Sievers
2005-02-25 22:39         ` Greg KH
2005-02-25 23:53           ` Kay Sievers
2005-02-25 23:58             ` Greg KH
2005-02-22 23:06 ` Chris Wedgwood
2005-02-22 23:21   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).