From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Brownell Date: Mon, 05 Feb 2001 22:50:50 +0000 Subject: Re: Any ETA on getting the PCI hardware detection event replaying MIME-Version: 1 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0313_01C08F83.07D59720" Message-Id: List-Id: References: In-Reply-To: To: linux-hotplug@vger.kernel.org This is a multi-part message in MIME format. ------=_NextPart_000_0313_01C08F83.07D59720 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit > There's a bit in CVS right now, relying on versions of > Adam Richter's "pcimodules". The USB analogue will > require usbdevfs and "usbmodules" ... that's for the quick > solution using off-the-shelf components. OK now the stuff in CVS is interesting for both USB and PCI ... > There's an issue there: how to get the related programs > properly up-to-date ... ... so I include Adam's "pcimodules" patch, against "pciutils 2.1.8" (the latest) ... also attached is a patch against "usbutils-0.7" that merges the two previous patches, updates the manpage for "usbmodules", and says it's version "0.7hotplug". Use "configure --prefix /usr" so it installs where the hotplug utilities will see it, and (a) normal hotplugging will use "usbmodules" if usbdevfs is available, also (b) it'll fake USB hotplug events. I'd expect rough edges; for example, bringing up a network interface (present at boot time and not hotplugged) went very slowly, unclear why. - Dave ------=_NextPart_000_0313_01C08F83.07D59720 Content-Type: application/x-gzip; name="pcimodules-pciutils-2.1.8.diff.gz" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="pcimodules-pciutils-2.1.8.diff.gz" H4sICIk9HjoCA3BjaW1vZHVsZXMtcGNpdXRpbHMtMi4xLjguZGlmZgCdWvl32kgS/hn+ihomB5jb uRwc55nYJGHX1zN4ZvKSLCukxmitg1VLwZ5J9m/fr7pbSAKcTdYvAam7urq66quju3Hc2YyaCTWb gVg2Z64naGG7Sex6srnb6rb22qfWjSi0r1rKzWbzPurSyIrp1Lqj3Q51XvSe7vU6e3judMr1en2T Velt5NJZ+IV2n1Jnt9d50nv2XJMfHlLzyW7jBdXV5+FhmcokbhdhFOOpaXlejzx3Sp4EU5Ii5i/1 0tozr629cn07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 1uJKISvylCJtzdi4tUksbPGi6UxJOBhQ/2R0ziu/NK5Y5cMR3X3aH56N8X9wqcPPlppWRQDeF/Kk eumFG91X/r8OJazVsv98vZq2fzV+f365YbwlYtUyuxnuO5ZPf2vRJSzFOeOVhYbDu/TOvoVk8rqR u7lWF8bIF+rGOHV66MMRPybV0fnFh8vhu/fjDcFUEZT/5UDjf/90QNegvgWM/j8/GdjN/UygXN/+ O4F7fyaw7dcB5br5ecC2XwcELjvaiG/qlRR9X0Tww1qr/F+X6RjABiwAAA== ------=_NextPart_000_0313_01C08F83.07D59720 Content-Type: application/octet-stream; name="usbutils-hotplug.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="usbutils-hotplug.patch" diff -u usbutils-0.7/configure usbutils/configure=0A= --- usbutils-0.7/configure Fri Nov 3 08:51:23 2000=0A= +++ usbutils/configure Mon Feb 5 14:01:30 2001=0A= @@ -781,7 +781,7 @@=0A= =0A= PACKAGE=3Dusbutils=0A= =0A= -VERSION=3D0.7=0A= +VERSION=3D0.7hotplug=0A= =0A= if test "`cd $srcdir && pwd`" !=3D "`pwd`" && test -f = $srcdir/config.status; then=0A= { echo "configure: error: source directory already configured; run = "make distclean" there first" 1>&2; exit 1; }=0A= diff -u usbutils-0.7/usbmodules.8 usbutils/usbmodules.8=0A= --- usbutils-0.7/usbmodules.8 Fri Nov 3 07:30:51 2000=0A= +++ usbutils/usbmodules.8 Mon Feb 5 13:59:06 2001=0A= @@ -1,19 +1,24 @@=0A= -.TH usbmodules 8 "03 November 2000" "usbutils-0.6" "Linux USB Utilities"=0A= +.TH usbmodules 8 "05 February 2001" "usbutils-0.7hotplug" "Linux USB = Utilities"=0A= .IX usbmodules=0A= .SH NAME=0A= -usbmodules \- List kernel driver modules available for all currently = plugged=0A= -in USB devices=0A= +usbmodules \- List kernel driver modules available for a plugged=0A= +in USB device=0A= .SH SYNOPSIS=0A= .B usbmodules=0A= -.RB [ --device /proc/bus/bus/NNN/NNN ]=0A= -.RB [ --check modulename ]=0A= +.RB [ "--device " /proc/bus/bus/NNN/NNN ]=0A= +.RB [ "--check " modulename ]=0A= .RB [ --help ]=0A= +.RB [ "--mapfile " pathname ]=0A= +.RB [ "--version " pathname ]=0A= .SH DESCRIPTION=0A= .B usbmodules=0A= -lists all driver modules for all currently plugged in USB devices.=0A= -.B usbmodules=0A= -should be run at by /sbin/hotplug of /etc/usb/policy, and whenever=0A= -a USB device is "hot plugged" into the system. This can be done by=0A= +lists driver modules that may be=0A= +able to manage interfaces on=0A= +currently plugged in USB devices.=0A= +.B usbmodules=0A= +may be used by /sbin/hotplug or one of its agents (normally=0A= +.IR /etc/hotplug/usb.agent )=0A= +when USB devices are "hot plugged" into the system. This can be done by=0A= the following Bourne shell syntax:=0A= .IP=0A= for module in $(usbmodules --device $DEVICE) ; do=0A= @@ -22,7 +27,11 @@=0A= .IP=0A= done=0A= .PP=0A= -The DEVICE environment variable is passed from the kernel to = /sbin/hotplug.=0A= +The DEVICE environment variable is passed from the kernel to = /sbin/hotplug=0A= +during USB hotplugging if the kernel was configured using=0A= +.I usbdevfs.=0A= +.B usbmodules=0A= +currently requires usbdevfs to operate.=0A= .PP=0A= When a USB device is removed from the system, the Linux kernel will=0A= decrement a usage count on USB driver module. If this count drops=0A= @@ -33,38 +42,52 @@=0A= .PP=0A= .SH OPTIONS=0A= .TP=0A= -.B --check modulename=0A= +.BI "--check " modulename=0A= Instead of listing the relevant modules, just exit with code 0 (success)=0A= if the given module's exported USB ID patterns matches. Otherwise,=0A= return failure. =0A= .B usbmodules=0A= emits no output either way.=0A= .TP=0A= -.B --device /proc/bus/usb/NNN/NNN=0A= +.BI "--device " /proc/bus/usb/MMM/NNN=0A= Selects which device=0A= .B usbmodules=0A= will examine. The argument is currently mandatory.=0A= .TP=0A= .B --help, -h=0A= Print a help message=0A= -.SH FILES=0A= .TP=0A= +.BI "--mapfile " /etc/hotplug/usb.handmap=0A= +Use the specified file instead of the=0A= +/lib/modules/.../modules.usbmap file=0A= +corresponding to the running kernel.=0A= +.TP=0A= +.B --version=0A= +Identifies the version of=0A= +.I usbutils=0A= +this tool was built with.=0A= .SH FILES=0A= +.TP=0A= .B /lib/modules//modules.usbmap=0A= This file is automatically generated by=0A= .B depmod,=0A= -and used by=0A= +versions 2.4.2 and later, and is used by=0A= .B usbmodules=0A= to determine which modules correspond to which USB ID's.=0A= .TP=0A= .B /proc/bus/usb=0A= -An interface to USB bus configuration space provided by the post-2.1.82 = Linux=0A= -kernels. Contains per-bus subdirectories with per-card config space = files and a=0A= +An optional interface to USB devices provided by Linux kernels with=0A= +versions of the 2.4 USB support. Contains per-bus subdirectories=0A= +with per-device files (offering a usermode driver API as well=0A= +as access to device and configuration descriptors), a=0A= .I devices=0A= -file containing a list of all USB devices.=0A= +file containing a list of all USB devices, and a =0A= +.I drivers=0A= +file listing USB device drivers known to the USB subsystem.=0A= =0A= .SH SEE ALSO=0A= -.BR lsusb (8)=0A= +.BR lsusb (8),=0A= +.I http://linux-hotplug.sourceforge.net=0A= =0A= .SH AUTHOR=0A= .B usbmodules=0A= @@ -73,6 +96,8 @@=0A= .B=0A= lsusb,=0A= which was written by Thomas Sailer .=0A= +=0A= +.\" Code and documentation updated by David Brownell.=0A= =0A= =0A= .SH COPYRIGHT=0A= diff -u usbutils-0.7/usbmodules.c usbutils/usbmodules.c=0A= --- usbutils-0.7/usbmodules.c Fri Nov 3 07:30:52 2000=0A= +++ usbutils/usbmodules.c Mon Feb 5 13:04:05 2001=0A= @@ -3,13 +3,17 @@=0A= /*=0A= * usmodules.c -- pcimodules like utility for the USB bus=0A= * =0A= - * Written by primarily by Adam J. Richter. lspci.c is derived = from:=0A= - * lsusb.c, written by Thomas Sailer, and pcimodules.c, which is=0A= - * also written by Adam J. Richter. usbmodules.h is derived from=0A= - * linux-2.4.0-test10/include/linux/usb.h (exact authorship = unknown,=0A= - * probably Randy Dunlap).=0A= + * lsusb.c is derived from:=0A= *=0A= - * Copyright (C) 2000 Yggdrasil Computing, Inc.=0A= + * lspci.c by Thomas Sailer,=0A= + * pcimodules.c by Adam J. Richter=0A= + * linux-2.4.0-test10/include/linux/usb.h probably by Randy Dunlap=0A= + *=0A= + * The code in usbmodules not derived from elsewhere was written by=0A= + * Adam J. Richter. David Brownell added the --mapfile and --version=0A= + * options.=0A= + *=0A= + * Copyright (C) 2000, 2001 Yggdrasil Computing, Inc.=0A= * Copyright (C) 1999 Thomas Sailer (sailer@ife.ee.ethz.ch)=0A= *=0A= * This program is free software; you can redistribute it and/or = modify=0A= @@ -68,12 +72,14 @@=0A= #define _GNU_SOURCE=0A= #include =0A= =0A= -#define OPT_STRING "c:d:h"=0A= +#define OPT_STRING "c:d:hm:v"=0A= static struct option long_options[] =3D {=0A= {"check", required_argument, NULL, 'c'},=0A= - {"device", required_argument, NULL, 'd'},=0A= + {"device", required_argument, NULL, 'd'},=0A= {"help", no_argument, NULL, 'h'},=0A= - { 0, 0, NULL, 0}=0A= + {"mapfile", required_argument, NULL, 'm'},=0A= + {"version", no_argument, NULL, 'v'},=0A= + { 0, 0, NULL, 0}=0A= };=0A= =0A= #define MODDIR "/lib/modules"=0A= @@ -92,8 +98,6 @@=0A= =0A= static char *checkname =3D NULL;=0A= =0A= -static const char *procbususb =3D "/proc/bus/usb";=0A= -=0A= static int idVendor;=0A= static int idProduct;=0A= static int bcdDevice;=0A= @@ -109,27 +113,103 @@=0A= fprintf(stderr, "Memory allocation failure.\n");=0A= exit(1);=0A= }=0A= + return result;=0A= +}=0A= +=0A= +static int=0A= +scan_without_flags(const char *line, struct usbmap_entry *entry, char = *name) {=0A= + unsigned int driver_info;=0A= + if (sscanf(line,=0A= + "%s 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x",=0A= + name,=0A= + &entry->idVendor,=0A= + &entry->idProduct,=0A= + &entry->bcdDevice_lo,=0A= + &entry->bcdDevice_hi,=0A= + &entry->bDeviceClass,=0A= + &entry->bDeviceSubClass,=0A= + &entry->bDeviceProtocol,=0A= + &entry->bInterfaceClass,=0A= + &entry->bInterfaceSubClass,=0A= + &entry->bInterfaceProtocol,=0A= + &driver_info) !=3D 12)=0A= + return 0;=0A= +=0A= + entry->match_flags =3D 0;=0A= +=0A= + /* idVendor=3D=3D0 is the wildcard for both idVendor and idProduct,=0A= + because idProduct=3D=3D0 is a legitimate product ID. */=0A= + if (entry->idVendor)=0A= + entry->match_flags |=3D USB_MATCH_VENDOR | USB_MATCH_PRODUCT;=0A= +=0A= + if (entry->bcdDevice_lo)=0A= + entry->match_flags |=3D USB_MATCH_DEV_LO;=0A= +=0A= + if (entry->bcdDevice_hi)=0A= + entry->match_flags |=3D USB_MATCH_DEV_HI;=0A= +=0A= + if (entry->bDeviceClass)=0A= + entry->match_flags |=3D USB_MATCH_DEV_CLASS;=0A= +=0A= + if (entry->bDeviceSubClass)=0A= + entry->match_flags |=3D USB_MATCH_DEV_SUBCLASS;=0A= +=0A= + if (entry->bDeviceProtocol)=0A= + entry->match_flags |=3D USB_MATCH_DEV_PROTOCOL;=0A= +=0A= + if (entry->bInterfaceClass)=0A= + entry->match_flags |=3D USB_MATCH_INT_CLASS;=0A= +=0A= + if (entry->bInterfaceSubClass)=0A= + entry->match_flags |=3D USB_MATCH_INT_SUBCLASS;=0A= +=0A= + if (entry->bInterfaceProtocol)=0A= + entry->match_flags |=3D USB_MATCH_INT_PROTOCOL;=0A= +=0A= + return 1;=0A= +}=0A= +=0A= +static int=0A= +scan_with_flags(const char *line, struct usbmap_entry *entry, char = *name) {=0A= + unsigned int driver_info;=0A= + return (sscanf(line, "%s 0x%x 0x%x "=0A= + "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x",=0A= + name,=0A= + &entry->match_flags,=0A= + &entry->idVendor,=0A= + &entry->idProduct,=0A= + &entry->bcdDevice_lo,=0A= + &entry->bcdDevice_hi,=0A= + &entry->bDeviceClass,=0A= + &entry->bDeviceSubClass,=0A= + &entry->bDeviceProtocol,=0A= + &entry->bInterfaceClass,=0A= + &entry->bInterfaceSubClass,=0A= + &entry->bInterfaceProtocol,=0A= + &driver_info) =3D=3D 13);=0A= }=0A= =0A= void=0A= -read_modules_usbmap(void)=0A= +read_modules_usbmap(char *pathname)=0A= {=0A= - struct utsname utsname;=0A= char filename[MAXPATHLEN];=0A= FILE *usbmap_file;=0A= char line[LINELENGTH];=0A= struct usbmap_entry *prev;=0A= struct usbmap_entry *entry;=0A= - unsigned int driver_data;=0A= char name[LINELENGTH];=0A= =0A= - if (uname(&utsname) < 0) {=0A= - perror("uname");=0A= - exit(1);=0A= + if (pathname =3D=3D NULL) {=0A= + struct utsname utsname;=0A= + if (uname(&utsname) < 0) {=0A= + perror("uname");=0A= + exit(1);=0A= + }=0A= + sprintf(filename, "%s/%s/%s", MODDIR, utsname.release, USBMAP);=0A= + pathname =3D filename;=0A= }=0A= - sprintf(filename, "%s/%s/%s", MODDIR, utsname.release, USBMAP);=0A= - if ((usbmap_file =3D fopen(filename, "r")) =3D=3D NULL) {=0A= - perror(filename);=0A= + if ((usbmap_file =3D fopen(pathname, "r")) =3D=3D NULL) {=0A= + perror(pathname);=0A= exit(1);=0A= }=0A= =0A= @@ -140,18 +220,8 @@=0A= =0A= entry =3D xmalloc(sizeof(struct usbmap_entry));=0A= =0A= - if (sscanf(line, "%s 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x = 0x%x 0x%x",=0A= - name,=0A= - &entry->idVendor,=0A= - &entry->idProduct,=0A= - &entry->bcdDevice_lo,=0A= - &entry->bcdDevice_hi,=0A= - &entry->bDeviceClass,=0A= - &entry->bDeviceSubClass,=0A= - &entry->bDeviceProtocol,=0A= - &entry->bInterfaceClass,=0A= - &entry->bInterfaceSubClass,=0A= - &entry->bInterfaceProtocol) !=3D 10) {=0A= + if (!scan_with_flags(line, entry, name) &&=0A= + !scan_without_flags(line, entry, name)) {=0A= fprintf (stderr,=0A= "modules.usbmap unparsable line: %s.\n", = line);=0A= free(entry);=0A= @@ -195,45 +265,44 @@=0A= =0A= for (mod =3D usbmap_list; mod !=3D NULL; mod =3D mod->next) {=0A= =0A= - if (mod->idVendor &&=0A= + if ((mod->match_flags & USB_MATCH_VENDOR) &&=0A= mod->idVendor !=3D idVendor)=0A= continue;=0A= =0A= - if (mod->idProduct &&=0A= + if ((mod->match_flags & USB_MATCH_PRODUCT) &&=0A= mod->idProduct !=3D idProduct)=0A= continue;=0A= =0A= - /* No need to test mod->bcdDevice_lo !=3D 0, since 0 is = never=0A= - greater than any unsigned number. */=0A= - if (mod->bcdDevice_lo > bcdDevice)=0A= + if ((mod->match_flags & USB_MATCH_DEV_LO) &&=0A= + mod->bcdDevice_lo > bcdDevice)=0A= continue;=0A= =0A= - if (mod->bcdDevice_hi &&=0A= + if ((mod->match_flags & USB_MATCH_DEV_HI) &&=0A= mod->bcdDevice_hi < bcdDevice)=0A= continue;=0A= =0A= - if (mod->bDeviceClass &&=0A= + if ((mod->match_flags & USB_MATCH_DEV_CLASS) &&=0A= mod->bDeviceClass !=3D bDeviceClass)=0A= continue;=0A= =0A= - if (mod->bDeviceSubClass &&=0A= - mod->bDeviceSubClass!=3D bDeviceClass)=0A= + if ((mod->match_flags & USB_MATCH_DEV_SUBCLASS) &&=0A= + mod->bDeviceSubClass !=3D bDeviceSubClass)=0A= continue;=0A= =0A= - if (mod->bDeviceProtocol &&=0A= + if ((mod->match_flags & USB_MATCH_DEV_PROTOCOL) &&=0A= mod->bDeviceProtocol !=3D bDeviceProtocol)=0A= continue;=0A= =0A= - if (mod->bInterfaceClass=0A= - && mod->bInterfaceClass !=3D bInterfaceClass)=0A= + if ((mod->match_flags & USB_MATCH_INT_CLASS) &&=0A= + mod->bInterfaceClass !=3D bInterfaceClass)=0A= continue;=0A= =0A= - if (mod->bInterfaceSubClass &&=0A= + if ((mod->match_flags & USB_MATCH_INT_SUBCLASS) &&=0A= mod->bInterfaceSubClass !=3D bInterfaceSubClass)=0A= continue;=0A= =0A= - if (mod->bInterfaceProtocol=0A= - && mod->bInterfaceProtocol !=3D bInterfaceProtocol)=0A= + if ((mod->match_flags & USB_MATCH_INT_PROTOCOL) &&=0A= + mod->bInterfaceProtocol !=3D bInterfaceProtocol)=0A= continue;=0A= =0A= if (checkname !=3D NULL) {=0A= @@ -286,9 +355,6 @@=0A= {=0A= unsigned char buf[1024], *p;=0A= unsigned int sz;=0A= - int bInterfaceClass;=0A= - int bInterfaceSubClass;=0A= - int bInterfaceProtocol;=0A= =0A= if (usb_control_msg(fd, USB_DIR_IN, USB_REQ_GET_DESCRIPTOR,=0A= (USB_DT_CONFIG << 8) | nr,=0A= @@ -327,8 +393,6 @@=0A= static void process_device(const char *path)=0A= {=0A= unsigned char buf[USB_DT_DEVICE_SIZE];=0A= - unsigned int vid, pid;=0A= - char vendor[128], product[128];=0A= int fd;=0A= unsigned int i, maxcfg;=0A= =0A= @@ -367,6 +431,7 @@=0A= int opt_index =3D 0;=0A= int opt;=0A= char *device =3D NULL;=0A= + char *pathname =3D NULL;=0A= =0A= while ((opt =3D getopt_long(argc, argv, OPT_STRING, long_options,=0A= &opt_index)) !=3D -1) {=0A= @@ -378,10 +443,17 @@=0A= device =3D optarg;=0A= break;=0A= case 'h':=0A= - printf ("Usage: usbmodules [--help] [--device = //proc/bus/usb/NNN/NNN] [--check module]\n"=0A= + printf ("Usage: usbmodules [--help] [--device = /proc/bus/usb/NNN/NNN] [--check module]\n"=0A= + "\t[--mapfile pathname] [--version]\n"=0A= " Lists kernel modules corresponding to USB devices currently = plugged\n"=0A= " into the computer.\n");=0A= return 0;=0A= + case 'm':=0A= + pathname =3D optarg;=0A= + break;=0A= + case 'v':=0A= + puts (VERSION);=0A= + return 0;=0A= default:=0A= fprintf(stderr,=0A= "Unknown argument character = \"%c\".\n",=0A= @@ -396,7 +468,7 @@=0A= "\tusbmodules --device = /proc/bus/usb/001/009\n");=0A= return 1;=0A= }=0A= - read_modules_usbmap();=0A= + read_modules_usbmap(pathname);=0A= process_device(device);=0A= =0A= if (checkname !=3D NULL)=0A= diff -u usbutils-0.7/usbmodules.h usbutils/usbmodules.h=0A= --- usbutils-0.7/usbmodules.h Fri Nov 3 06:00:32 2000=0A= +++ usbutils/usbmodules.h Mon Feb 5 12:54:16 2001=0A= @@ -1,7 +1,19 @@=0A= /* Declaring the usb_device_id fields as unsigned int simplifies=0A= the sscanf call. */=0A= =0A= +#define USB_MATCH_VENDOR 0x0001=0A= +#define USB_MATCH_PRODUCT 0x0002=0A= +#define USB_MATCH_DEV_LO 0x0004=0A= +#define USB_MATCH_DEV_HI 0x0008=0A= +#define USB_MATCH_DEV_CLASS 0x0010=0A= +#define USB_MATCH_DEV_SUBCLASS 0x0020=0A= +#define USB_MATCH_DEV_PROTOCOL 0x0040=0A= +#define USB_MATCH_INT_CLASS 0x0080=0A= +#define USB_MATCH_INT_SUBCLASS 0x0100=0A= +#define USB_MATCH_INT_PROTOCOL 0x0200=0A= +=0A= struct usbmap_entry {=0A= + unsigned int match_flags;=0A= /*=0A= * vendor/product codes are checked, if vendor is nonzero=0A= * Range is for device revision (bcdDevice), inclusive;=0A= ------=_NextPart_000_0313_01C08F83.07D59720-- _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel