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;
53 current->thread.forking = 1;
54 ret = do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0, NULL, 0, NULL,
56 current->thread.forking = 0;
60 /* common code for old and new mmaps */
61 long do_mmap2(struct mm_struct *mm, unsigned long addr, unsigned long len,
62 unsigned long prot, unsigned long flags, unsigned long fd,
66 struct file * file = NULL;
68 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
69 if (!(flags & MAP_ANONYMOUS)) {
75 down_write(&mm->mmap_sem);
76 error = do_mmap_pgoff(mm, file, addr, len, prot, flags, pgoff);
77 up_write(&mm->mmap_sem);
85 long sys_mmap2(unsigned long addr, unsigned long len,
86 unsigned long prot, unsigned long flags,
87 unsigned long fd, unsigned long pgoff)
89 return do_mmap2(current->mm, addr, len, prot, flags, fd, pgoff);
93 * Perform the select(nd, in, out, ex, tv) and mmap() system
94 * calls. Linux/i386 didn't use to be able to handle more than
95 * 4 system call parameters, so these system calls used a memory
96 * block for parameter passing..
99 struct mmap_arg_struct {
105 unsigned long offset;
108 long old_mmap(unsigned long addr, unsigned long len,
109 unsigned long prot, unsigned long flags,
110 unsigned long fd, unsigned long offset)
113 if (offset & ~PAGE_MASK)
116 err = do_mmap2(current->mm, addr, len, prot, flags, fd,
117 offset >> PAGE_SHIFT);
122 * sys_pipe() is the normal C calling standard for creating
123 * a pipe. It's not the way unix traditionally does this, though.
125 long sys_pipe(unsigned long * fildes)
132 if (copy_to_user(fildes, fd, sizeof(fd)))
139 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
141 * This is really horribly ugly.
143 int sys_ipc (uint call, int first, int second,
144 int third, void *ptr, long fifth)
148 version = call >> 16; /* hack for backward compatibility */
153 return sys_semtimedop(first, (struct sembuf *) ptr, second,
156 return sys_semtimedop(first, (struct sembuf *) ptr, second,
157 (const struct timespec *) fifth);
159 return sys_semget (first, second, third);
164 if (get_user(fourth.__pad, (void **) ptr))
166 return sys_semctl (first, second, third, fourth);
170 return sys_msgsnd (first, (struct msgbuf *) ptr,
175 struct ipc_kludge tmp;
179 if (copy_from_user(&tmp,
180 (struct ipc_kludge *) ptr,
183 return sys_msgrcv (first, tmp.msgp, second,
187 panic("msgrcv with version != 0");
188 return sys_msgrcv (first,
189 (struct msgbuf *) ptr,
190 second, fifth, third);
193 return sys_msgget ((key_t) first, second);
195 return sys_msgctl (first, second, (struct msqid_ds *) ptr);
201 ret = do_shmat (first, (char *) ptr, second, &raddr);
204 return put_user (raddr, (ulong *) third);
206 case 1: /* iBCS2 emulator entry point */
207 if (!segment_eq(get_fs(), get_ds()))
209 return do_shmat (first, (char *) ptr, second, (ulong *) third);
212 return sys_shmdt ((char *)ptr);
214 return sys_shmget (first, second, third);
216 return sys_shmctl (first, second,
217 (struct shmid_ds *) ptr);
223 long sys_uname(struct old_utsname * name)
229 err=copy_to_user(name, vx_new_utsname(), sizeof (*name));
231 return err?-EFAULT:0;
234 long sys_olduname(struct oldold_utsname * name)
237 struct new_utsname *ptr;
241 if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname)))
246 ptr = vx_new_utsname();
247 error = __copy_to_user(&name->sysname,ptr->sysname,
249 error |= __put_user(0,name->sysname+__OLD_UTS_LEN);
250 error |= __copy_to_user(&name->nodename,ptr->nodename,
252 error |= __put_user(0,name->nodename+__OLD_UTS_LEN);
253 error |= __copy_to_user(&name->release,ptr->release,
255 error |= __put_user(0,name->release+__OLD_UTS_LEN);
256 error |= __copy_to_user(&name->version,ptr->version,
258 error |= __put_user(0,name->version+__OLD_UTS_LEN);
259 error |= __copy_to_user(&name->machine,ptr->machine,
261 error |= __put_user(0,name->machine+__OLD_UTS_LEN);
265 error = error ? -EFAULT : 0;
270 long execute_syscall(void *r)
272 return(CHOOSE_MODE_PROC(execute_syscall_tt, execute_syscall_skas, r));
275 spinlock_t syscall_lock = SPIN_LOCK_UNLOCKED;
277 static int syscall_index = 0;
279 int next_syscall_index(int limit)
283 spin_lock(&syscall_lock);
285 if(++syscall_index == limit)
287 spin_unlock(&syscall_lock);
292 * Overrides for Emacs so that we follow Linus's tabbing style.
293 * Emacs will notice this stuff at the end of the file and automatically
294 * adjust the settings for this buffer only. This must remain at the end
296 * ---------------------------------------------------------------------------
298 * c-file-style: "linux"