blob: 4393173923f5f408019456a3428d9d7d1c1f75e5 [file] [log] [blame]
Jeff Dike1d3468a2006-07-10 04:45:13 -07001/*
Jeff Dikeba180fd2007-10-16 01:27:00 -07002 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * Licensed under the GPL
4 */
5
Linus Torvalds1da177e2005-04-16 15:20:36 -07006#include "linux/file.h"
Alexey Dobriyan4e950f62007-07-30 02:36:13 +04007#include "linux/fs.h"
Jeff Dikeba180fd2007-10-16 01:27:00 -07008#include "linux/mm.h"
9#include "linux/sched.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include "linux/utsname.h"
Al Virof8b72562009-11-30 17:37:04 -050011#include "linux/syscalls.h"
Jeff Dikeba180fd2007-10-16 01:27:00 -070012#include "asm/current.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include "asm/mman.h"
14#include "asm/uaccess.h"
Jeff Dikeba180fd2007-10-16 01:27:00 -070015#include "asm/unistd.h"
Al Viroff64b4c2008-08-18 04:01:47 -040016#include "internal.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Linus Torvalds1da177e2005-04-16 15:20:36 -070018long sys_fork(void)
19{
20 long ret;
21
22 current->thread.forking = 1;
Jeff Dikee0877f02005-06-25 14:55:21 -070023 ret = do_fork(SIGCHLD, UPT_SP(&current->thread.regs.regs),
24 &current->thread.regs, 0, NULL, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 current->thread.forking = 0;
Jeff Dikeba180fd2007-10-16 01:27:00 -070026 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -070027}
28
29long sys_vfork(void)
30{
31 long ret;
32
33 current->thread.forking = 1;
Jeff Dikee0877f02005-06-25 14:55:21 -070034 ret = do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD,
35 UPT_SP(&current->thread.regs.regs),
36 &current->thread.regs, 0, NULL, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 current->thread.forking = 0;
Jeff Dikeba180fd2007-10-16 01:27:00 -070038 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -070039}
40
Linus Torvalds1da177e2005-04-16 15:20:36 -070041long old_mmap(unsigned long addr, unsigned long len,
42 unsigned long prot, unsigned long flags,
43 unsigned long fd, unsigned long offset)
44{
45 long err = -EINVAL;
46 if (offset & ~PAGE_MASK)
47 goto out;
48
Al Virof8b72562009-11-30 17:37:04 -050049 err = sys_mmap_pgoff(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 out:
51 return err;
52}
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
Arnd Bergmann3db03b42006-10-02 02:18:31 -070054int kernel_execve(const char *filename, char *const argv[], char *const envp[])
55{
56 mm_segment_t fs;
57 int ret;
58
59 fs = get_fs();
60 set_fs(KERNEL_DS);
Miklos Szeredie4c2ff12009-04-02 16:56:53 -070061 ret = um_execve((char *)filename, (char __user *__user *)argv,
62 (char __user *__user *) envp);
Arnd Bergmann3db03b42006-10-02 02:18:31 -070063 set_fs(fs);
64
65 return ret;
66}