blob: f958cb876ee3d3e47ddff71094e8026c0a110f5d [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
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}