Use /proc/ide/hdx files from udev [PATCH]
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.
Signature · 1 line
Raf D'Halleweyn <[email protected]>
namedev.c +26 -0
@@ -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:
Quoted 5 lines · Raf D'Halleweyn
The attached patch makes it possible to use files in the
/proc/ide/hdxdirectory 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?
Quoted 2 lines
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_id78&alloc_id371&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 11 lines · Greg KH
Quoted 5 lines · Raf D'Halleweyn
The attached patch makes it possible to use files in the
/proc/ide/hdxdirectory 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?
Quoted 2 lines
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_id78&alloc_id371&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 10 lines · Kay Sievers
Quoted 9 lines · Greg KH
Quoted 5 lines · Raf D'Halleweyn
The attached patch makes it possible to use files in the
/proc/ide/hdxdirectory 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?
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
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_id78&alloc_id371&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel