1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #include <errno.h>
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <strings.h>
31 #include <unistd.h>
32 #include <sys/auxv.h>
33 #include <sys/bitmap.h>
34 #include <sys/brand.h>
35 #include <sys/inttypes.h>
36 #include <sys/lwp.h>
37 #include <sys/syscall.h>
38 #include <sys/systm.h>
39 #include <sys/utsname.h>
40 
41 #include <sn1_brand.h>
42 #include <sn1_misc.h>
43 
44 /*
45  * Principles of emulation 101.
46  *
47  *
48  * *** Setting errno
49  *
50  * Just don't do it.  This emulation library is loaded onto a
51  * seperate link map from the application who's address space we're
52  * running in.  We have our own private copy of libc, so there for,
53  * the errno value accessible from here is is also private and changing
54  * it will not affect any errno value that the processes who's address
55  * space we are running in will see.  To return an error condition we
56  * should return the negated errno value we'd like the system to return.
57  * For more information about this see the comment in sn1_handler().
58  * Basically, when we return to the caller that initiated the system
59  * call it's their responsibility to set errno.
60  *
61  *
62  * *** Recursion Considerations
63  *
64  * When emulating system calls we need to be very careful about what
65  * library calls we invoke.  Library calls should be kept to a minimum.
66  * One issue is that library calls can invoke system calls, so if we're
67  * emulating a system call and we invoke a library call that depends on
68  * that system call we will probably enter a recursive loop, which would
69  * be bad.
70  *
71  *
72  * *** Return Values.
73  *
74  * When declaring new syscall emulation functions, it is very important
75  * to to set the proper RV_* flags in the sn1_sysent_table.  Upon failure,
76  * syscall emulation fuctions should return an errno value.  Upon success
77  * syscall emulation functions should return 0 and set the sysret_t return
78  * value parameters accordingly.
79  *
80  *
81  * *** Agent lwp considerations
82  *
83  * It is currently impossible to do any emulation for these system call
84  * when they are being invoked on behalf of an agent lwp.  To understand why
85  * it's impossible you have to understand how agent lwp syscalls work.
86  *
87  * The agent lwp syscall process works as follows:
88  *   1  The controlling process stops the target.
89  *   2  The controlling process injects an agent lwp which is also stopped.
90  *      This agent lwp assumes the userland stack and register values
91  *      of another stopped lwp in the current process.
92  *   3  The controlling process configures the agent lwp to start
93  *      executing the requested system call.
94  *   4  The controlling process configure /proc to stop the agent lwp when
95  *      it enters the requested system call.
96  *   5  The controlling processes allows the agent lwp to start executing.
97  *   6  The agent lwp traps into the kernel to perform the requested system
98  *      call and immediately stop.
99  *   7  The controlling process copies all the arguments for the requested
100  *      system call onto the agent lwp's stack.
101  *   8  The controlling process configures /proc to stop the agent lwp
102  *      when it completes the requested system call.
103  *   9  The controlling processes allows the agent lwp to start executing.
104  *  10  The agent lwp executes the system call and then stop before returning
105  *      to userland.
106  *  11  The controlling process copies the return value and return arguments
107  *      back from the agent lwps stack.
108  *  12  The controlling process destroys the agent lwp and restarts
109  *      the target process.
110  *
111  * The fundamental problem is that when the agent executes the request
112  * system call in step 5, if we're emulating that system call then the
113  * lwp is redirected back to our emulation layer without blocking
114  * in the kernel.  But our emulation layer can't access the arguments
115  * for the system call because they haven't been copied to the stack
116  * yet and they still only exist in the controlling processes address
117  * space.  This prevents us from being able to do any emulation of
118  * agent lwp system calls.  Hence, currently our brand trap interposition
119  * callback (sn1_brand_syscall_callback_common) will detect if a system
120  * call is being made by an agent lwp, and if this is the case it will
121  * never redirect the system call to this emulation library.
122  *
123  * In the future, if this proves to be a problem the the easiest solution
124  * would probably be to replace the branded versions of these application
125  * with their native counterparts.  Ie,  truss, plimit, and pfiles could be
126  * replace with wrapper scripts that execute the native versions of these
127  * applications.  In the case of plimit and pfiles this should be pretty
128  * strait forward.  Truss would probably be more tricky since it can
129  * execute applications which would be branded applications, so in that
130  * case it might be necessary to create a loadable library which could
131  * be LD_PRELOADed into truss and this library would interpose on the
132  * exec() system call to allow truss to correctly execute branded
133  * processes.  It should be pointed out that this solution could work
134  * because "native agent lwps" (ie, agent lwps created by native
135  * processes) can be treated differently from "branded aged lwps" (ie,
136  * agent lwps created by branded processes), since native agent lwps
137  * would presumably be making native system calls and hence not need
138  * any interposition.
139  *
140  *
141  * *** sn1 brand emulation scope considerations
142  *
143  * One of the differences between the lx brand and the s8 and s9
144  * brands, is that the s8 and s9 brands only interpose on syscalls
145  * that need some kind of emulation, where as the lx brand interposes
146  * on _all_ system calls.  Lx branded system calls that don't need
147  * any emulation are then redirected back to the kernel from the
148  * userland library via the IN_KERNEL_SYSCALL macro.  The lx-syscall
149  * dtrace provider depends on this behavior.
150  *
151  * Given that the sn1 brand exists for testing purposes, it should
152  * eventually be enhanced to redirect all system calls through the
153  * brand emulation library.  This will ensure the maximum testing
154  * exposure for the brandz infrastructure.  Some other options to
155  * consider for improving brandz test exposure are:
156  * - Folding the sn1 brand into the native brand and only enabling
157  *   it on DEBUG builds.
158  * - Modifying the zones test suite to use sn1 branded zones by default,
159  *   any adapting functional test harnesses to use sn1 branded zones
160  *   by default instead of native zones.
161  */
162 
163 #define	EMULATE(cb, args)	{ (sysent_cb_t)(cb), (args) }
164 #define	NOSYS			EMULATE(sn1_unimpl, (0 | RV_DEFAULT))
165 
166 typedef long (*sysent_cb_t)();
167 typedef struct sn1_sysent_table {
168 	sysent_cb_t	st_callc;
169 	uintptr_t	st_args;
170 } sn1_sysent_table_t;
171 sn1_sysent_table_t sn1_sysent_table[];
172 
173 /*LINTED: static unused*/
174 static volatile int		sn1_abort_err;
175 /*LINTED: static unused*/
176 static volatile const char	*sn1_abort_msg;
177 /*LINTED: static unused*/
178 static volatile const char	*sn1_abort_file;
179 /*LINTED: static unused*/
180 static volatile int		sn1_abort_line;
181 
182 extern int errno;
183 
184 /*ARGSUSED*/
185 void
186 _sn1_abort(int err, const char *msg, const char *file, int line)
187 {
188 	sysret_t rval;
189 
190 	/* Save the error message into convenient globals */
191 	sn1_abort_err = err;
192 	sn1_abort_msg = msg;
193 	sn1_abort_file = file;
194 	sn1_abort_line = line;
195 
196 	/* kill ourselves */
197 	abort();
198 
199 	/* If abort() didn't work, try something stronger. */
200 	(void) __systemcall(&rval, SYS_lwp_kill + 1024, _lwp_self(), SIGKILL);
201 }
202 
203 /*
204  * This function is defined to be NOSYS but it won't be called from the
205  * the kernel since the NOSYS system calls are not enabled in the kernel.
206  * Thus, the only time this function is called is directly from within the
207  * indirect system call path.
208  */
209 /*ARGSUSED*/
210 static long
211 sn1_unimpl(sysret_t *rv, uintptr_t p1)
212 {
213 	sysret_t rval;
214 
215 	/*
216 	 * We'd like to print out some kind of error message here like
217 	 * "unsupported syscall", but we can't because it's not safe to
218 	 * assume that stderr or STDERR_FILENO actually points to something
219 	 * that is a terminal, and if we wrote to those files we could
220 	 * inadvertantly write to some applications open files, which would
221 	 * be bad.
222 	 *
223 	 * Normally, if an application calls an invalid system call
224 	 * it get a SIGSYS sent to it.  So we'll just go ahead and send
225 	 * ourselves a signal here.  Note that this is far from ideal since
226 	 * if the application has registered a signal handler, that signal
227 	 * handler may recieve a ucontext_t as the third parameter to
228 	 * indicate the context of the process when the signal was
229 	 * generated, and in this case that context will not be what the
230 	 * application is expecting.  Hence, we should probably create a
231 	 * brandsys() kernel function that can deliver the signal to us
232 	 * with the correct ucontext_t.
233 	 */
234 	(void) __systemcall(&rval, SYS_lwp_kill + 1024, _lwp_self(), SIGSYS);
235 	return (ENOSYS);
236 }
237 
238 #if defined(__sparc) && !defined(__sparcv9)
239 /*
240  * Yuck.  For 32-bit sparc applications, handle indirect system calls.
241  * Note that we declare this interface to use the maximum number of
242  * system call arguments.  If we recieve a system call that uses less
243  * arguments, then the additional arguments will be garbage, but they
244  * will also be ignored so that should be ok.
245  */
246 static long
247 sn1_indir(sysret_t *rv, int code,
248     uintptr_t a0, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4,
249     uintptr_t a5, uintptr_t a6, uintptr_t a7)
250 {
251 	sn1_sysent_table_t *sst = &(sn1_sysent_table[code]);
252 
253 	sn1_assert(code < NSYSCALL);
254 	switch (sst->st_args & NARGS_MASK) {
255 	case 0:
256 		return ((sst->st_callc)(rv));
257 	case 1:
258 		return ((sst->st_callc)(rv, a0));
259 	case 2:
260 		return ((sst->st_callc)(rv, a0, a1));
261 	case 3:
262 		return ((sst->st_callc)(rv, a0, a1, a2));
263 	case 4:
264 		return ((sst->st_callc)(rv, a0, a1, a2, a3));
265 	case 5:
266 		return ((sst->st_callc)(rv, a0, a1, a2, a3, a4));
267 	case 6:
268 		return ((sst->st_callc)(rv, rv, a0, a1, a2, a3, a4, a5));
269 	case 7:
270 		return ((sst->st_callc)(rv, a0, a1, a2, a3, a4, a5, a6));
271 	case 8:
272 		return ((sst->st_callc)(rv, a0, a1, a2, a3, a4, a5, a6, a7));
273 	}
274 	sn1_abort(0, "invalid entry in sn1_sysent_table");
275 	return (EINVAL);
276 }
277 #endif /* __sparc && !__sparcv9 */
278 
279 static long
280 sn1_uname(sysret_t *rv, uintptr_t p1)
281 {
282 	struct utsname	un, *unp = (struct utsname *)p1;
283 	int		rev, err;
284 
285 	if ((err = __systemcall(rv, SYS_uname + 1024, &un)) != 0)
286 		return (err);
287 
288 	rev = atoi(&un.release[2]);
289 	sn1_assert(rev >= 10);
290 	(void) sprintf(un.release, "5.%d", rev - 1);
291 
292 	if (uucopy(&un, unp, sizeof (un)) != 0)
293 		return (EFAULT);
294 	return (0);
295 }
296 
297 /*
298  * Close a libc file handle, but don't actually close the underlying
299  * file descriptor.
300  */
301 static void
302 sn1_close_fh(FILE *file)
303 {
304 	int fd, fd_new;
305 
306 	if (file == NULL)
307 		return;
308 
309 	if ((fd = fileno(file)) < 0)
310 		return;
311 
312 	fd_new = dup(fd);
313 	if (fd_new == -1)
314 		return;
315 
316 	(void) fclose(file);
317 	(void) dup2(fd_new, fd);
318 	(void) close(fd_new);
319 }
320 
321 /*ARGSUSED*/
322 int
323 sn1_init(int argc, char *argv[], char *envp[])
324 {
325 	sysret_t		rval;
326 	sn1_brand_reg_t		reg;
327 	sn1_elf_data_t		sed;
328 	auxv_t			*ap;
329 	uintptr_t		*p;
330 	int			i, err;
331 
332 	/* Sanity check our translation table return value codes */
333 	for (i = 0; i < NSYSCALL; i++) {
334 		sn1_sysent_table_t *est = &(sn1_sysent_table[i]);
335 		sn1_assert(BIT_ONLYONESET(est->st_args & RV_MASK));
336 	}
337 
338 	/*
339 	 * We need to shutdown all libc stdio.  libc stdio normally goes to
340 	 * file descriptors, but since we're actually part of a another
341 	 * process we don't own these file descriptors and we can't make
342 	 * any assumptions about their state.
343 	 */
344 	sn1_close_fh(stdin);
345 	sn1_close_fh(stdout);
346 	sn1_close_fh(stderr);
347 
348 	/*
349 	 * Register our syscall emulation table with the kernel.
350 	 * Note that we don't have to do invoke (syscall_number + 1024)
351 	 * until we've actually establised a syscall emulation callback
352 	 * handler address, which is what we're doing with this brand
353 	 * syscall.
354 	 */
355 	reg.sbr_version = SN1_VERSION;
356 #ifdef	__x86
357 	reg.sbr_handler = (caddr_t)sn1_handler_table;
358 #else	/* !__x86 */
359 	reg.sbr_handler = (caddr_t)sn1_handler;
360 #endif	/* !__x86 */
361 	if ((err = __systemcall(&rval, SYS_brand, B_REGISTER, &reg)) != 0) {
362 		sn1_abort(err, "Failed to brand current process");
363 		/*NOTREACHED*/
364 	}
365 
366 	/* Get data about the executable we're running from the kernel. */
367 	if ((err = __systemcall(&rval, SYS_brand + 1024,
368 	    B_ELFDATA, (void *)&sed)) != 0) {
369 		sn1_abort(err,
370 		    "Failed to get required brand ELF data from the kernel");
371 		/*NOTREACHED*/
372 	}
373 
374 	/*
375 	 * Find the aux vector on the stack.
376 	 */
377 	p = (uintptr_t *)envp;
378 	while (*p != NULL)
379 		p++;
380 
381 	/*
382 	 * p is now pointing at the 0 word after the environ pointers.
383 	 * After that is the aux vectors.
384 	 *
385 	 * The aux vectors are currently pointing to the brand emulation
386 	 * library and associated linker.  We're going to change them to
387 	 * point to the brand executable and associated linker (or to no
388 	 * linker for static binaries).  This matches the process data
389 	 * stored within the kernel and visible from /proc, which was
390 	 * all setup in sn1_elfexec().  We do this so that when a debugger
391 	 * attaches to the process it sees the process as a normal solaris
392 	 * process, this brand emulation library and everything on it's
393 	 * link map will not be visible, unless our librtld_db plugin
394 	 * is used.  Note that this is very different from how Linux
395 	 * branded processes are implemented within lx branded zones.
396 	 * In that situation, the primary linkmap of the process is the
397 	 * brand emulation libraries linkmap, not the Linux applications
398 	 * linkmap.
399 	 *
400 	 * We also need to clear the AF_SUN_NOPLM flag from the AT_SUN_AUXFLAGS
401 	 * aux vector.  This flag told our linker that we don't have a
402 	 * primary link map.  Now that our linker is done initializing, we
403 	 * want to clear this flag before we transfer control to the
404 	 * applications copy of the linker, since we want that linker to have
405 	 * a primary link map which will be the link map for the application
406 	 * we're running.
407 	 */
408 	p++;
409 	for (ap = (auxv_t *)p; ap->a_type != AT_NULL; ap++) {
410 		switch (ap->a_type) {
411 			case AT_BASE:
412 				/* Hide AT_BASE if static binary */
413 				if (sed.sed_base == NULL) {
414 					ap->a_type = AT_IGNORE;
415 					ap->a_un.a_val = NULL;
416 				} else {
417 					ap->a_un.a_val = sed.sed_base;
418 				}
419 				break;
420 			case AT_ENTRY:
421 				ap->a_un.a_val = sed.sed_entry;
422 				break;
423 			case AT_PHDR:
424 				ap->a_un.a_val = sed.sed_phdr;
425 				break;
426 			case AT_PHENT:
427 				ap->a_un.a_val = sed.sed_phent;
428 				break;
429 			case AT_PHNUM:
430 				ap->a_un.a_val = sed.sed_phnum;
431 				break;
432 			case AT_SUN_AUXFLAGS:
433 				ap->a_un.a_val &= ~AF_SUN_NOPLM;
434 				break;
435 			case AT_SUN_EMULATOR:
436 				/*
437 				 * ld.so.1 inspects AT_SUN_EMULATOR to see if
438 				 * if it is the linker for the brand emulation
439 				 * library.  Hide AT_SUN_EMULATOR, as the
440 				 * linker we are about to jump to is the linker
441 				 * for the binary.
442 				 */
443 				ap->a_type = AT_IGNORE;
444 				ap->a_un.a_val = NULL;
445 				break;
446 			case AT_SUN_LDDATA:
447 				/* Hide AT_SUN_LDDATA if static binary */
448 				if (sed.sed_lddata == NULL) {
449 					ap->a_type = AT_IGNORE;
450 					ap->a_un.a_val = NULL;
451 				} else {
452 					ap->a_un.a_val = sed.sed_lddata;
453 				}
454 				break;
455 			default:
456 				break;
457 		}
458 	}
459 
460 	sn1_runexe(argv, sed.sed_ldentry);
461 	/*NOTREACHED*/
462 	sn1_abort(0, "sn1_runexe() returned");
463 	return (-1);
464 }
465 
466 #define	IN_KERNEL_SYSCALL(name, num)					\
467 static long								\
468 sn1_##name(sysret_t *rv,						\
469     uintptr_t a0, uintptr_t a1, uintptr_t a2, uintptr_t a3,		\
470     uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7)		\
471 {									\
472 	return (__systemcall(rv, num + 1024,				\
473 	    a0, a1, a2, a3, a4, a5, a6, a7));				\
474 }
475 
476 /*
477  * These are branded system calls, which have been redirected to this
478  * userland emulation library, and are emulated by passing them strait
479  * on to the kernel as native system calls.
480  */
481 IN_KERNEL_SYSCALL(read,		SYS_read)		/*   3 */
482 IN_KERNEL_SYSCALL(write,	SYS_write)		/*   4 */
483 IN_KERNEL_SYSCALL(time,		SYS_time)		/*  13 */
484 IN_KERNEL_SYSCALL(getpid,	SYS_getpid)		/*  20 */
485 IN_KERNEL_SYSCALL(mount,	SYS_mount)		/*  21 */
486 IN_KERNEL_SYSCALL(getuid,	SYS_getuid)		/*  24 */
487 IN_KERNEL_SYSCALL(times,	SYS_times)		/*  43 */
488 IN_KERNEL_SYSCALL(getgid,	SYS_getgid)		/*  47 */
489 IN_KERNEL_SYSCALL(utssys,	SYS_utssys)		/*  57 */
490 IN_KERNEL_SYSCALL(readlink,	SYS_readlink)		/*  90 */
491 IN_KERNEL_SYSCALL(waitid,	SYS_waitid)		/* 107 */
492 
493 /*
494  * This table must have at least NSYSCALL entries in it.
495  *
496  * The second parameter of each entry in the sn1_sysent_table
497  * contains the number of parameters and flags that describe the
498  * syscall return value encoding.  See the block comments at the
499  * top of this file for more information about the syscall return
500  * value flags and when they should be used.
501  */
502 sn1_sysent_table_t sn1_sysent_table[] = {
503 #if defined(__sparc) && !defined(__sparcv9)
504 	EMULATE(sn1_indir, 9 | RV_64RVAL),	/*  0 */
505 #else /* !__sparc || __sparcv9 */
506 	NOSYS,					/*  0 */
507 #endif /* !__sparc || __sparcv9 */
508 	NOSYS,					/*   1 */
509 	NOSYS,					/*   2 */
510 	EMULATE(sn1_read, 3 | RV_DEFAULT),	/*   3 */
511 	EMULATE(sn1_write, 3 | RV_DEFAULT),	/*   4 */
512 	NOSYS,					/*   5 */
513 	NOSYS,					/*   6 */
514 	NOSYS,					/*   7 */
515 	NOSYS,					/*   8 */
516 	NOSYS,					/*   9 */
517 	NOSYS,					/*  10 */
518 	NOSYS,					/*  11 */
519 	NOSYS,					/*  12 */
520 	EMULATE(sn1_time, 0 | RV_DEFAULT),	/*  13 */
521 	NOSYS,					/*  14 */
522 	NOSYS,					/*  15 */
523 	NOSYS,					/*  16 */
524 	NOSYS,					/*  17 */
525 	NOSYS,					/*  18 */
526 	NOSYS,					/*  19 */
527 	EMULATE(sn1_getpid, 0 | RV_32RVAL2),	/*  20 */
528 	EMULATE(sn1_mount, 8 | RV_DEFAULT),	/*  21 */
529 	NOSYS,					/*  22 */
530 	NOSYS,					/*  23 */
531 	EMULATE(sn1_getuid, 0 | RV_32RVAL2),	/*  24 */
532 	NOSYS,					/*  25 */
533 	NOSYS,					/*  26 */
534 	NOSYS,					/*  27 */
535 	NOSYS,					/*  28 */
536 	NOSYS,					/*  29 */
537 	NOSYS,					/*  30 */
538 	NOSYS,					/*  31 */
539 	NOSYS,					/*  32 */
540 	NOSYS,					/*  33 */
541 	NOSYS,					/*  34 */
542 	NOSYS,					/*  35 */
543 	NOSYS,					/*  36 */
544 	NOSYS,					/*  37 */
545 	NOSYS,					/*  38 */
546 	NOSYS,					/*  39 */
547 	NOSYS,					/*  40 */
548 	NOSYS,					/*  41 */
549 	NOSYS,					/*  42 */
550 	EMULATE(sn1_times, 1 | RV_DEFAULT),	/*  43 */
551 	NOSYS,					/*  44 */
552 	NOSYS,					/*  45 */
553 	NOSYS,					/*  46 */
554 	EMULATE(sn1_getgid, 0 | RV_32RVAL2),	/*  47 */
555 	NOSYS,					/*  48 */
556 	NOSYS,					/*  49 */
557 	NOSYS,					/*  50 */
558 	NOSYS,					/*  51 */
559 	NOSYS,					/*  52 */
560 	NOSYS,					/*  53 */
561 	NOSYS,					/*  54 */
562 	NOSYS,					/*  55 */
563 	NOSYS,					/*  56 */
564 	EMULATE(sn1_utssys, 4 | RV_32RVAL2),	/*  57 */
565 	NOSYS,					/*  58 */
566 	NOSYS,					/*  59 */
567 	NOSYS,					/*  60 */
568 	NOSYS,					/*  61 */
569 	NOSYS,					/*  62 */
570 	NOSYS,					/*  63 */
571 	NOSYS,					/*  64 */
572 	NOSYS,					/*  65 */
573 	NOSYS,					/*  66 */
574 	NOSYS,					/*  67 */
575 	NOSYS,					/*  68 */
576 	NOSYS,					/*  69 */
577 	NOSYS,					/*  70 */
578 	NOSYS,					/*  71 */
579 	NOSYS,					/*  72 */
580 	NOSYS,					/*  73 */
581 	NOSYS,					/*  74 */
582 	NOSYS,					/*  75 */
583 	NOSYS,					/*  76 */
584 	NOSYS,					/*  77 */
585 	NOSYS,					/*  78 */
586 	NOSYS,					/*  79 */
587 	NOSYS,					/*  80 */
588 	NOSYS,					/*  81 */
589 	NOSYS,					/*  82 */
590 	NOSYS,					/*  83 */
591 	NOSYS,					/*  84 */
592 	NOSYS,					/*  85 */
593 	NOSYS,					/*  86 */
594 	NOSYS,					/*  87 */
595 	NOSYS,					/*  88 */
596 	NOSYS,					/*  89 */
597 	EMULATE(sn1_readlink, 3 | RV_DEFAULT),	/*  90 */
598 	NOSYS,					/*  91 */
599 	NOSYS,					/*  92 */
600 	NOSYS,					/*  93 */
601 	NOSYS,					/*  94 */
602 	NOSYS,					/*  95 */
603 	NOSYS,					/*  96 */
604 	NOSYS,					/*  97 */
605 	NOSYS,					/*  98 */
606 	NOSYS,					/*  99 */
607 	NOSYS,					/* 100 */
608 	NOSYS,					/* 101 */
609 	NOSYS,					/* 102 */
610 	NOSYS,					/* 103 */
611 	NOSYS,					/* 104 */
612 	NOSYS,					/* 105 */
613 	NOSYS,					/* 106 */
614 	EMULATE(sn1_waitid, 4 | RV_DEFAULT),	/* 107 */
615 	NOSYS,					/* 108 */
616 	NOSYS,					/* 109 */
617 	NOSYS,					/* 110 */
618 	NOSYS,					/* 111 */
619 	NOSYS,					/* 112 */
620 	NOSYS,					/* 113 */
621 	NOSYS,					/* 114 */
622 	NOSYS,					/* 115 */
623 	NOSYS,					/* 116 */
624 	NOSYS,					/* 117 */
625 	NOSYS,					/* 118 */
626 	NOSYS,					/* 119 */
627 	NOSYS,					/* 120 */
628 	NOSYS,					/* 121 */
629 	NOSYS,					/* 122 */
630 	NOSYS,					/* 123 */
631 	NOSYS,					/* 124 */
632 	NOSYS,					/* 125 */
633 	NOSYS,					/* 126 */
634 	NOSYS,					/* 127 */
635 	NOSYS,					/* 128 */
636 	NOSYS,					/* 129 */
637 	NOSYS,					/* 130 */
638 	NOSYS,					/* 131 */
639 	NOSYS,					/* 132 */
640 	NOSYS,					/* 133 */
641 	NOSYS,					/* 134 */
642 	EMULATE(sn1_uname, 1 | RV_DEFAULT),	/* 135 */
643 	NOSYS,					/* 136 */
644 	NOSYS,					/* 137 */
645 	NOSYS,					/* 138 */
646 	NOSYS,					/* 139 */
647 	NOSYS,					/* 140 */
648 	NOSYS,					/* 141 */
649 	NOSYS,					/* 142 */
650 	NOSYS,					/* 143 */
651 	NOSYS,					/* 144 */
652 	NOSYS,					/* 145 */
653 	NOSYS,					/* 146 */
654 	NOSYS,					/* 147 */
655 	NOSYS,					/* 148 */
656 	NOSYS,					/* 149 */
657 	NOSYS,					/* 150 */
658 	NOSYS,					/* 151 */
659 	NOSYS,					/* 152 */
660 	NOSYS,					/* 153 */
661 	NOSYS,					/* 154 */
662 	NOSYS,					/* 155 */
663 	NOSYS,					/* 156 */
664 	NOSYS,					/* 157 */
665 	NOSYS,					/* 158 */
666 	NOSYS,					/* 159 */
667 	NOSYS,					/* 160 */
668 	NOSYS,					/* 161 */
669 	NOSYS,					/* 162 */
670 	NOSYS,					/* 163 */
671 	NOSYS,					/* 164 */
672 	NOSYS,					/* 165 */
673 	NOSYS,					/* 166 */
674 	NOSYS,					/* 167 */
675 	NOSYS,					/* 168 */
676 	NOSYS,					/* 169 */
677 	NOSYS,					/* 170 */
678 	NOSYS,					/* 171 */
679 	NOSYS,					/* 172 */
680 	NOSYS,					/* 173 */
681 	NOSYS,					/* 174 */
682 	NOSYS,					/* 175 */
683 	NOSYS,					/* 176 */
684 	NOSYS,					/* 177 */
685 	NOSYS,					/* 178 */
686 	NOSYS,					/* 179 */
687 	NOSYS,					/* 180 */
688 	NOSYS,					/* 181 */
689 	NOSYS,					/* 182 */
690 	NOSYS,					/* 183 */
691 	NOSYS,					/* 184 */
692 	NOSYS,					/* 185 */
693 	NOSYS,					/* 186 */
694 	NOSYS,					/* 187 */
695 	NOSYS,					/* 188 */
696 	NOSYS,					/* 189 */
697 	NOSYS,					/* 190 */
698 	NOSYS,					/* 191 */
699 	NOSYS,					/* 192 */
700 	NOSYS,					/* 193 */
701 	NOSYS,					/* 194 */
702 	NOSYS,					/* 195 */
703 	NOSYS,					/* 196 */
704 	NOSYS,					/* 197 */
705 	NOSYS,					/* 198 */
706 	NOSYS,					/* 199 */
707 	NOSYS,					/* 200 */
708 	NOSYS,					/* 201 */
709 	NOSYS,					/* 202 */
710 	NOSYS,					/* 203 */
711 	NOSYS,					/* 204 */
712 	NOSYS,					/* 205 */
713 	NOSYS,					/* 206 */
714 	NOSYS,					/* 207 */
715 	NOSYS,					/* 208 */
716 	NOSYS,					/* 209 */
717 	NOSYS,					/* 210 */
718 	NOSYS,					/* 211 */
719 	NOSYS,					/* 212 */
720 	NOSYS,					/* 213 */
721 	NOSYS,					/* 214 */
722 	NOSYS,					/* 215 */
723 	NOSYS,					/* 216 */
724 	NOSYS,					/* 217 */
725 	NOSYS,					/* 218 */
726 	NOSYS,					/* 219 */
727 	NOSYS,					/* 220 */
728 	NOSYS,					/* 221 */
729 	NOSYS,					/* 222 */
730 	NOSYS,					/* 223 */
731 	NOSYS,					/* 224 */
732 	NOSYS,					/* 225 */
733 	NOSYS,					/* 226 */
734 	NOSYS,					/* 227 */
735 	NOSYS,					/* 228 */
736 	NOSYS,					/* 229 */
737 	NOSYS,					/* 230 */
738 	NOSYS,					/* 231 */
739 	NOSYS,					/* 232 */
740 	NOSYS,					/* 233 */
741 	NOSYS,					/* 234 */
742 	NOSYS,					/* 235 */
743 	NOSYS,					/* 236 */
744 	NOSYS,					/* 237 */
745 	NOSYS,					/* 238 */
746 	NOSYS,					/* 239 */
747 	NOSYS,					/* 240 */
748 	NOSYS,					/* 241 */
749 	NOSYS,					/* 242 */
750 	NOSYS,					/* 243 */
751 	NOSYS,					/* 244 */
752 	NOSYS,					/* 245 */
753 	NOSYS,					/* 246 */
754 	NOSYS,					/* 247 */
755 	NOSYS,					/* 248 */
756 	NOSYS,					/* 249 */
757 	NOSYS,					/* 250 */
758 	NOSYS,					/* 251 */
759 	NOSYS,					/* 252 */
760 	NOSYS,					/* 253 */
761 	NOSYS,					/* 254 */
762 	NOSYS					/* 255 */
763 };
764