2 * arch/v850/kernel/syscalls.c -- Various system-call definitions not
3 * defined in machine-independent code
5 * Copyright (C) 2001,02 NEC Corporation
6 * Copyright (C) 2001,02 Miles Bader <miles@gnu.org>
8 * This file is subject to the terms and conditions of the GNU General
9 * Public License. See the file COPYING in the main directory of this
10 * archive for more details.
12 * This file was derived the ppc version, arch/ppc/kernel/syscalls.c
13 * ... which was derived from "arch/i386/kernel/sys_i386.c" by Gary Thomas;
14 * modified by Cort Dougan (cort@cs.nmt.edu)
15 * and Paul Mackerras (paulus@cs.anu.edu.au).
18 #include <linux/errno.h>
20 #include <linux/smp.h>
21 #include <linux/smp_lock.h>
22 #include <linux/syscalls.h>
23 #include <linux/sem.h>
24 #include <linux/msg.h>
25 #include <linux/shm.h>
26 #include <linux/stat.h>
27 #include <linux/mman.h>
28 #include <linux/sys.h>
29 #include <linux/ipc.h>
30 #include <linux/utsname.h>
31 #include <linux/file.h>
33 #include <asm/uaccess.h>
35 #include <asm/semaphore.h>
38 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
40 * This is really horribly ugly.
43 sys_ipc (uint call
, int first
, int second
, int third
, void *ptr
, long fifth
)
47 version
= call
>> 16; /* hack for backward compatibility */
53 ret
= sys_semop (first
, (struct sembuf
*)ptr
, second
);
56 ret
= sys_semget (first
, second
, third
);
64 if ((ret
= access_ok(VERIFY_READ
, ptr
, sizeof(long)) ? 0 : -EFAULT
)
65 || (ret
= get_user(fourth
.__pad
, (void **)ptr
)))
67 ret
= sys_semctl (first
, second
, third
, fourth
);
71 ret
= sys_msgsnd (first
, (struct msgbuf
*) ptr
, second
, third
);
76 struct ipc_kludge tmp
;
80 if ((ret
= access_ok(VERIFY_READ
, ptr
, sizeof(tmp
)) ? 0 : -EFAULT
)
81 || (ret
= copy_from_user(&tmp
,
82 (struct ipc_kludge
*) ptr
,
85 ret
= sys_msgrcv (first
, tmp
.msgp
, second
, tmp
.msgtyp
,
90 ret
= sys_msgrcv (first
, (struct msgbuf
*) ptr
,
91 second
, fifth
, third
);
96 ret
= sys_msgget ((key_t
) first
, second
);
99 ret
= sys_msgctl (first
, second
, (struct msqid_ds
*) ptr
);
106 if ((ret
= access_ok(VERIFY_WRITE
, (ulong
*) third
,
107 sizeof(ulong
)) ? 0 : -EFAULT
))
109 ret
= do_shmat (first
, (char *) ptr
, second
, &raddr
);
112 ret
= put_user (raddr
, (ulong
*) third
);
115 case 1: /* iBCS2 emulator entry point */
116 if (!segment_eq(get_fs(), get_ds()))
118 ret
= do_shmat (first
, (char *) ptr
, second
,
124 ret
= sys_shmdt ((char *)ptr
);
127 ret
= sys_shmget (first
, second
, third
);
130 ret
= sys_shmctl (first
, second
, (struct shmid_ds
*) ptr
);
138 * sys_pipe() is the normal C calling standard for creating
139 * a pipe. It's not the way unix traditionally does this, though.
141 int sys_pipe (int *fildes
)
146 error
= do_pipe (fd
);
148 if (copy_to_user (fildes
, fd
, 2*sizeof (int)))
154 static inline unsigned long
155 do_mmap2 (unsigned long addr
, size_t len
,
156 unsigned long prot
, unsigned long flags
,
157 unsigned long fd
, unsigned long pgoff
)
159 struct file
* file
= NULL
;
162 flags
&= ~(MAP_EXECUTABLE
| MAP_DENYWRITE
);
163 if (! (flags
& MAP_ANONYMOUS
)) {
164 if (!(file
= fget (fd
)))
168 down_write (¤t
->mm
->mmap_sem
);
169 ret
= do_mmap_pgoff (file
, addr
, len
, prot
, flags
, pgoff
);
170 up_write (¤t
->mm
->mmap_sem
);
177 unsigned long sys_mmap2 (unsigned long addr
, size_t len
,
178 unsigned long prot
, unsigned long flags
,
179 unsigned long fd
, unsigned long pgoff
)
181 return do_mmap2 (addr
, len
, prot
, flags
, fd
, pgoff
);
184 unsigned long sys_mmap (unsigned long addr
, size_t len
,
185 unsigned long prot
, unsigned long flags
,
186 unsigned long fd
, off_t offset
)
190 if (offset
& ~PAGE_MASK
)
193 err
= do_mmap2 (addr
, len
, prot
, flags
, fd
, offset
>> PAGE_SHIFT
);