myrmmod.c 595 B

12345678910111213141516171819202122232425
  1. /* https://github.com/cirosantilli/linux-kernel-module-cheat#myinsmod */
  2. #define _GNU_SOURCE
  3. #include <fcntl.h>
  4. #include <stdio.h>
  5. #include <sys/stat.h>
  6. #include <sys/syscall.h>
  7. #include <sys/types.h>
  8. #include <unistd.h>
  9. #include <stdlib.h>
  10. #define delete_module(name, flags) syscall(__NR_delete_module, name, flags)
  11. int main(int argc, char **argv) {
  12. if (argc != 2) {
  13. puts("Usage ./prog mymodule");
  14. return EXIT_FAILURE;
  15. }
  16. if (delete_module(argv[1], O_NONBLOCK) != 0) {
  17. perror("delete_module");
  18. return EXIT_FAILURE;
  19. }
  20. return EXIT_SUCCESS;
  21. }