syscalls_32.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
  3. * Licensed under the GPL
  4. */
  5. #include "linux/sched.h"
  6. #include "linux/shm.h"
  7. #include "linux/ipc.h"
  8. #include "linux/syscalls.h"
  9. #include "asm/mman.h"
  10. #include "asm/uaccess.h"
  11. #include "asm/unistd.h"
  12. /*
  13. * The prototype on i386 is:
  14. *
  15. * int clone(int flags, void * child_stack, int * parent_tidptr, struct user_desc * newtls, int * child_tidptr)
  16. *
  17. * and the "newtls" arg. on i386 is read by copy_thread directly from the
  18. * register saved on the stack.
  19. */
  20. long sys_clone(unsigned long clone_flags, unsigned long newsp,
  21. int __user *parent_tid, void *newtls, int __user *child_tid)
  22. {
  23. long ret;
  24. if (!newsp)
  25. newsp = UPT_SP(&current->thread.regs.regs);
  26. current->thread.forking = 1;
  27. ret = do_fork(clone_flags, newsp, &current->thread.regs, 0, parent_tid,
  28. child_tid);
  29. current->thread.forking = 0;
  30. return ret;
  31. }
  32. long sys_sigaction(int sig, const struct old_sigaction __user *act,
  33. struct old_sigaction __user *oact)
  34. {
  35. struct k_sigaction new_ka, old_ka;
  36. int ret;
  37. if (act) {
  38. old_sigset_t mask;
  39. if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
  40. __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
  41. __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
  42. return -EFAULT;
  43. __get_user(new_ka.sa.sa_flags, &act->sa_flags);
  44. __get_user(mask, &act->sa_mask);
  45. siginitset(&new_ka.sa.sa_mask, mask);
  46. }
  47. ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
  48. if (!ret && oact) {
  49. if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
  50. __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
  51. __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
  52. return -EFAULT;
  53. __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
  54. __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
  55. }
  56. return ret;
  57. }