From 19a4b38f2bcfe6a1809bdcbcd23fdec15c3cf771 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Sun, 1 Jun 2025 10:03:28 +0000 Subject: Add config test option to mdevd (thanks lanodan) Signed-off-by: Laurent Bercot --- AUTHORS | 3 +++ doc/mdevd.html | 5 ++++- src/mdevd/mdevd.c | 6 ++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/AUTHORS b/AUTHORS index 33d961a..797c469 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,6 +1,9 @@ Main author: Laurent Bercot +Contributors: + Haelwenn (lanodan) Monnier + Thanks to: Rob Landley Natanael Copa diff --git a/doc/mdevd.html b/doc/mdevd.html index 7c2a869..4b814de 100644 --- a/doc/mdevd.html +++ b/doc/mdevd.html @@ -49,7 +49,7 @@ to running mdevd over mdev.

Interface

-     mdevd [ -v verbosity ] [ -D notif ] [ -I intake ] [ -o outputfd ] [ -I intake ] [ -O nlgroups ] [ -b kbufsz ] [ -f conffile ] [ -n ] [ -s slashsys ] [ -d slashdev ] [ -F fwbase ] [ -C ]
+     mdevd [ -v verbosity ] [ -D notif ] [ -I intake ] [ -o outputfd ] [ -I intake ] [ -O nlgroups ] [ -b kbufsz ] [ -f conffile ] [ -n | -N ] [ -s slashsys ] [ -d slashdev ] [ -F fwbase ] [ -C ]
 
    @@ -126,6 +126,9 @@ from mdevd at coldplug time, try increasing this number.
  • -n : dry run. mdevd will not create or delete device nodes, and it will not spawn commands. Instead, it will print to stdout the actions it would have performed.
  • +
  • -N : configuration file test. mdevd will not run, it will +only parse its configuration file and exit 0 on success or nonzero (with an +error message) on failure. This option overrides, and is overridden by, -n.
  • -f conffile : read the configuration file from conffile. Default is /etc/mdev.conf. conffile must be an absolute path.
  • diff --git a/src/mdevd/mdevd.c b/src/mdevd/mdevd.c index f5222f7..c34bf58 100644 --- a/src/mdevd/mdevd.c +++ b/src/mdevd/mdevd.c @@ -43,7 +43,7 @@ #include #include "mdevd-internal.h" -#define USAGE "mdevd [ -v verbosity ] [ -D notif ] [ -I intake ] [ -o outputfd ] [ -O nlgroups ] [ -b kbufsz ] [ -f conffile ] [ -n ] [ -s slashsys ] [ -d slashdev ] [ -F fwbase ] [ -C ]" +#define USAGE "mdevd [ -v verbosity ] [ -D notif ] [ -I intake ] [ -o outputfd ] [ -O nlgroups ] [ -b kbufsz ] [ -f conffile ] [ -n | -N ] [ -s slashsys ] [ -d slashdev ] [ -F fwbase ] [ -C ]" #define dieusage() strerr_dieusage(100, USAGE) #define CONFBUFSIZE 8192 @@ -915,11 +915,12 @@ int main (int argc, char const *const *argv) subgetopt l = SUBGETOPT_ZERO ; for (;;) { - int opt = subgetopt_r(argc, argv, "nv:D:I:o:O:b:f:s:d:F:C", &l) ; + int opt = subgetopt_r(argc, argv, "nNv:D:I:o:O:b:f:s:d:F:C", &l) ; if (opt == -1) break ; switch (opt) { case 'n' : dryrun = 1 ; break ; + case 'N' : dryrun = 2 ; break ; case 'v' : if (!uint0_scan(l.arg, &verbosity)) dieusage() ; break ; case 'D' : if (!uint0_scan(l.arg, ¬if)) dieusage() ; break ; case 'I' : if (!uint0_scan(l.arg, &intake)) dieusage() ; break ; @@ -1023,6 +1024,7 @@ int main (int argc, char const *const *argv) memset(script, 0, scriptlen * sizeof(scriptelem)) ; script[scriptlen++] = scriptelem_catchall ; script_secondpass(storage, script, envmatch) ; + if (dryrun == 2) break ; cont = 2 ; if (docoldplug) { -- cgit v1.3.1