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"
18 #include <linux/vs_cvirt.h>
21 #include "asm/uaccess.h"
23 #include "kern_util.h"
24 #include "user_util.h"
25 #include "sysdep/syscalls.h"
26 #include "mode_kern.h"
27 #include "choose-mode.h"
29 /* Unlocked, I don't care if this is a bit off */
32 long um_mount(char * dev_name, char * dir_name, char * type,
33 unsigned long new_flags, void * data)
35 if(type == NULL) type = "";
36 return(sys_mount(dev_name, dir_name, type, new_flags, data));
43 current->thread.forking = 1;
44 ret = do_fork(SIGCHLD, 0, NULL, 0, NULL, NULL);
45 current->thread.forking = 0;
49 long sys_clone(unsigned long clone_flags, unsigned long newsp,
50 int *parent_tid, int *child_tid)
54 current->thread.forking = 1;
55 ret = do_fork(clone_flags, newsp, NULL, 0, parent_tid, child_tid);
56 current->thread.forking = 0;
64 current->thread.forking = 1;
65 ret = do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0, NULL, 0, NULL,
67 current->thread.forking = 0;
71 /* common code for old and new mmaps */
72 long do_mmap2(struct mm_struct *mm, unsigned long addr, unsigned long len,
73 unsigned long prot, unsigned long flags, unsigned long fd,
77 struct file * file = NULL;
79 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
80 if (!(flags & MAP_ANONYMOUS)) {
86 down_write(&mm->mmap_sem);
87 error = do_mmap_pgoff(mm, file, addr, len, prot, flags, pgoff);
88 up_write(&mm->mmap_sem);
96 long sys_mmap2(unsigned long addr, unsigned long len,
97 unsigned long prot, unsigned long flags,
98 unsigned long fd, unsigned long pgoff)
100 return do_mmap2(current->mm, addr, len, prot, flags, fd, pgoff);
104 * Perform the select(nd, in, out, ex, tv) and mmap() system
105 * calls. Linux/i386 didn't use to be able to handle more than
106 * 4 system call parameters, so these system calls used a memory
107 * block for parameter passing..
110 struct mmap_arg_struct {
116 unsigned long offset;
119 int old_mmap(unsigned long addr, unsigned long len,
120 unsigned long prot, unsigned long flags,
121 unsigned long fd, unsigned long offset)
124 if (offset & ~PAGE_MASK)
127 err = do_mmap2(current->mm, addr, len, prot, flags, fd,
128 offset >> PAGE_SHIFT);
133 * sys_pipe() is the normal C calling standard for creating
134 * a pipe. It's not the way unix traditionally does this, though.
136 int sys_pipe(unsigned long * fildes)
143 if (copy_to_user(fildes, fd, sizeof(fd)))
150 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
152 * This is really horribly ugly.
154 int sys_ipc (uint call, int first, int second,
155 int third, void *ptr, long fifth)
159 version = call >> 16; /* hack for backward compatibility */
164 return sys_semtimedop(first, (struct sembuf *) ptr, second,
167 return sys_semtimedop(first, (struct sembuf *) ptr, second,
168 (const struct timespec *) fifth);
170 return sys_semget (first, second, third);
175 if (get_user(fourth.__pad, (void **) ptr))
177 return sys_semctl (first, second, third, fourth);
181 return sys_msgsnd (first, (struct msgbuf *) ptr,
186 struct ipc_kludge tmp;
190 if (copy_from_user(&tmp,
191 (struct ipc_kludge *) ptr,
194 return sys_msgrcv (first, tmp.msgp, second,
198 panic("msgrcv with version != 0");
199 return sys_msgrcv (first,
200 (struct msgbuf *) ptr,
201 second, fifth, third);
204 return sys_msgget ((key_t) first, second);
206 return sys_msgctl (first, second, (struct msqid_ds *) ptr);
212 ret = do_shmat (first, (char *) ptr, second, &raddr);
215 return put_user (raddr, (ulong *) third);
217 case 1: /* iBCS2 emulator entry point */
218 if (!segment_eq(get_fs(), get_ds()))
220 return do_shmat (first, (char *) ptr, second, (ulong *) third);
223 return sys_shmdt ((char *)ptr);
225 return sys_shmget (first, second, third);
227 return sys_shmctl (first, second,
228 (struct shmid_ds *) ptr);
234 int sys_uname(struct old_utsname * name)
240 err=copy_to_user(name, vx_new_utsname(), sizeof (*name));
242 return err?-EFAULT:0;
245 int sys_olduname(struct oldold_utsname * name)
248 struct new_utsname *ptr;
252 if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname)))
257 ptr = vx_new_utsname();
258 error = __copy_to_user(&name->sysname,ptr->sysname,
260 error |= __put_user(0,name->sysname+__OLD_UTS_LEN);
261 error |= __copy_to_user(&name->nodename,ptr->nodename,
263 error |= __put_user(0,name->nodename+__OLD_UTS_LEN);
264 error |= __copy_to_user(&name->release,ptr->release,
266 error |= __put_user(0,name->release+__OLD_UTS_LEN);
267 error |= __copy_to_user(&name->version,ptr->version,
269 error |= __put_user(0,name->version+__OLD_UTS_LEN);
270 error |= __copy_to_user(&name->machine,ptr->machine,
272 error |= __put_user(0,name->machine+__OLD_UTS_LEN);
276 error = error ? -EFAULT : 0;
281 long execute_syscall(void *r)
283 return(CHOOSE_MODE_PROC(execute_syscall_tt, execute_syscall_skas, r));
286 spinlock_t syscall_lock = SPIN_LOCK_UNLOCKED;
288 static int syscall_index = 0;
290 int next_syscall_index(int limit)
294 spin_lock(&syscall_lock);
296 if(++syscall_index == limit)
298 spin_unlock(&syscall_lock);
303 * Overrides for Emacs so that we follow Linus's tabbing style.
304 * Emacs will notice this stuff at the end of the file and automatically
305 * adjust the settings for this buffer only. This must remain at the end
307 * ---------------------------------------------------------------------------
309 * c-file-style: "linux"