2 * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
6 #include "linux/sched.h"
9 #include "linux/syscalls.h"
11 #include "asm/uaccess.h"
12 #include "asm/unistd.h"
15 * Perform the select(nd, in, out, ex, tv) and mmap() system
16 * calls. Linux/i386 didn't use to be able to handle more than
17 * 4 system call parameters, so these system calls used a memory
18 * block for parameter passing..
21 struct mmap_arg_struct
{
30 extern int old_mmap(unsigned long addr
, unsigned long len
,
31 unsigned long prot
, unsigned long flags
,
32 unsigned long fd
, unsigned long offset
);
34 long old_mmap_i386(struct mmap_arg_struct __user
*arg
)
36 struct mmap_arg_struct a
;
39 if (copy_from_user(&a
, arg
, sizeof(a
)))
42 err
= old_mmap(a
.addr
, a
.len
, a
.prot
, a
.flags
, a
.fd
, a
.offset
);
47 struct sel_arg_struct
{
52 struct timeval __user
*tvp
;
55 long old_select(struct sel_arg_struct __user
*arg
)
57 struct sel_arg_struct a
;
59 if (copy_from_user(&a
, arg
, sizeof(a
)))
61 /* sys_select() does the appropriate kernel locking */
62 return sys_select(a
.n
, a
.inp
, a
.outp
, a
.exp
, a
.tvp
);
66 * The prototype on i386 is:
68 * int clone(int flags, void * child_stack, int * parent_tidptr, struct user_desc * newtls, int * child_tidptr)
70 * and the "newtls" arg. on i386 is read by copy_thread directly from the
71 * register saved on the stack.
73 long sys_clone(unsigned long clone_flags
, unsigned long newsp
,
74 int __user
*parent_tid
, void *newtls
, int __user
*child_tid
)
79 newsp
= UPT_SP(¤t
->thread
.regs
.regs
);
81 current
->thread
.forking
= 1;
82 ret
= do_fork(clone_flags
, newsp
, ¤t
->thread
.regs
, 0, parent_tid
,
84 current
->thread
.forking
= 0;
89 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
91 * This is really horribly ugly.
93 long sys_ipc (uint call
, int first
, int second
,
94 int third
, void __user
*ptr
, long fifth
)
98 version
= call
>> 16; /* hack for backward compatibility */
103 return sys_semtimedop(first
, (struct sembuf __user
*) ptr
,
106 return sys_semtimedop(first
, (struct sembuf __user
*) ptr
,
108 (const struct timespec __user
*) fifth
);
110 return sys_semget (first
, second
, third
);
115 if (get_user(fourth
.__pad
, (void __user
* __user
*) ptr
))
117 return sys_semctl (first
, second
, third
, fourth
);
121 return sys_msgsnd (first
, (struct msgbuf
*) ptr
,
126 struct ipc_kludge tmp
;
130 if (copy_from_user(&tmp
,
131 (struct ipc_kludge
*) ptr
,
134 return sys_msgrcv (first
, tmp
.msgp
, second
,
138 panic("msgrcv with version != 0");
139 return sys_msgrcv (first
,
140 (struct msgbuf
*) ptr
,
141 second
, fifth
, third
);
144 return sys_msgget ((key_t
) first
, second
);
146 return sys_msgctl (first
, second
, (struct msqid_ds
*) ptr
);
152 ret
= do_shmat (first
, (char *) ptr
, second
, &raddr
);
155 return put_user (raddr
, (ulong
*) third
);
157 case 1: /* iBCS2 emulator entry point */
158 if (!segment_eq(get_fs(), get_ds()))
160 return do_shmat (first
, (char *) ptr
, second
, (ulong
*) third
);
163 return sys_shmdt ((char *)ptr
);
165 return sys_shmget (first
, second
, third
);
167 return sys_shmctl (first
, second
,
168 (struct shmid_ds
*) ptr
);
174 long sys_sigaction(int sig
, const struct old_sigaction __user
*act
,
175 struct old_sigaction __user
*oact
)
177 struct k_sigaction new_ka
, old_ka
;
182 if (!access_ok(VERIFY_READ
, act
, sizeof(*act
)) ||
183 __get_user(new_ka
.sa
.sa_handler
, &act
->sa_handler
) ||
184 __get_user(new_ka
.sa
.sa_restorer
, &act
->sa_restorer
))
186 __get_user(new_ka
.sa
.sa_flags
, &act
->sa_flags
);
187 __get_user(mask
, &act
->sa_mask
);
188 siginitset(&new_ka
.sa
.sa_mask
, mask
);
191 ret
= do_sigaction(sig
, act
? &new_ka
: NULL
, oact
? &old_ka
: NULL
);
194 if (!access_ok(VERIFY_WRITE
, oact
, sizeof(*oact
)) ||
195 __put_user(old_ka
.sa
.sa_handler
, &oact
->sa_handler
) ||
196 __put_user(old_ka
.sa
.sa_restorer
, &oact
->sa_restorer
))
198 __put_user(old_ka
.sa
.sa_flags
, &oact
->sa_flags
);
199 __put_user(old_ka
.sa
.sa_mask
.sig
[0], &oact
->sa_mask
);