syscall.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. return do_fork(SIGCHLD, UPT_SP(&current->thread.regs.regs),
  19. &current->thread.regs, 0, NULL, NULL);
  20. }
  21. long sys_vfork(void)
  22. {
  23. return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD,
  24. UPT_SP(&current->thread.regs.regs),
  25. &current->thread.regs, 0, NULL, NULL);
  26. }
  27. long sys_clone(unsigned long clone_flags, unsigned long newsp,
  28. void __user *parent_tid, void __user *child_tid)
  29. {
  30. if (!newsp)
  31. newsp = UPT_SP(&current->thread.regs.regs);
  32. return do_fork(clone_flags, newsp, &current->thread.regs, 0, parent_tid,
  33. child_tid);
  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. }