linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Use /proc/ide/hdx files from udev [PATCH]
@ 2004-01-03 18:33 Raf D'Halleweyn
  2004-01-04  8:55 ` Greg KH
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Raf D'Halleweyn @ 2004-01-03 18:33 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 319 bytes --]


The attached patch makes it possible to use files in the /proc/ide/hdx
directory in LABEL rules, e.g.:

LABEL, BUS="ide", SYSFS_media="cdrom", NAME="cdrom"

I expect that those proc files are going to be moved into sysfs and at
that time, this patch will not be useful anymore.


-- 
Raf D'Halleweyn <raf@noduck.net>


[-- Attachment #2: udev-012-procide.diff --]
[-- Type: text/x-patch, Size: 1363 bytes --]

diff -u udev-012/namedev.c udev-012-raf/namedev.c
--- udev-012/namedev.c	2003-12-30 17:24:46.000000000 -0500
+++ udev-012-raf/namedev.c	2004-01-01 22:32:02.000000000 -0500
@@ -430,6 +430,8 @@
 static int match_pair(struct sysfs_class_device *class_dev, struct sysfs_device *sysfs_device, struct sysfs_pair *pair)
 {
 	struct sysfs_attribute *tmpattr = NULL;
+	struct sysfs_attribute procattr;
+	char procval[256];
 	char *c;
 
 	if ((pair == NULL) || (pair->file[0] == '\0') || (pair->value == '\0'))
@@ -448,6 +450,30 @@
 			goto label_found;
 	}
 
+	/* finally, if it is an IDE device, try /proc/ide/hdx/<name> */
+#define SYS_BLOCK_HD "/sys/block/hd"
+	if (strncmp(class_dev->path, SYS_BLOCK_HD, sizeof(SYS_BLOCK_HD)) != 0
+		&& class_dev->path[sizeof(SYS_BLOCK_HD)+1] == 0) {
+		FILE *fd;
+
+		dbg("trying to find IDE attribute file in /proc");
+		snprintf(procattr.path, SYSFS_PATH_MAX, "/proc/ide/%s/%s",
+			class_dev->name, pair->file);
+		fd = fopen(procattr.path, "r");
+		if (fd) {
+			procattr.len = fread(procval, 1, sizeof(procval)-1, fd);
+			procval[procattr.len] = 0;
+			procattr.value = procval;
+			fclose(fd);
+
+			strncpy(procattr.name, pair->file, SYSFS_NAME_LEN);
+			procattr.name[SYSFS_NAME_LEN-1] = 0;
+			procattr.method = SYSFS_METHOD_SHOW;
+			tmpattr = &procattr;
+			goto label_found;
+		}
+	}
+
 	return -ENODEV;
 
 label_found:

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

* Re: Use /proc/ide/hdx files from udev [PATCH]
  2004-01-03 18:33 Use /proc/ide/hdx files from udev [PATCH] Raf D'Halleweyn
@ 2004-01-04  8:55 ` Greg KH
  2004-01-05 22:13 ` Kay Sievers
  2004-01-05 22:29 ` Greg KH
  2 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2004-01-04  8:55 UTC (permalink / raw)
  To: linux-hotplug

On Sat, Jan 03, 2004 at 01:33:31PM -0500, Raf D'Halleweyn wrote:
> 
> The attached patch makes it possible to use files in the /proc/ide/hdx
> directory in LABEL rules, e.g.:
> 
> LABEL, BUS="ide", SYSFS_media="cdrom", NAME="cdrom"

But your patch doesn't do this for only ide devices, does it?

> I expect that those proc files are going to be moved into sysfs and at
> that time, this patch will not be useful anymore.

I'd really prefer that we get the kernel fixed.  It shouldn't be that
hard...

thanks,

greg k-h


-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id\x1278&alloc_id371&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

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

* Re: Use /proc/ide/hdx files from udev [PATCH]
  2004-01-03 18:33 Use /proc/ide/hdx files from udev [PATCH] Raf D'Halleweyn
  2004-01-04  8:55 ` Greg KH
@ 2004-01-05 22:13 ` Kay Sievers
  2004-01-05 22:29 ` Greg KH
  2 siblings, 0 replies; 4+ messages in thread
From: Kay Sievers @ 2004-01-05 22:13 UTC (permalink / raw)
  To: linux-hotplug

On Sun, Jan 04, 2004 at 12:55:28AM -0800, Greg KH wrote:
> On Sat, Jan 03, 2004 at 01:33:31PM -0500, Raf D'Halleweyn wrote:
> > 
> > The attached patch makes it possible to use files in the /proc/ide/hdx
> > directory in LABEL rules, e.g.:
> > 
> > LABEL, BUS="ide", SYSFS_media="cdrom", NAME="cdrom"
> 
> But your patch doesn't do this for only ide devices, does it?
> 
> > I expect that those proc files are going to be moved into sysfs and at
> > that time, this patch will not be useful anymore.


For now we may simply use a CALLOUT rule:

  CALLOUT, BUS="ide", PROGRAM="/bin/cat /proc/ide/%k/media", ID="cdrom", NAME="%k", SYMLINK="cdrom"

If this doesn't work for you, let us know.

thanks,
Kay


-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id\x1278&alloc_id371&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

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

* Re: Use /proc/ide/hdx files from udev [PATCH]
  2004-01-03 18:33 Use /proc/ide/hdx files from udev [PATCH] Raf D'Halleweyn
  2004-01-04  8:55 ` Greg KH
  2004-01-05 22:13 ` Kay Sievers
@ 2004-01-05 22:29 ` Greg KH
  2 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2004-01-05 22:29 UTC (permalink / raw)
  To: linux-hotplug

On Mon, Jan 05, 2004 at 11:13:33PM +0100, Kay Sievers wrote:
> On Sun, Jan 04, 2004 at 12:55:28AM -0800, Greg KH wrote:
> > On Sat, Jan 03, 2004 at 01:33:31PM -0500, Raf D'Halleweyn wrote:
> > > 
> > > The attached patch makes it possible to use files in the /proc/ide/hdx
> > > directory in LABEL rules, e.g.:
> > > 
> > > LABEL, BUS="ide", SYSFS_media="cdrom", NAME="cdrom"
> > 
> > But your patch doesn't do this for only ide devices, does it?
> > 
> > > I expect that those proc files are going to be moved into sysfs and at
> > > that time, this patch will not be useful anymore.
> 
> 
> For now we may simply use a CALLOUT rule:
> 
>   CALLOUT, BUS="ide", PROGRAM="/bin/cat /proc/ide/%k/media", ID="cdrom", NAME="%k", SYMLINK="cdrom"

Ah, sweet, I like that rule.  I think that just about sums up how
flexible udev is right now :)

I'll go add it to the default udev.rules file...

thanks,

greg k-h


-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id\x1278&alloc_id371&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

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

end of thread, other threads:[~2004-01-05 22:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-03 18:33 Use /proc/ide/hdx files from udev [PATCH] Raf D'Halleweyn
2004-01-04  8:55 ` Greg KH
2004-01-05 22:13 ` Kay Sievers
2004-01-05 22:29 ` 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).