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.
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.
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]
23 * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
29 #include <sys/syscall.h>
33 * Array of SVR4 system call numbers. The 4.1 numbers are mapped
34 * to their SVR4/5.0 equivalents before trapping into the kernel.
37 int syscallnum
[190] = { SYS_syscall
, SYS_exit
, -1 /*fork1*/,
38 SYS_read
, SYS_write
, -1 /*open*/, SYS_close
,
39 -1, -1 /*creat*/, -1 /*link*/, -1 /*unlink*/,
40 -1, SYS_chdir
, 0, -1 /*mknod*/,
41 -1 /*chmod*/, -1 /*lchown*/, 0, 0,
42 SYS_lseek
, SYS_getpid
, 0, 0,
45 0, 0, -1 /*access*/, 0,
46 0, SYS_sync
, SYS_kill
, -1 /*stat*/,
47 0, -1 /*lstat*/, -1 /*dup*/, SYS_pipe
,
50 SYS_acct
, 0, -1, SYS_ioctl
,
51 -1 /*reboot*/, 0, -1 /*symlink*/, -1 /*readlink*/,
52 SYS_execve
, SYS_umask
, SYS_chroot
, -1 /*fstat*/,
53 0, -1/*getpagesize*/,-1, 0,
55 SYS_mmap
, -1, SYS_munmap
, SYS_mprotect
,
56 -1 /*advise*/, SYS_vhangup
, 0, SYS_mincore
,
57 SYS_getgroups
, SYS_setgroups
, -1 /*getpgrp*/, -1 /*setpgrp*/,
58 SYS_setitimer
, 0, -1 /*swapon*/, SYS_getitimer
,
59 -1/*gethostname*/,-1/*sethostname*/,-1/*getdtablesize*/,-1/*dup2*/,
60 -1/*getdopt*/, SYS_fcntl
, -1 /*select*/, -1 /*setdopt*/,
61 SYS_fdsync
, -1 /*setprio*/, -1 /*socket*/, -1 /*connect*/,
62 -1 /*accept*/, -1 /*getprio*/, -1 /*send*/, -1 /*recv*/,
63 0, -1 /*bind*/, -1 /*setsockopt*/,-1 /*listen*/,
64 0, -1 /*sigvec*/, -1 /*sigblock*/, -1 /*sigsetmask*/,
65 -1 /*sigpause*/, -1 /*sigstack*/, -1 /*recvmsg*/, -1 /*sendmsg*/,
66 -1 /*vtrace*/, SYS_gettimeofday
, -1 /*getrusage*/, -1 /*getsockopt*/,
67 0, SYS_readv
, SYS_writev
, -1 /*settimeofday*/,
68 -1 /*fchown*/, -1 /*fchmod*/, -1 /*recvfrom*/, -1 /*setreuid*/,
69 -1 /*getregid*/, -1 /*rename*/, -1 /*truncate*/, -1 /*ftruncate*/,
70 -1 /*flock*/, 0, -1 /*sendto*/, -1 /*shutdown*/,
71 -1 /*socketpair*/, -1 /*mkdir*/, -1 /*rmdir*/, -1 /*utimes*/,
72 0, SYS_adjtime
, -1 /*getpeername*/,-1 /*gethostid*/,
73 0, SYS_getrlimit
, SYS_setrlimit
, -1 /*killpg*/,
74 0, 0, 0, -1/*getsockname*/,
75 SYS_getmsg
, SYS_putmsg
, -1 /*poll*/, 0,
76 -1/*nfssvc*/, -1 /*getdirentries*/, SYS_statfs
, SYS_fstatfs
,
77 -1/*SYS_umount*/, -1 /*async_daemmon*/ -1 /*getfh*/, -1/*getdomain*/,
78 -1/*setdomain*/, 0, -1 /*quotactl*/, -1 /*exportfs*/,
79 SYS_mount
, -1/*ustat*/, SYS_semsys
, SYS_msgsys
,
80 SYS_shmsys
, -1 /*auditsys*/, -1 /*rfsys*/, SYS_getdents
,
81 -1 /*setsid*/, SYS_fchdir
, SYS_fchroot
, -1 /*vpixsys*/,
82 -1 /*aioread*/, -1 /*aiowrite*/, -1 /*aiocancel*/, SYS_sigpending
,
83 0, -1 /*setpgid*/, SYS_pathconf
, SYS_uname
,
87 syscall(int sysnum
, ...)
91 char *c1
, *c2
, *c3
, *c4
;
98 c1
= va_arg(ap
, char *);
101 return (bc_read(i1
, c1
, i2
));
103 i1
= va_arg(ap
, int);
104 c1
= va_arg(ap
, char *);
105 i2
= va_arg(ap
, int);
107 return (bc_write(i1
, c1
, i2
));
109 i1
= va_arg(ap
, int);
110 c1
= va_arg(ap
, char *);
111 i2
= va_arg(ap
, int);
113 return (bc_readv(i1
, c1
, i2
));
115 i1
= va_arg(ap
, int);
116 c1
= va_arg(ap
, char *);
117 i2
= va_arg(ap
, int);
119 return (bc_writev(i1
, c1
, i2
));
121 c1
= va_arg(ap
, char *);
122 i1
= va_arg(ap
, int);
123 i2
= va_arg(ap
, int);
126 return (bc_open(c1
, i1
, i2
));
128 return (bc_open(c1
, i1
));
130 i1
= va_arg(ap
, int);
132 return (bc_close(i1
));
134 i1
= va_arg(ap
, int);
135 i2
= va_arg(ap
, int);
136 i3
= va_arg(ap
, int);
138 return (bc_fcntl(i1
, i2
, i3
));
140 i1
= va_arg(ap
, int);
141 c1
= va_arg(ap
, char *);
142 c2
= va_arg(ap
, char *);
143 c3
= va_arg(ap
, char *);
144 c4
= va_arg(ap
, char *);
146 return (select(i1
, c1
, c2
, c3
, c4
));
148 i1
= va_arg(ap
, int);
149 i2
= va_arg(ap
, int);
150 c1
= va_arg(ap
, char *);
152 return (bc_ioctl(i1
, i2
, c1
));
154 c1
= va_arg(ap
, char *);
155 c2
= va_arg(ap
, char *);
157 return (bc_stat(c1
, c2
));
159 c1
= va_arg(ap
, char *);
160 c2
= va_arg(ap
, char *);
162 return (bc_lstat(c1
, c2
));
164 i1
= va_arg(ap
, int);
165 c1
= va_arg(ap
, char *);
167 return (bc_fstat(i1
, c1
));
169 i1
= va_arg(ap
, int);
170 c1
= va_arg(ap
, char *);
171 i2
= va_arg(ap
, int);
173 return (bc_getdents(i1
, c1
, i2
));
175 i1
= va_arg(ap
, int);
176 i2
= va_arg(ap
, int);
178 return (bc_kill(i1
, i2
));
180 c1
= va_arg(ap
, char *);
181 c2
= va_arg(ap
, char *);
182 i1
= va_arg(ap
, int);
183 c3
= va_arg(ap
, char *);
185 return (mount(c1
, c2
, i1
, c3
));
187 i1
= va_arg(ap
, int);
188 c1
= va_arg(ap
, char *);
190 return (bc_getrlimit(i1
, c1
));
192 i1
= va_arg(ap
, int);
193 c1
= va_arg(ap
, char *);
195 return (bc_setrlimit(i1
, c1
));
197 c1
= va_arg(ap
, char *);
199 return (bc_uname(c1
));
201 c1
= va_arg(ap
, char *);
202 i1
= va_arg(ap
, int);
204 return (creat(c1
, i1
));
206 c1
= va_arg(ap
, char *);
210 c1
= va_arg(ap
, char *);
211 c2
= va_arg(ap
, char *);
213 return (link(c1
, c2
));
215 c1
= va_arg(ap
, char *);
219 c1
= va_arg(ap
, char *);
223 c1
= va_arg(ap
, char *);
224 i1
= va_arg(ap
, int);
225 i2
= va_arg(ap
, int);
227 return (mknod(c1
, i1
, i2
));
229 c1
= va_arg(ap
, char *);
230 i1
= va_arg(ap
, int);
232 return (chmod(c1
, i1
));
234 c1
= va_arg(ap
, char *);
235 i1
= va_arg(ap
, int);
236 i2
= va_arg(ap
, int);
238 return (chown(c1
, i1
, i2
));
240 i1
= va_arg(ap
, int);
241 i2
= va_arg(ap
, int);
242 i3
= va_arg(ap
, int);
244 return (lseek(i1
, i2
, i3
));
246 c1
= va_arg(ap
, char *);
247 i1
= va_arg(ap
, int);
249 return (access(c1
, i1
));
251 i1
= va_arg(ap
, int);
255 i1
= va_arg(ap
, int);
256 i2
= va_arg(ap
, int);
258 return (dup2(i1
, i2
));
260 c1
= (char *)va_arg(ap
, int *);
264 c1
= va_arg(ap
, char *);
265 c2
= va_arg(ap
, char *);
267 return (symlink(c1
, c2
));
269 c1
= va_arg(ap
, char *);
270 c2
= va_arg(ap
, char *);
271 i1
= va_arg(ap
, int);
273 return (readlink(c1
, c2
, i1
));
275 c1
= va_arg(ap
, char *);
276 c2
= (char *)va_arg(ap
, char **);
277 c3
= (char *)va_arg(ap
, char **);
279 return (execve(c1
, c2
, c3
));
281 c1
= va_arg(ap
, char *);
285 i1
= va_arg(ap
, int);
286 c1
= (char *)va_arg(ap
, int *);
288 return (getgroups(i1
, c1
));
290 i1
= va_arg(ap
, int);
291 c1
= (char *)va_arg(ap
, int *);
293 return (setgroups(i1
, c1
));
295 i1
= va_arg(ap
, int);
298 case XSYS_gettimeofday
:
299 c1
= va_arg(ap
, char *);
300 c2
= va_arg(ap
, char *);
302 return (gettimeofday(c1
, c2
));
303 case XSYS_settimeofday
:
304 c1
= va_arg(ap
, char *);
305 c2
= va_arg(ap
, char *);
307 return (settimeofday(c1
, c2
));
309 c1
= va_arg(ap
, char *);
310 c2
= va_arg(ap
, char *);
312 return (rename(c1
, c2
));
314 c1
= va_arg(ap
, char *);
315 i1
= va_arg(ap
, int);
317 return (mkdir(c1
, i1
));
319 c1
= va_arg(ap
, char *);
323 c1
= va_arg(ap
, char *);
324 c2
= va_arg(ap
, char *);
326 return (statfs(c1
, c2
));
328 i1
= va_arg(ap
, int);
329 c1
= va_arg(ap
, char *);
331 return (fstatfs(i1
, c1
));
332 case XSYS_getpagesize
:
334 return (getpagesize());
337 return (gethostid());
338 case XSYS_getdtablesize
:
340 return (getdtablesize());
342 c1
= va_arg(ap
, char *);
343 i1
= va_arg(ap
, int);
345 return (pathconf(c1
, i1
));
346 case XSYS_gethostname
:
347 c1
= va_arg(ap
, char *);
348 i1
= va_arg(ap
, int);
350 return (gethostname(c1
, i1
));
351 case XSYS_sethostname
:
352 c1
= va_arg(ap
, char *);
353 i1
= va_arg(ap
, int);
355 return (sethostname(c1
, i1
));
357 i1
= va_arg(ap
, int);
358 i2
= va_arg(ap
, int);
360 return (setreuid(i1
, i2
));
362 i1
= va_arg(ap
, int);
363 i2
= va_arg(ap
, int);
365 return (setregid(i1
, i2
));
366 case XSYS_getpriority
:
367 i1
= va_arg(ap
, int);
368 i2
= va_arg(ap
, int);
370 return (getpriority(i1
, i2
));
371 case XSYS_setpriority
:
372 i1
= va_arg(ap
, int);
373 i2
= va_arg(ap
, int);
374 i3
= va_arg(ap
, int);
376 return (setpriority(i1
, i2
, i3
));
378 i1
= va_arg(ap
, int);
379 c1
= va_arg(ap
, char *);
380 c2
= va_arg(ap
, char *);
382 return (sigvec(i1
, c1
, c2
));
384 i1
= va_arg(ap
, int);
386 return (sigblock(i1
));
387 case XSYS_sigpending
:
388 c1
= va_arg(ap
, char *);
390 return (sigpending(c1
));
391 case XSYS_sigsetmask
:
392 i1
= va_arg(ap
, int);
394 return (sigsetmask(i1
));
396 c1
= va_arg(ap
, char *);
398 return (sigpause(c1
));
400 c1
= va_arg(ap
, char *);
401 c2
= va_arg(ap
, char *);
403 return (sigstack(c1
, c2
));
405 c1
= va_arg(ap
, char *);
406 i1
= va_arg(ap
, int);
408 return (truncate(c1
, i1
));
410 i1
= va_arg(ap
, int);
411 i2
= va_arg(ap
, int);
413 return (ftruncate(i1
, i2
));
415 i1
= va_arg(ap
, int);
416 i2
= va_arg(ap
, int);
418 return (killpg(i1
, i2
));
420 i1
= va_arg(ap
, int);
421 i2
= va_arg(ap
, int);
423 return (setpgid(i1
, i2
));
425 i1
= va_arg(ap
, int);
426 i2
= va_arg(ap
, int);
427 i3
= va_arg(ap
, int);
428 c1
= va_arg(ap
, char *);
429 i4
= va_arg(ap
, int);
430 c2
= va_arg(ap
, char *);
432 return (ptrace(i1
, i2
, i3
, c1
, i4
, c2
));
442 i1
= va_arg(ap
, int);
444 return (getpgrp(i1
));
446 i1
= va_arg(ap
, int);
447 i2
= va_arg(ap
, int);
449 return (setpgrp(i1
, i2
));
452 i1
= va_arg(ap
, int);
453 c1
= va_arg(ap
, char *);
455 return (getrusage(i1
, c1
));
461 i1
= va_arg(ap
, int);
462 i2
= va_arg(ap
, int);
464 return (flock(i1
, i2
));
466 c1
= va_arg(ap
, char *);
467 c2
= va_arg(ap
, char *);
469 return (utimes(c1
, c2
));
471 c1
= va_arg(ap
, char *);
472 i2
= va_arg(ap
, int);
473 i3
= va_arg(ap
, int);
475 return (poll(c1
, i2
, i3
));
477 i1
= va_arg(ap
, int);
478 i2
= va_arg(ap
, int);
480 return (fchmod(i1
, i2
));
482 i1
= va_arg(ap
, int);
483 i2
= va_arg(ap
, int);
484 i3
= va_arg(ap
, int);
486 return (fchown(i1
, i2
, i3
));
491 /* the following system calls are now implemented in
494 i1
= va_arg(ap
, int);
495 c1
= va_arg(ap
, char *);
496 c2
= (char *)va_arg(ap
, int *);
498 return (_accept(i1
, c1
, c2
));
500 i1
= va_arg(ap
, int);
501 c1
= va_arg(ap
, char *);
502 i2
= va_arg(ap
, int);
504 return (_bind(i1
, c1
, i2
));
506 i1
= va_arg(ap
, int);
507 c1
= va_arg(ap
, char *);
508 i2
= va_arg(ap
, int);
510 return (_connect(i1
, c1
, i2
));
511 case XSYS_getsockopt
:
512 i1
= va_arg(ap
, int);
513 i2
= va_arg(ap
, int);
514 i3
= va_arg(ap
, int);
515 c1
= va_arg(ap
, char *);
516 c2
= va_arg(ap
, char *);
518 return (_getsockopt(i1
, i2
, i3
, c1
, c2
));
519 case XSYS_getpeername
:
520 i1
= va_arg(ap
, int);
521 c1
= va_arg(ap
, char *);
522 c2
= va_arg(ap
, char *);
524 return (_getpeername(i1
, c1
, c2
));
525 case XSYS_getsockname
:
526 i1
= va_arg(ap
, int);
527 c1
= va_arg(ap
, char *);
528 c2
= va_arg(ap
, char *);
530 return (_getsockname(i1
, c1
, c2
));
531 case XSYS_getdomainname
:
532 c1
= va_arg(ap
, char *);
533 i1
= va_arg(ap
, int);
535 return (getdomainname(c1
, i1
));
537 i1
= va_arg(ap
, int);
538 i2
= va_arg(ap
, int);
540 return (_listen(i1
, i2
));
542 i1
= va_arg(ap
, int);
543 c1
= va_arg(ap
, char *);
544 i2
= va_arg(ap
, int);
545 i3
= va_arg(ap
, int);
547 return (_recv(i1
, c1
, i2
, i3
));
549 i1
= va_arg(ap
, int);
550 c1
= va_arg(ap
, char *);
551 i2
= va_arg(ap
, int);
552 i3
= va_arg(ap
, int);
553 c2
= va_arg(ap
, char *);
554 c3
= va_arg(ap
, char *);
556 return (_recvfrom(i1
, c1
, i2
, i3
, c2
, c3
));
558 i1
= va_arg(ap
, int);
559 c1
= va_arg(ap
, char *);
560 i2
= va_arg(ap
, int);
562 return (_recvmsg(i1
, c1
, i2
));
564 i1
= va_arg(ap
, int);
565 c1
= va_arg(ap
, char *);
566 i2
= va_arg(ap
, int);
567 i3
= va_arg(ap
, int);
569 return (_send(i1
, c1
, i2
, i3
));
571 i1
= va_arg(ap
, int);
572 c1
= va_arg(ap
, char *);
573 i2
= va_arg(ap
, int);
574 i3
= va_arg(ap
, int);
575 c2
= va_arg(ap
, char *);
576 i4
= va_arg(ap
, int);
578 return (_sendto(i1
, c1
, i2
, i3
, c2
, i4
));
580 i1
= va_arg(ap
, int);
581 c1
= va_arg(ap
, char *);
582 i2
= va_arg(ap
, int);
584 return (_sendmsg(i1
, c1
, i2
));
585 case XSYS_setdomainname
:
586 c1
= va_arg(ap
, char *);
587 i1
= va_arg(ap
, int);
589 return (setdomainname(c1
,i1
));
590 case XSYS_setsockopt
:
591 i1
= va_arg(ap
, int);
592 i2
= va_arg(ap
, int);
593 i3
= va_arg(ap
, int);
594 c1
= va_arg(ap
, char *);
595 i4
= va_arg(ap
, int);
597 return (_setsockopt(i1
, i2
, i3
, c1
, i4
));
599 i1
= va_arg(ap
, int);
600 i2
= va_arg(ap
, int);
602 return (_shutdown(i1
, i2
));
604 i1
= va_arg(ap
, int);
605 i2
= va_arg(ap
, int);
606 i3
= va_arg(ap
, int);
608 return (_socket(i1
, i2
, i3
));
609 case XSYS_socketpair
:
610 i1
= va_arg(ap
, int);
611 i2
= va_arg(ap
, int);
612 i3
= va_arg(ap
, int);
613 c1
= va_arg(ap
, char *);
615 return (_socketpair(i1
, i2
, i3
, c1
));
618 /* The following can directly go through syscall */
642 ret_val
= _syscall(syscallnum
[sysnum
], ap
);
650 case XSYS_async_daemon
:
664 case XSYS_getdirentries
:
666 fprintf(stderr
,"system call not supported\n");