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;
51 current->thread.forking = 1;
52 ret = do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0, NULL, 0, NULL,
54 current->thread.forking = 0;
58 /* common code for old and new mmaps */
59 static inline long do_mmap2(
60 unsigned long addr, unsigned long len,
61 unsigned long prot, unsigned long flags,
62 unsigned long fd, unsigned long pgoff)
65 struct file * file = NULL;
67 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
68 if (!(flags & MAP_ANONYMOUS)) {
74 down_write(¤t->mm->mmap_sem);
75 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
76 up_write(¤t->mm->mmap_sem);
84 long sys_mmap2(unsigned long addr, unsigned long len,
85 unsigned long prot, unsigned long flags,
86 unsigned long fd, unsigned long pgoff)
88 return do_mmap2(addr, len, prot, flags, fd, pgoff);
92 * Perform the select(nd, in, out, ex, tv) and mmap() system
93 * calls. Linux/i386 didn't use to be able to handle more than
94 * 4 system call parameters, so these system calls used a memory
95 * block for parameter passing..
98 struct mmap_arg_struct {
104 unsigned long offset;
107 long old_mmap(unsigned long addr, unsigned long len,
108 unsigned long prot, unsigned long flags,
109 unsigned long fd, unsigned long offset)
112 if (offset & ~PAGE_MASK)
115 err = do_mmap2(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
120 * sys_pipe() is the normal C calling standard for creating
121 * a pipe. It's not the way unix traditionally does this, though.
123 long sys_pipe(unsigned long * fildes)
130 if (copy_to_user(fildes, fd, sizeof(fd)))
137 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
139 * This is really horribly ugly.
141 int sys_ipc (uint call, int first, int second,
142 int third, void *ptr, long fifth)
146 version = call >> 16; /* hack for backward compatibility */
151 return sys_semtimedop(first, (struct sembuf *) ptr, second,
154 return sys_semtimedop(first, (struct sembuf *) ptr, second,
155 (const struct timespec *) fifth);
157 return sys_semget (first, second, third);
162 if (get_user(fourth.__pad, (void **) ptr))
164 return sys_semctl (first, second, third, fourth);
168 return sys_msgsnd (first, (struct msgbuf *) ptr,
173 struct ipc_kludge tmp;
177 if (copy_from_user(&tmp,
178 (struct ipc_kludge *) ptr,
181 return sys_msgrcv (first, tmp.msgp, second,
185 panic("msgrcv with version != 0");
186 return sys_msgrcv (first,
187 (struct msgbuf *) ptr,
188 second, fifth, third);
191 return sys_msgget ((key_t) first, second);
193 return sys_msgctl (first, second, (struct msqid_ds *) ptr);
199 ret = do_shmat (first, (char *) ptr, second, &raddr);
202 return put_user (raddr, (ulong *) third);
204 case 1: /* iBCS2 emulator entry point */
205 if (!segment_eq(get_fs(), get_ds()))
207 return do_shmat (first, (char *) ptr, second, (ulong *) third);
210 return sys_shmdt ((char *)ptr);
212 return sys_shmget (first, second, third);
214 return sys_shmctl (first, second,
215 (struct shmid_ds *) ptr);
221 long sys_uname(struct old_utsname * name)
227 err=copy_to_user(name, &system_utsname, sizeof (*name));
229 return err?-EFAULT:0;
232 long sys_olduname(struct oldold_utsname * name)
238 if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname)))
243 error = __copy_to_user(&name->sysname,&system_utsname.sysname,
245 error |= __put_user(0,name->sysname+__OLD_UTS_LEN);
246 error |= __copy_to_user(&name->nodename,&system_utsname.nodename,
248 error |= __put_user(0,name->nodename+__OLD_UTS_LEN);
249 error |= __copy_to_user(&name->release,&system_utsname.release,
251 error |= __put_user(0,name->release+__OLD_UTS_LEN);
252 error |= __copy_to_user(&name->version,&system_utsname.version,
254 error |= __put_user(0,name->version+__OLD_UTS_LEN);
255 error |= __copy_to_user(&name->machine,&system_utsname.machine,
257 error |= __put_user(0,name->machine+__OLD_UTS_LEN);
261 error = error ? -EFAULT : 0;
266 long execute_syscall(void *r)
268 return(CHOOSE_MODE_PROC(execute_syscall_tt, execute_syscall_skas, r));
271 spinlock_t syscall_lock = SPIN_LOCK_UNLOCKED;
273 static int syscall_index = 0;
275 int next_syscall_index(int limit)
279 spin_lock(&syscall_lock);
281 if(++syscall_index == limit)
283 spin_unlock(&syscall_lock);
288 * Overrides for Emacs so that we follow Linus's tabbing style.
289 * Emacs will notice this stuff at the end of the file and automatically
290 * adjust the settings for this buffer only. This must remain at the end
292 * ---------------------------------------------------------------------------
294 * c-file-style: "linux"