zdev: Introduce --no-module-load option for chzdev

When called with a device parameter, chzdev tries to load the kernel
module of the corresponding device type. This might not be desired in
certain situations like early initial RAM-disk processing.

To support this use cases, add a new command-line option
--no-module-load to prevent the loading of any kernel module by chzdev.

Suggested-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
This commit is contained in:
Vineeth Vijayan
2025-08-26 12:42:29 +02:00
committed by Steffen Eiden
parent 0356d78bc2
commit d1bf9e68c6
3 changed files with 19 additions and 0 deletions

View File

@@ -109,6 +109,7 @@ struct options {
unsigned int quiet:1;
unsigned int no_settle:1;
unsigned int site_id;
unsigned int no_module_load:1;
};
/* Makefile converts chzdev_usage.txt into C file which we include here. */
@@ -156,6 +157,7 @@ enum {
OPT_NO_SETTLE = (OPT_ANONYMOUS_BASE+__COUNTER__),
OPT_AUTO_CONF = (OPT_ANONYMOUS_BASE+__COUNTER__),
OPT_SITE = 's',
OPT_NO_MODULE_LOAD = (OPT_ANONYMOUS_BASE+__COUNTER__),
};
static struct opts_conflict conflict_list[] = {
@@ -260,6 +262,7 @@ static const struct option opt_list[] = {
{ "quiet", no_argument, NULL, OPT_QUIET },
{ "no-settle", no_argument, NULL, OPT_NO_SETTLE },
{ "site", required_argument, NULL, OPT_SITE },
{ "no-module-load", no_argument, NULL, OPT_NO_MODULE_LOAD },
{ NULL, no_argument, NULL, 0 },
};
@@ -1018,6 +1021,11 @@ static exit_code_t parse_options(struct options *opts, int argc, char *argv[])
opts->no_settle = 1;
break;
case OPT_NO_MODULE_LOAD:
/* --no-module-load */
opts->no_module_load = 1;
break;
case OPT_SITE:
/* --site */
/* 1. User can specify only site-ids from 0 to 9
@@ -3177,6 +3185,7 @@ int main(int argc, char *argv[])
dryrun = opts.dryrun;
udev_no_settle = opts.no_settle;
path_set_base(opts.base);
module_load_suppress(opts.no_module_load);
if (dryrun)
info("Starting dry-run, configuration will not be changed\n");

View File

@@ -57,6 +57,7 @@ OPTIONS
--dry-run Display changes without applying
--base PATH Use PATH as base for accessing files
--no-settle Do not wait for udev to settle
--no-module-load Do not load kernel modules during execution
--auto-conf Apply changes to auto-configuration only
-s, --site ID Apply changes to the specified site only
--is-owner FILE Examine whether the file is generated by zdev