xref: /titanic_44/usr/src/lib/libbc/libc/sys/common/syscall.c (revision 726fad2a65f16c200a03969c29cb5c86c2d427db)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #include <errno.h>
28 #include <stdio.h>
29 #include <stdarg.h>
30 #include <sys/syscall.h>
31 #include "xsyscall.h"
32 
33 /*
34  * Array of SVR4 system call numbers. The 4.1 numbers are mapped
35  * to their SVR4/5.0 equivalents before trapping into the kernel.
36  */
37 
38 int syscallnum[190] = {	SYS_syscall,	SYS_exit,	-1 /*fork1*/,
39 	SYS_read,	SYS_write,	-1 /*open*/,	SYS_close,
40         -1,		-1 /*creat*/,	SYS_link,	-1 /*unlink*/,
41 	-1,		SYS_chdir,	0,		SYS_mknod,
42         SYS_chmod,	-1 /*lchown*/,	0,		0,
43         SYS_lseek,	SYS_getpid,	0,		0,
44 	0,		SYS_getuid,	0,		0,
45 	0,		0,		0,		0,
46 	0,		0,		-1 /*access*/, 	0,
47 	0,		SYS_sync,	SYS_kill,	-1 /*stat*/,
48 	0,		-1 /*lstat*/,	-1 /*dup*/,	SYS_pipe,
49 	0,		SYS_profil,	0,		0,
50 	SYS_getgid,	0,		0,		0,
51 	SYS_acct,	0,		-1,		SYS_ioctl,
52 	-1 /*reboot*/,	0,		SYS_symlink,	SYS_readlink,
53 	SYS_execve,	SYS_umask,	SYS_chroot,	-1 /*fstat*/,
54 	0,		-1/*getpagesize*/,-1,		0,
55 	0,		0,		-1,		-1,
56 	SYS_mmap,	-1,		SYS_munmap,	SYS_mprotect,
57 	-1 /*advise*/,	SYS_vhangup,	0,		SYS_mincore,
58 	SYS_getgroups,	SYS_setgroups,	-1 /*getpgrp*/,	-1 /*setpgrp*/,
59 	SYS_setitimer,	0,		-1 /*swapon*/,	SYS_getitimer,
60 	-1/*gethostname*/,-1/*sethostname*/,-1/*getdtablesize*/,-1/*dup2*/,
61 	-1/*getdopt*/,	SYS_fcntl,	-1 /*select*/,	-1 /*setdopt*/,
62 	SYS_fdsync,	-1 /*setprio*/,	-1 /*socket*/,	-1 /*connect*/,
63 	-1 /*accept*/,	-1 /*getprio*/,	-1 /*send*/,	-1 /*recv*/,
64 	0,		-1 /*bind*/,	-1 /*setsockopt*/,-1 /*listen*/,
65 	0,		-1 /*sigvec*/,	-1 /*sigblock*/, -1 /*sigsetmask*/,
66 	-1 /*sigpause*/, -1 /*sigstack*/, -1 /*recvmsg*/, -1 /*sendmsg*/,
67 	-1 /*vtrace*/,	SYS_gettimeofday, -1 /*getrusage*/, -1 /*getsockopt*/,
68 	0,		SYS_readv,	SYS_writev,	-1 /*settimeofday*/,
69 	-1 /*fchown*/,	SYS_fchmod,	-1 /*recvfrom*/, -1 /*setreuid*/,
70 	-1 /*getregid*/, -1 /*rename*/,	-1 /*truncate*/, -1 /*ftruncate*/,
71 	-1 /*flock*/,	0,		-1 /*sendto*/,	-1 /*shutdown*/,
72 	-1 /*socketpair*/,SYS_mkdir,	-1 /*rmdir*/,	-1 /*utimes*/,
73 	0,		SYS_adjtime,	-1 /*getpeername*/,-1 /*gethostid*/,
74 	0,		SYS_getrlimit,	SYS_setrlimit,	-1 /*killpg*/,
75 	0,		0,		0,		-1/*getsockname*/,
76 	SYS_getmsg,	SYS_putmsg,	-1 /*poll*/,	0,
77 	-1/*nfssvc*/,	-1 /*getdirentries*/, SYS_statfs, SYS_fstatfs,
78 	-1/*SYS_umount*/, -1 /*async_daemmon*/ -1 /*getfh*/, -1/*getdomain*/,
79 	-1/*setdomain*/, 0,		-1 /*quotactl*/, -1 /*exportfs*/,
80 	SYS_mount,	-1/*ustat*/,	SYS_semsys,	SYS_msgsys,
81 	SYS_shmsys,	-1 /*auditsys*/, -1 /*rfsys*/,	SYS_getdents,
82 	-1 /*setsid*/,	SYS_fchdir,	SYS_fchroot,	-1 /*vpixsys*/,
83 	-1 /*aioread*/,	-1 /*aiowrite*/, -1 /*aiocancel*/, SYS_sigpending,
84 	0,		-1 /*setpgid*/, SYS_pathconf,	SYS_uname,
85 };
86 
87 int
88 syscall(int sysnum, ...)
89 {
90 	va_list ap;
91 	int i1, i2, i3, i4;
92 	char *c1, *c2, *c3, *c4;
93 	int	ret_val;
94 
95 	va_start(ap, sysnum);
96 	switch(sysnum) {
97 		case XSYS_read:
98 			i1 = va_arg(ap, int);
99 			c1 = va_arg(ap, char *);
100 			i2 = va_arg(ap, int);
101 			va_end(ap);
102 			return (bc_read(i1, c1, i2));
103 		case XSYS_write:
104 			i1 = va_arg(ap, int);
105 			c1 = va_arg(ap, char *);
106 			i2 = va_arg(ap, int);
107 			va_end(ap);
108 			return (bc_write(i1, c1, i2));
109 		case XSYS_readv:
110 			i1 = va_arg(ap, int);
111 			c1 = va_arg(ap, char *);
112 			i2 = va_arg(ap, int);
113 			va_end(ap);
114 			return (bc_readv(i1, c1, i2));
115 		case XSYS_writev:
116 			i1 = va_arg(ap, int);
117 			c1 = va_arg(ap, char *);
118 			i2 = va_arg(ap, int);
119 			va_end(ap);
120 			return (bc_writev(i1, c1, i2));
121 		case XSYS_open:
122 			c1 = va_arg(ap, char *);
123 			i1 = va_arg(ap, int);
124 			i2 = va_arg(ap, int);
125 			va_end(ap);
126 			if (i2)
127 				return (bc_open(c1, i1, i2));
128 			else
129 				return (bc_open(c1, i1));
130 		case XSYS_close:
131 			i1 = va_arg(ap, int);
132 			va_end(ap);
133 			return (bc_close(i1));
134 		case XSYS_fcntl:
135 			i1 = va_arg(ap, int);
136 			i2 = va_arg(ap, int);
137 			i3 = va_arg(ap, int);
138 			va_end(ap);
139 			return (bc_fcntl(i1, i2, i3));
140 		case XSYS_select:
141 			i1 = va_arg(ap, int);
142 			c1 = va_arg(ap, char *);
143 			c2 = va_arg(ap, char *);
144 			c3 = va_arg(ap, char *);
145 			c4 = va_arg(ap, char *);
146 			va_end(ap);
147 			return (select(i1, c1, c2, c3, c4));
148 		case XSYS_ioctl :
149 			i1 = va_arg(ap, int);
150 			i2 = va_arg(ap, int);
151 			c1 = va_arg(ap, char *);
152 			va_end(ap);
153 			return (bc_ioctl(i1, i2, c1));
154 		case XSYS_stat:
155 			c1 = va_arg(ap, char *);
156 			c2 = va_arg(ap, char *);
157 			va_end(ap);
158 			return (bc_stat(c1, c2));
159 		case XSYS_lstat:
160 			c1 = va_arg(ap, char *);
161 			c2 = va_arg(ap, char *);
162 			va_end(ap);
163 			return (bc_lstat(c1, c2));
164 		case XSYS_fstat:
165 			i1 = va_arg(ap, int);
166 			c1 = va_arg(ap, char *);
167 			va_end(ap);
168 			return (bc_fstat(i1, c1));
169         	case XSYS_getdents:
170 			i1 = va_arg(ap, int);
171 			c1 = va_arg(ap, char *);
172 			i2 = va_arg(ap, int);
173 			va_end(ap);
174 			return (bc_getdents(i1, c1, i2));
175 		case XSYS_kill:
176 			i1 = va_arg(ap, int);
177 			i2 = va_arg(ap, int);
178 			va_end(ap);
179 			return (bc_kill(i1, i2));
180 		case XSYS_mount:
181 			c1 = va_arg(ap, char *);
182 			c2 = va_arg(ap, char *);
183 			i1 = va_arg(ap, int);
184 			c3 = va_arg(ap, char *);
185 			va_end(ap);
186 			return (mount(c1, c2, i1, c3));
187 		case XSYS_getrlimit:
188 			i1 = va_arg(ap, int);
189 			c1 = va_arg(ap, char *);
190 			va_end(ap);
191 			return (bc_getrlimit(i1, c1));
192 		case XSYS_setrlimit:
193 			i1 = va_arg(ap, int);
194 			c1 = va_arg(ap, char *);
195 			va_end(ap);
196 			return (bc_setrlimit(i1, c1));
197 		case XSYS_uname:
198 			c1 = va_arg(ap, char *);
199 			va_end(ap);
200 			return (bc_uname(c1));
201 		case XSYS_creat:
202 			c1 = va_arg(ap, char *);
203 			i1 = va_arg(ap, int);
204 			va_end(ap);
205 			return (creat(c1, i1));
206 		case XSYS_unmount:
207 			c1 = va_arg(ap, char *);
208 			va_end(ap);
209 			return (umount(c1));
210 		case XSYS_link:
211 			c1 = va_arg(ap, char *);
212 			c2 = va_arg(ap, char *);
213 			va_end(ap);
214 			return (link(c1, c2));
215 		case XSYS_unlink:
216 			c1 = va_arg(ap, char *);
217 			va_end(ap);
218 			return (unlink(c1));
219 		case XSYS_chdir:
220 			c1 = va_arg(ap, char *);
221 			va_end(ap);
222 			return (chdir(c1));
223 		case XSYS_mknod:
224 			c1 = va_arg(ap, char *);
225 			i1 = va_arg(ap, int);
226 			i2 = va_arg(ap, int);
227 			va_end(ap);
228 			return (mknod(c1, i1, i2));
229 		case XSYS_chmod:
230 			c1 = va_arg(ap, char *);
231 			i1 = va_arg(ap, int);
232 			va_end(ap);
233 			return (chmod(c1, i1));
234 		case XSYS_chown:
235 			c1 = va_arg(ap, char *);
236 			i1 = va_arg(ap, int);
237 			i2 = va_arg(ap, int);
238 			va_end(ap);
239 			return (chown(c1, i1, i2));
240 		case XSYS_lseek:
241 			i1 = va_arg(ap, int);
242 			i2 = va_arg(ap, int);
243 			i3 = va_arg(ap, int);
244 			va_end(ap);
245 			return (lseek(i1, i2, i3));
246 		case XSYS_access:
247 			c1 = va_arg(ap, char *);
248 			i1 = va_arg(ap, int);
249 			va_end(ap);
250 			return (access(c1, i1));
251         	case XSYS_dup:
252 			i1 = va_arg(ap, int);
253 			va_end(ap);
254 			return (dup(i1));
255 		case XSYS_dup2:
256 			i1 = va_arg(ap, int);
257 			i2 = va_arg(ap, int);
258 			va_end(ap);
259 			return (dup2(i1, i2));
260 		case XSYS_pipe:
261 			c1 = (char *)va_arg(ap, int *);
262 			va_end(ap);
263 			return (pipe(c1));
264 		case XSYS_symlink:
265 			c1 = va_arg(ap, char *);
266 			c2 = va_arg(ap, char *);
267 			va_end(ap);
268 			return (symlink(c1, c2));
269 		case XSYS_readlink:
270 			c1 = va_arg(ap, char *);
271 			c2 = va_arg(ap, char *);
272 			i1 = va_arg(ap, int);
273 			va_end(ap);
274 			return (readlink(c1, c2, i1));
275 		case XSYS_execve:
276 			c1 = va_arg(ap, char *);
277 			c2 = (char *)va_arg(ap, char **);
278 			c3 = (char *)va_arg(ap, char **);
279 			va_end(ap);
280 			return (execve(c1, c2, c3));
281 		case XSYS_chroot:
282 			c1 = va_arg(ap, char *);
283 			va_end(ap);
284 			return (chroot(c1));
285 		case XSYS_getgroups:
286 			i1 = va_arg(ap, int);
287 			c1 = (char *)va_arg(ap, int *);
288 			va_end(ap);
289 			return (getgroups(i1, c1));
290 		case XSYS_setgroups:
291 			i1 = va_arg(ap, int);
292 			c1 = (char *)va_arg(ap, int *);
293 			va_end(ap);
294 			return (setgroups(i1, c1));
295 		case XSYS_fsync:
296 			i1 = va_arg(ap, int);
297 			va_end(ap);
298 			return (fsync(i1));
299 		case XSYS_gettimeofday:
300 			c1 = va_arg(ap, char *);
301 			c2 = va_arg(ap, char *);
302 			va_end(ap);
303 			return (gettimeofday(c1, c2));
304 		case XSYS_settimeofday:
305 			c1 = va_arg(ap, char *);
306 			c2 = va_arg(ap, char *);
307 			va_end(ap);
308 			return (settimeofday(c1, c2));
309 		case XSYS_rename:
310 			c1 = va_arg(ap, char *);
311 			c2 = va_arg(ap, char *);
312 			va_end(ap);
313 			return (rename(c1, c2));
314 		case XSYS_mkdir:
315 			c1 = va_arg(ap, char *);
316 			i1 = va_arg(ap, int);
317 			va_end(ap);
318 			return (mkdir(c1, i1));
319 		case XSYS_rmdir:
320 			c1 = va_arg(ap, char *);
321 			va_end(ap);
322 			return (rmdir(c1));
323         	case XSYS_statfs:
324 			c1 = va_arg(ap, char *);
325 			c2 = va_arg(ap, char *);
326 			va_end(ap);
327 			return (statfs(c1, c2));
328 		case XSYS_fstatfs:
329 			i1 = va_arg(ap, int);
330 			c1 = va_arg(ap, char *);
331 			va_end(ap);
332 			return (fstatfs(i1, c1));
333 		case XSYS_getpagesize:
334 			va_end(ap);
335 			return (getpagesize());
336 		case XSYS_gethostid:
337 			va_end(ap);
338 			return (gethostid());
339 		case XSYS_getdtablesize:
340 			va_end(ap);
341 			return (getdtablesize());
342 		case XSYS_pathconf:
343 			c1 = va_arg(ap, char *);
344 			i1 = va_arg(ap, int);
345 			va_end(ap);
346 			return (pathconf(c1, i1));
347 		case XSYS_gethostname:
348 			c1 = va_arg(ap, char *);
349 			i1 = va_arg(ap, int);
350 			va_end(ap);
351 			return (gethostname(c1, i1));
352 		case XSYS_sethostname:
353 			c1 = va_arg(ap, char *);
354 			i1 = va_arg(ap, int);
355 			va_end(ap);
356 			return (sethostname(c1, i1));
357 		case XSYS_setreuid:
358 			i1 = va_arg(ap, int);
359 			i2 = va_arg(ap, int);
360 			va_end(ap);
361 			return (setreuid(i1, i2));
362 		case XSYS_setregid:
363 			i1 = va_arg(ap, int);
364 			i2 = va_arg(ap, int);
365 			va_end(ap);
366 			return (setregid(i1, i2));
367 		case XSYS_getpriority:
368 			i1 = va_arg(ap, int);
369 			i2 = va_arg(ap, int);
370 			va_end(ap);
371 			return (getpriority(i1, i2));
372 		case XSYS_setpriority:
373 			i1 = va_arg(ap, int);
374 			i2 = va_arg(ap, int);
375 			i3 = va_arg(ap, int);
376 			va_end(ap);
377 			return (setpriority(i1, i2, i3));
378 		case XSYS_sigvec:
379 			i1 = va_arg(ap, int);
380 			c1 = va_arg(ap, char *);
381 			c2 = va_arg(ap, char *);
382 			va_end(ap);
383 			return (sigvec(i1, c1, c2));
384 		case XSYS_sigblock:
385 			i1 = va_arg(ap, int);
386 			va_end(ap);
387 			return (sigblock(i1));
388 		case XSYS_sigpending:
389 			c1 = va_arg(ap, char *);
390 			va_end(ap);
391 			return (sigpending(c1));
392 		case XSYS_sigsetmask:
393 			i1 = va_arg(ap, int);
394 			va_end(ap);
395 			return (sigsetmask(i1));
396 		case XSYS_sigpause:
397 			c1 = va_arg(ap, char *);
398 			va_end(ap);
399 			return (sigpause(c1));
400 		case XSYS_sigstack:
401 			c1 = va_arg(ap, char *);
402 			c2 = va_arg(ap, char *);
403 			va_end(ap);
404 			return (sigstack(c1, c2));
405 		case XSYS_truncate:
406 			c1 = va_arg(ap, char *);
407 			i1 = va_arg(ap, int);
408 			va_end(ap);
409 			return (truncate(c1, i1));
410 		case XSYS_ftruncate:
411 			i1 = va_arg(ap, int);
412 			i2 = va_arg(ap, int);
413 			va_end(ap);
414 			return (ftruncate(i1, i2));
415 		case XSYS_killpg:
416 			i1 = va_arg(ap, int);
417 			i2 = va_arg(ap, int);
418 			va_end(ap);
419 			return (killpg(i1, i2));
420 		case XSYS_setpgid:
421 			i1 = va_arg(ap, int);
422 			i2 = va_arg(ap, int);
423 			va_end(ap);
424 			return (setpgid(i1, i2));
425 		case XSYS_ptrace:
426 			i1 = va_arg(ap, int);
427 			i2 = va_arg(ap, int);
428 			i3 = va_arg(ap, int);
429 			c1 = va_arg(ap, char *);
430 			i4 = va_arg(ap, int);
431 			c2 = va_arg(ap, char *);
432 			va_end(ap);
433 			return (ptrace(i1, i2, i3, c1, i4, c2));
434 #ifdef S5EMUL
435 		case XSYS_getpgrp:
436 			va_end(ap);
437 			return (getpgrp());
438 		case XSYS_setpgrp:
439 			va_end(ap);
440 			return (setpgrp());
441 #else
442 		case XSYS_getpgrp:
443 			i1 = va_arg(ap, int);
444 			va_end(ap);
445 			return (getpgrp(i1));
446 		case XSYS_setpgrp:
447 			i1 = va_arg(ap, int);
448 			i2 = va_arg(ap, int);
449 			va_end(ap);
450 			return (setpgrp(i1, i2));
451 #endif
452 		case XSYS_getrusage:
453 			i1 = va_arg(ap, int);
454 			c1 = va_arg(ap, char *);
455 			va_end(ap);
456 			return (getrusage(i1, c1));
457 		case XSYS_setsid:
458 			va_end(ap);
459 			return (setsid());
460 
461 		case XSYS_flock:
462 			i1 = va_arg(ap, int);
463 			i2 = va_arg(ap, int);
464 			va_end(ap);
465 			return (flock(i1, i2));
466 		case XSYS_utimes:
467 			c1 = va_arg(ap, char *);
468 			c2 = va_arg(ap, char *);
469 			va_end(ap);
470 			return (utimes(c1, c2));
471 		case XSYS_poll:
472 			c1 = va_arg(ap, char *);
473 			i2 = va_arg(ap, int);
474 			i3 = va_arg(ap, int);
475 			va_end(ap);
476 			return (poll(c1, i2, i3));
477 		case XSYS_fchown:
478 			i1 = va_arg(ap, int);
479 			i2 = va_arg(ap, int);
480 			i3 = va_arg(ap, int);
481 			va_end(ap);
482 			return (fchown(i1, i2, i3));
483 		case XSYS_fork:
484 			va_end(ap);
485 			return (fork1());
486 
487 		/* the following system calls are now implemented in
488 		 * libsocket */
489 		case XSYS_accept:
490 			i1 = va_arg(ap, int);
491 			c1 = va_arg(ap, char *);
492 			c2 = (char *)va_arg(ap, int *);
493 			va_end(ap);
494 			return (_accept(i1, c1, c2));
495 		case XSYS_bind:
496 			i1 = va_arg(ap, int);
497 			c1 = va_arg(ap, char *);
498 			i2 = va_arg(ap, int);
499 			va_end(ap);
500 			return (_bind(i1, c1, i2));
501 		case XSYS_connect:
502 			i1 = va_arg(ap, int);
503 			c1 = va_arg(ap, char *);
504 			i2 = va_arg(ap, int);
505 			va_end(ap);
506 			return (_connect(i1, c1, i2));
507 		case XSYS_getsockopt:
508 			i1 = va_arg(ap, int);
509 			i2 = va_arg(ap, int);
510 			i3 = va_arg(ap, int);
511 			c1 = va_arg(ap, char *);
512 			c2 = va_arg(ap, char *);
513 			va_end(ap);
514 			return (_getsockopt(i1, i2, i3, c1, c2));
515 		case XSYS_getpeername:
516 			i1 = va_arg(ap, int);
517 			c1 = va_arg(ap, char *);
518 			c2 = va_arg(ap, char *);
519 			va_end(ap);
520 			return (_getpeername(i1, c1, c2));
521 		case XSYS_getsockname:
522 			i1 = va_arg(ap, int);
523 			c1 = va_arg(ap, char *);
524 			c2 = va_arg(ap, char *);
525 			va_end(ap);
526 			return (_getsockname(i1, c1, c2));
527 		case XSYS_getdomainname:
528 			c1 = va_arg(ap, char *);
529 			i1 = va_arg(ap, int);
530 			va_end(ap);
531 			return (getdomainname(c1, i1));
532 		case XSYS_listen:
533 			i1 = va_arg(ap, int);
534 			i2 = va_arg(ap, int);
535 			va_end(ap);
536 			return (_listen(i1, i2));
537 		case XSYS_recv:
538 			i1 = va_arg(ap, int);
539 			c1 = va_arg(ap, char *);
540 			i2 = va_arg(ap, int);
541 			i3 = va_arg(ap, int);
542 			va_end(ap);
543 			return (_recv(i1, c1, i2, i3));
544 		case XSYS_recvfrom:
545 			i1 = va_arg(ap, int);
546 			c1 = va_arg(ap, char *);
547 			i2 = va_arg(ap, int);
548 			i3 = va_arg(ap, int);
549 			c2 = va_arg(ap, char *);
550 			c3 = va_arg(ap, char *);
551 			va_end(ap);
552 			return (_recvfrom(i1, c1, i2, i3, c2, c3));
553 		case XSYS_recvmsg:
554 			i1 = va_arg(ap, int);
555 			c1 = va_arg(ap, char *);
556 			i2 = va_arg(ap, int);
557 			va_end(ap);
558 			return (_recvmsg(i1, c1, i2));
559 		case XSYS_send:
560 			i1 = va_arg(ap, int);
561 			c1 = va_arg(ap, char *);
562 			i2 = va_arg(ap, int);
563 			i3 = va_arg(ap, int);
564 			va_end(ap);
565 			return (_send(i1, c1, i2, i3));
566 		case XSYS_sendto:
567 			i1 = va_arg(ap, int);
568 			c1 = va_arg(ap, char *);
569 			i2 = va_arg(ap, int);
570 			i3 = va_arg(ap, int);
571 			c2 = va_arg(ap, char *);
572 			i4 = va_arg(ap, int);
573 			va_end(ap);
574 			return (_sendto(i1, c1, i2, i3, c2, i4));
575 		case XSYS_sendmsg:
576 			i1 = va_arg(ap, int);
577 			c1 = va_arg(ap, char *);
578 			i2 = va_arg(ap, int);
579 			va_end(ap);
580 			return (_sendmsg(i1, c1, i2));
581 		case XSYS_setdomainname:
582 			c1 = va_arg(ap, char *);
583 			i1 = va_arg(ap, int);
584 			va_end(ap);
585 			return (setdomainname(c1 ,i1));
586 		case XSYS_setsockopt:
587 			i1 = va_arg(ap, int);
588 			i2 = va_arg(ap, int);
589 			i3 = va_arg(ap, int);
590 			c1 = va_arg(ap, char *);
591 			i4 = va_arg(ap, int);
592 			va_end(ap);
593 			return (_setsockopt(i1, i2, i3, c1, i4));
594 		case XSYS_shutdown:
595 			i1 = va_arg(ap, int);
596 			i2 = va_arg(ap, int);
597 			va_end(ap);
598 			return (_shutdown(i1, i2));
599 		case XSYS_socket:
600 			i1 = va_arg(ap, int);
601 			i2 = va_arg(ap, int);
602 			i3 = va_arg(ap, int);
603 			va_end(ap);
604 			return (_socket(i1, i2, i3));
605 		case XSYS_socketpair:
606 			i1 = va_arg(ap, int);
607 			i2 = va_arg(ap, int);
608 			i3 = va_arg(ap, int);
609 			c1 = va_arg(ap, char *);
610 			va_end(ap);
611 			return (_socketpair(i1, i2, i3, c1));
612 
613 
614 		/* The following can directly go through syscall */
615 		case XSYS_acct:
616 		case XSYS_adjtime:
617 		case XSYS_exit:
618 		case XSYS_fchdir:
619 		case XSYS_fchmod:
620 		case XSYS_fchroot:
621 		case XSYS_getgid:
622 		case XSYS_getitimer:
623 		case XSYS_getmsg:
624 		case XSYS_getpid:
625 		case XSYS_getuid:
626 		case XSYS_mincore:
627 		case XSYS_mprotect:
628 		case XSYS_munmap:
629 		case XSYS_putmsg:
630 		case XSYS_profil:
631 		case XSYS_setitimer:
632 		case XSYS_sync:
633 		case XSYS_umask:
634 		case XSYS_semsys:
635 		case XSYS_msgsys:
636 		case XSYS_shmsys:
637 		case XSYS_mmap:
638 		case XSYS_vhangup:
639 			ret_val = _syscall(syscallnum[sysnum], ap);
640 			va_end(ap);
641 			return (ret_val);
642 
643 		case XSYS_aioread:
644 		case XSYS_aiowrite:
645 		case XSYS_aiocancel:
646 		case XSYS_swapon:
647 		case XSYS_async_daemon:
648 		case XSYS_getfh:
649 		case XSYS_nfssvc:
650 		case XSYS_exportfs:
651 		case XSYS_auditsys:
652         	case XSYS_vpixsys:
653 		case XSYS_quotactl:
654 		case XSYS_getdopt:
655 		case XSYS_setdopt:
656 		case XSYS_ustat:
657 		case XSYS_vtrace:
658 		case XSYS_reboot:
659 		case XSYS_madvise:
660 		case XSYS_vadvise:
661 		case XSYS_getdirentries:
662 			va_end(ap);
663 			fprintf(stderr,"system call not supported\n");
664 			return(-1);
665 	}
666 	va_end(ap);
667 	return (-1);
668 }
669