2 * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
6 #include "linux/sched.h"
7 #include "linux/file.h"
8 #include "linux/smp_lock.h"
10 #include "linux/utsname.h"
11 #include "linux/msg.h"
12 #include "linux/shm.h"
13 #include "linux/sys.h"
14 #include "linux/syscalls.h"
15 #include "linux/unistd.h"
16 #include "linux/slab.h"
17 #include "linux/utime.h"
19 #include "asm/uaccess.h"
20 #include "kern_util.h"
21 #include "sysdep/syscalls.h"
22 #include "mode_kern.h"
23 #include "choose-mode.h"
25 /* Unlocked, I don't care if this is a bit off */
32 current
->thread
.forking
= 1;
33 ret
= do_fork(SIGCHLD
, UPT_SP(¤t
->thread
.regs
.regs
),
34 ¤t
->thread
.regs
, 0, NULL
, NULL
);
35 current
->thread
.forking
= 0;
43 current
->thread
.forking
= 1;
44 ret
= do_fork(CLONE_VFORK
| CLONE_VM
| SIGCHLD
,
45 UPT_SP(¤t
->thread
.regs
.regs
),
46 ¤t
->thread
.regs
, 0, NULL
, NULL
);
47 current
->thread
.forking
= 0;
51 /* common code for old and new mmaps */
52 long sys_mmap2(unsigned long addr
, unsigned long len
,
53 unsigned long prot
, unsigned long flags
,
54 unsigned long fd
, unsigned long pgoff
)
57 struct file
* file
= NULL
;
59 flags
&= ~(MAP_EXECUTABLE
| MAP_DENYWRITE
);
60 if (!(flags
& MAP_ANONYMOUS
)) {
66 down_write(¤t
->mm
->mmap_sem
);
67 error
= do_mmap_pgoff(file
, addr
, len
, prot
, flags
, pgoff
);
68 up_write(¤t
->mm
->mmap_sem
);
76 long old_mmap(unsigned long addr
, unsigned long len
,
77 unsigned long prot
, unsigned long flags
,
78 unsigned long fd
, unsigned long offset
)
81 if (offset
& ~PAGE_MASK
)
84 err
= sys_mmap2(addr
, len
, prot
, flags
, fd
, offset
>> PAGE_SHIFT
);
89 * sys_pipe() is the normal C calling standard for creating
90 * a pipe. It's not the way unix traditionally does this, though.
92 long sys_pipe(unsigned long __user
* fildes
)
99 if (copy_to_user(fildes
, fd
, sizeof(fd
)))
106 long sys_uname(struct old_utsname __user
* name
)
112 err
= copy_to_user(name
, utsname(), sizeof (*name
));
114 return err
?-EFAULT
:0;
117 long sys_olduname(struct oldold_utsname __user
* name
)
123 if (!access_ok(VERIFY_WRITE
,name
,sizeof(struct oldold_utsname
)))
128 error
= __copy_to_user(&name
->sysname
, &utsname()->sysname
,
130 error
|= __put_user(0, name
->sysname
+ __OLD_UTS_LEN
);
131 error
|= __copy_to_user(&name
->nodename
, &utsname()->nodename
,
133 error
|= __put_user(0, name
->nodename
+ __OLD_UTS_LEN
);
134 error
|= __copy_to_user(&name
->release
, &utsname()->release
,
136 error
|= __put_user(0, name
->release
+ __OLD_UTS_LEN
);
137 error
|= __copy_to_user(&name
->version
, &utsname()->version
,
139 error
|= __put_user(0, name
->version
+ __OLD_UTS_LEN
);
140 error
|= __copy_to_user(&name
->machine
, &utsname()->machine
,
142 error
|= __put_user(0, name
->machine
+ __OLD_UTS_LEN
);
146 error
= error
? -EFAULT
: 0;
151 int kernel_execve(const char *filename
, char *const argv
[], char *const envp
[])
158 ret
= um_execve(filename
, argv
, envp
);