syscall.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  3. * Licensed under the GPL
  4. */
  5. #include "linux/file.h"
  6. #include "linux/fs.h"
  7. #include "linux/mm.h"
  8. #include "linux/sched.h"
  9. #include "linux/utsname.h"
  10. #include "linux/syscalls.h"
  11. #include "asm/current.h"
  12. #include "asm/mman.h"
  13. #include "asm/uaccess.h"
  14. #include "asm/unistd.h"
  15. #include "internal.h"
  16. long sys_fork(void)
  17. {
  18. long ret;
  19. current->thread.forking = 1;
  20. ret = do_fork(SIGCHLD, UPT_SP(&current->thread.regs.regs),
  21. &current->thread.regs, 0, NULL, NULL);
  22. current->thread.forking = 0;
  23. return ret;
  24. }
  25. long sys_vfork(void)
  26. {
  27. long ret;
  28. current->thread.forking = 1;
  29. ret = do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD,
  30. UPT_SP(&current->thread.regs.regs),
  31. &current->thread.regs, 0, NULL, NULL);
  32. current->thread.forking = 0;
  33. return ret;
  34. }
  35. long old_mmap(unsigned long addr, unsigned long len,
  36. unsigned long prot, unsigned long flags,
  37. unsigned long fd, unsigned long offset)
  38. {
  39. long err = -EINVAL;
  40. if (offset & ~PAGE_MASK)
  41. goto out;
  42. err = sys_mmap_pgoff(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
  43. out:
  44. return err;
  45. }
  46. int kernel_execve(const char *filename,
  47. const char *const argv[],
  48. const char *const envp[])
  49. {
  50. mm_segment_t fs;
  51. int ret;
  52. fs = get_fs();
  53. set_fs(KERNEL_DS);
  54. ret = um_execve(filename, (const char __user *const __user *)argv,
  55. (const char __user *const __user *) envp);
  56. set_fs(fs);
  57. return ret;
  58. }