test_module.c 794 B

12345678910111213141516171819202122232425262728293031323334
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * This module emits "Hello, world" on printk when loaded.
  4. *
  5. * It is designed to be used for basic evaluation of the module loading
  6. * subsystem (for example when validating module signing/verification). It
  7. * lacks any extra dependencies, and will not normally be loaded by the
  8. * system unless explicitly requested by name.
  9. */
  10. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  11. #include <linux/init.h>
  12. #include <linux/module.h>
  13. #include <linux/printk.h>
  14. static int __init test_module_init(void)
  15. {
  16. pr_warn("Hello, world\n");
  17. return 0;
  18. }
  19. module_init(test_module_init);
  20. static void __exit test_module_exit(void)
  21. {
  22. pr_warn("Goodbye\n");
  23. }
  24. module_exit(test_module_exit);
  25. MODULE_AUTHOR("Kees Cook <keescook@chromium.org>");
  26. MODULE_LICENSE("GPL");