From owner-svn-src-head@freebsd.org Mon Dec 25 19:11:18 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4AAE4EA0EE7; Mon, 25 Dec 2017 19:11:18 +0000 (UTC) (envelope-from ohartmann@walstatt.org) Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "mout.gmx.net", Issuer "TeleSec ServerPass DE-2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BE9D66F52B; Mon, 25 Dec 2017 19:11:17 +0000 (UTC) (envelope-from ohartmann@walstatt.org) Received: from thor.intern.walstatt.dynvpn.de ([77.179.219.206]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MEXHd-1eiiUi11Y1-00FleR; Mon, 25 Dec 2017 20:06:01 +0100 Date: Mon, 25 Dec 2017 20:05:27 +0100 From: "O. Hartmann" To: Warner Losh Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r327177 - in head/usr.sbin: . devmatch Message-ID: <20171225200554.71a71213@thor.intern.walstatt.dynvpn.de> In-Reply-To: <201712251856.vBPIu8av032814@repo.freebsd.org> References: <201712251856.vBPIu8av032814@repo.freebsd.org> Organization: WALSTATT User-Agent: OutScare 3.1415926 X-Operating-System: ImNotAnOperatingSystem 3.141592527 MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; boundary="Sig_/WkbZv=7gKi.w6jObxPedIQs"; protocol="application/pgp-signature" X-Provags-ID: V03:K0:razmKxwOerUsxsbklmd6GDbWoE0joQ7HAHjhoS0dZ09lIGXR6vq M39R2qGCBpgYn/4NIVvj1MHI/Wchu/nqEEe9DN4mkdR4gepTJvj74q9SlnGMxUNIEEpGlqO /L++yAibfMOmR9adkeXsnU8t402DEn47A6TN65EPPhQyMGRlSXZcldHiNhE/VBb3hng8s9P 0IHDUxdPgtnOM8Xau53KA== X-UI-Out-Filterresults: notjunk:1;V01:K0:H0HJHBZwk8Y=:xWaavrJTFBsMCOMmw/fJ4t uNzQ4Aq4eUCjxpYc9X7FotbKoBo/oSo5TWEn568Dru+omWHU9/fsWRq4NIeOUBT044HX+bsgL oR6/A9EWZsMOemGPwPcVGeaS5jtOzW6klVlH2NT6oQzgLMT4J1yYp+5ilz7EGGkM+l48Pe/Y8 H4ACetigasccoGlCh7eJAkekMa9hWrdj0M0t+sbDLzMVe2QF33mVFOxDxbfF5qqdC9dWBNMB0 jFhot3+yCxtm8gGlSoVebiZzP8x002UEvi/E5PHaHZ60hSEEQaRdzyRuTkjyC+roLmA+KG6So aeKKMG0Ubcn9aCmWiLPG2CfktguLS+70hUTr7HvCjr4RBy0za2EpjGAhAsxwfbMKpZxkTiLRm cGHEYzx8sFSlquUVAuid78HoYyJd9aiuZnE7n8TQfGhqbEXhg4txZxj+tzaqSIhTzzpA9gxGP kJX44d6NLKKVTg5iyzfejMjPeAXgW1KaORPBXrTIGDeIEOdLeKLIiforfthklqs6GtlFnlcLf eQnkAsshFiZhQbJsFREKnsd4Pk4or3mvpJwOVPpdMqKbj7S2htQ0dfdFgIL2NI4wAIi9KtHno QbGOj9eqpAPejgs7z5/YicKbUGSk1Gfic0VOWEYi4cpszUqJU32rUtmEXftCbtu61rl2besX6 B8hBdotISVwIi7qIFYBJtZoyV6PRkuaUucUSHMjAD4+kHwmg2+aurvUAFoAgCNG75LIGNT6wO 0OXA7I7KugP3dL4ii3GHEImcSocb9seWWEkqLvMtFgMQe+YrPct0jjlSjuyWRf7k/0ptAZjSY fRi9/puZzV7yZ8cldd8xVmmtanFSg== X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Dec 2017 19:11:18 -0000 --Sig_/WkbZv=7gKi.w6jObxPedIQs Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Am Mon, 25 Dec 2017 18:56:08 +0000 (UTC) Warner Losh schrieb: > Author: imp > Date: Mon Dec 25 18:56:08 2017 > New Revision: 327177 > URL: https://svnweb.freebsd.org/changeset/base/327177 >=20 > Log: > Match unattached devices on the system to potential kernel modules. > =20 > devmatch(8) matchs up devices in the system device tree with drivers > that may match them. For each unattached device in the system, it > tries to find matching PNP info in the linker hints and prints modules > to load to claim the devices. > =20 > In --unbound mode, devmatch can look for drivers that have attached to > devices in the device tree and have plug and play information, but for > which no PNP info exists. This helps find drivers that haven't been > converted yet that are in use on this system. > =20 > In addition, the ability to dump out linker.hints is provided. > =20 > Future commits will add hooks to devd.conf and rc.d to fully automate > using this information. >=20 > Added: > head/usr.sbin/devmatch/ > head/usr.sbin/devmatch/Makefile (contents, props changed) > head/usr.sbin/devmatch/devmatch.8 (contents, props changed) > head/usr.sbin/devmatch/devmatch.c (contents, props changed) > Modified: > head/usr.sbin/Makefile >=20 > Modified: head/usr.sbin/Makefile > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/usr.sbin/Makefile Mon Dec 25 16:40:09 2017 (r327176) > +++ head/usr.sbin/Makefile Mon Dec 25 18:56:08 2017 (r327177) > @@ -21,6 +21,7 @@ SUBDIR=3D adduser \ > dconschat \ > devctl \ > devinfo \ > + devmath \ > digictl \ > diskinfo \ > dumpcis \ >=20 > Added: head/usr.sbin/devmatch/Makefile > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/usr.sbin/devmatch/Makefile Mon Dec 25 18:56:08 2017 (r327177) > @@ -0,0 +1,8 @@ > +# $FreeBSD$ > + > +PROG=3D devmatch > +MAN=3D devmatch.8 > + > +LIBADD=3D devinfo > + > +.include >=20 > Added: head/usr.sbin/devmatch/devmatch.8 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/usr.sbin/devmatch/devmatch.8 Mon Dec 25 18:56:08 2017 (r327177) > @@ -0,0 +1,85 @@ > +.\" > +.\" Copyright (c) 2017 Netflix, Inc > +.\" > +.\" All rights reserved. > +.\" > +.\" Redistribution and use in source and binary forms, with or without > +.\" modification, are permitted provided that the following conditions > +.\" are met: > +.\" 1. Redistributions of source code must retain the above copyright > +.\" notice, this list of conditions and the following disclaimer. > +.\" 2. Redistributions in binary form must reproduce the above copyright > +.\" notice, this list of conditions and the following disclaimer in t= he > +.\" documentation and/or other materials provided with the distributi= on. > +.\" > +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR > +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRA= NTIES > +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIM= ED. > +.\" IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, > +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,= BUT > +.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF= USE, > +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY > +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE US= E OF > +.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > +.\" > +.\" $FreeBSD$ > +.\" > +.Dd December 25, 2017 > +.Dt DEVMATCH 8 > +.Os > +.Sh NAME > +.Nm devinfo > +.Nd print information about unattached devices > +.Sh SYNOPSIS > +.Nm > +.Op Fl aduv > +.Op Fl -all > +.Op Fl -dump > +.Op Fl -unbound > +.Op Fl -verbose > +.Sh DESCRIPTION > +The > +.Nm > +utility, without any arguments, prints all the kernel modules it has > +found for all the unattached, enabled devices in the system. > +.Bl -tag -width 20m > +.It Fl a Fl -all > +Include all devices, not just the ones that are unattached. > +.It Fl d Fl -dump > +Produce a human readable dump of the > +.Pa linker.hints > +file. > +.It Fl u Fl -unbound > +Attempt to produce a list of those drivers with PNP info whose driver > +tables with that PNP info can't be found. > +.It Fl v Fl -verbose > +Produce more verbose output. > +.El > +.Sh SEE ALSO > +.Xr devinfo 8 > +.Sh BUGS > +The kernel has hints in it, but we exclude it from the list of modules > +to suggest for unmatched devices. > +We exclude it when suggesting drivers, but include it when looking for > +unbound devices or producing a full dump of > +.Pa linker.hints . > +This can be confusing. > +.Pp > +Some modules are hard links in > +.Pa /boot/kernel > +and will be reported twice. > +.Pp > +The PNP string's attributes are evaluated once per PNP entry on that > +bus rather than once. > +.Pp > +The term PNP is overloaded in FreeBSD. > +It means, generically, the identifying data the bus provides about a > +device. > +While this include old ISA PNP identifiers, it also includes the > +logical equivalent in USB, PCI, and others. > +.Pp > +Many drivers currently lack proper PNP table decorations and need to > +be updated. > +.Sh AUTHORS > +.An Warner Losh Aq Mt imp@FreeBSD.org >=20 > Added: head/usr.sbin/devmatch/devmatch.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/usr.sbin/devmatch/devmatch.c Mon Dec 25 18:56:08 2017 (r327177) > @@ -0,0 +1,425 @@ > +/*- > + * Copyright (c) 2017 Netflix, Inc > + * All rights reserved. > + * > + * Redistribution and use in source and binary forms, with or without > + * modification, are permitted provided that the following conditions > + * are met: > + * 1. Redistributions of source code must retain the above copyright > + * notice, this list of conditions and the following disclaimer. > + * 2. Redistributions in binary form must reproduce the above copyright > + * notice, this list of conditions and the following disclaimer in the > + * documentation and/or other materials provided with the distributio= n. > + * > + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PU= RPOSE > + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIAB= LE > + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUE= NTIAL > + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOO= DS > + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, S= TRICT > + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY= WAY > + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > + * SUCH DAMAGE. > + */ > + > +#include > +__FBSDID("$FreeBSD$"); > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +/* options descriptor */ > +static struct option longopts[] =3D { > + { "all", no_argument, NULL, 'a' }, > + { "dump", no_argument, NULL, 'd' }, > + { "unbound", no_argument, NULL, 'u' }, > + { "verbose", no_argument, NULL, 'v' }, > + { NULL, 0, NULL, 0 } > +}; > + > +static int all_flag; > +static int dump_flag; > +static int unbound_flag; > +static int verbose_flag; > + > +static void *hints; > +static void *hints_end; > + > +static void > +read_linker_hints(void) > +{ > + char fn[MAXPATHLEN]; > + struct stat sb; > + char *modpath, *p, *q; > + size_t buflen; > + int fd; > + > + if (sysctlbyname("kern.module_path", NULL, &buflen, NULL, 0) < 0) > + errx(1, "Can't find kernel module path."); > + modpath =3D malloc(buflen); > + if (modpath =3D=3D NULL) > + err(1, "Can't get memory for modpath."); > + if (sysctlbyname("kern.module_path", modpath, &buflen, NULL, 0) < 0) > + errx(1, "Can't find kernel module path."); > + p =3D modpath; > + while ((q =3D strsep(&p, ";")) !=3D NULL) { > + snprintf(fn, sizeof(fn), "%s/linker.hints", q); > + if (stat(fn, &sb) !=3D 0) > + continue; > + hints =3D malloc(sb.st_size); > + if (hints =3D=3D NULL) > + err(1, "not enough space to read hints file of %ju bytes", > (uintmax_t)sb.st_size); > + fd =3D open(fn, O_RDONLY); > + if (fd < 0) > + err(1, "Can't open %s for reading", fn); > + if (read(fd, hints, sb.st_size) !=3D sb.st_size) > + err(1, "Can't read in %ju bytes from %s", > (uintmax_t)sb.st_size, fn); > + close(fd); > + break; > + } > + if (q =3D=3D NULL) { > + warnx("Can't read linker hints file."); > + free(hints); > + hints =3D NULL; > + } > + if (*(int *)(intptr_t)hints !=3D LINKER_HINTS_VERSION) { > + warnx("Linker hints version %d doesn't match expected %d.", > + *(int *)(intptr_t)hints, LINKER_HINTS_VERSION); > + free(hints); > + hints =3D NULL; > + } > + if (hints !=3D NULL) > + hints_end =3D (void *)((intptr_t)hints + (intptr_t)sb.st_size); > +} > + > +static int > +getint(void **ptr) > +{ > + int *p =3D *ptr; > + int rv; > + > + p =3D (int *)roundup2((intptr_t)p, sizeof(int)); > + rv =3D *p++; > + *ptr =3D p; > + return rv; > +} > + > +static void > +getstr(void **ptr, char *val) > +{ > + int *p =3D *ptr; > + char *c =3D (char *)p; > + int len =3D *(uint8_t *)c; > + > + memcpy(val, c + 1, len); > + val[len] =3D 0; > + c +=3D len + 1; > + *ptr =3D (void *)c; > +} > + > +static int > +pnpval_as_int(const char *val, const char *pnpinfo) > +{ > + int rv; > + char key[256]; > + char *cp; > + > + if (pnpinfo =3D=3D NULL) > + return -1; > + > + cp =3D strchr(val, ';'); > + key[0] =3D ' '; > + if (cp =3D=3D NULL) > + strcpy(key + 1, val); > + else { > + memcpy(key + 1, val, cp - val); > + key[cp - val + 1] =3D '\0'; > + } > + strcat(key, "=3D"); > + if (strncmp(key + 1, pnpinfo, strlen(key + 1)) =3D=3D 0) > + rv =3D strtol(pnpinfo + strlen(key + 1), NULL, 0); > + else { > + cp =3D strstr(pnpinfo, key); > + if (cp =3D=3D NULL) > + rv =3D -1; > + else > + rv =3D strtol(cp + strlen(key), NULL, 0); > + } > + return rv; > +} > + > +static void > +quoted_strcpy(char *dst, const char *src) > +{ > + char q =3D ' '; > + > + if (*src =3D=3D '\'' || *src =3D=3D '"') > + q =3D *src++; > + while (*src && *src !=3D q) > + *dst++ =3D *src++; // XXX backtick quoting > + *dst++ =3D '\0'; > + // XXX overflow > +} > + > +static char * > +pnpval_as_str(const char *val, const char *pnpinfo) > +{ > + static char retval[256]; > + char key[256]; > + char *cp; > + > + if (pnpinfo =3D=3D NULL) { > + *retval =3D '\0'; > + return retval; > + } > + > + cp =3D strchr(val, ';'); > + key[0] =3D ' '; > + if (cp =3D=3D NULL) > + strcpy(key + 1, val); > + else { > + memcpy(key + 1, val, cp - val); > + key[cp - val + 1] =3D '\0'; > + } > + strcat(key, "=3D"); > + if (strncmp(key + 1, pnpinfo, strlen(key + 1)) =3D=3D 0) > + quoted_strcpy(retval, pnpinfo + strlen(key + 1)); > + else { > + cp =3D strstr(pnpinfo, key); > + if (cp =3D=3D NULL) > + strcpy(retval, "MISSING"); > + else > + quoted_strcpy(retval, cp + strlen(key)); > + } > + return retval; > +} > + > +static void > +search_hints(const char *bus, const char *dev, const char *pnpinfo) > +{ > + char val1[256], val2[256]; > + int ival, len, ents, i, notme, mask, bit, v, found; > + void *ptr, *walker; > + char *lastmod =3D NULL, *cp, *s; > + > + walker =3D hints; > + getint(&walker); > + found =3D 0; > + while (walker < hints_end) { > + len =3D getint(&walker); > + ival =3D getint(&walker); > + ptr =3D walker; > + switch (ival) { > + case MDT_VERSION: > + getstr(&ptr, val1); > + ival =3D getint(&ptr); > + getstr(&ptr, val2); > + if (dump_flag) > + printf("Version: if %s.%d kmod %s\n", val1, ival, > val2); > + break; > + case MDT_MODULE: > + getstr(&ptr, val1); > + getstr(&ptr, val2); > + if (lastmod) > + free(lastmod); > + lastmod =3D strdup(val2); > + if (dump_flag) > + printf("Module %s in %s\n", val1, val2); > + break; > + case MDT_PNP_INFO: > + if (!dump_flag && !unbound_flag && strcmp(lastmod, "kernel") > =3D=3D 0) > + break; > + getstr(&ptr, val1); > + getstr(&ptr, val2); > + ents =3D getint(&ptr); > + if (bus && strcmp(val1, bus) !=3D 0) > + break; > + if (dump_flag) > + printf("PNP info for bus %s format %s %d entries > (%s)\n", > + val1, val2, ents, lastmod); > + for (i =3D 0; i < ents; i++) { > + if (dump_flag) > + printf(" "); > + cp =3D val2; > + notme =3D 0; > + mask =3D -1; > + bit =3D -1; > + do { > + switch (*cp) { > + case 'I': > + case 'J': > + case 'G': > + case 'L': > + case 'M': > + ival =3D getint(&ptr); > + if (dump_flag) { > + printf("%#x:", ival); > + break; > + } > + if (bit >=3D 0 && ((1 << bit) & mask) =3D=3D > 0) > + break; > + v =3D pnpval_as_int(cp + 2, pnpinfo); > + switch (*cp) { > + case 'J': > + if (ival =3D=3D -1) > + break; > + /*FALLTHROUGH*/ > + case 'I': > + if (v !=3D ival && ival !=3D 0) > + notme++; > + break; > + case 'G': > + if (v < ival) > + notme++; > + break; > + case 'L': > + if (v > ival) > + notme++; > + break; > + case 'M': > + mask =3D ival; > + break; > + } > + break; > + case 'D': > + case 'Z': > + getstr(&ptr, val1); > + if (dump_flag) { > + printf("'%s':", val1); > + break; > + } > + if (*cp =3D=3D 'D') > + break; > + s =3D pnpval_as_str(cp + 2, pnpinfo); > + if (strcmp(s, val1) !=3D 0) > + notme++; > + break; > + default: > + break; > + } > + bit++; > + cp =3D strchr(cp, ';'); > + if (cp) > + cp++; > + } while (cp && *cp); > + if (dump_flag) > + printf("\n"); > + else if (!notme) { > + if (!unbound_flag) { > + if (all_flag) > + printf("%s: ", *dev ? dev : > "unattahed" ); > + printf("%s\n", lastmod); > + } > + found++; > + } > + } > + break; > + default: > + if (dump_flag) > + printf("Unknown Type %d len %d\n", ival, len); > + break; > + } > + walker =3D (void *)(len - sizeof(int) + (intptr_t)walker); > + } > + if (unbound_flag && found =3D=3D 0 && *pnpinfo) { > + if (verbose_flag) > + printf("------------------------- "); > + printf("%s on %s pnpinfo %s", *dev ? dev : "unattahed", bus, pnpinfo); > + if (verbose_flag) > + printf(" -------------------------"); > + printf("\n"); > + } > +} > + > +static int > +find_unmatched(struct devinfo_dev *dev, void *arg) > +{ > + struct devinfo_dev *parent; > + char *bus, *p; > + > + do { > + if (!all_flag && dev->dd_name[0] !=3D '\0') > + break; > + if (!(dev->dd_flags & DF_ENABLED)) > + break; > + parent =3D devinfo_handle_to_device(dev->dd_parent); > + bus =3D strdup(parent->dd_name); > + p =3D bus + strlen(bus) - 1; > + while (p >=3D bus && isdigit(*p)) > + p--; > + *++p =3D '\0'; > + if (verbose_flag) > + printf("Searching %s %s bus at %s for pnpinfo %s\n", > + dev->dd_name, bus, dev->dd_location, dev->dd_pnpinfo); > + search_hints(bus, dev->dd_name, dev->dd_pnpinfo); > + free(bus); > + } while (0); > + > + return (devinfo_foreach_device_child(dev, find_unmatched, arg)); > +} > + > +static void > +usage(void) > +{ > + > + errx(1, "devmatch [-adv]"); > +} > + > +int > +main(int argc, char **argv) > +{ > + struct devinfo_dev *root; > + int ch; > + > + while ((ch =3D getopt_long(argc, argv, "aduv", > + longopts, NULL)) !=3D -1) { > + switch (ch) { > + case 'a': > + all_flag++; > + break; > + case 'd': > + dump_flag++; > + break; > + case 'u': > + unbound_flag++; > + break; > + case 'v': > + verbose_flag++; > + break; > + default: > + usage(); > + } > + } > + argc -=3D optind; > + argv +=3D optind; > + > + if (argc >=3D 1) > + usage(); > + > + read_linker_hints(); > + if (dump_flag) { > + search_hints(NULL, NULL, NULL); > + exit(0); > + } > + > + if (devinfo_init()) > + err(1, "devinfo_init"); > + if ((root =3D devinfo_handle_to_device(DEVINFO_ROOT_DEVICE)) =3D=3D NUL= L) > + errx(1, "can't find root device"); > + devinfo_foreach_device_child(root, find_unmatched, (void *)0); > + devinfo_free(); > +} > _______________________________________________ > svn-src-head@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-head > To unsubscribe, send any mail to "svn-src-head-unsubscribe@freebsd.org" Well, I remeber that someone told me that "math" and "match" are different = thingis ;-) To be serious: there is some strange error ... [...] =3D=3D=3D> usr.sbin/devmath (includes) cd: /usr/src/usr.sbin/devmath: No such file or directory *** [includes_subdir_usr.sbin/devmath] Error code 2 make[3]: stopped in /usr/src/usr.sbin .ERROR_TARGET=3D'includes_subdir_usr.sbin/devmath' --=20 O. Hartmann Ich widerspreche der Nutzung oder =C3=9Cbermittlung meiner Daten f=C3=BCr Werbezwecke oder f=C3=BCr die Markt- oder Meinungsforschung (=C2=A7 28 Abs.= 4 BDSG). --Sig_/WkbZv=7gKi.w6jObxPedIQs Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iLUEARMKAB0WIQQZVZMzAtwC2T/86TrS528fyFhYlAUCWkFMEgAKCRDS528fyFhY lDmhAf0X9IoOG/6nnI0uCXCOyTVgi4EOaZwjWfaJmdVeU4Ng2QZ5zq6RiRAGWOeY u+Hk/VlZDqvS0gQGmWVdMers3TBfAf4oALvuJT9embmYzlC6hxHHDVzQhQLYrbJq QFQgUvc3x2c4USfJKaO/sWIbkdmLQV+ixkzQmeboLZEYlgYfxtCn =SYZy -----END PGP SIGNATURE----- --Sig_/WkbZv=7gKi.w6jObxPedIQs--