From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Raf D'Halleweyn" Date: Sat, 03 Jan 2004 18:33:31 +0000 Subject: Use /proc/ide/hdx files from udev [PATCH] Message-Id: <1073154810.6053.15.camel@bigboy> MIME-Version: 1 Content-Type: multipart/mixed; boundary="=-fEqUHa1fhUJ3+pCDAVwF" List-Id: To: linux-hotplug@vger.kernel.org --=-fEqUHa1fhUJ3+pCDAVwF Content-Type: text/plain Content-Transfer-Encoding: 7bit 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 --=-fEqUHa1fhUJ3+pCDAVwF Content-Disposition: attachment; filename=udev-012-procide.diff Content-Type: text/x-patch; name=udev-012-procide.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit 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/ */ +#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: --=-fEqUHa1fhUJ3+pCDAVwF-- ------------------------------------------------------- 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=1278&alloc_id=3371&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