2 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL
6 #include "linux/file.h"
9 #include "linux/sched.h"
10 #include "linux/utsname.h"
11 #include "asm/current.h"
13 #include "asm/uaccess.h"
14 #include "asm/unistd.h"
16 /* Unlocked, I don't care if this is a bit off */
23 current
->thread
.forking
= 1;
24 ret
= do_fork(SIGCHLD
, UPT_SP(¤t
->thread
.regs
.regs
),
25 ¤t
->thread
.regs
, 0, NULL
, NULL
);
26 current
->thread
.forking
= 0;
34 current
->thread
.forking
= 1;
35 ret
= do_fork(CLONE_VFORK
| CLONE_VM
| SIGCHLD
,
36 UPT_SP(¤t
->thread
.regs
.regs
),
37 ¤t
->thread
.regs
, 0, NULL
, NULL
);
38 current
->thread
.forking
= 0;
42 /* common code for old and new mmaps */
43 long sys_mmap2(unsigned long addr
, unsigned long len
,
44 unsigned long prot
, unsigned long flags
,
45 unsigned long fd
, unsigned long pgoff
)
48 struct file
* file
= NULL
;
50 flags
&= ~(MAP_EXECUTABLE
| MAP_DENYWRITE
);
51 if (!(flags
& MAP_ANONYMOUS
)) {
57 down_write(¤t
->mm
->mmap_sem
);
58 error
= do_mmap_pgoff(file
, addr
, len
, prot
, flags
, pgoff
);
59 up_write(¤t
->mm
->mmap_sem
);
67 long old_mmap(unsigned long addr
, unsigned long len
,
68 unsigned long prot
, unsigned long flags
,
69 unsigned long fd
, unsigned long offset
)
72 if (offset
& ~PAGE_MASK
)
75 err
= sys_mmap2(addr
, len
, prot
, flags
, fd
, offset
>> PAGE_SHIFT
);
80 * sys_pipe() is the normal C calling standard for creating
81 * a pipe. It's not the way unix traditionally does this, though.
83 long sys_pipe(unsigned long __user
* fildes
)
90 if (copy_to_user(fildes
, fd
, sizeof(fd
)))
97 long sys_uname(struct old_utsname __user
* name
)
103 err
= copy_to_user(name
, utsname(), sizeof (*name
));
105 return err
?-EFAULT
:0;
108 long sys_olduname(struct oldold_utsname __user
* name
)
114 if (!access_ok(VERIFY_WRITE
,name
,sizeof(struct oldold_utsname
)))
119 error
= __copy_to_user(&name
->sysname
, &utsname()->sysname
,
121 error
|= __put_user(0, name
->sysname
+ __OLD_UTS_LEN
);
122 error
|= __copy_to_user(&name
->nodename
, &utsname()->nodename
,
124 error
|= __put_user(0, name
->nodename
+ __OLD_UTS_LEN
);
125 error
|= __copy_to_user(&name
->release
, &utsname()->release
,
127 error
|= __put_user(0, name
->release
+ __OLD_UTS_LEN
);
128 error
|= __copy_to_user(&name
->version
, &utsname()->version
,
130 error
|= __put_user(0, name
->version
+ __OLD_UTS_LEN
);
131 error
|= __copy_to_user(&name
->machine
, &utsname()->machine
,
133 error
|= __put_user(0, name
->machine
+ __OLD_UTS_LEN
);
137 error
= error
? -EFAULT
: 0;
142 int kernel_execve(const char *filename
, char *const argv
[], char *const envp
[])
149 ret
= um_execve(filename
, argv
, envp
);