insmod.c 662 B

123456789101112131415161718192021222324252627
  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 <errno.h>
  11. #include <sys/sysfunc.h>
  12. int main(int argc, char * argv[]) {
  13. if (argc < 2) {
  14. fprintf(stderr, "Usage: %s <modulepath>\n", argv[0]);
  15. return 1;
  16. }
  17. int ret = 0;
  18. for (int i = 1; i < argc; ++i) {
  19. int status = sysfunc(TOARU_SYS_FUNC_INSMOD, &argv[i]);
  20. if (status < 0) {
  21. fprintf(stderr, "%s: %s: %s\n", argv[0], argv[i], strerror(errno));
  22. ret = 1;
  23. }
  24. }
  25. return ret;
  26. }