3
0

insmod.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 source tree.
  8. */
  9. //applet:IF_INSMOD(APPLET(insmod, _BB_DIR_SBIN, _BB_SUID_DROP))
  10. #include "libbb.h"
  11. #include "modutils.h"
  12. /* 2.6 style insmod has no options and required filename
  13. * (not module name - .ko can't be omitted) */
  14. //usage:#if !ENABLE_MODPROBE_SMALL
  15. //usage:#define insmod_trivial_usage
  16. //usage: IF_FEATURE_2_4_MODULES("[OPTIONS] MODULE ")
  17. //usage: IF_NOT_FEATURE_2_4_MODULES("FILE ")
  18. //usage: "[SYMBOL=VALUE]..."
  19. //usage:#define insmod_full_usage "\n\n"
  20. //usage: "Load the specified kernel modules into the kernel"
  21. //usage: IF_FEATURE_2_4_MODULES( "\n"
  22. //usage: "\nOptions:"
  23. //usage: "\n -f Force module to load into the wrong kernel version"
  24. //usage: "\n -k Make module autoclean-able"
  25. //usage: "\n -v Verbose"
  26. //usage: "\n -q Quiet"
  27. //usage: "\n -L Lock: prevent simultaneous loads"
  28. //usage: IF_FEATURE_INSMOD_LOAD_MAP(
  29. //usage: "\n -m Output load map to stdout"
  30. //usage: )
  31. //usage: "\n -x Don't export externs"
  32. //usage: )
  33. //usage:#endif
  34. int insmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  35. int insmod_main(int argc UNUSED_PARAM, char **argv)
  36. {
  37. char *filename;
  38. int rc;
  39. /* Compat note:
  40. * 2.6 style insmod has no options and required filename
  41. * (not module name - .ko can't be omitted).
  42. * 2.4 style insmod can take module name without .o
  43. * and performs module search in default directories
  44. * or in $MODPATH.
  45. */
  46. IF_FEATURE_2_4_MODULES(
  47. getopt32(argv, INSMOD_OPTS INSMOD_ARGS);
  48. argv += optind - 1;
  49. );
  50. filename = *++argv;
  51. if (!filename)
  52. bb_show_usage();
  53. rc = bb_init_module(filename, parse_cmdline_module_options(argv));
  54. if (rc)
  55. bb_error_msg("can't insert '%s': %s", filename, moderror(rc));
  56. return rc;
  57. }