diff options
author | Paul Mundt <lethal@linux-sh.org> | 2007-11-20 01:50:59 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2008-01-27 23:18:49 -0500 |
commit | bcb28e42be8c1cce6cc523c1b656980011464016 (patch) | |
tree | 3c951c59a88eac348a34fb2b714dd255166a2a47 /arch/sh | |
parent | e7e0a4b54a7f225f770d313f9e042f83ece57a35 (diff) |
sh: sys_sh consolidation for arch_get_unmapped_area().
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh')
-rw-r--r-- | arch/sh/kernel/Makefile_32 | 2 | ||||
-rw-r--r-- | arch/sh/kernel/Makefile_64 | 2 | ||||
-rw-r--r-- | arch/sh/kernel/sys_sh.c | 100 | ||||
-rw-r--r-- | arch/sh/kernel/sys_sh32.c | 84 | ||||
-rw-r--r-- | arch/sh/kernel/sys_sh64.c | 246 |
5 files changed, 108 insertions, 326 deletions
diff --git a/arch/sh/kernel/Makefile_32 b/arch/sh/kernel/Makefile_32 index 17216f5e7c93..34e8fa0d40cc 100644 --- a/arch/sh/kernel/Makefile_32 +++ b/arch/sh/kernel/Makefile_32 | |||
@@ -5,7 +5,7 @@ | |||
5 | extra-y := head_32.o init_task.o vmlinux.lds | 5 | extra-y := head_32.o init_task.o vmlinux.lds |
6 | 6 | ||
7 | obj-y := debugtraps.o io.o io_generic.o irq.o machvec.o process_32.o \ | 7 | obj-y := debugtraps.o io.o io_generic.o irq.o machvec.o process_32.o \ |
8 | ptrace_32.o semaphore.o setup.o signal_32.o sys_sh.o \ | 8 | ptrace_32.o semaphore.o setup.o signal_32.o sys_sh.o sys_sh32.o \ |
9 | syscalls_32.o time.o topology.o traps_32.o | 9 | syscalls_32.o time.o topology.o traps_32.o |
10 | 10 | ||
11 | obj-y += cpu/ timers/ | 11 | obj-y += cpu/ timers/ |
diff --git a/arch/sh/kernel/Makefile_64 b/arch/sh/kernel/Makefile_64 index 1211e864ef12..aeac4006df7b 100644 --- a/arch/sh/kernel/Makefile_64 +++ b/arch/sh/kernel/Makefile_64 | |||
@@ -1,7 +1,7 @@ | |||
1 | extra-y := head_64.o init_task.o vmlinux.lds | 1 | extra-y := head_64.o init_task.o vmlinux.lds |
2 | 2 | ||
3 | obj-y := debugtraps.o io.o io_generic.o irq.o machvec.o process_64.o \ | 3 | obj-y := debugtraps.o io.o io_generic.o irq.o machvec.o process_64.o \ |
4 | ptrace_64.o semaphore.o setup.o signal_64.o sys_sh64.o \ | 4 | ptrace_64.o semaphore.o setup.o signal_64.o sys_sh.o sys_sh64.o \ |
5 | syscalls_64.o time.o topology.o traps_64.o | 5 | syscalls_64.o time.o topology.o traps_64.o |
6 | 6 | ||
7 | obj-y += cpu/ timers/ | 7 | obj-y += cpu/ timers/ |
diff --git a/arch/sh/kernel/sys_sh.c b/arch/sh/kernel/sys_sh.c index d545a686a201..59cd2859ce9b 100644 --- a/arch/sh/kernel/sys_sh.c +++ b/arch/sh/kernel/sys_sh.c | |||
@@ -7,7 +7,6 @@ | |||
7 | * | 7 | * |
8 | * Taken from i386 version. | 8 | * Taken from i386 version. |
9 | */ | 9 | */ |
10 | |||
11 | #include <linux/errno.h> | 10 | #include <linux/errno.h> |
12 | #include <linux/sched.h> | 11 | #include <linux/sched.h> |
13 | #include <linux/mm.h> | 12 | #include <linux/mm.h> |
@@ -27,28 +26,7 @@ | |||
27 | #include <asm/uaccess.h> | 26 | #include <asm/uaccess.h> |
28 | #include <asm/unistd.h> | 27 | #include <asm/unistd.h> |
29 | 28 | ||
30 | /* | ||
31 | * sys_pipe() is the normal C calling standard for creating | ||
32 | * a pipe. It's not the way Unix traditionally does this, though. | ||
33 | */ | ||
34 | asmlinkage int sys_pipe(unsigned long r4, unsigned long r5, | ||
35 | unsigned long r6, unsigned long r7, | ||
36 | struct pt_regs __regs) | ||
37 | { | ||
38 | struct pt_regs *regs = RELOC_HIDE(&__regs, 0); | ||
39 | int fd[2]; | ||
40 | int error; | ||
41 | |||
42 | error = do_pipe(fd); | ||
43 | if (!error) { | ||
44 | regs->regs[1] = fd[1]; | ||
45 | return fd[0]; | ||
46 | } | ||
47 | return error; | ||
48 | } | ||
49 | |||
50 | unsigned long shm_align_mask = PAGE_SIZE - 1; /* Sane caches */ | 29 | unsigned long shm_align_mask = PAGE_SIZE - 1; /* Sane caches */ |
51 | |||
52 | EXPORT_SYMBOL(shm_align_mask); | 30 | EXPORT_SYMBOL(shm_align_mask); |
53 | 31 | ||
54 | #ifdef CONFIG_MMU | 32 | #ifdef CONFIG_MMU |
@@ -140,7 +118,7 @@ full_search: | |||
140 | #endif /* CONFIG_MMU */ | 118 | #endif /* CONFIG_MMU */ |
141 | 119 | ||
142 | static inline long | 120 | static inline long |
143 | do_mmap2(unsigned long addr, unsigned long len, unsigned long prot, | 121 | do_mmap2(unsigned long addr, unsigned long len, unsigned long prot, |
144 | unsigned long flags, int fd, unsigned long pgoff) | 122 | unsigned long flags, int fd, unsigned long pgoff) |
145 | { | 123 | { |
146 | int error = -EBADF; | 124 | int error = -EBADF; |
@@ -195,12 +173,13 @@ asmlinkage int sys_ipc(uint call, int first, int second, | |||
195 | if (call <= SEMCTL) | 173 | if (call <= SEMCTL) |
196 | switch (call) { | 174 | switch (call) { |
197 | case SEMOP: | 175 | case SEMOP: |
198 | return sys_semtimedop(first, (struct sembuf __user *)ptr, | 176 | return sys_semtimedop(first, |
177 | (struct sembuf __user *)ptr, | ||
199 | second, NULL); | 178 | second, NULL); |
200 | case SEMTIMEDOP: | 179 | case SEMTIMEDOP: |
201 | return sys_semtimedop(first, (struct sembuf __user *)ptr, | 180 | return sys_semtimedop(first, |
202 | second, | 181 | (struct sembuf __user *)ptr, second, |
203 | (const struct timespec __user *)fifth); | 182 | (const struct timespec __user *)fifth); |
204 | case SEMGET: | 183 | case SEMGET: |
205 | return sys_semget (first, second, third); | 184 | return sys_semget (first, second, third); |
206 | case SEMCTL: { | 185 | case SEMCTL: { |
@@ -215,25 +194,28 @@ asmlinkage int sys_ipc(uint call, int first, int second, | |||
215 | return -EINVAL; | 194 | return -EINVAL; |
216 | } | 195 | } |
217 | 196 | ||
218 | if (call <= MSGCTL) | 197 | if (call <= MSGCTL) |
219 | switch (call) { | 198 | switch (call) { |
220 | case MSGSND: | 199 | case MSGSND: |
221 | return sys_msgsnd (first, (struct msgbuf __user *) ptr, | 200 | return sys_msgsnd (first, (struct msgbuf __user *) ptr, |
222 | second, third); | 201 | second, third); |
223 | case MSGRCV: | 202 | case MSGRCV: |
224 | switch (version) { | 203 | switch (version) { |
225 | case 0: { | 204 | case 0: |
205 | { | ||
226 | struct ipc_kludge tmp; | 206 | struct ipc_kludge tmp; |
207 | |||
227 | if (!ptr) | 208 | if (!ptr) |
228 | return -EINVAL; | 209 | return -EINVAL; |
229 | 210 | ||
230 | if (copy_from_user(&tmp, | 211 | if (copy_from_user(&tmp, |
231 | (struct ipc_kludge __user *) ptr, | 212 | (struct ipc_kludge __user *) ptr, |
232 | sizeof (tmp))) | 213 | sizeof (tmp))) |
233 | return -EFAULT; | 214 | return -EFAULT; |
215 | |||
234 | return sys_msgrcv (first, tmp.msgp, second, | 216 | return sys_msgrcv (first, tmp.msgp, second, |
235 | tmp.msgtyp, third); | 217 | tmp.msgtyp, third); |
236 | } | 218 | } |
237 | default: | 219 | default: |
238 | return sys_msgrcv (first, | 220 | return sys_msgrcv (first, |
239 | (struct msgbuf __user *) ptr, | 221 | (struct msgbuf __user *) ptr, |
@@ -247,7 +229,7 @@ asmlinkage int sys_ipc(uint call, int first, int second, | |||
247 | default: | 229 | default: |
248 | return -EINVAL; | 230 | return -EINVAL; |
249 | } | 231 | } |
250 | if (call <= SHMCTL) | 232 | if (call <= SHMCTL) |
251 | switch (call) { | 233 | switch (call) { |
252 | case SHMAT: | 234 | case SHMAT: |
253 | switch (version) { | 235 | switch (version) { |
@@ -265,7 +247,7 @@ asmlinkage int sys_ipc(uint call, int first, int second, | |||
265 | return do_shmat (first, (char __user *) ptr, | 247 | return do_shmat (first, (char __user *) ptr, |
266 | second, (ulong *) third); | 248 | second, (ulong *) third); |
267 | } | 249 | } |
268 | case SHMDT: | 250 | case SHMDT: |
269 | return sys_shmdt ((char __user *)ptr); | 251 | return sys_shmdt ((char __user *)ptr); |
270 | case SHMGET: | 252 | case SHMGET: |
271 | return sys_shmget (first, second, third); | 253 | return sys_shmget (first, second, third); |
@@ -275,7 +257,7 @@ asmlinkage int sys_ipc(uint call, int first, int second, | |||
275 | default: | 257 | default: |
276 | return -EINVAL; | 258 | return -EINVAL; |
277 | } | 259 | } |
278 | 260 | ||
279 | return -EINVAL; | 261 | return -EINVAL; |
280 | } | 262 | } |
281 | 263 | ||
@@ -289,49 +271,3 @@ asmlinkage int sys_uname(struct old_utsname * name) | |||
289 | up_read(&uts_sem); | 271 | up_read(&uts_sem); |
290 | return err?-EFAULT:0; | 272 | return err?-EFAULT:0; |
291 | } | 273 | } |
292 | |||
293 | asmlinkage ssize_t sys_pread_wrapper(unsigned int fd, char * buf, | ||
294 | size_t count, long dummy, loff_t pos) | ||
295 | { | ||
296 | return sys_pread64(fd, buf, count, pos); | ||
297 | } | ||
298 | |||
299 | asmlinkage ssize_t sys_pwrite_wrapper(unsigned int fd, const char * buf, | ||
300 | size_t count, long dummy, loff_t pos) | ||
301 | { | ||
302 | return sys_pwrite64(fd, buf, count, pos); | ||
303 | } | ||
304 | |||
305 | asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, u32 offset1, | ||
306 | u32 len0, u32 len1, int advice) | ||
307 | { | ||
308 | #ifdef __LITTLE_ENDIAN__ | ||
309 | return sys_fadvise64_64(fd, (u64)offset1 << 32 | offset0, | ||
310 | (u64)len1 << 32 | len0, advice); | ||
311 | #else | ||
312 | return sys_fadvise64_64(fd, (u64)offset0 << 32 | offset1, | ||
313 | (u64)len0 << 32 | len1, advice); | ||
314 | #endif | ||
315 | } | ||
316 | |||
317 | #if defined(CONFIG_CPU_SH2) || defined(CONFIG_CPU_SH2A) | ||
318 | #define SYSCALL_ARG3 "trapa #0x23" | ||
319 | #else | ||
320 | #define SYSCALL_ARG3 "trapa #0x13" | ||
321 | #endif | ||
322 | |||
323 | /* | ||
324 | * Do a system call from kernel instead of calling sys_execve so we | ||
325 | * end up with proper pt_regs. | ||
326 | */ | ||
327 | int kernel_execve(const char *filename, char *const argv[], char *const envp[]) | ||
328 | { | ||
329 | register long __sc0 __asm__ ("r3") = __NR_execve; | ||
330 | register long __sc4 __asm__ ("r4") = (long) filename; | ||
331 | register long __sc5 __asm__ ("r5") = (long) argv; | ||
332 | register long __sc6 __asm__ ("r6") = (long) envp; | ||
333 | __asm__ __volatile__ (SYSCALL_ARG3 : "=z" (__sc0) | ||
334 | : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6) | ||
335 | : "memory"); | ||
336 | return __sc0; | ||
337 | } | ||
diff --git a/arch/sh/kernel/sys_sh32.c b/arch/sh/kernel/sys_sh32.c new file mode 100644 index 000000000000..125e493ead82 --- /dev/null +++ b/arch/sh/kernel/sys_sh32.c | |||
@@ -0,0 +1,84 @@ | |||
1 | #include <linux/errno.h> | ||
2 | #include <linux/sched.h> | ||
3 | #include <linux/mm.h> | ||
4 | #include <linux/smp.h> | ||
5 | #include <linux/sem.h> | ||
6 | #include <linux/msg.h> | ||
7 | #include <linux/shm.h> | ||
8 | #include <linux/stat.h> | ||
9 | #include <linux/syscalls.h> | ||
10 | #include <linux/mman.h> | ||
11 | #include <linux/file.h> | ||
12 | #include <linux/utsname.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/fs.h> | ||
15 | #include <linux/ipc.h> | ||
16 | #include <asm/cacheflush.h> | ||
17 | #include <asm/uaccess.h> | ||
18 | #include <asm/unistd.h> | ||
19 | |||
20 | /* | ||
21 | * sys_pipe() is the normal C calling standard for creating | ||
22 | * a pipe. It's not the way Unix traditionally does this, though. | ||
23 | */ | ||
24 | asmlinkage int sys_pipe(unsigned long r4, unsigned long r5, | ||
25 | unsigned long r6, unsigned long r7, | ||
26 | struct pt_regs __regs) | ||
27 | { | ||
28 | struct pt_regs *regs = RELOC_HIDE(&__regs, 0); | ||
29 | int fd[2]; | ||
30 | int error; | ||
31 | |||
32 | error = do_pipe(fd); | ||
33 | if (!error) { | ||
34 | regs->regs[1] = fd[1]; | ||
35 | return fd[0]; | ||
36 | } | ||
37 | return error; | ||
38 | } | ||
39 | |||
40 | asmlinkage ssize_t sys_pread_wrapper(unsigned int fd, char * buf, | ||
41 | size_t count, long dummy, loff_t pos) | ||
42 | { | ||
43 | return sys_pread64(fd, buf, count, pos); | ||
44 | } | ||
45 | |||
46 | asmlinkage ssize_t sys_pwrite_wrapper(unsigned int fd, const char * buf, | ||
47 | size_t count, long dummy, loff_t pos) | ||
48 | { | ||
49 | return sys_pwrite64(fd, buf, count, pos); | ||
50 | } | ||
51 | |||
52 | asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, u32 offset1, | ||
53 | u32 len0, u32 len1, int advice) | ||
54 | { | ||
55 | #ifdef __LITTLE_ENDIAN__ | ||
56 | return sys_fadvise64_64(fd, (u64)offset1 << 32 | offset0, | ||
57 | (u64)len1 << 32 | len0, advice); | ||
58 | #else | ||
59 | return sys_fadvise64_64(fd, (u64)offset0 << 32 | offset1, | ||
60 | (u64)len0 << 32 | len1, advice); | ||
61 | #endif | ||
62 | } | ||
63 | |||
64 | #if defined(CONFIG_CPU_SH2) || defined(CONFIG_CPU_SH2A) | ||
65 | #define SYSCALL_ARG3 "trapa #0x23" | ||
66 | #else | ||
67 | #define SYSCALL_ARG3 "trapa #0x13" | ||
68 | #endif | ||
69 | |||
70 | /* | ||
71 | * Do a system call from kernel instead of calling sys_execve so we | ||
72 | * end up with proper pt_regs. | ||
73 | */ | ||
74 | int kernel_execve(const char *filename, char *const argv[], char *const envp[]) | ||
75 | { | ||
76 | register long __sc0 __asm__ ("r3") = __NR_execve; | ||
77 | register long __sc4 __asm__ ("r4") = (long) filename; | ||
78 | register long __sc5 __asm__ ("r5") = (long) argv; | ||
79 | register long __sc6 __asm__ ("r6") = (long) envp; | ||
80 | __asm__ __volatile__ (SYSCALL_ARG3 : "=z" (__sc0) | ||
81 | : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6) | ||
82 | : "memory"); | ||
83 | return __sc0; | ||
84 | } | ||
diff --git a/arch/sh/kernel/sys_sh64.c b/arch/sh/kernel/sys_sh64.c index de0a303ba26f..578004d71e02 100644 --- a/arch/sh/kernel/sys_sh64.c +++ b/arch/sh/kernel/sys_sh64.c | |||
@@ -1,9 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * This file is subject to the terms and conditions of the GNU General Public | 2 | * arch/sh/kernel/sys_sh64.c |
3 | * License. See the file "COPYING" in the main directory of this archive | ||
4 | * for more details. | ||
5 | * | ||
6 | * arch/sh64/kernel/sys_sh64.c | ||
7 | * | 3 | * |
8 | * Copyright (C) 2000, 2001 Paolo Alberelli | 4 | * Copyright (C) 2000, 2001 Paolo Alberelli |
9 | * | 5 | * |
@@ -11,10 +7,10 @@ | |||
11 | * have a non-standard calling sequence on the Linux/SH5 | 7 | * have a non-standard calling sequence on the Linux/SH5 |
12 | * platform. | 8 | * platform. |
13 | * | 9 | * |
14 | * Mostly taken from i386 version. | 10 | * This file is subject to the terms and conditions of the GNU General Public |
15 | * | 11 | * License. See the file "COPYING" in the main directory of this archive |
12 | * for more details. | ||
16 | */ | 13 | */ |
17 | |||
18 | #include <linux/errno.h> | 14 | #include <linux/errno.h> |
19 | #include <linux/rwsem.h> | 15 | #include <linux/rwsem.h> |
20 | #include <linux/sched.h> | 16 | #include <linux/sched.h> |
@@ -34,48 +30,10 @@ | |||
34 | #include <asm/ptrace.h> | 30 | #include <asm/ptrace.h> |
35 | #include <asm/unistd.h> | 31 | #include <asm/unistd.h> |
36 | 32 | ||
37 | #define REG_3 3 | ||
38 | |||
39 | /* | 33 | /* |
40 | * sys_pipe() is the normal C calling standard for creating | 34 | * sys_pipe() is the normal C calling standard for creating |
41 | * a pipe. It's not the way Unix traditionally does this, though. | 35 | * a pipe. It's not the way Unix traditionally does this, though. |
42 | */ | 36 | */ |
43 | #ifdef NEW_PIPE_IMPLEMENTATION | ||
44 | asmlinkage int sys_pipe(unsigned long * fildes, | ||
45 | unsigned long dummy_r3, | ||
46 | unsigned long dummy_r4, | ||
47 | unsigned long dummy_r5, | ||
48 | unsigned long dummy_r6, | ||
49 | unsigned long dummy_r7, | ||
50 | struct pt_regs * regs) /* r8 = pt_regs forced by entry.S */ | ||
51 | { | ||
52 | int fd[2]; | ||
53 | int ret; | ||
54 | |||
55 | ret = do_pipe(fd); | ||
56 | if (ret == 0) | ||
57 | /* | ||
58 | *********************************************************************** | ||
59 | * To avoid the copy_to_user we prefer to break the ABIs convention, * | ||
60 | * packing the valid pair of file IDs into a single register (r3); * | ||
61 | * while r2 is the return code as defined by the sh5-ABIs. * | ||
62 | * BE CAREFUL: pipe stub, into glibc, must be aware of this solution * | ||
63 | *********************************************************************** | ||
64 | |||
65 | #ifdef __LITTLE_ENDIAN__ | ||
66 | regs->regs[REG_3] = (((unsigned long long) fd[1]) << 32) | ((unsigned long long) fd[0]); | ||
67 | #else | ||
68 | regs->regs[REG_3] = (((unsigned long long) fd[0]) << 32) | ((unsigned long long) fd[1]); | ||
69 | #endif | ||
70 | |||
71 | */ | ||
72 | /* although not very clever this is endianess independent */ | ||
73 | regs->regs[REG_3] = (unsigned long long) *((unsigned long long *) fd); | ||
74 | |||
75 | return ret; | ||
76 | } | ||
77 | |||
78 | #else | ||
79 | asmlinkage int sys_pipe(unsigned long * fildes) | 37 | asmlinkage int sys_pipe(unsigned long * fildes) |
80 | { | 38 | { |
81 | int fd[2]; | 39 | int fd[2]; |
@@ -89,202 +47,6 @@ asmlinkage int sys_pipe(unsigned long * fildes) | |||
89 | return error; | 47 | return error; |
90 | } | 48 | } |
91 | 49 | ||
92 | #endif | ||
93 | |||
94 | /* | ||
95 | * To avoid cache alias, we map the shard page with same color. | ||
96 | */ | ||
97 | #define COLOUR_ALIGN(addr) (((addr)+SHMLBA-1)&~(SHMLBA-1)) | ||
98 | |||
99 | unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, | ||
100 | unsigned long len, unsigned long pgoff, unsigned long flags) | ||
101 | { | ||
102 | struct vm_area_struct *vma; | ||
103 | |||
104 | if (flags & MAP_FIXED) { | ||
105 | /* We do not accept a shared mapping if it would violate | ||
106 | * cache aliasing constraints. | ||
107 | */ | ||
108 | if ((flags & MAP_SHARED) && (addr & (SHMLBA - 1))) | ||
109 | return -EINVAL; | ||
110 | return addr; | ||
111 | } | ||
112 | |||
113 | if (len > TASK_SIZE) | ||
114 | return -ENOMEM; | ||
115 | if (!addr) | ||
116 | addr = TASK_UNMAPPED_BASE; | ||
117 | |||
118 | if (flags & MAP_PRIVATE) | ||
119 | addr = PAGE_ALIGN(addr); | ||
120 | else | ||
121 | addr = COLOUR_ALIGN(addr); | ||
122 | |||
123 | for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) { | ||
124 | /* At this point: (!vma || addr < vma->vm_end). */ | ||
125 | if (TASK_SIZE - len < addr) | ||
126 | return -ENOMEM; | ||
127 | if (!vma || addr + len <= vma->vm_start) | ||
128 | return addr; | ||
129 | addr = vma->vm_end; | ||
130 | if (!(flags & MAP_PRIVATE)) | ||
131 | addr = COLOUR_ALIGN(addr); | ||
132 | } | ||
133 | } | ||
134 | |||
135 | /* common code for old and new mmaps */ | ||
136 | static inline long do_mmap2( | ||
137 | unsigned long addr, unsigned long len, | ||
138 | unsigned long prot, unsigned long flags, | ||
139 | unsigned long fd, unsigned long pgoff) | ||
140 | { | ||
141 | int error = -EBADF; | ||
142 | struct file * file = NULL; | ||
143 | |||
144 | flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); | ||
145 | if (!(flags & MAP_ANONYMOUS)) { | ||
146 | file = fget(fd); | ||
147 | if (!file) | ||
148 | goto out; | ||
149 | } | ||
150 | |||
151 | down_write(¤t->mm->mmap_sem); | ||
152 | error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff); | ||
153 | up_write(¤t->mm->mmap_sem); | ||
154 | |||
155 | if (file) | ||
156 | fput(file); | ||
157 | out: | ||
158 | return error; | ||
159 | } | ||
160 | |||
161 | asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, | ||
162 | unsigned long prot, unsigned long flags, | ||
163 | unsigned long fd, unsigned long pgoff) | ||
164 | { | ||
165 | return do_mmap2(addr, len, prot, flags, fd, pgoff); | ||
166 | } | ||
167 | |||
168 | asmlinkage int old_mmap(unsigned long addr, unsigned long len, | ||
169 | unsigned long prot, unsigned long flags, | ||
170 | int fd, unsigned long off) | ||
171 | { | ||
172 | if (off & ~PAGE_MASK) | ||
173 | return -EINVAL; | ||
174 | return do_mmap2(addr, len, prot, flags, fd, off>>PAGE_SHIFT); | ||
175 | } | ||
176 | |||
177 | /* | ||
178 | * sys_ipc() is the de-multiplexer for the SysV IPC calls.. | ||
179 | * | ||
180 | * This is really horribly ugly. | ||
181 | */ | ||
182 | asmlinkage int sys_ipc(uint call, int first, int second, | ||
183 | int third, void __user *ptr, long fifth) | ||
184 | { | ||
185 | int version, ret; | ||
186 | |||
187 | version = call >> 16; /* hack for backward compatibility */ | ||
188 | call &= 0xffff; | ||
189 | |||
190 | if (call <= SEMCTL) | ||
191 | switch (call) { | ||
192 | case SEMOP: | ||
193 | return sys_semtimedop(first, (struct sembuf __user *)ptr, | ||
194 | second, NULL); | ||
195 | case SEMTIMEDOP: | ||
196 | return sys_semtimedop(first, (struct sembuf __user *)ptr, | ||
197 | second, | ||
198 | (const struct timespec __user *)fifth); | ||
199 | case SEMGET: | ||
200 | return sys_semget (first, second, third); | ||
201 | case SEMCTL: { | ||
202 | union semun fourth; | ||
203 | if (!ptr) | ||
204 | return -EINVAL; | ||
205 | if (get_user(fourth.__pad, (void * __user *) ptr)) | ||
206 | return -EFAULT; | ||
207 | return sys_semctl (first, second, third, fourth); | ||
208 | } | ||
209 | default: | ||
210 | return -EINVAL; | ||
211 | } | ||
212 | |||
213 | if (call <= MSGCTL) | ||
214 | switch (call) { | ||
215 | case MSGSND: | ||
216 | return sys_msgsnd (first, (struct msgbuf __user *) ptr, | ||
217 | second, third); | ||
218 | case MSGRCV: | ||
219 | switch (version) { | ||
220 | case 0: { | ||
221 | struct ipc_kludge tmp; | ||
222 | if (!ptr) | ||
223 | return -EINVAL; | ||
224 | |||
225 | if (copy_from_user(&tmp, | ||
226 | (struct ipc_kludge __user *) ptr, | ||
227 | sizeof (tmp))) | ||
228 | return -EFAULT; | ||
229 | return sys_msgrcv (first, tmp.msgp, second, | ||
230 | tmp.msgtyp, third); | ||
231 | } | ||
232 | default: | ||
233 | return sys_msgrcv (first, | ||
234 | (struct msgbuf __user *) ptr, | ||
235 | second, fifth, third); | ||
236 | } | ||
237 | case MSGGET: | ||
238 | return sys_msgget ((key_t) first, second); | ||
239 | case MSGCTL: | ||
240 | return sys_msgctl (first, second, | ||
241 | (struct msqid_ds __user *) ptr); | ||
242 | default: | ||
243 | return -EINVAL; | ||
244 | } | ||
245 | if (call <= SHMCTL) | ||
246 | switch (call) { | ||
247 | case SHMAT: | ||
248 | switch (version) { | ||
249 | default: { | ||
250 | ulong raddr; | ||
251 | ret = do_shmat (first, (char __user *) ptr, | ||
252 | second, &raddr); | ||
253 | if (ret) | ||
254 | return ret; | ||
255 | return put_user (raddr, (ulong __user *) third); | ||
256 | } | ||
257 | case 1: /* iBCS2 emulator entry point */ | ||
258 | if (!segment_eq(get_fs(), get_ds())) | ||
259 | return -EINVAL; | ||
260 | return do_shmat (first, (char __user *) ptr, | ||
261 | second, (ulong *) third); | ||
262 | } | ||
263 | case SHMDT: | ||
264 | return sys_shmdt ((char __user *)ptr); | ||
265 | case SHMGET: | ||
266 | return sys_shmget (first, second, third); | ||
267 | case SHMCTL: | ||
268 | return sys_shmctl (first, second, | ||
269 | (struct shmid_ds __user *) ptr); | ||
270 | default: | ||
271 | return -EINVAL; | ||
272 | } | ||
273 | |||
274 | return -EINVAL; | ||
275 | } | ||
276 | |||
277 | asmlinkage int sys_uname(struct old_utsname * name) | ||
278 | { | ||
279 | int err; | ||
280 | if (!name) | ||
281 | return -EFAULT; | ||
282 | down_read(&uts_sem); | ||
283 | err = copy_to_user(name, utsname(), sizeof (*name)); | ||
284 | up_read(&uts_sem); | ||
285 | return err?-EFAULT:0; | ||
286 | } | ||
287 | |||
288 | /* | 50 | /* |
289 | * Do a system call from kernel instead of calling sys_execve so we | 51 | * Do a system call from kernel instead of calling sys_execve so we |
290 | * end up with proper pt_regs. | 52 | * end up with proper pt_regs. |