vserver 1.9.3
[linux-2.6.git] / arch / um / sys-i386 / syscalls.c
1 /* 
2  * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
3  * Licensed under the GPL
4  */
5
6 #include "linux/sched.h"
7 #include "asm/mman.h"
8 #include "asm/uaccess.h"
9 #include "asm/unistd.h"
10
11 /*
12  * Perform the select(nd, in, out, ex, tv) and mmap() system
13  * calls. Linux/i386 didn't use to be able to handle more than
14  * 4 system call parameters, so these system calls used a memory
15  * block for parameter passing..
16  */
17
18 struct mmap_arg_struct {
19         unsigned long addr;
20         unsigned long len;
21         unsigned long prot;
22         unsigned long flags;
23         unsigned long fd;
24         unsigned long offset;
25 };
26
27 extern int old_mmap(unsigned long addr, unsigned long len,
28                     unsigned long prot, unsigned long flags,
29                     unsigned long fd, unsigned long offset);
30
31 int old_mmap_i386(struct mmap_arg_struct *arg)
32 {
33         struct mmap_arg_struct a;
34         int err = -EFAULT;
35
36         if (copy_from_user(&a, arg, sizeof(a)))
37                 goto out;
38
39         err = old_mmap(a.addr, a.len, a.prot, a.flags, a.fd, a.offset);
40  out:
41         return err;
42 }
43
44 struct sel_arg_struct {
45         unsigned long n;
46         fd_set *inp, *outp, *exp;
47         struct timeval *tvp;
48 };
49
50 int old_select(struct sel_arg_struct *arg)
51 {
52         struct sel_arg_struct a;
53
54         if (copy_from_user(&a, arg, sizeof(a)))
55                 return -EFAULT;
56         /* sys_select() does the appropriate kernel locking */
57         return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
58 }
59
60 /* The i386 version skips reading from %esi, the fourth argument. So we must do
61  * this, too.
62  */
63 int sys_clone(unsigned long clone_flags, unsigned long newsp, int *parent_tid,
64               int unused, int *child_tid)
65 {
66         long ret;
67
68         /* XXX: normal arch do here this pass, and also pass the regs to
69          * do_fork, instead of NULL. Currently the arch-independent code
70          * ignores these values, while the UML code (actually it's
71          * copy_thread) does the right thing. But this should change,
72          probably. */
73         /*if (!newsp)
74                 newsp = UPT_SP(current->thread.regs);*/
75         current->thread.forking = 1;
76         ret = do_fork(clone_flags, newsp, NULL, 0, parent_tid, child_tid);
77         current->thread.forking = 0;
78         return(ret);
79 }
80
81 /*
82  * Overrides for Emacs so that we follow Linus's tabbing style.
83  * Emacs will notice this stuff at the end of the file and automatically
84  * adjust the settings for this buffer only.  This must remain at the end
85  * of the file.
86  * ---------------------------------------------------------------------------
87  * Local variables:
88  * c-file-style: "linux"
89  * End:
90  */