tools/insmod: add --force longopt and document it

As of the initial import to git, the option was silently ignored.
Shortly afterwards, functionality was reinstated lacking a longopt and
any documentation.

As per insmod(8) for most use-cases you'd want to use modprobe(8).
Although since the option is available and we have an equivalent in
rmmod(8) having it documented and consistent triumphs.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/138
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
This commit is contained in:
Emil Velikov 2024-09-18 16:49:08 +01:00 committed by Lucas De Marchi
parent ca8f04e87a
commit e102d2c070
2 changed files with 9 additions and 0 deletions

View File

@ -20,6 +20,12 @@ information about errors.
# OPTIONS # OPTIONS
*-f*
*--force*
This option can be extremely dangerous: it tells the kernel to ignore
the module version and vermagic fields when loading. With this option,
you can load modules build locally or by third parties, although this
can lead to memory corruption, system crashes and data loss.
*-s* *-s*
*--syslog* *--syslog*
Send errors to syslog instead of standard error. Send errors to syslog instead of standard error.

View File

@ -18,6 +18,7 @@
static const char cmdopts_s[] = "fsvVh"; static const char cmdopts_s[] = "fsvVh";
static const struct option cmdopts[] = { static const struct option cmdopts[] = {
// clang-format off // clang-format off
{ "force", no_argument, 0, 'f' },
{ "syslog", no_argument, 0, 's' }, { "syslog", no_argument, 0, 's' },
{ "verbose", no_argument, 0, 'v' }, { "verbose", no_argument, 0, 'v' },
{ "version", no_argument, 0, 'V' }, { "version", no_argument, 0, 'V' },
@ -31,6 +32,8 @@ static void help(void)
printf("Usage:\n" printf("Usage:\n"
"\t%s [options] filename [args]\n" "\t%s [options] filename [args]\n"
"Options:\n" "Options:\n"
"\t-f, --force DANGEROUS: forces a module load, may cause\n"
"\t data corruption and crash your machine\n"
"\t-s, --syslog print to syslog, not stderr\n" "\t-s, --syslog print to syslog, not stderr\n"
"\t-v, --verbose enables more messages\n" "\t-v, --verbose enables more messages\n"
"\t-V, --version show version\n" "\t-V, --version show version\n"