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