insmod.c 638 B

1234567891011121314151617181920212223242526
  1. /* vim: tabstop=4 shiftwidth=4 noexpandtab
  2. * This file is part of ToaruOS and is released under the terms
  3. * of the NCSA / University of Illinois License - see LICENSE.md
  4. * Copyright (C) 2016 K. Lange
  5. *
  6. * insmod - Load kernel module
  7. *
  8. */
  9. #include <stdio.h>
  10. #include <syscall.h>
  11. int main(int argc, char * argv[]) {
  12. if (argc < 2) {
  13. fprintf(stderr, "Usage: %s <modulepath>\n", argv[0]);
  14. return 1;
  15. }
  16. int ret = 0;
  17. for (int i = 1; i < argc; ++i) {
  18. int status = syscall_system_function(8, &argv[i]);
  19. if (status) {
  20. fprintf(stderr, "%s: %s: kernel returned %d\n", argv[0], argv[i], status);
  21. ret = 1;
  22. }
  23. }
  24. return ret;
  25. }