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

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