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
|
|
|
*
|
2008-09-13 14:59:38 +00:00
|
|
|
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
2007-11-02 23:31:10 +00:00
|
|
|
*/
|
2003-12-11 01:42:13 +00:00
|
|
|
|
2008-09-13 14:59:38 +00:00
|
|
|
#include "libbb.h"
|
|
|
|
#include "modutils.h"
|
2003-12-11 01:42:13 +00: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.
|
|
|
|
*/
|
|
|
|
|
2008-09-13 14:59:38 +00:00
|
|
|
USE_FEATURE_2_4_MODULES(
|
|
|
|
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();
|
|
|
|
|
2008-09-13 14:59:38 +00:00
|
|
|
rc = bb_init_module(filename, parse_cmdline_module_options(argv));
|
|
|
|
if (rc)
|
|
|
|
bb_error_msg("cannot 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
|
|
|
}
|