insmod.c 964 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Mini insmod implementation for busybox
  4. *
  5. * Copyright (C) 2008 Timo Teras <timo.teras@iki.fi>
  6. *
  7. * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  8. */
  9. #include "libbb.h"
  10. #include "modutils.h"
  11. int insmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  12. int insmod_main(int argc UNUSED_PARAM, char **argv)
  13. {
  14. char *filename;
  15. int rc;
  16. /* Compat note:
  17. * 2.6 style insmod has no options and required filename
  18. * (not module name - .ko can't be omitted).
  19. * 2.4 style insmod can take module name without .o
  20. * and performs module search in default directories
  21. * or in $MODPATH.
  22. */
  23. IF_FEATURE_2_4_MODULES(
  24. getopt32(argv, INSMOD_OPTS INSMOD_ARGS);
  25. argv += optind - 1;
  26. );
  27. filename = *++argv;
  28. if (!filename)
  29. bb_show_usage();
  30. rc = bb_init_module(filename, parse_cmdline_module_options(argv));
  31. if (rc)
  32. bb_error_msg("can't insert '%s': %s", filename, moderror(rc));
  33. return rc;
  34. }