From: "Raf D'Halleweyn" <raf@noduck.net>
To: linux-hotplug@vger.kernel.org
Subject: Use /proc/ide/hdx files from udev [PATCH]
Date: Sat, 03 Jan 2004 18:33:31 +0000 [thread overview]
Message-ID: <1073154810.6053.15.camel@bigboy> (raw)
[-- 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:
next reply other threads:[~2004-01-03 18:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-03 18:33 Raf D'Halleweyn [this message]
2004-01-04 8:55 ` Use /proc/ide/hdx files from udev [PATCH] Greg KH
2004-01-05 22:13 ` Kay Sievers
2004-01-05 22:29 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1073154810.6053.15.camel@bigboy \
--to=raf@noduck.net \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).