blob: 2c7f647e2980aacc14a9579c6c90ba14b4c28507 [file] [log] [blame]
Erik Andersene49d5ec2000-02-08 19:58:47 +00001/* vi: set sw=4 ts=4: */
Erik Andersen02104321999-12-17 18:57:34 +00002/*
3 * Mini insmod implementation for busybox
Eric Andersen2835efe2001-07-25 16:58:58 +00004 *
Denis Vlasenkoba1315d2008-09-13 14:59:38 +00005 * Copyright (C) 2008 Timo Teras <timo.teras@iki.fi>
Erik Andersen02104321999-12-17 18:57:34 +00006 *
Bernhard Reutner-Fischerc2cb0f32006-04-13 12:45:04 +00007 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
Erik Andersen02104321999-12-17 18:57:34 +00008 */
9
Denis Vlasenkob6adbf12007-05-26 19:00:18 +000010#include "libbb.h"
Denis Vlasenkoba1315d2008-09-13 14:59:38 +000011#include "modutils.h"
Eric Andersene7047882003-12-11 01:42:13 +000012
Denis Vlasenkob68979a2007-11-02 23:31:10 +000013int insmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Denis Vlasenkoa60f84e2008-07-05 09:18:54 +000014int insmod_main(int argc UNUSED_PARAM, char **argv)
Eric Andersene7047882003-12-11 01:42:13 +000015{
Denis Vlasenkoba1315d2008-09-13 14:59:38 +000016 char *filename;
17 int rc;
18
Denis Vlasenko36309cf2008-11-22 18:29:01 +000019 /* Compat note:
20 * 2.6 style insmod has no options and required filename
21 * (not module name - .ko can't be omitted).
Bernhard Reutner-Fischer9a280fa2008-11-22 20:30:53 +000022 * 2.4 style insmod can take module name without .o
Denis Vlasenko36309cf2008-11-22 18:29:01 +000023 * and performs module search in default directories
24 * or in $MODPATH.
25 */
26
Denis Vlasenkoba1315d2008-09-13 14:59:38 +000027 USE_FEATURE_2_4_MODULES(
28 getopt32(argv, INSMOD_OPTS INSMOD_ARGS);
Denis Vlasenko36309cf2008-11-22 18:29:01 +000029 argv += optind - 1;
Denis Vlasenkoba1315d2008-09-13 14:59:38 +000030 );
Eric Andersen3b1a7442003-12-24 20:30:45 +000031
Denis Vlasenko92297942006-11-21 11:58:14 +000032 filename = *++argv;
33 if (!filename)
Eric Andersene7047882003-12-11 01:42:13 +000034 bb_show_usage();
Eric Andersene7047882003-12-11 01:42:13 +000035
Denis Vlasenkoba1315d2008-09-13 14:59:38 +000036 rc = bb_init_module(filename, parse_cmdline_module_options(argv));
37 if (rc)
38 bb_error_msg("cannot insert '%s': %s", filename, moderror(rc));
Eric Andersene7047882003-12-11 01:42:13 +000039
Denis Vlasenkoba1315d2008-09-13 14:59:38 +000040 return rc;
Eric Andersene7047882003-12-11 01:42:13 +000041}