vermagic.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* https://cirosantilli.com/linux-kernel-module-cheat#vermagic */
  2. #include <linux/module.h>
  3. #include <linux/kernel.h>
  4. #include <linux/utsname.h>
  5. #if 0
  6. #include <linux/vermagic.h> /* VERMAGIC_STRING */
  7. #endif
  8. static int myinit(void)
  9. {
  10. struct new_utsname *uts = init_utsname();
  11. pr_info(
  12. "sysname = %s\n"
  13. "nodename = %s\n"
  14. "release = %s\n"
  15. "version = %s\n"
  16. "machine = %s\n"
  17. "domainname = %s\n",
  18. uts->sysname,
  19. uts->nodename,
  20. uts->release,
  21. uts->version,
  22. uts->machine,
  23. uts->domainname
  24. );
  25. #if 0
  26. /* Possible before v5.8, but was buggy apparently, not sure why:
  27. * https://github.com/cirosantilli/linux/commit/51161bfc66a68d21f13d15a689b3ea7980457790 */
  28. pr_info("VERMAGIC_STRING = " VERMAGIC_STRING "\n");
  29. #endif
  30. /* Nice try, but it is not a member. */
  31. /*pr_info("THIS_MODULE->vermagic = %s\n", THIS_MODULE->vermagic);*/
  32. return 0;
  33. }
  34. static void myexit(void) {}
  35. module_init(myinit)
  36. module_exit(myexit)
  37. MODULE_LICENSE("GPL");