xref: /titanic_41/usr/src/uts/common/os/sysent.c (revision 0a44ef6d9afbfe052a7e975f55ea0d2954b62a82)
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 /* ONC_PLUS EXTRACT START */
23 /*
24  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
29 /*	  All Rights Reserved  	*/
30 
31 /* ONC_PLUS EXTRACT END */
32 
33 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.51	*/
34 
35 #include <sys/param.h>
36 #include <sys/types.h>
37 #include <sys/systm.h>
38 #include <sys/systrace.h>
39 #include <sys/procfs.h>
40 
41 /* ONC_PLUS EXTRACT START */
42 /*
43  * This table is the switch used to transfer to the appropriate
44  * routine for processing a system call.  Each row contains the
45  * number of arguments expected, a switch that tells systrap()
46  * in trap.c whether a setjmp() is not necessary, and a pointer
47  * to the routine.
48  */
49 /* ONC_PLUS EXTRACT END */
50 
51 int	access();
52 int	alarm();
53 int	auditsys();
54 int64_t	brandsys();
55 int	brk();
56 int	chdir();
57 int	chmod();
58 int	chown();
59 int	chroot();
60 int	cladm();
61 int	close();
62 int	creat();
63 int	dup();
64 int	exec();
65 int	exece();
66 int	fcntl();
67 int64_t	forkall();
68 int64_t	fork1();
69 int	fstat();
70 int	fsat32();
71 int	fdsync();
72 int64_t	getgid();
73 int	ucredsys();
74 int64_t	getpid();
75 int64_t	getuid();
76 time_t	gtime();
77 int	getloadavg();
78 int	rusagesys();
79 int	getpagesizes();
80 int	gtty();
81 #if defined(__i386) || defined(__amd64)
82 int	hrtsys();
83 #endif /* __i386 || __amd64 */
84 int	ioctl();
85 int	issetugid();
86 int	kill();
87 int	labelsys();
88 int	link();
89 off32_t	lseek32();
90 off_t	lseek64();
91 int	lgrpsys();
92 int	mknod();
93 int	mount();
94 int	nice();
95 int	nullsys();
96 int	open();
97 int	pause();
98 long	pcsample();
99 int	privsys();
100 int	profil();
101 ssize_t	pread();
102 ssize_t	pwrite();
103 ssize_t	read();
104 int	rename();
105 void	rexit();
106 int	semsys();
107 int	setgid();
108 int	setpgrp();
109 int	setuid();
110 uintptr_t	shmsys();
111 int	ssig();
112 int	sigprocmask();
113 int	sigsuspend();
114 int	sigaltstack();
115 int	sigaction();
116 int	sigpending();
117 int	sigtimedwait();
118 int	getsetcontext();
119 int	stat();
120 int	stime();
121 int	stty();
122 int	syssync();
123 int	sysacct();
124 clock_t	times();
125 long	ulimit();
126 int	getrlimit32();
127 int	setrlimit32();
128 int	umask();
129 int	umount();
130 int	umount2();
131 int	unlink();
132 int	utime();
133 int64_t	utssys32();
134 int64_t	utssys64();
135 int	uucopy();
136 ssize_t	uucopystr();
137 int64_t	wait();
138 ssize_t	write();
139 ssize_t	readv();
140 ssize_t	writev();
141 int	syslwp_park();
142 int	rmdir();
143 int	mkdir();
144 int	getdents32();
145 int	statfs32();
146 int	fstatfs32();
147 int	sysfs();
148 int	getmsg();
149 int	poll();
150 int	pollsys();
151 int	putmsg();
152 int	uadmin();
153 int	lstat();
154 int	symlink();
155 ssize_t	readlink();
156 int	resolvepath();
157 int	setgroups();
158 int	getgroups();
159 int	fchdir();
160 int	fchown();
161 int	fchmod();
162 int	getcwd();
163 int	statvfs();
164 int	fstatvfs();
165 offset_t llseek32();
166 
167 #if (defined(__i386) && !defined(__amd64)) || defined(__i386_COMPAT)
168 int	sysi86();
169 #endif
170 
171 int	acl();
172 int	facl();
173 long	priocntlsys();
174 int	waitsys();
175 int	sigsendsys();
176 int	mincore();
177 caddr_t	smmap64();
178 caddr_t smmap32();
179 int	smmaplf32();
180 int	mprotect();
181 int	munmap();
182 int64_t	vfork();
183 #if (defined(__i386) && !defined(__amd64)) || defined(__i386_COMPAT)
184 int	xstat();
185 int	lxstat();
186 int	fxstat();
187 int	xmknod();
188 #endif
189 int	uname();
190 int	lchown();
191 int	getpmsg();
192 int	putpmsg();
193 int	memcntl();
194 long	sysconfig();
195 int	adjtime();
196 long	systeminfo();
197 int	setegid();
198 int	seteuid();
199 
200 int	setreuid();
201 int	setregid();
202 int	install_utrap();
203 #ifdef __sparc
204 int	sparc_utrap_install();
205 #endif
206 
207 int	syslwp_create();
208 void	syslwp_exit();
209 int	syslwp_suspend();
210 int	syslwp_continue();
211 int	syslwp_private();
212 int	lwp_detach();
213 int	lwp_info();
214 int	lwp_kill();
215 int	lwp_self();
216 int64_t	lwp_sigmask();
217 int	yield();
218 int	lwp_wait();
219 int	lwp_mutex_lock();
220 int	lwp_mutex_timedlock();
221 int	lwp_mutex_wakeup();
222 int	lwp_mutex_unlock();
223 int	lwp_mutex_trylock();
224 int	lwp_mutex_init();
225 int	lwp_rwlock_sys();
226 int	lwp_sema_post();
227 int	lwp_sema_wait();
228 int	lwp_sema_timedwait();
229 int	lwp_sema_trywait();
230 int	lwp_cond_wait();
231 int	lwp_cond_signal();
232 int	lwp_cond_broadcast();
233 caddr_t	schedctl();
234 
235 long	pathconf();
236 long	fpathconf();
237 int	processor_bind();
238 int	processor_info();
239 int	p_online();
240 
241 /*
242  *	POSIX .4 system calls *
243  */
244 int	clock_gettime();
245 int	clock_settime();
246 int	clock_getres();
247 int	timer_create();
248 int	timer_delete();
249 int	timer_settime();
250 int	timer_gettime();
251 int	timer_getoverrun();
252 int	nanosleep();
253 int	sigqueue();
254 int	signotify();
255 
256 int	getdents64();
257 int	stat64();
258 int	fsat64();
259 int	lstat64();
260 int	fstatat64();
261 int	fstat64();
262 int	statvfs64();
263 int	fstatvfs64();
264 int	setrlimit64();
265 int	getrlimit64();
266 int	pread64();
267 int	pwrite64();
268 int	creat64();
269 int	open64();
270 
271 /*
272  * NTP syscalls
273  */
274 
275 int ntp_gettime();
276 int ntp_adjtime();
277 
278 /*
279  *	++++++++++++++++++++++++
280  *	++  SunOS4.1 Buyback  ++
281  *	++++++++++++++++++++++++
282  *
283  *	fchroot, utimes, vhangup, gettimeofday
284  */
285 
286 int	fchroot();
287 int	utimes();
288 int	vhangup();
289 int	gettimeofday();
290 int	getitimer();
291 int	setitimer();
292 
293 int	corectl();
294 int	modctl();
295 int64_t loadable_syscall();
296 int64_t indir();
297 
298 long	tasksys();
299 long	rctlsys();
300 
301 long	zone();
302 
303 int	so_socket();
304 int	so_socketpair();
305 int	bind();
306 int	listen();
307 int	accept();
308 int	connect();
309 int	shutdown();
310 ssize_t	recv();
311 ssize_t	recvfrom();
312 ssize_t	recvmsg();
313 ssize_t	send();
314 ssize_t	sendmsg();
315 ssize_t	sendto();
316 int	getpeername();
317 int	getsockname();
318 int	getsockopt();
319 int	setsockopt();
320 int	sockconfig();
321 ssize_t	sendfilev();
322 
323 typedef int64_t	(*llfcn_t)();	/* for casting one-word returns */
324 
325 /*
326  * Sysent initialization macros.
327  * 	These take the name string of the system call even though that isn't
328  *	currently used in the sysent entry.  This might be useful someday.
329  *
330  * Initialization macro for system calls which take their args in the C style.
331  * These system calls return the longlong_t return value and must call
332  * set_errno() to return an error.  For SPARC, narg must be at most six.
333  * For more args, use the SYSENT_AP() routine.
334  *
335  * We are able to return two distinct values to userland via the rval_t.
336  * At this time, that corresponds to one 64-bit quantity, or two 32-bit
337  * quantities.  The kernel does not currently need to return two 64-bit
338  * values, or one 128 bit value(!), but we may do one day, so the calling
339  * sequence between userland and the kernel should permit it.
340  *
341  * The interpretation of rval_t is provided by the sy_flags field
342  * which is used to determine how to arrange the results in registers
343  * (or on the stack) for return userland.
344  */
345 	/* returns a 64-bit quantity for both ABIs */
346 #define	SYSENT_C(name, call, narg)	\
347 	{ (narg), SE_64RVAL, NULL, NULL, (llfcn_t)(call) }
348 
349 	/* returns one 32-bit value for both ABIs: r_val1 */
350 #define	SYSENT_CI(name, call, narg)	\
351 	{ (narg), SE_32RVAL1, NULL, NULL, (llfcn_t)(call) }
352 
353 	/* returns 2 32-bit values: r_val1 & r_val2 */
354 #define	SYSENT_2CI(name, call, narg)	\
355 	{ (narg), SE_32RVAL1|SE_32RVAL2, NULL, NULL, (llfcn_t)(call) }
356 
357 /*
358  * Initialization macro for system calls which take their args in the standard
359  * Unix style of a pointer to the arg structure and a pointer to the rval_t.
360  *
361  * Deprecated wherever possible (slower on some architectures, and trickier
362  * to maintain two flavours).
363  */
364 #define	SYSENT_AP(name, call, narg)	\
365 	{ (narg), SE_64RVAL, (call), NULL, syscall_ap }
366 
367 /*
368  * Conditional constructors to build the tables without #ifdef clutter
369  */
370 #if defined(_LP64)
371 #define	IF_LP64(true, false)	true
372 #else
373 #define	IF_LP64(true, false)	false
374 #endif
375 
376 #if defined(__sparc)
377 #define	IF_sparc(true, false)	true
378 #else
379 #define	IF_sparc(true, false)	false
380 #endif
381 
382 #if defined(__i386) && !defined(__amd64)
383 #define	IF_i386(true, false)	true
384 #else
385 #define	IF_i386(true, false)	false
386 #endif
387 
388 #if defined(__i386) || defined(__amd64)
389 #define	IF_x86(true, false)	true
390 #else
391 #define	IF_x86(true, false)	false
392 #endif
393 
394 #if (defined(__i386) && !defined(__amd64)) || defined(__i386_COMPAT)
395 #define	IF_386_ABI(true, false)	true
396 #else
397 #define	IF_386_ABI(true, false)	false
398 #endif
399 
400 /*
401  * Define system calls that return a native 'long' quantity i.e. a 32-bit
402  * or 64-bit integer - depending on how the kernel is itself compiled
403  * e.g. read(2) returns 'ssize_t' in the kernel and in userland.
404  */
405 #define	SYSENT_CL(name, call, narg)	\
406 	IF_LP64(SYSENT_C(name, call, narg), SYSENT_CI(name, call, narg))
407 
408 /*
409  * Initialization macro for loadable native system calls.
410  */
411 #define	SYSENT_LOADABLE()	\
412 	{ 0, SE_LOADABLE, (int (*)())nosys, NULL, loadable_syscall }
413 /* ONC_PLUS EXTRACT END */
414 
415 /*
416  * Initialization macro for loadable 32-bit compatibility system calls.
417  */
418 #define	SYSENT_LOADABLE32()	SYSENT_LOADABLE()
419 
420 #define	SYSENT_NOSYS()		SYSENT_C("nosys", nosys, 0)
421 
422 struct sysent nosys_ent = SYSENT_NOSYS();
423 
424 /* ONC_PLUS EXTRACT START */
425 /*
426  * Native sysent table.
427  */
428 struct sysent sysent[NSYSCALL] =
429 {
430 /* ONC_PLUS EXTRACT END */
431 	/*  0 */ IF_LP64(
432 			SYSENT_NOSYS(),
433 			SYSENT_C("indir",	indir,		1)),
434 	/*  1 */ SYSENT_CI("exit",		rexit,		1),
435 	/*  2 */ SYSENT_2CI("forkall",		forkall,	0),
436 	/*  3 */ SYSENT_CL("read",		read,		3),
437 	/*  4 */ SYSENT_CL("write",		write,		3),
438 	/*  5 */ SYSENT_CI("open",		open,		3),
439 	/*  6 */ SYSENT_CI("close",		close,		1),
440 	/*  7 */ SYSENT_2CI("wait",		wait,		0),
441 	/*  8 */ SYSENT_CI("creat",		creat,		2),
442 	/*  9 */ SYSENT_CI("link",		link,		2),
443 	/* 10 */ SYSENT_CI("unlink",		unlink,		1),
444 	/* 11 */ SYSENT_CI("exec",		exec,		2),
445 	/* 12 */ SYSENT_CI("chdir",		chdir,		1),
446 	/* 13 */ SYSENT_CL("time",		gtime,		0),
447 	/* 14 */ SYSENT_CI("mknod",		mknod,		3),
448 	/* 15 */ SYSENT_CI("chmod",		chmod,		2),
449 	/* 16 */ SYSENT_CI("chown",		chown,		3),
450 	/* 17 */ SYSENT_CI("brk",		brk,		1),
451 	/* 18 */ SYSENT_CI("stat",		stat,		2),
452 	/* 19 */ IF_LP64(
453 			SYSENT_CL("lseek",	lseek64,	3),
454 			SYSENT_CL("lseek",	lseek32,	3)),
455 	/* 20 */ SYSENT_2CI("getpid",		getpid,		0),
456 	/* 21 */ SYSENT_AP("mount",		mount,		8),
457 	/* 22 */ SYSENT_CI("umount",		umount,		1),
458 	/* 23 */ SYSENT_CI("setuid",		setuid,		1),
459 	/* 24 */ SYSENT_2CI("getuid",		getuid,		0),
460 	/* 25 */ SYSENT_CI("stime",		stime,		1),
461 	/* 26 */ SYSENT_CL("pcsample",		pcsample,	2),
462 	/* 27 */ SYSENT_CI("alarm",		alarm,		1),
463 	/* 28 */ SYSENT_CI("fstat",		fstat,		2),
464 	/* 29 */ SYSENT_CI("pause",		pause,		0),
465 	/* 30 */ SYSENT_CI("utime",		utime,		2),
466 	/* 31 */ SYSENT_CI("stty",		stty,		2),
467 	/* 32 */ SYSENT_CI("gtty",		gtty,		2),
468 	/* 33 */ SYSENT_CI("access",		access,		2),
469 	/* 34 */ SYSENT_CI("nice",		nice,		1),
470 	/* 35 */ IF_LP64(
471 			SYSENT_NOSYS(),
472 			SYSENT_CI("statfs",	statfs32,	4)),
473 	/* 36 */ SYSENT_CI("sync",		syssync,	0),
474 	/* 37 */ SYSENT_CI("kill",		kill,		2),
475 	/* 38 */ IF_LP64(
476 			SYSENT_NOSYS(),
477 			SYSENT_CI("fstatfs",	fstatfs32,	4)),
478 	/* 39 */ SYSENT_CI("setpgrp",		setpgrp,	3),
479 	/* 40 */ SYSENT_CI("uucopystr",		uucopystr,	3),
480 	/* 41 */ SYSENT_CI("dup",		dup,		1),
481 	/* 42 */ SYSENT_LOADABLE(),			/* (was pipe ) */
482 	/* 43 */ SYSENT_CL("times",		times,		1),
483 	/* 44 */ SYSENT_CI("prof",		profil,		4),
484 	/* 45 */ SYSENT_LOADABLE(),			/* (was proc lock) */
485 	/* 46 */ SYSENT_CI("setgid",		setgid,		1),
486 	/* 47 */ SYSENT_2CI("getgid",		getgid,		0),
487 	/* 48 */ SYSENT_CI("sig",		ssig,		2),
488 	/* 49 */ SYSENT_LOADABLE(),			/* (was msgsys) */
489 	/* 50 */ IF_x86(
490 			SYSENT_CI("sysi86",	sysi86,		4),
491 			SYSENT_LOADABLE()),		/* (was sys3b) */
492 	/* 51 */ SYSENT_LOADABLE(),			/* sysacct */
493 	/* 52 */ SYSENT_LOADABLE(),			/* shmsys */
494 	/* 53 */ SYSENT_LOADABLE(),			/* semsys */
495 	/* 54 */ SYSENT_CI("ioctl",		ioctl,		3),
496 	/* 55 */ SYSENT_CI("uadmin",		uadmin,		3),
497 	/* 56 */ SYSENT_LOADABLE(),
498 	/* 57 */ IF_LP64(
499 			SYSENT_2CI("utssys",	utssys64,	4),
500 			SYSENT_2CI("utssys",	utssys32,	4)),
501 	/* 58 */ SYSENT_CI("fdsync",		fdsync,		2),
502 	/* 59 */ SYSENT_CI("exece",		exece,		3),
503 	/* 60 */ SYSENT_CI("umask",		umask,		1),
504 	/* 61 */ SYSENT_CI("chroot",		chroot,		1),
505 	/* 62 */ SYSENT_CI("fcntl",		fcntl,		3),
506 	/* 63 */ SYSENT_CI("ulimit",		ulimit,		2),
507 
508 	/*
509 	 * The following 6 entries were reserved for the UNIX PC.
510 	 */
511 	/* 64 */ SYSENT_LOADABLE(),
512 	/* 65 */ SYSENT_LOADABLE(),
513 	/* 66 */ SYSENT_LOADABLE(),
514 	/* 67 */ SYSENT_LOADABLE(),		/* file locking call */
515 	/* 68 */ SYSENT_LOADABLE(),		/* local system calls */
516 	/* 69 */ SYSENT_LOADABLE(),		/* inode open */
517 
518 	/* 70 */ SYSENT_CI("tasksys",		tasksys,	5),
519 	/* 71 */ SYSENT_LOADABLE(),		/* acctctl */
520 	/* 72 */ SYSENT_LOADABLE(),		/* exacct */
521 	/* 73 */ SYSENT_CI("getpagesizes",	getpagesizes,	2),
522 	/* 74 */ SYSENT_CI("rctlsys",		rctlsys,	6),
523 	/* 75 */ SYSENT_CI("issetugid",		issetugid,	0),
524 	/* 76 */ IF_LP64(
525 			SYSENT_CI("fsat",	fsat64,		6),
526 			SYSENT_CI("fsat",	fsat32,		6)),
527 	/* 77 */ SYSENT_CI("lwp_park",		syslwp_park,	3),
528 	/* 78 */ SYSENT_CL("sendfilev",		sendfilev,	5),
529 	/* 79 */ SYSENT_CI("rmdir",		rmdir,		1),
530 	/* 80 */ SYSENT_CI("mkdir",		mkdir,		2),
531 	/* 81 */ IF_LP64(
532 			SYSENT_CI("getdents",	getdents64,	3),
533 			SYSENT_CI("getdents",	getdents32,	3)),
534 	/* 82 */ SYSENT_CI("privsys",		privsys,	5),
535 	/* 83 */ SYSENT_CI("ucredsys",		ucredsys,	3),
536 	/* 84 */ SYSENT_CI("sysfs",		sysfs,		3),
537 	/* 85 */ SYSENT_CI("getmsg",		getmsg,		4),
538 	/* 86 */ SYSENT_CI("putmsg",		putmsg,		4),
539 	/* 87 */ SYSENT_CI("poll",		poll,		3),
540 	/* 88 */ SYSENT_CI("lstat",		lstat,		2),
541 	/* 89 */ SYSENT_CI("symlink",		symlink,	2),
542 	/* 90 */ SYSENT_CL("readlink",		readlink,	3),
543 	/* 91 */ SYSENT_CI("setgroups",		setgroups,	2),
544 	/* 92 */ SYSENT_CI("getgroups",		getgroups,	2),
545 	/* 93 */ SYSENT_CI("fchmod",		fchmod,		2),
546 	/* 94 */ SYSENT_CI("fchown",		fchown,		3),
547 	/* 95 */ SYSENT_CI("sigprocmask",	sigprocmask,	3),
548 	/* 96 */ SYSENT_CI("sigsuspend",	sigsuspend,	1),
549 	/* 97 */ SYSENT_CI("sigaltstack",	sigaltstack,	2),
550 	/* 98 */ SYSENT_CI("sigaction",		sigaction,	3),
551 	/* 99 */ SYSENT_CI("sigpending",	sigpending,	2),
552 
553 	/* 100 */ SYSENT_CI("getsetcontext",	getsetcontext,	2),
554 	/* 101 */ SYSENT_LOADABLE(),		/* (was evsys) */
555 	/* 102 */ SYSENT_LOADABLE(),		/* (was evtrapret) */
556 	/* 103 */ SYSENT_CI("statvfs",		statvfs,	2),
557 	/* 104 */ SYSENT_CI("fstatvfs",		fstatvfs,	2),
558 	/* 105 */ SYSENT_CI("getloadavg",	getloadavg,	2),
559 /* ONC_PLUS EXTRACT START */
560 	/* 106 */ SYSENT_LOADABLE(),		/* nfssys */
561 /* ONC_PLUS EXTRACT END */
562 	/* 107 */ SYSENT_CI("waitsys",		waitsys,	4),
563 	/* 108 */ SYSENT_CI("sigsendset",	sigsendsys,	2),
564 	/* 109 */ IF_x86(
565 			SYSENT_AP("hrtsys",	hrtsys,		5),
566 			SYSENT_LOADABLE()),
567 	/* 110 */ SYSENT_LOADABLE(),		/* was acancel */
568 	/* 111 */ SYSENT_LOADABLE(),		/* was async */
569 	/* 112 */ SYSENT_CL("priocntlsys",	priocntlsys,	5),
570 	/* 113 */ SYSENT_CL("pathconf",		pathconf,	2),
571 	/* 114 */ SYSENT_CI("mincore",		mincore,	3),
572 	/* 115 */ IF_LP64(
573 			SYSENT_CL("mmap",	smmap64,	6),
574 			SYSENT_CL("mmap",	smmap32,	6)),
575 	/* 116 */ SYSENT_CI("mprotect",		mprotect,	3),
576 	/* 117 */ SYSENT_CI("munmap",		munmap,		2),
577 	/* 118 */ SYSENT_CL("fpathconf",	fpathconf,	2),
578 	/* 119 */ SYSENT_2CI("vfork",		vfork,		0),
579 	/* 120 */ SYSENT_CI("fchdir",		fchdir,		1),
580 	/* 121 */ SYSENT_CL("readv",		readv,		3),
581 	/* 122 */ SYSENT_CL("writev",		writev,		3),
582 	/* 123 */ IF_LP64(
583 			SYSENT_NOSYS(),
584 			IF_i386(
585 				SYSENT_CI("xstat",	xstat,	3),
586 				SYSENT_NOSYS())),
587 	/* 124 */ IF_LP64(
588 			SYSENT_NOSYS(),
589 			IF_i386(
590 				SYSENT_CI("lxstat",	lxstat,	3),
591 				SYSENT_NOSYS())),
592 	/* 125 */ IF_LP64(
593 			SYSENT_NOSYS(),
594 			IF_i386(
595 				SYSENT_CI("fxstat",	fxstat,	3),
596 				SYSENT_NOSYS())),
597 	/* 126 */ IF_LP64(
598 			SYSENT_NOSYS(),
599 			IF_i386(
600 				SYSENT_CI("xmknod",	xmknod,	4),
601 				SYSENT_NOSYS())),
602 	/* 127 */ SYSENT_LOADABLE(),		/* was clocal */
603 	/* 128 */ IF_LP64(
604 			SYSENT_CI("setrlimit",	setrlimit64,	2),
605 			SYSENT_CI("setrlimit",	setrlimit32,	2)),
606 	/* 129 */ IF_LP64(
607 			SYSENT_CI("getrlimit",	getrlimit64,	2),
608 			SYSENT_CI("getrlimit",	getrlimit32,	2)),
609 	/* 130 */ SYSENT_CI("lchown",		lchown,		3),
610 	/* 131 */ SYSENT_CI("memcntl",		memcntl,	6),
611 	/* 132 */ SYSENT_CI("getpmsg",		getpmsg,	5),
612 	/* 133 */ SYSENT_CI("putpmsg",		putpmsg,	5),
613 	/* 134 */ SYSENT_CI("rename",		rename,		2),
614 	/* 135 */ SYSENT_CI("uname",		uname,		1),
615 	/* 136 */ SYSENT_CI("setegid",		setegid,	1),
616 	/* 137 */ SYSENT_CL("sysconfig",	sysconfig,	1),
617 	/* 138 */ SYSENT_CI("adjtime",		adjtime,	2),
618 	/* 139 */ SYSENT_CL("systeminfo",	systeminfo,	3),
619 	/* 140 */ SYSENT_LOADABLE(),		/* reserved */
620 	/* 141 */ SYSENT_CI("seteuid",		seteuid,	1),
621 	/* 142 */ SYSENT_LOADABLE(),		/* reserved */
622 	/* 143 */ SYSENT_2CI("fork1",		fork1,		0),
623 	/* 144 */ SYSENT_CI("sigtimedwait",	sigtimedwait,	3),
624 	/* 145 */ SYSENT_CI("lwp_info",		lwp_info,	1),
625 	/* 146 */ SYSENT_CI("yield",		yield,		0),
626 	/* 147 */ SYSENT_CI("lwp_sema_wait",	lwp_sema_wait,	1),
627 	/* 148 */ SYSENT_CI("lwp_sema_post",	lwp_sema_post,	1),
628 	/* 149 */ SYSENT_CI("lwp_sema_trywait",	lwp_sema_trywait, 1),
629 	/* 150 */ SYSENT_CI("lwp_detach",	lwp_detach,	1),
630 	/* 151 */ SYSENT_CI("corectl",		corectl,	4),
631 	/* 152 */ SYSENT_CI("modctl",		modctl,		6),
632 	/* 153 */ SYSENT_CI("fchroot",		fchroot,	1),
633 	/* 154 */ SYSENT_CI("utimes",		utimes,		2),
634 	/* 155 */ SYSENT_CI("vhangup",		vhangup,	0),
635 	/* 156 */ SYSENT_CI("gettimeofday",	gettimeofday,	1),
636 	/* 157 */ SYSENT_CI("getitimer",	getitimer,	2),
637 	/* 158 */ SYSENT_CI("setitimer",	setitimer,	3),
638 	/* 159 */ SYSENT_CI("lwp_create",	syslwp_create,	3),
639 	/* 160 */ SYSENT_CI("lwp_exit",	(int (*)())syslwp_exit,	0),
640 	/* 161 */ SYSENT_CI("lwp_suspend",	syslwp_suspend,	1),
641 	/* 162 */ SYSENT_CI("lwp_continue",	syslwp_continue, 1),
642 	/* 163 */ SYSENT_CI("lwp_kill",		lwp_kill,	2),
643 	/* 164 */ SYSENT_CI("lwp_self",		lwp_self,	0),
644 	/* 165 */ SYSENT_2CI("lwp_sigmask",	lwp_sigmask,	3),
645 	/* 166 */ IF_x86(
646 			SYSENT_CI("lwp_private", syslwp_private, 3),
647 			SYSENT_NOSYS()),
648 	/* 167 */ SYSENT_CI("lwp_wait",		lwp_wait,	2),
649 	/* 168 */ SYSENT_CI("lwp_mutex_wakeup",	lwp_mutex_wakeup,	1),
650 	/* 169 */ SYSENT_CI("lwp_mutex_lock",	lwp_mutex_lock,		1),
651 	/* 170 */ SYSENT_CI("lwp_cond_wait",	lwp_cond_wait,		4),
652 	/* 171 */ SYSENT_CI("lwp_cond_signal",	lwp_cond_signal,	1),
653 	/* 172 */ SYSENT_CI("lwp_cond_broadcast", lwp_cond_broadcast,	1),
654 	/* 173 */ SYSENT_CL("pread",		pread,		4),
655 	/* 174 */ SYSENT_CL("pwrite ",		pwrite,		4),
656 	/*
657 	 * The 64-bit C library maps llseek() to lseek(), so this
658 	 * is needed as a native syscall only on the 32-bit kernel.
659 	 */
660 	/* 175 */ IF_LP64(
661 			SYSENT_NOSYS(),
662 			SYSENT_C("llseek",	llseek32,	4)),
663 	/* 176 */ SYSENT_LOADABLE(),		/* inst_sync */
664 	/* 177 */ SYSENT_CI("brandsys",		brandsys,	6),
665 	/* 178 */ SYSENT_LOADABLE(),		/* kaio */
666 	/* 179 */ SYSENT_LOADABLE(),		/* cpc */
667 	/* 180 */ SYSENT_CI("lgrpsys",		lgrpsys,	3),
668 	/* 181 */ SYSENT_CI("rusagesys",	rusagesys, 	2),
669 	/* 182 */ SYSENT_LOADABLE(),		/* portfs */
670 	/* 183 */ SYSENT_CI("pollsys",		pollsys,	4),
671 	/* 184 */ SYSENT_CI("labelsys",		labelsys,	5),
672 	/* 185 */ SYSENT_CI("acl",		acl,		4),
673 	/* 186 */ SYSENT_AP("auditsys",		auditsys,	2),
674 	/* 187 */ SYSENT_CI("processor_bind",	processor_bind,	4),
675 	/* 188 */ SYSENT_CI("processor_info",	processor_info,	2),
676 	/* 189 */ SYSENT_CI("p_online",		p_online,	2),
677 	/* 190 */ SYSENT_CI("sigqueue",		sigqueue,	5),
678 	/* 191 */ SYSENT_CI("clock_gettime",	clock_gettime,	2),
679 	/* 192 */ SYSENT_CI("clock_settime",	clock_settime,	2),
680 	/* 193 */ SYSENT_CI("clock_getres",	clock_getres,	2),
681 	/* 194 */ SYSENT_CI("timer_create",	timer_create,	3),
682 	/* 195 */ SYSENT_CI("timer_delete",	timer_delete,	1),
683 	/* 196 */ SYSENT_CI("timer_settime",	timer_settime,	4),
684 	/* 197 */ SYSENT_CI("timer_gettime",	timer_gettime,	2),
685 	/* 198 */ SYSENT_CI("timer_getoverrun",	timer_getoverrun, 1),
686 	/* 199 */ SYSENT_CI("nanosleep",	nanosleep,	2),
687 	/* 200 */ SYSENT_CI("facl",		facl,		4),
688 	/* 201 */ SYSENT_LOADABLE(),		/* door */
689 	/* 202 */ SYSENT_CI("setreuid",		setreuid,	2),
690 	/* 203 */ SYSENT_CI("setregid",		setregid,	2),
691 	/* 204 */ SYSENT_CI("install_utrap",	install_utrap,	3),
692 	/* 205 */ SYSENT_CI("signotify",	signotify,	3),
693 	/* 206 */ SYSENT_CL("schedctl",		schedctl,	0),
694 	/* 207 */ SYSENT_LOADABLE(),		/* pset */
695 	/* 208 */ IF_sparc(
696 		SYSENT_CI("sparc_utrap_install", sparc_utrap_install, 5),
697 		SYSENT_NOSYS()),
698 	/* 209 */ SYSENT_CI("resolvepath",	resolvepath,	3),
699 	/* 210 */ SYSENT_CI("lwp_mutex_timedlock", lwp_mutex_timedlock,	2),
700 	/* 211 */ SYSENT_CI("lwp_sema_timedwait", lwp_sema_timedwait,	3),
701 	/* 212 */ SYSENT_CI("lwp_rwlock_sys",	lwp_rwlock_sys,	3),
702 	/*
703 	 * Syscalls 213-225: 32-bit system call support for large files.
704 	 *
705 	 * (The 64-bit C library transparently maps these system calls
706 	 * back to their native versions, so almost all of them are only
707 	 * needed as native syscalls on the 32-bit kernel).
708 	 */
709 	/* 213 */ IF_LP64(
710 			SYSENT_NOSYS(),
711 			SYSENT_CI("getdents64",	getdents64,	3)),
712 	/* 214 */ IF_LP64(
713 			SYSENT_NOSYS(),
714 			SYSENT_AP("smmaplf32",	smmaplf32,	7)),
715 	/* 215 */ IF_LP64(
716 			SYSENT_NOSYS(),
717 			SYSENT_CI("stat64",	stat64, 	2)),
718 	/* 216 */ IF_LP64(
719 			SYSENT_NOSYS(),
720 			SYSENT_CI("lstat64",	lstat64,	2)),
721 	/* 217 */ IF_LP64(
722 			SYSENT_NOSYS(),
723 			SYSENT_CI("fstat64", 	fstat64, 	2)),
724 	/* 218 */ IF_LP64(
725 			SYSENT_NOSYS(),
726 			SYSENT_CI("statvfs64", 	statvfs64, 	2)),
727 	/* 219 */ IF_LP64(
728 			SYSENT_NOSYS(),
729 			SYSENT_CI("fstatvfs64",	fstatvfs64, 	2)),
730 	/* 220 */ IF_LP64(
731 			SYSENT_NOSYS(),
732 			SYSENT_CI("setrlimit64", setrlimit64, 	2)),
733 	/* 221 */ IF_LP64(
734 			SYSENT_NOSYS(),
735 			SYSENT_CI("getrlimit64", getrlimit64, 	2)),
736 	/* 222 */ IF_LP64(
737 			SYSENT_NOSYS(),
738 			SYSENT_CI("pread64",	pread64, 	5)),
739 	/* 223 */ IF_LP64(
740 			SYSENT_NOSYS(),
741 			SYSENT_CI("pwrite64", 	pwrite64, 	5)),
742 	/* 224 */ IF_LP64(
743 			SYSENT_NOSYS(),
744 			SYSENT_CI("creat64",	creat64,	2)),
745 	/* 225 */ IF_LP64(
746 			SYSENT_NOSYS(),
747 			SYSENT_CI("open64",	open64,		3)),
748 	/* 226 */ SYSENT_LOADABLE(),		/* rpcsys */
749 	/* 227 */ SYSENT_CL("zone",		zone,		5),
750 	/* 228 */ SYSENT_LOADABLE(),		/* autofssys */
751 	/* 229 */ SYSENT_CI("getcwd",		getcwd,		2),
752 	/* 230 */ SYSENT_CI("so_socket",	so_socket,	5),
753 	/* 231 */ SYSENT_CI("so_socketpair",	so_socketpair,	1),
754 	/* 232 */ SYSENT_CI("bind",		bind,		4),
755 	/* 233 */ SYSENT_CI("listen",		listen,		3),
756 	/* 234 */ SYSENT_CI("accept",		accept,		4),
757 	/* 235 */ SYSENT_CI("connect",		connect,	4),
758 	/* 236 */ SYSENT_CI("shutdown",		shutdown,	3),
759 	/* 237 */ SYSENT_CL("recv",		recv,		4),
760 	/* 238 */ SYSENT_CL("recvfrom",		recvfrom,	6),
761 	/* 239 */ SYSENT_CL("recvmsg",		recvmsg,	3),
762 	/* 240 */ SYSENT_CL("send",		send,		4),
763 	/* 241 */ SYSENT_CL("sendmsg",		sendmsg,	3),
764 	/* 242 */ SYSENT_CL("sendto",		sendto,		6),
765 	/* 243 */ SYSENT_CI("getpeername",	getpeername,	4),
766 	/* 244 */ SYSENT_CI("getsockname",	getsockname,	4),
767 	/* 245 */ SYSENT_CI("getsockopt",	getsockopt,	6),
768 	/* 246 */ SYSENT_CI("setsockopt",	setsockopt,	6),
769 	/* 247 */ SYSENT_CI("sockconfig",	sockconfig,	4),
770 	/* 248 */ SYSENT_CI("ntp_gettime",	ntp_gettime,	1),
771 	/* 249 */ SYSENT_CI("ntp_adjtime",	ntp_adjtime,	1),
772 	/* 250 */ SYSENT_CI("lwp_mutex_unlock",	lwp_mutex_unlock,	1),
773 	/* 251 */ SYSENT_CI("lwp_mutex_trylock", lwp_mutex_trylock,	1),
774 	/* 252 */ SYSENT_CI("lwp_mutex_init",	lwp_mutex_init,		2),
775 	/* 253 */ SYSENT_CI("cladm",		cladm,		3),
776 	/* 254 */ SYSENT_CI("uucopy",		uucopy,		3),
777 	/* 255 */ SYSENT_CI("umount2",		umount2,	2)
778 /* ONC_PLUS EXTRACT START */
779 };
780 /* ONC_PLUS EXTRACT END */
781 
782 
783 #ifdef _SYSCALL32_IMPL
784 
785 extern int ulimit32();
786 extern ssize_t read32();
787 extern ssize_t write32();
788 extern ssize_t pread32();
789 extern ssize_t pwrite32();
790 extern ssize_t readv32();
791 extern ssize_t writev32();
792 extern ssize_t readlink32();
793 extern int open32();
794 extern int creat32();
795 #if (defined(__i386) && !defined(__amd64)) || defined(__i386_COMPAT)
796 extern int xstat32();
797 extern int lxstat32();
798 extern int fxstat32();
799 #endif
800 extern int stat32();
801 extern int fstatat32();
802 extern int lstat32();
803 extern int fstat32();
804 extern int fstatat64_32();
805 extern int stat64_32();
806 extern int lstat64_32();
807 extern int fstat64_32();
808 extern int getmsg32();
809 extern int putmsg32();
810 extern int getpmsg32();
811 extern int putpmsg32();
812 extern int getsetcontext32();
813 extern int statvfs32();
814 extern int fstatvfs32();
815 extern int statvfs64_32();
816 extern int fstatvfs64_32();
817 extern int sigaction32();
818 extern clock32_t times32();
819 extern int stime32();
820 extern int getpagesizes32();
821 extern int sigaltstack32();
822 extern int sigqueue32();
823 extern offset_t	llseek32();
824 extern int waitsys32();
825 
826 extern ssize_t recv32();
827 extern ssize_t recvfrom32();
828 extern ssize_t send32();
829 extern ssize_t sendto32();
830 
831 extern int privsys32();
832 extern int ucredsys32();
833 
834 /* ONC_PLUS EXTRACT START */
835 /*
836  * sysent table for ILP32 processes running on
837  * a LP64 kernel.
838  */
839 struct sysent sysent32[NSYSCALL] =
840 {
841 /* ONC_PLUS EXTRACT END */
842 	/*  0 */ SYSENT_C("indir",		indir,		1),
843 	/*  1 */ SYSENT_CI("exit",	(int (*)())rexit,	1),
844 	/*  2 */ SYSENT_2CI("forkall",		forkall,	0),
845 	/*  3 */ SYSENT_CI("read",		read32,		3),
846 	/*  4 */ SYSENT_CI("write",		write32,	3),
847 	/*  5 */ SYSENT_CI("open",		open32,		3),
848 	/*  6 */ SYSENT_CI("close",		close,		1),
849 	/*  7 */ SYSENT_2CI("wait",		wait,		0),
850 	/*  8 */ SYSENT_CI("creat",		creat32,	2),
851 	/*  9 */ SYSENT_CI("link",		link,		2),
852 	/* 10 */ SYSENT_CI("unlink",		unlink,		1),
853 	/* 11 */ SYSENT_CI("exec",		exec,		2),
854 	/* 12 */ SYSENT_CI("chdir",		chdir,		1),
855 	/* 13 */ SYSENT_CI("time",		gtime,		0),
856 	/* 14 */ SYSENT_CI("mknod",		mknod,		3),
857 	/* 15 */ SYSENT_CI("chmod",		chmod,		2),
858 	/* 16 */ SYSENT_CI("chown",		chown,		3),
859 	/* 17 */ SYSENT_CI("brk",		brk,		1),
860 	/* 18 */ SYSENT_CI("stat",		stat32,		2),
861 	/* 19 */ SYSENT_CI("lseek",		lseek32,	3),
862 	/* 20 */ SYSENT_2CI("getpid",		getpid,		0),
863 	/* 21 */ SYSENT_AP("mount",		mount,		8),
864 	/* 22 */ SYSENT_CI("umount",		umount,		1),
865 	/* 23 */ SYSENT_CI("setuid",		setuid,		1),
866 	/* 24 */ SYSENT_2CI("getuid",		getuid,		0),
867 	/* 25 */ SYSENT_CI("stime",		stime32,	1),
868 	/* 26 */ SYSENT_CI("pcsample",		pcsample,	2),
869 	/* 27 */ SYSENT_CI("alarm",		alarm,		1),
870 	/* 28 */ SYSENT_CI("fstat",		fstat32,	2),
871 	/* 29 */ SYSENT_CI("pause",		pause,		0),
872 	/* 30 */ SYSENT_CI("utime",		utime,		2),
873 	/* 31 */ SYSENT_CI("stty",		stty,		2),
874 	/* 32 */ SYSENT_CI("gtty",		gtty,		2),
875 	/* 33 */ SYSENT_CI("access",		access,		2),
876 	/* 34 */ SYSENT_CI("nice",		nice,		1),
877 	/* 35 */ SYSENT_CI("statfs",		statfs32,	4),
878 	/* 36 */ SYSENT_CI("sync",		syssync,	0),
879 	/* 37 */ SYSENT_CI("kill",		kill,		2),
880 	/* 38 */ SYSENT_CI("fstatfs",		fstatfs32,	4),
881 	/* 39 */ SYSENT_CI("setpgrp",		setpgrp,	3),
882 	/* 40 */ SYSENT_CI("uucopystr",		uucopystr,	3),
883 	/* 41 */ SYSENT_CI("dup",		dup,		1),
884 	/* 42 */ SYSENT_LOADABLE32(),			/* (was pipe ) */
885 	/* 43 */ SYSENT_CI("times",		times32,	1),
886 	/* 44 */ SYSENT_CI("prof",		profil,		4),
887 	/* 45 */ SYSENT_LOADABLE32(),			/* (was proc lock) */
888 	/* 46 */ SYSENT_CI("setgid",		setgid,		1),
889 	/* 47 */ SYSENT_2CI("getgid",		getgid,		0),
890 	/* 48 */ SYSENT_CI("sig",		ssig,		2),
891 	/* 49 */ SYSENT_LOADABLE32(),			/* (was msgsys) */
892 	/* 50 */ IF_386_ABI(
893 			SYSENT_CI("sysi86",	sysi86,		4),
894 			SYSENT_LOADABLE()),		/* (was sys3b) */
895 	/* 51 */ SYSENT_LOADABLE32(),			/* sysacct */
896 	/* 52 */ SYSENT_LOADABLE32(),			/* shmsys */
897 	/* 53 */ SYSENT_LOADABLE32(),			/* semsys */
898 	/* 54 */ SYSENT_CI("ioctl",		ioctl,		3),
899 	/* 55 */ SYSENT_CI("uadmin",		uadmin,		3),
900 	/* 56 */ SYSENT_LOADABLE32(),
901 	/* 57 */ SYSENT_2CI("utssys",		utssys32,	4),
902 	/* 58 */ SYSENT_CI("fdsync",		fdsync,		2),
903 	/* 59 */ SYSENT_CI("exece",		exece,		3),
904 	/* 60 */ SYSENT_CI("umask",		umask,		1),
905 	/* 61 */ SYSENT_CI("chroot",		chroot,		1),
906 	/* 62 */ SYSENT_CI("fcntl",		fcntl,		3),
907 	/* 63 */ SYSENT_CI("ulimit",		ulimit32,	2),
908 
909 	/*
910 	 * The following 6 entries were reserved for the UNIX PC.
911 	 */
912 	/* 64 */ SYSENT_LOADABLE32(),
913 	/* 65 */ SYSENT_LOADABLE32(),
914 	/* 66 */ SYSENT_LOADABLE32(),
915 	/* 67 */ SYSENT_LOADABLE32(),		/* file locking call */
916 	/* 68 */ SYSENT_LOADABLE32(),		/* local system calls */
917 	/* 69 */ SYSENT_LOADABLE32(),		/* inode open */
918 
919 	/* 70 */ SYSENT_CI("tasksys",		tasksys,	5),
920 	/* 71 */ SYSENT_LOADABLE32(),		/* acctctl */
921 	/* 72 */ SYSENT_LOADABLE32(),		/* exacct */
922 	/* 73 */ SYSENT_CI("getpagesizes",	getpagesizes32,	2),
923 	/* 74 */ SYSENT_CI("rctlsys",		rctlsys,	6),
924 	/* 75 */ SYSENT_CI("issetugid",		issetugid,	0),
925 	/* 76 */ SYSENT_CI("fsat",		fsat32,		6),
926 	/* 77 */ SYSENT_CI("lwp_park",		syslwp_park,	3),
927 	/* 78 */ SYSENT_CI("sendfilev",		sendfilev,	5),
928 	/* 79 */ SYSENT_CI("rmdir",		rmdir,		1),
929 	/* 80 */ SYSENT_CI("mkdir",		mkdir,		2),
930 	/* 81 */ SYSENT_CI("getdents",		getdents32,	3),
931 	/* 82 */ SYSENT_CI("privsys",		privsys32,	5),
932 	/* 83 */ SYSENT_CI("ucredsys",		ucredsys32,	3),
933 	/* 84 */ SYSENT_CI("sysfs",		sysfs,		3),
934 	/* 85 */ SYSENT_CI("getmsg",		getmsg32,	4),
935 	/* 86 */ SYSENT_CI("putmsg",		putmsg32,	4),
936 	/* 87 */ SYSENT_CI("poll",		poll,		3),
937 	/* 88 */ SYSENT_CI("lstat",		lstat32,	2),
938 	/* 89 */ SYSENT_CI("symlink",		symlink,	2),
939 	/* 90 */ SYSENT_CI("readlink",		readlink32,	3),
940 	/* 91 */ SYSENT_CI("setgroups",		setgroups,	2),
941 	/* 92 */ SYSENT_CI("getgroups",		getgroups,	2),
942 	/* 93 */ SYSENT_CI("fchmod",		fchmod,		2),
943 	/* 94 */ SYSENT_CI("fchown",		fchown,		3),
944 	/* 95 */ SYSENT_CI("sigprocmask",	sigprocmask,	3),
945 	/* 96 */ SYSENT_CI("sigsuspend",	sigsuspend,	1),
946 	/* 97 */ SYSENT_CI("sigaltstack",	sigaltstack32,	2),
947 	/* 98 */ SYSENT_CI("sigaction",		sigaction32,	3),
948 	/* 99 */ SYSENT_CI("sigpending",	sigpending,	2),
949 
950 	/* 100 */ SYSENT_CI("getsetcontext",	getsetcontext32, 2),
951 	/* 101 */ SYSENT_LOADABLE32(),		/* (was evsys) */
952 	/* 102 */ SYSENT_LOADABLE32(),		/* (was evtrapret) */
953 	/* 103 */ SYSENT_CI("statvfs",		statvfs32,	2),
954 	/* 104 */ SYSENT_CI("fstatvfs",		fstatvfs32,	2),
955 	/* 105 */ SYSENT_CI("getloadavg",	getloadavg,	2),
956 /* ONC_PLUS EXTRACT START */
957 	/* 106 */ SYSENT_LOADABLE32(),		/* nfssys */
958 /* ONC_PLUS EXTRACT END */
959 	/* 107 */ SYSENT_CI("waitsys",		waitsys32,	4),
960 	/* 108 */ SYSENT_CI("sigsendset",	sigsendsys,	2),
961 	/* 109 */ IF_x86(
962 			SYSENT_AP("hrtsys",	hrtsys,		5),
963 			SYSENT_LOADABLE32()),
964 	/* 110 */ SYSENT_LOADABLE32(),		/* was acancel */
965 	/* 111 */ SYSENT_LOADABLE32(),		/* was async */
966 	/* 112 */ SYSENT_CI("priocntlsys",	priocntlsys,	5),
967 	/* 113 */ SYSENT_CI("pathconf",		pathconf,	2),
968 	/* 114 */ SYSENT_CI("mincore",		mincore,	3),
969 	/* 115 */ SYSENT_CI("mmap",		smmap32,	6),
970 	/* 116 */ SYSENT_CI("mprotect",		mprotect,	3),
971 	/* 117 */ SYSENT_CI("munmap",		munmap,		2),
972 	/* 118 */ SYSENT_CI("fpathconf",	fpathconf,	2),
973 	/* 119 */ SYSENT_2CI("vfork",		vfork,		0),
974 	/* 120 */ SYSENT_CI("fchdir",		fchdir,		1),
975 	/* 121 */ SYSENT_CI("readv",		readv32,	3),
976 	/* 122 */ SYSENT_CI("writev",		writev32,	3),
977 	/* 123 */ IF_386_ABI(
978 			SYSENT_CI("xstat",	xstat32,	3),
979 			SYSENT_NOSYS()),
980 	/* 124 */ IF_386_ABI(
981 			SYSENT_CI("lxstat",	lxstat32,	3),
982 			SYSENT_NOSYS()),
983 	/* 125 */ IF_386_ABI(
984 			SYSENT_CI("fxstat",	fxstat32,	3),
985 			SYSENT_NOSYS()),
986 	/* 126 */ IF_386_ABI(
987 			SYSENT_CI("xmknod",	xmknod,		4),
988 			SYSENT_NOSYS()),
989 	/* 127 */ SYSENT_LOADABLE32(),		/* was clocal */
990 	/* 128 */ SYSENT_CI("setrlimit",	setrlimit32,	2),
991 	/* 129 */ SYSENT_CI("getrlimit",	getrlimit32,	2),
992 	/* 130 */ SYSENT_CI("lchown",		lchown,		3),
993 	/* 131 */ SYSENT_CI("memcntl",		memcntl,	6),
994 	/* 132 */ SYSENT_CI("getpmsg",		getpmsg32,	5),
995 	/* 133 */ SYSENT_CI("putpmsg",		putpmsg32,	5),
996 	/* 134 */ SYSENT_CI("rename",		rename,		2),
997 
998 	/* 135 */ SYSENT_CI("uname",		uname,		1),
999 	/* 136 */ SYSENT_CI("setegid",		setegid,	1),
1000 	/* 137 */ SYSENT_CI("sysconfig",	sysconfig,	1),
1001 	/* 138 */ SYSENT_CI("adjtime",		adjtime,	2),
1002 	/* 139 */ SYSENT_CI("systeminfo",	systeminfo,	3),
1003 	/* 140 */ SYSENT_LOADABLE32(),		/* reserved */
1004 	/* 141 */ SYSENT_CI("seteuid",		seteuid,	1),
1005 	/* 142 */ SYSENT_LOADABLE32(),		/* reserved */
1006 	/* 143 */ SYSENT_2CI("fork1",		fork1,		0),
1007 	/* 144 */ SYSENT_CI("sigtimedwait",	sigtimedwait,	3),
1008 	/* 145 */ SYSENT_CI("lwp_info",		lwp_info,	1),
1009 	/* 146 */ SYSENT_CI("yield",		yield,		0),
1010 	/* 147 */ SYSENT_CI("lwp_sema_wait",	lwp_sema_wait,	1),
1011 	/* 148 */ SYSENT_CI("lwp_sema_post",	lwp_sema_post,	1),
1012 	/* 149 */ SYSENT_CI("lwp_sema_trywait",	lwp_sema_trywait, 1),
1013 	/* 150 */ SYSENT_CI("lwp_detach",	lwp_detach,	1),
1014 	/* 151 */ SYSENT_CI("corectl",		corectl,	4),
1015 	/* 152 */ SYSENT_CI("modctl",		modctl,		6),
1016 	/* 153 */ SYSENT_CI("fchroot",		fchroot,	1),
1017 	/* 154 */ SYSENT_CI("utimes",		utimes,		2),
1018 	/* 155 */ SYSENT_CI("vhangup",		vhangup,	0),
1019 	/* 156 */ SYSENT_CI("gettimeofday",	gettimeofday,	1),
1020 	/* 157 */ SYSENT_CI("getitimer",	getitimer,	2),
1021 	/* 158 */ SYSENT_CI("setitimer",	setitimer,	3),
1022 	/* 159 */ SYSENT_CI("lwp_create",	syslwp_create,	3),
1023 	/* 160 */ SYSENT_CI("lwp_exit",	(int (*)())syslwp_exit,	0),
1024 	/* 161 */ SYSENT_CI("lwp_suspend",	syslwp_suspend,	1),
1025 	/* 162 */ SYSENT_CI("lwp_continue",	syslwp_continue, 1),
1026 	/* 163 */ SYSENT_CI("lwp_kill",		lwp_kill,	2),
1027 	/* 164 */ SYSENT_CI("lwp_self",		lwp_self,	0),
1028 	/* 165 */ SYSENT_2CI("lwp_sigmask",	lwp_sigmask,	3),
1029 	/* 166 */ IF_x86(
1030 			SYSENT_CI("lwp_private", syslwp_private, 3),
1031 			SYSENT_NOSYS()),
1032 	/* 167 */ SYSENT_CI("lwp_wait",		lwp_wait,	2),
1033 	/* 168 */ SYSENT_CI("lwp_mutex_wakeup",	lwp_mutex_wakeup,	1),
1034 	/* 169 */ SYSENT_CI("lwp_mutex_lock",	lwp_mutex_lock,		1),
1035 	/* 170 */ SYSENT_CI("lwp_cond_wait",	lwp_cond_wait,		4),
1036 	/* 171 */ SYSENT_CI("lwp_cond_signal",	lwp_cond_signal,	1),
1037 	/* 172 */ SYSENT_CI("lwp_cond_broadcast", lwp_cond_broadcast,	1),
1038 	/* 173 */ SYSENT_CI("pread",		pread32,		4),
1039 	/* 174 */ SYSENT_CI("pwrite",		pwrite32,		4),
1040 	/* 175 */ SYSENT_C("llseek",		llseek32,	4),
1041 	/* 176 */ SYSENT_LOADABLE32(),		/* inst_sync */
1042 	/* 177 */ SYSENT_CI("brandsys",		brandsys,	6),
1043 	/* 178 */ SYSENT_LOADABLE32(),		/* kaio */
1044 	/* 179 */ SYSENT_LOADABLE32(),		/* cpc */
1045 	/* 180 */ SYSENT_CI("lgrpsys",		lgrpsys,	3),
1046 	/* 181 */ SYSENT_CI("rusagesys",	rusagesys,	2),
1047 	/* 182 */ SYSENT_LOADABLE32(),		/* portfs */
1048 	/* 183 */ SYSENT_CI("pollsys",		pollsys,	4),
1049 	/* 184 */ SYSENT_CI("labelsys",		labelsys,	5),
1050 	/* 185 */ SYSENT_CI("acl",		acl,		4),
1051 	/* 186 */ SYSENT_AP("auditsys",		auditsys,	2),
1052 	/* 187 */ SYSENT_CI("processor_bind",	processor_bind,	4),
1053 	/* 188 */ SYSENT_CI("processor_info",	processor_info,	2),
1054 	/* 189 */ SYSENT_CI("p_online",		p_online,	2),
1055 	/* 190 */ SYSENT_CI("sigqueue",		sigqueue32,	5),
1056 	/* 191 */ SYSENT_CI("clock_gettime",	clock_gettime,	2),
1057 	/* 192 */ SYSENT_CI("clock_settime",	clock_settime,	2),
1058 	/* 193 */ SYSENT_CI("clock_getres",	clock_getres,	2),
1059 	/* 194 */ SYSENT_CI("timer_create",	timer_create,	3),
1060 	/* 195 */ SYSENT_CI("timer_delete",	timer_delete,	1),
1061 	/* 196 */ SYSENT_CI("timer_settime",	timer_settime,	4),
1062 	/* 197 */ SYSENT_CI("timer_gettime",	timer_gettime,	2),
1063 	/* 198 */ SYSENT_CI("timer_getoverrun",	timer_getoverrun, 1),
1064 	/* 199 */ SYSENT_CI("nanosleep",	nanosleep,	2),
1065 	/* 200 */ SYSENT_CI("facl",		facl,		4),
1066 	/* 201 */ SYSENT_LOADABLE32(),		/* door */
1067 	/* 202 */ SYSENT_CI("setreuid",		setreuid,	2),
1068 	/* 203 */ SYSENT_CI("setregid",		setregid,	2),
1069 	/* 204 */ SYSENT_CI("install_utrap",	install_utrap,	3),
1070 	/* 205 */ SYSENT_CI("signotify",	signotify,	3),
1071 	/* 206 */ SYSENT_CI("schedctl",		schedctl,	0),
1072 	/* 207 */ SYSENT_LOADABLE32(),		/* pset */
1073 	/* 208 */ SYSENT_LOADABLE32(),
1074 	/* 209 */ SYSENT_CI("resolvepath",	resolvepath,	3),
1075 	/* 210 */ SYSENT_CI("lwp_mutex_timedlock", lwp_mutex_timedlock, 2),
1076 	/* 211 */ SYSENT_CI("lwp_sema_timedwait", lwp_sema_timedwait,	3),
1077 	/* 212 */ SYSENT_CI("lwp_rwlock_sys",	lwp_rwlock_sys,	3),
1078 	/*
1079 	 * Syscalls 213-225: 32-bit system call support for large files.
1080 	 */
1081 	/* 213 */ SYSENT_CI("getdents64",	getdents64,	3),
1082 	/* 214 */ SYSENT_AP("smmaplf32", 	smmaplf32, 	7),
1083 	/* 215 */ SYSENT_CI("stat64", 		stat64_32, 	2),
1084 	/* 216 */ SYSENT_CI("lstat64", 		lstat64_32,	2),
1085 	/* 217 */ SYSENT_CI("fstat64", 		fstat64_32, 	2),
1086 	/* 218 */ SYSENT_CI("statvfs64", 	statvfs64_32, 	2),
1087 	/* 219 */ SYSENT_CI("fstatvfs64", 	fstatvfs64_32, 	2),
1088 	/* 220 */ SYSENT_CI("setrlimit64", 	setrlimit64, 	2),
1089 	/* 221 */ SYSENT_CI("getrlimit64", 	getrlimit64, 	2),
1090 	/* 222 */ SYSENT_CI("pread64", 		pread64, 	5),
1091 	/* 223 */ SYSENT_CI("pwrite64", 	pwrite64, 	5),
1092 	/* 224 */ SYSENT_CI("creat64",		creat64,	2),
1093 	/* 225 */ SYSENT_CI("open64",		open64,		3),
1094 	/* 226 */ SYSENT_LOADABLE32(),		/* rpcsys */
1095 	/* 227 */ SYSENT_CI("zone",		zone,		6),
1096 	/* 228 */ SYSENT_LOADABLE32(),		/* autofssys */
1097 	/* 229 */ SYSENT_CI("getcwd",		getcwd,		2),
1098 	/* 230 */ SYSENT_CI("so_socket",	so_socket,	5),
1099 	/* 231 */ SYSENT_CI("so_socketpair",	so_socketpair,	1),
1100 	/* 232 */ SYSENT_CI("bind",		bind,		4),
1101 	/* 233 */ SYSENT_CI("listen",		listen,		3),
1102 	/* 234 */ SYSENT_CI("accept",		accept,		4),
1103 	/* 235 */ SYSENT_CI("connect",		connect,	4),
1104 	/* 236 */ SYSENT_CI("shutdown",		shutdown,	3),
1105 	/* 237 */ SYSENT_CI("recv",		recv32,		4),
1106 	/* 238 */ SYSENT_CI("recvfrom",		recvfrom32,	6),
1107 	/* 239 */ SYSENT_CI("recvmsg",		recvmsg,	3),
1108 	/* 240 */ SYSENT_CI("send",		send32,		4),
1109 	/* 241 */ SYSENT_CI("sendmsg",		sendmsg,	3),
1110 	/* 242 */ SYSENT_CI("sendto",		sendto32,	6),
1111 	/* 243 */ SYSENT_CI("getpeername",	getpeername,	4),
1112 	/* 244 */ SYSENT_CI("getsockname",	getsockname,	4),
1113 	/* 245 */ SYSENT_CI("getsockopt",	getsockopt,	6),
1114 	/* 246 */ SYSENT_CI("setsockopt",	setsockopt,	6),
1115 	/* 247 */ SYSENT_CI("sockconfig",	sockconfig,	4),
1116 	/* 248 */ SYSENT_CI("ntp_gettime",	ntp_gettime,	1),
1117 	/* 249 */ SYSENT_CI("ntp_adjtime",	ntp_adjtime,	1),
1118 	/* 250 */ SYSENT_CI("lwp_mutex_unlock",	lwp_mutex_unlock,	1),
1119 	/* 251 */ SYSENT_CI("lwp_mutex_trylock", lwp_mutex_trylock,	1),
1120 	/* 252 */ SYSENT_CI("lwp_mutex_init",	lwp_mutex_init,		2),
1121 	/* 253 */ SYSENT_CI("cladm",		cladm,		3),
1122 	/* 254 */ SYSENT_CI("uucopy",		uucopy,		3),
1123 	/* 255 */ SYSENT_CI("umount2",		umount2,	2)
1124 /* ONC_PLUS EXTRACT START */
1125 };
1126 /* ONC_PLUS EXTRACT END */
1127 #endif /* _SYSCALL32_IMPL */
1128 
1129 /*
1130  * Space allocated and initialized in init_syscallnames().
1131  */
1132 char **syscallnames;
1133 
1134 systrace_sysent_t *systrace_sysent;
1135 void (*systrace_probe)(dtrace_id_t, uintptr_t, uintptr_t,
1136     uintptr_t, uintptr_t, uintptr_t, uintptr_t);
1137 
1138 /*ARGSUSED*/
1139 void
1140 systrace_stub(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1,
1141     uintptr_t arg2, uintptr_t arg3, uintptr_t arg4, uintptr_t arg5)
1142 {}
1143 
1144 /*ARGSUSED*/
1145 int64_t
1146 dtrace_systrace_syscall(uintptr_t arg0, uintptr_t arg1, uintptr_t arg2,
1147     uintptr_t arg3, uintptr_t arg4, uintptr_t arg5)
1148 {
1149 	systrace_sysent_t *sy = &systrace_sysent[curthread->t_sysnum];
1150 	dtrace_id_t id;
1151 	int64_t rval;
1152 	proc_t *p;
1153 
1154 	if ((id = sy->stsy_entry) != DTRACE_IDNONE)
1155 		(*systrace_probe)(id, arg0, arg1, arg2, arg3, arg4, arg5);
1156 
1157 	/*
1158 	 * We want to explicitly allow DTrace consumers to stop a process
1159 	 * before it actually executes the meat of the syscall.
1160 	 */
1161 	p = ttoproc(curthread);
1162 	mutex_enter(&p->p_lock);
1163 	if (curthread->t_dtrace_stop && !curthread->t_lwp->lwp_nostop) {
1164 		curthread->t_dtrace_stop = 0;
1165 		stop(PR_REQUESTED, 0);
1166 	}
1167 	mutex_exit(&p->p_lock);
1168 
1169 	rval = (*sy->stsy_underlying)(arg0, arg1, arg2, arg3, arg4, arg5);
1170 
1171 	if (ttolwp(curthread)->lwp_errno != 0)
1172 		rval = -1;
1173 
1174 	if ((id = sy->stsy_return) != DTRACE_IDNONE)
1175 		(*systrace_probe)(id, (uintptr_t)rval, (uintptr_t)rval,
1176 		    (uintptr_t)((int64_t)rval >> 32), 0, 0, 0);
1177 
1178 	return (rval);
1179 }
1180 
1181 #ifdef _SYSCALL32_IMPL
1182 
1183 systrace_sysent_t *systrace_sysent32;
1184 
1185 /*ARGSUSED*/
1186 int64_t
1187 dtrace_systrace_syscall32(uintptr_t arg0, uintptr_t arg1, uintptr_t arg2,
1188     uintptr_t arg3, uintptr_t arg4, uintptr_t arg5)
1189 {
1190 	systrace_sysent_t *sy = &systrace_sysent32[curthread->t_sysnum];
1191 	dtrace_id_t id;
1192 	int64_t rval;
1193 	proc_t *p;
1194 
1195 	if ((id = sy->stsy_entry) != DTRACE_IDNONE)
1196 		(*systrace_probe)(id, arg0, arg1, arg2, arg3, arg4, arg5);
1197 
1198 	/*
1199 	 * We want to explicitly allow DTrace consumers to stop a process
1200 	 * before it actually executes the meat of the syscall.
1201 	 */
1202 	p = ttoproc(curthread);
1203 	mutex_enter(&p->p_lock);
1204 	if (curthread->t_dtrace_stop && !curthread->t_lwp->lwp_nostop) {
1205 		curthread->t_dtrace_stop = 0;
1206 		stop(PR_REQUESTED, 0);
1207 	}
1208 	mutex_exit(&p->p_lock);
1209 
1210 	rval = (*sy->stsy_underlying)(arg0, arg1, arg2, arg3, arg4, arg5);
1211 
1212 	if (ttolwp(curthread)->lwp_errno != 0)
1213 		rval = -1;
1214 
1215 	if ((id = sy->stsy_return) != DTRACE_IDNONE)
1216 		(*systrace_probe)(id, (uintptr_t)rval, (uintptr_t)rval,
1217 		    (uintptr_t)((uint64_t)rval >> 32), 0, 0, 0);
1218 
1219 	return (rval);
1220 }
1221 
1222 #endif
1223 
1224 void
1225 dtrace_systrace_rtt(void)
1226 {
1227 	systrace_sysent_t *sy;
1228 	dtrace_id_t id;
1229 
1230 	if (get_udatamodel() == DATAMODEL_NATIVE) {
1231 		if (systrace_sysent == NULL)
1232 			return;
1233 
1234 		sy = &systrace_sysent[curthread->t_sysnum];
1235 #ifdef _SYSCALL32_IMPL
1236 	} else {
1237 		if (systrace_sysent32 == NULL)
1238 			return;
1239 
1240 		sy = &systrace_sysent32[curthread->t_sysnum];
1241 #endif
1242 	}
1243 
1244 	if ((id = sy->stsy_return) != DTRACE_IDNONE)
1245 		(*systrace_probe)(id, 0, 0, 0, 0, 0, 0);
1246 }
1247