syscall_kern.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #ifdef CONFIG_SYSCALL_DEBUG
  23. int index;
  24. index = record_syscall_start(syscall);
  25. #endif
  26. sc = UPT_SC(&regs->regs);
  27. SC_START_SYSCALL(sc);
  28. syscall_trace(&regs->regs, 0);
  29. current->thread.nsyscalls++;
  30. nsyscalls++;
  31. syscall = UPT_SYSCALL_NR(&regs->regs);
  32. if((syscall >= NR_syscalls) || (syscall < 0))
  33. result = -ENOSYS;
  34. else result = EXECUTE_SYSCALL(syscall, regs);
  35. /* regs->sc may have changed while the system call ran (there may
  36. * have been an interrupt or segfault), so it needs to be refreshed.
  37. */
  38. UPT_SC(&regs->regs) = sc;
  39. SC_SET_SYSCALL_RETURN(sc, result);
  40. syscall_trace(&regs->regs, 1);
  41. #ifdef CONFIG_SYSCALL_DEBUG
  42. record_syscall_end(index, result);
  43. #endif
  44. }