syscall_kern.c 1015 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
  3. * Licensed under the GPL
  4. */
  5. #include "linux/types.h"
  6. #include "linux/utime.h"
  7. #include "linux/sys.h"
  8. #include "linux/ptrace.h"
  9. #include "asm/unistd.h"
  10. #include "asm/ptrace.h"
  11. #include "asm/uaccess.h"
  12. #include "asm/stat.h"
  13. #include "sysdep/syscalls.h"
  14. #include "sysdep/sigcontext.h"
  15. #include "kern_util.h"
  16. #include "syscall.h"
  17. void syscall_handler_tt(int sig, struct pt_regs *regs)
  18. {
  19. void *sc;
  20. long result;
  21. int syscall;
  22. sc = UPT_SC(&regs->regs);
  23. SC_START_SYSCALL(sc);
  24. syscall = UPT_SYSCALL_NR(&regs->regs);
  25. syscall_trace(&regs->regs, 0);
  26. current->thread.nsyscalls++;
  27. nsyscalls++;
  28. if((syscall >= NR_syscalls) || (syscall < 0))
  29. result = -ENOSYS;
  30. else result = EXECUTE_SYSCALL(syscall, regs);
  31. /* regs->sc may have changed while the system call ran (there may
  32. * have been an interrupt or segfault), so it needs to be refreshed.
  33. */
  34. UPT_SC(&regs->regs) = sc;
  35. SC_SET_SYSCALL_RETURN(sc, result);
  36. syscall_trace(&regs->regs, 1);
  37. }