syscall.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
  3. * Licensed under the GPL
  4. */
  5. #include "linux/sys.h"
  6. #include "linux/ptrace.h"
  7. #include "asm/errno.h"
  8. #include "asm/unistd.h"
  9. #include "asm/ptrace.h"
  10. #include "asm/current.h"
  11. #include "sysdep/syscalls.h"
  12. #include "kern_util.h"
  13. #include "syscall.h"
  14. void handle_syscall(union uml_pt_regs *r)
  15. {
  16. struct pt_regs *regs = container_of(r, struct pt_regs, regs);
  17. long result;
  18. int syscall;
  19. syscall_trace(r, 0);
  20. current->thread.nsyscalls++;
  21. nsyscalls++;
  22. /* This should go in the declaration of syscall, but when I do that,
  23. * strace -f -c bash -c 'ls ; ls' breaks, sometimes not tracing
  24. * children at all, sometimes hanging when bash doesn't see the first
  25. * ls exit.
  26. * The assembly looks functionally the same to me. This is
  27. * gcc version 4.0.1 20050727 (Red Hat 4.0.1-5)
  28. * in case it's a compiler bug.
  29. */
  30. syscall = UPT_SYSCALL_NR(r);
  31. if((syscall >= NR_syscalls) || (syscall < 0))
  32. result = -ENOSYS;
  33. else result = EXECUTE_SYSCALL(syscall, regs);
  34. REGS_SET_SYSCALL_RETURN(r->skas.regs, result);
  35. syscall_trace(r, 1);
  36. }