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"
19 #include "asm/uaccess.h"
21 #include "kern_util.h"
22 #include "user_util.h"
23 #include "sysdep/syscalls.h"
24 #include "mode_kern.h"
25 #include "choose-mode.h"
27 /* Unlocked, I don't care if this is a bit off */
30 long um_mount(char * dev_name, char * dir_name, char * type,
31 unsigned long new_flags, void * data)
33 if(type == NULL) type = "";
34 return(sys_mount(dev_name, dir_name, type, new_flags, data));
41 current->thread.forking = 1;
42 ret = do_fork(SIGCHLD, 0, NULL, 0, NULL, NULL);
43 current->thread.forking = 0;
47 long sys_clone(unsigned long clone_flags, unsigned long newsp,
48 int *parent_tid, int *child_tid)
52 current->thread.forking = 1;
53 ret = do_fork(clone_flags, newsp, NULL, 0, parent_tid, child_tid);
54 current->thread.forking = 0;
62 current->thread.forking = 1;
63 ret = do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0, NULL, 0, NULL,
65 current->thread.forking = 0;
69 /* common code for old and new mmaps */
70 long do_mmap2(struct mm_struct *mm, unsigned long addr, unsigned long len,
71 unsigned long prot, unsigned long flags, unsigned long fd,
75 struct file * file = NULL;
77 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
78 if (!(flags & MAP_ANONYMOUS)) {
84 down_write(&mm->mmap_sem);
85 error = do_mmap_pgoff(mm, file, addr, len, prot, flags, pgoff);
86 up_write(&mm->mmap_sem);
94 long sys_mmap2(unsigned long addr, unsigned long len,
95 unsigned long prot, unsigned long flags,
96 unsigned long fd, unsigned long pgoff)
98 return do_mmap2(current->mm, addr, len, prot, flags, fd, pgoff);
102 * Perform the select(nd, in, out, ex, tv) and mmap() system
103 * calls. Linux/i386 didn't use to be able to handle more than
104 * 4 system call parameters, so these system calls used a memory
105 * block for parameter passing..
108 struct mmap_arg_struct {
114 unsigned long offset;
117 int old_mmap(unsigned long addr, unsigned long len,
118 unsigned long prot, unsigned long flags,
119 unsigned long fd, unsigned long offset)
122 if (offset & ~PAGE_MASK)
125 err = do_mmap2(current->mm, addr, len, prot, flags, fd,
126 offset >> PAGE_SHIFT);
131 * sys_pipe() is the normal C calling standard for creating
132 * a pipe. It's not the way unix traditionally does this, though.
134 int sys_pipe(unsigned long * fildes)
141 if (copy_to_user(fildes, fd, sizeof(fd)))
148 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
150 * This is really horribly ugly.
152 int sys_ipc (uint call, int first, int second,
153 int third, void *ptr, long fifth)
157 version = call >> 16; /* hack for backward compatibility */
162 return sys_semtimedop(first, (struct sembuf *) ptr, second,
165 return sys_semtimedop(first, (struct sembuf *) ptr, second,
166 (const struct timespec *) fifth);
168 return sys_semget (first, second, third);
173 if (get_user(fourth.__pad, (void **) ptr))
175 return sys_semctl (first, second, third, fourth);
179 return sys_msgsnd (first, (struct msgbuf *) ptr,
184 struct ipc_kludge tmp;
188 if (copy_from_user(&tmp,
189 (struct ipc_kludge *) ptr,
192 return sys_msgrcv (first, tmp.msgp, second,
196 panic("msgrcv with version != 0");
197 return sys_msgrcv (first,
198 (struct msgbuf *) ptr,
199 second, fifth, third);
202 return sys_msgget ((key_t) first, second);
204 return sys_msgctl (first, second, (struct msqid_ds *) ptr);
210 ret = do_shmat (first, (char *) ptr, second, &raddr);
213 return put_user (raddr, (ulong *) third);
215 case 1: /* iBCS2 emulator entry point */
216 if (!segment_eq(get_fs(), get_ds()))
218 return do_shmat (first, (char *) ptr, second, (ulong *) third);
221 return sys_shmdt ((char *)ptr);
223 return sys_shmget (first, second, third);
225 return sys_shmctl (first, second,
226 (struct shmid_ds *) ptr);
232 int sys_uname(struct old_utsname * name)
238 err=copy_to_user(name, vx_new_utsname(), sizeof (*name));
240 return err?-EFAULT:0;
243 int sys_olduname(struct oldold_utsname * name)
246 struct new_utsname *ptr;
250 if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname)))
255 ptr = vx_new_utsname();
256 error = __copy_to_user(&name->sysname,ptr->sysname,
258 error |= __put_user(0,name->sysname+__OLD_UTS_LEN);
259 error |= __copy_to_user(&name->nodename,ptr->nodename,
261 error |= __put_user(0,name->nodename+__OLD_UTS_LEN);
262 error |= __copy_to_user(&name->release,ptr->release,
264 error |= __put_user(0,name->release+__OLD_UTS_LEN);
265 error |= __copy_to_user(&name->version,ptr->version,
267 error |= __put_user(0,name->version+__OLD_UTS_LEN);
268 error |= __copy_to_user(&name->machine,ptr->machine,
270 error |= __put_user(0,name->machine+__OLD_UTS_LEN);
274 error = error ? -EFAULT : 0;
279 long execute_syscall(void *r)
281 return(CHOOSE_MODE_PROC(execute_syscall_tt, execute_syscall_skas, r));
284 spinlock_t syscall_lock = SPIN_LOCK_UNLOCKED;
286 static int syscall_index = 0;
288 int next_syscall_index(int limit)
292 spin_lock(&syscall_lock);
294 if(++syscall_index == limit)
296 spin_unlock(&syscall_lock);
301 * Overrides for Emacs so that we follow Linus's tabbing style.
302 * Emacs will notice this stuff at the end of the file and automatically
303 * adjust the settings for this buffer only. This must remain at the end
305 * ---------------------------------------------------------------------------
307 * c-file-style: "linux"