blob: a4c6d8eee74c702999cc26955e250f40db30f553 [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{
Al Virod2ce4e92012-09-20 09:28:25 -040020 return do_fork(SIGCHLD, UPT_SP(&current->thread.regs.regs),
Jeff Dikee0877f02005-06-25 14:55:21 -070021 &current->thread.regs, 0, NULL, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070022}
23
24long sys_vfork(void)
25{
Al Virod2ce4e92012-09-20 09:28:25 -040026 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD,
Jeff Dikee0877f02005-06-25 14:55:21 -070027 UPT_SP(&current->thread.regs.regs),
28 &current->thread.regs, 0, NULL, NULL);
Al Virod2ce4e92012-09-20 09:28:25 -040029}
30
31long sys_clone(unsigned long clone_flags, unsigned long newsp,
32 void __user *parent_tid, void __user *child_tid)
33{
34 if (!newsp)
35 newsp = UPT_SP(&current->thread.regs.regs);
36
37 return do_fork(clone_flags, newsp, &current->thread.regs, 0, parent_tid,
38 child_tid);
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
David Howellsd7627462010-08-17 23:52:56 +010054int kernel_execve(const char *filename,
55 const char *const argv[],
56 const char *const envp[])
Arnd Bergmann3db03b42006-10-02 02:18:31 -070057{
58 mm_segment_t fs;
59 int ret;
60
61 fs = get_fs();
62 set_fs(KERNEL_DS);
Richard Weinbergercb1dcc02010-09-22 13:05:07 -070063 ret = um_execve(filename, (const char __user *const __user *)argv,
64 (const char __user *const __user *) envp);
Arnd Bergmann3db03b42006-10-02 02:18:31 -070065 set_fs(fs);
66
67 return ret;
68}