3
0

insmod.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 kernel module"
  21. //usage: IF_FEATURE_2_4_MODULES( "\n"
  22. //usage: "\n -f Force module to load into the wrong kernel version"
  23. //usage: "\n -k Make module autoclean-able"
  24. //usage: "\n -v Verbose"
  25. //usage: "\n -q Quiet"
  26. //usage: "\n -L Lock: prevent simultaneous loads"
  27. //usage: IF_FEATURE_INSMOD_LOAD_MAP(
  28. //usage: "\n -m Output load map to stdout"
  29. //usage: )
  30. //usage: "\n -x Don't export externs"
  31. //usage: )
  32. //usage:#endif
  33. int insmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  34. int insmod_main(int argc UNUSED_PARAM, char **argv)
  35. {
  36. char *filename;
  37. int rc;
  38. /* Compat note:
  39. * 2.6 style insmod has no options and required filename
  40. * (not module name - .ko can't be omitted).
  41. * 2.4 style insmod can take module name without .o
  42. * and performs module search in default directories
  43. * or in $MODPATH.
  44. */
  45. IF_FEATURE_2_4_MODULES(
  46. getopt32(argv, INSMOD_OPTS INSMOD_ARGS);
  47. argv += optind - 1;
  48. );
  49. filename = *++argv;
  50. if (!filename)
  51. bb_show_usage();
  52. rc = bb_init_module(filename, parse_cmdline_module_options(argv, /*quote_spaces:*/ 0));
  53. if (rc)
  54. bb_error_msg("can't insert '%s': %s", filename, moderror(rc));
  55. return rc;
  56. }