syscall_kern.c 1.2 KB

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