2000-02-08 19:58:47 +00:00
|
|
|
/* vi: set sw=4 ts=4: */
|
1999-12-17 18:57:34 +00:00
|
|
|
/*
|
|
|
|
* Mini insmod implementation for busybox
|
2001-07-25 16:58:58 +00:00
|
|
|
*
|
2008-09-13 14:59:38 +00:00
|
|
|
* Copyright (C) 2008 Timo Teras <timo.teras@iki.fi>
|
2001-07-25 16:58:58 +00:00
|
|
|
*
|
2010-08-16 20:14:46 +02:00
|
|
|
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
2007-11-02 23:31:10 +00:00
|
|
|
*/
|
2016-11-23 07:54:52 +01:00
|
|
|
//config:config INSMOD
|
2017-07-18 22:01:24 +02:00
|
|
|
//config: bool "insmod (22 kb)"
|
2016-12-23 15:22:44 +01:00
|
|
|
//config: default y
|
2016-11-23 07:54:52 +01:00
|
|
|
//config: help
|
2017-07-21 09:50:55 +02:00
|
|
|
//config: insmod is used to load specified modules in the running kernel.
|
2003-12-11 01:42:13 +00:00
|
|
|
|
2017-08-04 02:56:39 +02:00
|
|
|
//applet:IF_INSMOD(IF_NOT_MODPROBE_SMALL(APPLET_NOEXEC(insmod, insmod, BB_DIR_SBIN, BB_SUID_DROP, insmod)))
|
2010-10-15 11:29:02 +02:00
|
|
|
|
2016-12-23 15:12:27 +01:00
|
|
|
//kbuild:ifneq ($(CONFIG_MODPROBE_SMALL),y)
|
2016-11-23 07:54:52 +01:00
|
|
|
//kbuild:lib-$(CONFIG_INSMOD) += insmod.o modutils.o
|
2016-12-23 15:12:27 +01:00
|
|
|
//kbuild:endif
|
2016-11-23 07:54:52 +01:00
|
|
|
|
2008-09-13 14:59:38 +00:00
|
|
|
#include "libbb.h"
|
|
|
|
#include "modutils.h"
|
2003-12-11 01:42:13 +00:00
|
|
|
|
2010-06-07 01:16:45 +02:00
|
|
|
/* 2.6 style insmod has no options and required filename
|
|
|
|
* (not module name - .ko can't be omitted) */
|
|
|
|
|
2010-10-16 01:56:41 +02:00
|
|
|
//usage:#if !ENABLE_MODPROBE_SMALL
|
2010-06-07 01:16:45 +02:00
|
|
|
//usage:#define insmod_trivial_usage
|
2020-12-13 22:34:05 +01:00
|
|
|
//usage: IF_FEATURE_2_4_MODULES("[-fkvqLx] MODULE")
|
2017-01-31 21:09:17 +08:00
|
|
|
//usage: IF_NOT_FEATURE_2_4_MODULES("FILE")
|
|
|
|
//usage: IF_FEATURE_CMDLINE_MODULE_OPTIONS(" [SYMBOL=VALUE]...")
|
2010-06-07 01:16:45 +02:00
|
|
|
//usage:#define insmod_full_usage "\n\n"
|
2014-04-19 15:04:39 +02:00
|
|
|
//usage: "Load kernel module"
|
2010-06-07 01:16:45 +02:00
|
|
|
//usage: IF_FEATURE_2_4_MODULES( "\n"
|
|
|
|
//usage: "\n -f Force module to load into the wrong kernel version"
|
|
|
|
//usage: "\n -k Make module autoclean-able"
|
|
|
|
//usage: "\n -v Verbose"
|
|
|
|
//usage: "\n -q Quiet"
|
|
|
|
//usage: "\n -L Lock: prevent simultaneous loads"
|
|
|
|
//usage: IF_FEATURE_INSMOD_LOAD_MAP(
|
|
|
|
//usage: "\n -m Output load map to stdout"
|
|
|
|
//usage: )
|
|
|
|
//usage: "\n -x Don't export externs"
|
|
|
|
//usage: )
|
2010-10-16 01:56:41 +02:00
|
|
|
//usage:#endif
|
2010-06-07 01:16:45 +02:00
|
|
|
|
2007-11-02 23:31:10 +00:00
|
|
|
int insmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
2008-07-05 09:18:54 +00:00
|
|
|
int insmod_main(int argc UNUSED_PARAM, char **argv)
|
2003-12-11 01:42:13 +00:00
|
|
|
{
|
2008-09-13 14:59:38 +00:00
|
|
|
char *filename;
|
|
|
|
int rc;
|
|
|
|
|
2008-11-22 18:29:01 +00:00
|
|
|
/* Compat note:
|
|
|
|
* 2.6 style insmod has no options and required filename
|
|
|
|
* (not module name - .ko can't be omitted).
|
2008-11-22 20:30:53 +00:00
|
|
|
* 2.4 style insmod can take module name without .o
|
2008-11-22 18:29:01 +00:00
|
|
|
* and performs module search in default directories
|
|
|
|
* or in $MODPATH.
|
|
|
|
*/
|
|
|
|
|
2009-04-21 11:09:40 +00:00
|
|
|
IF_FEATURE_2_4_MODULES(
|
2008-09-13 14:59:38 +00:00
|
|
|
getopt32(argv, INSMOD_OPTS INSMOD_ARGS);
|
2008-11-22 18:29:01 +00:00
|
|
|
argv += optind - 1;
|
2008-09-13 14:59:38 +00:00
|
|
|
);
|
2003-12-24 20:30:45 +00:00
|
|
|
|
2006-11-21 11:58:14 +00:00
|
|
|
filename = *++argv;
|
|
|
|
if (!filename)
|
2003-12-11 01:42:13 +00:00
|
|
|
bb_show_usage();
|
|
|
|
|
2011-02-02 00:00:36 +01:00
|
|
|
rc = bb_init_module(filename, parse_cmdline_module_options(argv, /*quote_spaces:*/ 0));
|
2008-09-13 14:59:38 +00:00
|
|
|
if (rc)
|
2009-04-13 02:25:40 +00:00
|
|
|
bb_error_msg("can't insert '%s': %s", filename, moderror(rc));
|
2003-12-11 01:42:13 +00:00
|
|
|
|
2008-09-13 14:59:38 +00:00
|
|
|
return rc;
|
2003-12-11 01:42:13 +00:00
|
|
|
}
|