2000-02-09 01:28:47 +05:30
|
|
|
/* vi: set sw=4 ts=4: */
|
1999-12-18 00:27:34 +05:30
|
|
|
/*
|
|
|
|
* Mini insmod implementation for busybox
|
2001-07-25 22:28:58 +05:30
|
|
|
*
|
2008-09-13 20:29:38 +05:30
|
|
|
* Copyright (C) 2008 Timo Teras <timo.teras@iki.fi>
|
2001-07-25 22:28:58 +05:30
|
|
|
*
|
2010-08-16 23:44:46 +05:30
|
|
|
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
2007-11-03 05:01:10 +05:30
|
|
|
*/
|
2003-12-11 07:12:13 +05:30
|
|
|
|
2011-01-18 18:28:01 +05:30
|
|
|
//applet:IF_INSMOD(APPLET(insmod, BB_DIR_SBIN, BB_SUID_DROP))
|
2010-10-15 14:59:02 +05:30
|
|
|
|
2008-09-13 20:29:38 +05:30
|
|
|
#include "libbb.h"
|
|
|
|
#include "modutils.h"
|
2003-12-11 07:12:13 +05:30
|
|
|
|
2010-06-07 04:46:45 +05:30
|
|
|
/* 2.6 style insmod has no options and required filename
|
|
|
|
* (not module name - .ko can't be omitted) */
|
|
|
|
|
2010-10-16 05:26:41 +05:30
|
|
|
//usage:#if !ENABLE_MODPROBE_SMALL
|
2010-06-07 04:46:45 +05:30
|
|
|
//usage:#define insmod_trivial_usage
|
|
|
|
//usage: IF_FEATURE_2_4_MODULES("[OPTIONS] MODULE ")
|
|
|
|
//usage: IF_NOT_FEATURE_2_4_MODULES("FILE ")
|
2010-10-10 00:40:32 +05:30
|
|
|
//usage: "[SYMBOL=VALUE]..."
|
2010-06-07 04:46:45 +05:30
|
|
|
//usage:#define insmod_full_usage "\n\n"
|
|
|
|
//usage: "Load the specified kernel modules into the kernel"
|
|
|
|
//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 05:26:41 +05:30
|
|
|
//usage:#endif
|
2010-06-07 04:46:45 +05:30
|
|
|
|
2007-11-03 05:01:10 +05:30
|
|
|
int insmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
2008-07-05 14:48:54 +05:30
|
|
|
int insmod_main(int argc UNUSED_PARAM, char **argv)
|
2003-12-11 07:12:13 +05:30
|
|
|
{
|
2008-09-13 20:29:38 +05:30
|
|
|
char *filename;
|
|
|
|
int rc;
|
|
|
|
|
2008-11-22 23:59:01 +05:30
|
|
|
/* Compat note:
|
|
|
|
* 2.6 style insmod has no options and required filename
|
|
|
|
* (not module name - .ko can't be omitted).
|
2008-11-23 02:00:53 +05:30
|
|
|
* 2.4 style insmod can take module name without .o
|
2008-11-22 23:59:01 +05:30
|
|
|
* and performs module search in default directories
|
|
|
|
* or in $MODPATH.
|
|
|
|
*/
|
|
|
|
|
2009-04-21 16:39:40 +05:30
|
|
|
IF_FEATURE_2_4_MODULES(
|
2008-09-13 20:29:38 +05:30
|
|
|
getopt32(argv, INSMOD_OPTS INSMOD_ARGS);
|
2008-11-22 23:59:01 +05:30
|
|
|
argv += optind - 1;
|
2008-09-13 20:29:38 +05:30
|
|
|
);
|
2003-12-25 02:00:45 +05:30
|
|
|
|
2006-11-21 17:28:14 +05:30
|
|
|
filename = *++argv;
|
|
|
|
if (!filename)
|
2003-12-11 07:12:13 +05:30
|
|
|
bb_show_usage();
|
|
|
|
|
2011-02-02 04:30:36 +05:30
|
|
|
rc = bb_init_module(filename, parse_cmdline_module_options(argv, /*quote_spaces:*/ 0));
|
2008-09-13 20:29:38 +05:30
|
|
|
if (rc)
|
2009-04-13 07:55:40 +05:30
|
|
|
bb_error_msg("can't insert '%s': %s", filename, moderror(rc));
|
2003-12-11 07:12:13 +05:30
|
|
|
|
2008-09-13 20:29:38 +05:30
|
|
|
return rc;
|
2003-12-11 07:12:13 +05:30
|
|
|
}
|