diff --git a/sbin/devmatch/devmatch.8 b/sbin/devmatch/devmatch.8 --- 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 @@ 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 --- a/sbin/devmatch/devmatch.c +++ b/sbin/devmatch/devmatch.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -48,6 +49,7 @@ { "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 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 @@ 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 @@ { 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 @@ case 'p': nomatch_str = optarg; break; + case 'q': + quiet_flag++; + break; case 'u': unbound_flag++; break;