git: a1df36f1b99b - main - devmatch: introduce quiet command line option
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 15 Aug 2023 22:57:10 UTC
The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=a1df36f1b99bf2b8dcee66327f55888667fa4b2f commit a1df36f1b99bf2b8dcee66327f55888667fa4b2f Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2023-08-13 21:33:48 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2023-08-15 22:54:48 +0000 devmatch: introduce quiet command line option In setups without hints whatsoever one can get a long list of "Can't read linker hints file" error messages during boot. Add a -q/--quiet option which would suppress the noise and leave space for more essential information. While here switch to a pre-defined exit code from sysexits. MFC after: 4 weeks Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D41443 --- sbin/devmatch/devmatch.8 | 7 ++++++- sbin/devmatch/devmatch.c | 16 +++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/sbin/devmatch/devmatch.8 b/sbin/devmatch/devmatch.8 index 14e2add65aa1..68705cd954ad 100644 --- a/sbin/devmatch/devmatch.8 +++ b/sbin/devmatch/devmatch.8 @@ -23,7 +23,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 3, 2022 +.Dd August 13, 2023 .Dt DEVMATCH 8 .Os .Sh NAME @@ -35,6 +35,7 @@ .Op Fl d | -dump .Op Oo Fl h | -hints Oc Ar file .Op Oo Fl p | -nomatch Oc Ar event +.Op Fl q | -quiet .Op Fl u | -unbound .Op Fl v | -verbose .Sh DESCRIPTION @@ -59,6 +60,10 @@ guessed from the current module load path. Parse and use a standard NOMATCH event from .Xr devd 8 for matching instead of searching the device tree. +.It Fl q Fl -quiet +Suppress some error messages and simply return a non-zero exit code. +This is helpful to avoid an endless list of warnings during bootup if +no hints are available. .It Fl u Fl -unbound Attempt to produce a list of those drivers with PNP info whose driver tables with that PNP info cannot be found. diff --git a/sbin/devmatch/devmatch.c b/sbin/devmatch/devmatch.c index 20a57353ecf6..f9f5122663a1 100644 --- a/sbin/devmatch/devmatch.c +++ b/sbin/devmatch/devmatch.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sysexits.h> #include <unistd.h> #include <sys/linker.h> #include <sys/module.h> @@ -48,6 +49,7 @@ static struct option longopts[] = { { "dump", no_argument, NULL, 'd' }, { "hints", required_argument, NULL, 'h' }, { "nomatch", required_argument, NULL, 'p' }, + { "quiet", no_argument, NULL, 'q' }, { "unbound", no_argument, NULL, 'u' }, { "verbose", no_argument, NULL, 'v' }, { NULL, 0, NULL, 0 } @@ -59,6 +61,7 @@ static int all_flag; static int dump_flag; static char *linker_hints; static char *nomatch_str; +static int quiet_flag; static int unbound_flag; static int verbose_flag; @@ -114,8 +117,12 @@ read_linker_hints(void) continue; break; } - if (q == NULL) - errx(1, "Can't read linker hints file."); + if (q == NULL) { + if (quiet_flag) + exit(EX_UNAVAILABLE); + else + errx(EX_UNAVAILABLE, "Can't read linker hints file."); + } } else { hints = read_hints(linker_hints, &len); if (hints == NULL) @@ -565,7 +572,7 @@ main(int argc, char **argv) { int ch; - while ((ch = getopt_long(argc, argv, "adh:p:uv", + while ((ch = getopt_long(argc, argv, "adh:p:quv", longopts, NULL)) != -1) { switch (ch) { case 'a': @@ -580,6 +587,9 @@ main(int argc, char **argv) case 'p': nomatch_str = optarg; break; + case 'q': + quiet_flag++; + break; case 'u': unbound_flag++; break;