1/*
2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 *    derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 *	$Id: system.c,v 1.37 2005/06/01 19:22:06 roland Exp $
31 */
32
33#include "defs.h"
34
35#ifdef LINUX
36
37#ifdef HAVE_ANDROID_OS
38#undef __unused
39#include <linux/sysctl.h>
40#include <sys/mount.h>
41#define CTL_PROC 4
42
43#else
44#define _LINUX_SOCKET_H
45#define _LINUX_FS_H
46
47#define MS_RDONLY	 1	/* Mount read-only */
48#define MS_NOSUID	 2	/* Ignore suid and sgid bits */
49#define MS_NODEV	 4	/* Disallow access to device special files */
50#define MS_NOEXEC	 8	/* Disallow program execution */
51#define MS_SYNCHRONOUS	16	/* Writes are synced at once */
52#define MS_REMOUNT	32	/* Alter flags of a mounted FS */
53#define MS_MANDLOCK	64	/* Allow mandatory locks on an FS */
54#define MS_DIRSYNC	128	/* Directory modifications are synchronous */
55#define MS_NOATIME	1024	/* Do not update access times. */
56#define MS_NODIRATIME	2048	/* Do not update directory access times */
57#define MS_BIND		4096
58#define MS_MOVE		8192
59#define MS_REC		16384
60#define MS_VERBOSE	32768
61#define MS_POSIXACL	(1<<16)	/* VFS does not apply the umask */
62#define MS_ACTIVE	(1<<30)
63#define MS_NOUSER	(1<<31)
64#endif /* HAVE_ANDROID_OS */
65
66#include <sys/socket.h>
67#include <netinet/in.h>
68#include <arpa/inet.h>
69
70#include <sys/syscall.h>
71
72#ifdef SYS_capget
73#include <linux/capability.h>
74#endif
75
76#ifdef SYS_cacheflush
77#include <asm/cachectl.h>
78#endif
79
80#ifdef HAVE_LINUX_USTNAME_H
81#include <linux/utsname.h>
82#endif
83
84#ifdef MIPS
85#include <asm/sysmips.h>
86#endif
87
88#include <linux/sysctl.h>
89
90static const struct xlat mount_flags[] = {
91	{ MS_RDONLY,	"MS_RDONLY"	},
92	{ MS_NOSUID,	"MS_NOSUID"	},
93	{ MS_NODEV,	"MS_NODEV"	},
94	{ MS_NOEXEC,	"MS_NOEXEC"	},
95	{ MS_SYNCHRONOUS,"MS_SYNCHRONOUS"},
96	{ MS_REMOUNT,	"MS_REMOUNT"	},
97	{ MS_MANDLOCK,	"MS_MANDLOCK"	},
98	{ MS_NOATIME,	"MS_NOATIME"	},
99	{ MS_NODIRATIME,"MS_NODIRATIME"	},
100	{ MS_BIND,	"MS_BIND"	},
101	{ MS_MOVE,	"MS_MOVE"	},
102	{ MS_REC,	"MS_REC"	},
103	{ MS_VERBOSE,	"MS_VERBOSE"	},
104	{ MS_POSIXACL,	"MS_POSIXACL"	},
105	{ MS_ACTIVE,	"MS_ACTIVE"	},
106	{ MS_NOUSER,	"MS_NOUSER"	},
107	{ 0,		NULL		},
108};
109
110int
111sys_mount(tcp)
112struct tcb *tcp;
113{
114	if (entering(tcp)) {
115		printpath(tcp, tcp->u_arg[0]);
116		tprintf(", ");
117		printpath(tcp, tcp->u_arg[1]);
118		tprintf(", ");
119		if ((tcp->u_arg[3] & (MS_BIND|MS_MOVE|MS_REMOUNT)) == 0)
120			printpath(tcp, tcp->u_arg[2]);
121		else
122			tprintf("%#lx", tcp->u_arg[2]);
123		tprintf(", ");
124		printflags(mount_flags, tcp->u_arg[3], "MS_???");
125		tprintf(", %#lx", tcp->u_arg[4]);
126	}
127	return 0;
128}
129
130int
131sys_umount2(tcp)
132struct tcb *tcp;
133{
134	if (entering(tcp)) {
135		printstr(tcp, tcp->u_arg[0], -1);
136		tprintf(", ");
137		if (tcp->u_arg[1] & 1)
138			tprintf("MNT_FORCE");
139		else
140			tprintf("0");
141	}
142	return 0;
143}
144
145/* These are not macros, but enums.  We just copy the values by hand
146   from Linux 2.6.9 here.  */
147static const struct xlat personality_options[] = {
148	{ 0,		"PER_LINUX"	},
149	{ 0x00800000,	"PER_LINUX_32BIT"},
150	{ 0x04100001,	"PER_SVR4"	},
151	{ 0x05000002,	"PER_SVR3"	},
152	{ 0x07000003,	"PER_SCOSVR3"	},
153	{ 0x06000003,	"PER_OSR5"	},
154	{ 0x05000004,	"PER_WYSEV386"	},
155	{ 0x04000005,	"PER_ISCR4"	},
156	{ 0x00000006,	"PER_BSD"	},
157	{ 0x04000006,	"PER_SUNOS"	},
158	{ 0x05000007,	"PER_XENIX"	},
159	{ 0x00000008,	"PER_LINUX32"	},
160	{ 0x08000008,	"PER_LINUX32_3GB"},
161	{ 0x04000009,	"PER_IRIX32"	},
162	{ 0x0400000a,	"PER_IRIXN32"	},
163	{ 0x0400000b,	"PER_IRIX64"	},
164	{ 0x0000000c,	"PER_RISCOS"	},
165	{ 0x0400000d,	"PER_SOLARIS"	},
166	{ 0x0410000e,	"PER_UW7"	},
167	{ 0x0000000f,	"PER_OSF4"	},
168	{ 0x00000010,	"PER_HPUX"	},
169	{ 0,		NULL		},
170};
171
172int
173sys_personality(tcp)
174struct tcb *tcp;
175{
176	if (entering(tcp))
177		printxval(personality_options, tcp->u_arg[0], "PER_???");
178	return 0;
179}
180
181#include <linux/reboot.h>
182static const struct xlat bootflags1[] = {
183	{ LINUX_REBOOT_MAGIC1,	"LINUX_REBOOT_MAGIC1"	},
184	{ 0,			NULL			},
185};
186
187static const struct xlat bootflags2[] = {
188	{ LINUX_REBOOT_MAGIC2,	"LINUX_REBOOT_MAGIC2"	},
189	{ LINUX_REBOOT_MAGIC2A,	"LINUX_REBOOT_MAGIC2A"	},
190	{ LINUX_REBOOT_MAGIC2B,	"LINUX_REBOOT_MAGIC2B"	},
191	{ 0,			NULL			},
192};
193
194static const struct xlat bootflags3[] = {
195	{ LINUX_REBOOT_CMD_CAD_OFF,	"LINUX_REBOOT_CMD_CAD_OFF"	},
196	{ LINUX_REBOOT_CMD_RESTART,	"LINUX_REBOOT_CMD_RESTART"	},
197	{ LINUX_REBOOT_CMD_HALT,	"LINUX_REBOOT_CMD_HALT"		},
198	{ LINUX_REBOOT_CMD_CAD_ON,	"LINUX_REBOOT_CMD_CAD_ON"	},
199	{ LINUX_REBOOT_CMD_POWER_OFF,	"LINUX_REBOOT_CMD_POWER_OFF"	},
200	{ LINUX_REBOOT_CMD_RESTART2,	"LINUX_REBOOT_CMD_RESTART2"	},
201	{ 0,				NULL				},
202};
203
204int
205sys_reboot(tcp)
206struct tcb *tcp;
207{
208	if (entering(tcp)) {
209		printflags(bootflags1, tcp->u_arg[0], "LINUX_REBOOT_MAGIC_???");
210		tprintf(", ");
211		printflags(bootflags2, tcp->u_arg[1], "LINUX_REBOOT_MAGIC_???");
212		tprintf(", ");
213		printflags(bootflags3, tcp->u_arg[2], "LINUX_REBOOT_CMD_???");
214		if (tcp->u_arg[2] == LINUX_REBOOT_CMD_RESTART2) {
215			tprintf(", ");
216			printstr(tcp, tcp->u_arg[3], -1);
217		}
218	}
219	return 0;
220}
221
222#ifdef M68K
223static const struct xlat cacheflush_scope[] = {
224#ifdef FLUSH_SCOPE_LINE
225	{ FLUSH_SCOPE_LINE,	"FLUSH_SCOPE_LINE" },
226#endif
227#ifdef FLUSH_SCOPE_PAGE
228	{ FLUSH_SCOPE_PAGE,	"FLUSH_SCOPE_PAGE" },
229#endif
230#ifdef FLUSH_SCOPE_ALL
231	{ FLUSH_SCOPE_ALL,	"FLUSH_SCOPE_ALL" },
232#endif
233	{ 0,			NULL },
234};
235
236static const struct xlat cacheflush_flags[] = {
237#ifdef FLUSH_CACHE_BOTH
238	{ FLUSH_CACHE_BOTH,	"FLUSH_CACHE_BOTH" },
239#endif
240#ifdef FLUSH_CACHE_DATA
241	{ FLUSH_CACHE_DATA,	"FLUSH_CACHE_DATA" },
242#endif
243#ifdef FLUSH_CACHE_INSN
244	{ FLUSH_CACHE_INSN,	"FLUSH_CACHE_INSN" },
245#endif
246	{ 0,			NULL },
247};
248
249int
250sys_cacheflush(tcp)
251struct tcb *tcp;
252{
253	if (entering(tcp)) {
254		/* addr */
255		tprintf("%#lx, ", tcp->u_arg[0]);
256		/* scope */
257		printxval(cacheflush_scope, tcp->u_arg[1], "FLUSH_SCOPE_???");
258		tprintf(", ");
259		/* flags */
260		printflags(cacheflush_flags, tcp->u_arg[2], "FLUSH_CACHE_???");
261		/* len */
262		tprintf(", %lu", tcp->u_arg[3]);
263	}
264	return 0;
265}
266#endif /* M68K */
267
268#endif /* LINUX */
269
270#ifdef SUNOS4
271
272#include <sys/reboot.h>
273#define NFSCLIENT
274#define LOFS
275#define RFS
276#define PCFS
277#include <sys/mount.h>
278#include <sys/socket.h>
279#include <nfs/export.h>
280#include <rpc/types.h>
281#include <rpc/auth.h>
282
283/*ARGSUSED*/
284int
285sys_sync(tcp)
286struct tcb *tcp;
287{
288	return 0;
289}
290
291static const struct xlat bootflags[] = {
292	{ RB_AUTOBOOT,	"RB_AUTOBOOT"	},	/* for system auto-booting itself */
293	{ RB_ASKNAME,	"RB_ASKNAME"	},	/* ask for file name to reboot from */
294	{ RB_SINGLE,	"RB_SINGLE"	},	/* reboot to single user only */
295	{ RB_NOSYNC,	"RB_NOSYNC"	},	/* dont sync before reboot */
296	{ RB_HALT,	"RB_HALT"	},	/* don't reboot, just halt */
297	{ RB_INITNAME,	"RB_INITNAME"	},	/* name given for /etc/init */
298	{ RB_NOBOOTRC,	"RB_NOBOOTRC"	},	/* don't run /etc/rc.boot */
299	{ RB_DEBUG,	"RB_DEBUG"	},	/* being run under debugger */
300	{ RB_DUMP,	"RB_DUMP"	},	/* dump system core */
301	{ RB_WRITABLE,	"RB_WRITABLE"	},	/* mount root read/write */
302	{ RB_STRING,	"RB_STRING"	},	/* pass boot args to prom monitor */
303	{ 0,		NULL		},
304};
305
306int
307sys_reboot(tcp)
308struct tcb *tcp;
309{
310	if (entering(tcp)) {
311		printflags(bootflags, tcp->u_arg[0], "RB_???");
312		if (tcp->u_arg[0] & RB_STRING) {
313			printstr(tcp, tcp->u_arg[1], -1);
314		}
315	}
316	return 0;
317}
318
319int
320sys_sysacct(tcp)
321struct tcb *tcp;
322{
323	if (entering(tcp)) {
324		printstr(tcp, tcp->u_arg[0], -1);
325	}
326	return 0;
327}
328
329int
330sys_swapon(tcp)
331struct tcb *tcp;
332{
333	if (entering(tcp)) {
334		printstr(tcp, tcp->u_arg[0], -1);
335	}
336	return 0;
337}
338
339int
340sys_nfs_svc(tcp)
341struct tcb *tcp;
342{
343	if (entering(tcp)) {
344		printsock(tcp, tcp->u_arg[0]);
345	}
346	return 0;
347}
348
349static const struct xlat mountflags[] = {
350	{ M_RDONLY,	"M_RDONLY"	},
351	{ M_NOSUID,	"M_NOSUID"	},
352	{ M_NEWTYPE,	"M_NEWTYPE"	},
353	{ M_GRPID,	"M_GRPID"	},
354#ifdef	M_REMOUNT
355	{ M_REMOUNT,	"M_REMOUNT"	},
356#endif
357#ifdef	M_NOSUB
358	{ M_NOSUB,	"M_NOSUB"	},
359#endif
360#ifdef	M_MULTI
361	{ M_MULTI,	"M_MULTI"	},
362#endif
363#ifdef	M_SYS5
364	{ M_SYS5,	"M_SYS5"	},
365#endif
366	{ 0,		NULL		},
367};
368
369static const struct xlat nfsflags[] = {
370	{ NFSMNT_SOFT,		"NFSMNT_SOFT"		},
371	{ NFSMNT_WSIZE,		"NFSMNT_WSIZE"		},
372	{ NFSMNT_RSIZE,		"NFSMNT_RSIZE"		},
373	{ NFSMNT_TIMEO,		"NFSMNT_TIMEO"		},
374	{ NFSMNT_RETRANS,	"NFSMNT_RETRANS"	},
375	{ NFSMNT_HOSTNAME,	"NFSMNT_HOSTNAME"	},
376	{ NFSMNT_INT,		"NFSMNT_INT"		},
377	{ NFSMNT_NOAC,		"NFSMNT_NOAC"		},
378	{ NFSMNT_ACREGMIN,	"NFSMNT_ACREGMIN"	},
379	{ NFSMNT_ACREGMAX,	"NFSMNT_ACREGMAX"	},
380	{ NFSMNT_ACDIRMIN,	"NFSMNT_ACDIRMIN"	},
381	{ NFSMNT_ACDIRMAX,	"NFSMNT_ACDIRMAX"	},
382#ifdef	NFSMNT_SECURE
383	{ NFSMNT_SECURE,	"NFSMNT_SECURE"		},
384#endif
385#ifdef	NFSMNT_NOCTO
386	{ NFSMNT_NOCTO,		"NFSMNT_NOCTO"		},
387#endif
388#ifdef	NFSMNT_POSIX
389	{ NFSMNT_POSIX,		"NFSMNT_POSIX"		},
390#endif
391	{ 0,			NULL			},
392};
393
394int
395sys_mount(tcp)
396struct tcb *tcp;
397{
398	char type[4];
399
400	if (entering(tcp)) {
401		if (!(tcp->u_arg[2] & M_NEWTYPE) || umovestr(tcp,
402				tcp->u_arg[0],  sizeof type, type) < 0) {
403			tprintf("OLDTYPE:#%lx", tcp->u_arg[0]);
404		} else {
405			tprintf("\"%s\", ", type);
406		}
407		printstr(tcp, tcp->u_arg[1], -1);
408		tprintf(", ");
409		printflags(mountflags, tcp->u_arg[2] & ~M_NEWTYPE, "M_???");
410		tprintf(", ");
411
412		if (strcmp(type, "4.2") == 0) {
413			struct ufs_args a;
414			if (umove(tcp, tcp->u_arg[3], &a) < 0)
415				return 0;
416			printstr(tcp, (int)a.fspec, -1);
417		} else if (strcmp(type, "lo") == 0) {
418			struct lo_args a;
419			if (umove(tcp, tcp->u_arg[3], &a) < 0)
420				return 0;
421			printstr(tcp, (int)a.fsdir, -1);
422		} else if (strcmp(type, "nfs") == 0) {
423			struct nfs_args a;
424			if (umove(tcp, tcp->u_arg[3], &a) < 0)
425				return 0;
426			tprintf("[");
427			printsock(tcp, (int) a.addr);
428			tprintf(", ");
429			printflags(nfsflags, a.flags, "NFSMNT_???");
430			tprintf(", ws:%u,rs:%u,to:%u,re:%u,",
431				a.wsize, a.rsize, a.timeo, a.retrans);
432			if (a.flags & NFSMNT_HOSTNAME && a.hostname)
433				printstr(tcp, (int)a.hostname, -1);
434			else
435				tprintf("%#lx", (unsigned long) a.hostname);
436			tprintf(",reg-min:%u,max:%u,dir-min:%u,max:%u,",
437				a.acregmin, a.acregmax, a.acdirmin, a.acdirmax);
438			if ((a.flags & NFSMNT_SECURE) && a.netname)
439				printstr(tcp, (int) a.netname, -1);
440			else
441				tprintf("%#lx", (unsigned long) a.netname);
442			tprintf("]");
443		} else if (strcmp(type, "rfs") == 0) {
444			struct rfs_args a;
445			struct token t;
446			if (umove(tcp, tcp->u_arg[3], &a) < 0)
447				return 0;
448			tprintf("[");
449			printstr(tcp, (int)a.rmtfs, -1);
450			if (umove(tcp, (int)a.token, &t) < 0)
451				return 0;
452			tprintf(", %u, %s]", t.t_id, t.t_uname);
453		} else if (strcmp(type, "pcfs") == 0) {
454			struct pc_args a;
455			if (umove(tcp, tcp->u_arg[3], &a) < 0)
456				return 0;
457			printstr(tcp, (int)a.fspec, -1);
458		}
459	}
460	return 0;
461}
462
463int
464sys_unmount(tcp)
465struct tcb *tcp;
466{
467	if (entering(tcp)) {
468		printstr(tcp, tcp->u_arg[0], -1);
469	}
470	return 0;
471}
472
473int
474sys_umount(tcp)
475struct tcb *tcp;
476{
477	return sys_unmount(tcp);
478}
479
480int
481sys_auditsys(tcp)
482struct tcb *tcp;
483{
484	/* XXX - no information available */
485	return printargs(tcp);
486}
487
488static const struct xlat ex_auth_flags[] = {
489	{ AUTH_UNIX,	"AUTH_UNIX"	},
490	{ AUTH_DES,	"AUTH_DES"	},
491	{ 0,		NULL		},
492};
493
494int
495sys_exportfs(tcp)
496struct tcb *tcp;
497{
498	struct export e;
499	int i;
500
501	if (entering(tcp)) {
502		printstr(tcp, tcp->u_arg[0], -1);
503		if (umove(tcp, tcp->u_arg[1], &e) < 0) {
504			tprintf("%#lx", tcp->u_arg[1]);
505			return 0;
506		}
507		tprintf("{fl:%u, anon:%u, ", e.ex_flags, e.ex_anon);
508		printxval(ex_auth_flags, e.ex_auth, "AUTH_???");
509		tprintf(", roots:[");
510		if (e.ex_auth == AUTH_UNIX) {
511			for (i=0; i<e.ex_u.exunix.rootaddrs.naddrs; i++) {
512				printsock(tcp,
513					(int)&e.ex_u.exunix.rootaddrs.addrvec[i]);
514			}
515			tprintf("], writers:[");
516			for (i=0; i<e.ex_writeaddrs.naddrs; i++) {
517				printsock(tcp,
518					(int)&e.ex_writeaddrs.addrvec[i]);
519			}
520			tprintf("]");
521		} else {
522			for (i=0; i<e.ex_u.exdes.nnames; i++) {
523				printsock(tcp,
524					(int)&e.ex_u.exdes.rootnames[i]);
525				tprintf(", ");
526			}
527			tprintf("], window:%u", e.ex_u.exdes.window);
528		}
529		tprintf("}");
530	}
531	return 0;
532}
533
534static const struct xlat sysconflimits[] = {
535#ifdef	_SC_ARG_MAX
536	{ _SC_ARG_MAX,	"_SC_ARG_MAX"	},	/* space for argv & envp */
537#endif
538#ifdef	_SC_CHILD_MAX
539	{ _SC_CHILD_MAX,	"_SC_CHILD_MAX"	},	/* maximum children per process??? */
540#endif
541#ifdef	_SC_CLK_TCK
542	{ _SC_CLK_TCK,	"_SC_CLK_TCK"	},	/* clock ticks/sec */
543#endif
544#ifdef	_SC_NGROUPS_MAX
545	{ _SC_NGROUPS_MAX,	"_SC_NGROUPS_MAX"	},	/* number of groups if multple supp. */
546#endif
547#ifdef	_SC_OPEN_MAX
548	{ _SC_OPEN_MAX,	"_SC_OPEN_MAX"	},	/* max open files per process */
549#endif
550#ifdef	_SC_JOB_CONTROL
551	{ _SC_JOB_CONTROL,	"_SC_JOB_CONTROL"	},	/* do we have job control */
552#endif
553#ifdef	_SC_SAVED_IDS
554	{ _SC_SAVED_IDS,	"_SC_SAVED_IDS"	},	/* do we have saved uid/gids */
555#endif
556#ifdef	_SC_VERSION
557	{ _SC_VERSION,	"_SC_VERSION"	},	/* POSIX version supported */
558#endif
559	{ 0,		NULL		},
560};
561
562int
563sys_sysconf(tcp)
564struct tcb *tcp;
565{
566	if (entering(tcp)) {
567		printxval(sysconflimits, tcp->u_arg[0], "_SC_???");
568	}
569	return 0;
570}
571
572#endif /* SUNOS4 */
573
574#if defined(SUNOS4) || defined(FREEBSD)
575static const struct xlat pathconflimits[] = {
576#ifdef	_PC_LINK_MAX
577	{ _PC_LINK_MAX,	"_PC_LINK_MAX"	},	/* max links to file/dir */
578#endif
579#ifdef	_PC_MAX_CANON
580	{ _PC_MAX_CANON,	"_PC_MAX_CANON"	},	/* max line length */
581#endif
582#ifdef	_PC_MAX_INPUT
583	{ _PC_MAX_INPUT,	"_PC_MAX_INPUT"	},	/* max "packet" to a tty device */
584#endif
585#ifdef	_PC_NAME_MAX
586	{ _PC_NAME_MAX,	"_PC_NAME_MAX"	},	/* max pathname component length */
587#endif
588#ifdef	_PC_PATH_MAX
589	{ _PC_PATH_MAX,	"_PC_PATH_MAX"	},	/* max pathname length */
590#endif
591#ifdef	_PC_PIPE_BUF
592	{ _PC_PIPE_BUF,	"_PC_PIPE_BUF"	},	/* size of a pipe */
593#endif
594#ifdef	_PC_CHOWN_RESTRICTED
595	{ _PC_CHOWN_RESTRICTED,	"_PC_CHOWN_RESTRICTED"	},	/* can we give away files */
596#endif
597#ifdef	_PC_NO_TRUNC
598	{ _PC_NO_TRUNC,	"_PC_NO_TRUNC"	},	/* trunc or error on >NAME_MAX */
599#endif
600#ifdef	_PC_VDISABLE
601	{ _PC_VDISABLE,	"_PC_VDISABLE"	},	/* best char to shut off tty c_cc */
602#endif
603	{ 0,		NULL		},
604};
605
606
607int
608sys_pathconf(tcp)
609struct tcb *tcp;
610{
611	if (entering(tcp)) {
612		printstr(tcp, tcp->u_arg[0], -1);
613		tprintf(", ");
614		printxval(pathconflimits, tcp->u_arg[1], "_PC_???");
615	}
616	return 0;
617}
618
619int
620sys_fpathconf(tcp)
621struct tcb *tcp;
622{
623	if (entering(tcp)) {
624		tprintf("%lu, ", tcp->u_arg[0]);
625		printxval(pathconflimits, tcp->u_arg[1], "_PC_???");
626	}
627	return 0;
628}
629
630#endif /* SUNOS4 || FREEBSD */
631
632#ifdef SVR4
633
634#ifdef HAVE_SYS_SYSCONFIG_H
635#include <sys/sysconfig.h>
636#endif /* HAVE_SYS_SYSCONFIG_H */
637
638#include <sys/mount.h>
639#include <sys/systeminfo.h>
640#include <sys/utsname.h>
641
642static const struct xlat sysconfig_options[] = {
643#ifdef _CONFIG_NGROUPS
644	{ _CONFIG_NGROUPS,		"_CONFIG_NGROUPS"		},
645#endif
646#ifdef _CONFIG_CHILD_MAX
647	{ _CONFIG_CHILD_MAX,		"_CONFIG_CHILD_MAX"		},
648#endif
649#ifdef _CONFIG_OPEN_FILES
650	{ _CONFIG_OPEN_FILES,		"_CONFIG_OPEN_FILES"		},
651#endif
652#ifdef _CONFIG_POSIX_VER
653	{ _CONFIG_POSIX_VER,		"_CONFIG_POSIX_VER"		},
654#endif
655#ifdef _CONFIG_PAGESIZE
656	{ _CONFIG_PAGESIZE,		"_CONFIG_PAGESIZE"		},
657#endif
658#ifdef _CONFIG_CLK_TCK
659	{ _CONFIG_CLK_TCK,		"_CONFIG_CLK_TCK"		},
660#endif
661#ifdef _CONFIG_XOPEN_VER
662	{ _CONFIG_XOPEN_VER,		"_CONFIG_XOPEN_VER"		},
663#endif
664#ifdef _CONFIG_PROF_TCK
665	{ _CONFIG_PROF_TCK,		"_CONFIG_PROF_TCK"		},
666#endif
667#ifdef _CONFIG_NPROC_CONF
668	{ _CONFIG_NPROC_CONF,		"_CONFIG_NPROC_CONF"		},
669#endif
670#ifdef _CONFIG_NPROC_ONLN
671	{ _CONFIG_NPROC_ONLN,		"_CONFIG_NPROC_ONLN"		},
672#endif
673#ifdef _CONFIG_AIO_LISTIO_MAX
674	{ _CONFIG_AIO_LISTIO_MAX,	"_CONFIG_AIO_LISTIO_MAX"	},
675#endif
676#ifdef _CONFIG_AIO_MAX
677	{ _CONFIG_AIO_MAX,		"_CONFIG_AIO_MAX"		},
678#endif
679#ifdef _CONFIG_AIO_PRIO_DELTA_MAX
680	{ _CONFIG_AIO_PRIO_DELTA_MAX,	"_CONFIG_AIO_PRIO_DELTA_MAX"	},
681#endif
682#ifdef _CONFIG_CONFIG_DELAYTIMER_MAX
683	{ _CONFIG_DELAYTIMER_MAX,	"_CONFIG_DELAYTIMER_MAX"	},
684#endif
685#ifdef _CONFIG_MQ_OPEN_MAX
686	{ _CONFIG_MQ_OPEN_MAX,		"_CONFIG_MQ_OPEN_MAX"		},
687#endif
688#ifdef _CONFIG_MQ_PRIO_MAX
689	{ _CONFIG_MQ_PRIO_MAX,		"_CONFIG_MQ_PRIO_MAX"		},
690#endif
691#ifdef _CONFIG_RTSIG_MAX
692	{ _CONFIG_RTSIG_MAX,		"_CONFIG_RTSIG_MAX"		},
693#endif
694#ifdef _CONFIG_SEM_NSEMS_MAX
695	{ _CONFIG_SEM_NSEMS_MAX,	"_CONFIG_SEM_NSEMS_MAX"		},
696#endif
697#ifdef _CONFIG_SEM_VALUE_MAX
698	{ _CONFIG_SEM_VALUE_MAX,	"_CONFIG_SEM_VALUE_MAX"		},
699#endif
700#ifdef _CONFIG_SIGQUEUE_MAX
701	{ _CONFIG_SIGQUEUE_MAX,		"_CONFIG_SIGQUEUE_MAX"		},
702#endif
703#ifdef _CONFIG_SIGRT_MIN
704	{ _CONFIG_SIGRT_MIN,		"_CONFIG_SIGRT_MIN"		},
705#endif
706#ifdef _CONFIG_SIGRT_MAX
707	{ _CONFIG_SIGRT_MAX,		"_CONFIG_SIGRT_MAX"		},
708#endif
709#ifdef _CONFIG_TIMER_MAX
710	{ _CONFIG_TIMER_MAX,		"_CONFIG_TIMER_MAX"		},
711#endif
712#ifdef _CONFIG_CONFIG_PHYS_PAGES
713	{ _CONFIG_PHYS_PAGES,		"_CONFIG_PHYS_PAGES"		},
714#endif
715#ifdef _CONFIG_AVPHYS_PAGES
716	{ _CONFIG_AVPHYS_PAGES,		"_CONFIG_AVPHYS_PAGES"		},
717#endif
718	{ 0,				NULL				},
719};
720
721int
722sys_sysconfig(tcp)
723struct tcb *tcp;
724{
725	if (entering(tcp))
726		printxval(sysconfig_options, tcp->u_arg[0], "_CONFIG_???");
727	return 0;
728}
729
730static const struct xlat sysinfo_options[] = {
731	{ SI_SYSNAME,		"SI_SYSNAME"		},
732	{ SI_HOSTNAME,		"SI_HOSTNAME"		},
733	{ SI_RELEASE,		"SI_RELEASE"		},
734	{ SI_VERSION,		"SI_VERSION"		},
735	{ SI_MACHINE,		"SI_MACHINE"		},
736	{ SI_ARCHITECTURE,	"SI_ARCHITECTURE"	},
737	{ SI_HW_SERIAL,		"SI_HW_SERIAL"		},
738	{ SI_HW_PROVIDER,	"SI_HW_PROVIDER"	},
739	{ SI_SRPC_DOMAIN,	"SI_SRPC_DOMAIN"	},
740#ifdef SI_SET_HOSTNAME
741	{ SI_SET_HOSTNAME,	"SI_SET_HOSTNAME"	},
742#endif
743#ifdef SI_SET_SRPC_DOMAIN
744	{ SI_SET_SRPC_DOMAIN,	"SI_SET_SRPC_DOMAIN"	},
745#endif
746#ifdef SI_SET_KERB_REALM
747	{ SI_SET_KERB_REALM,	"SI_SET_KERB_REALM"	},
748#endif
749#ifdef 	SI_KERB_REALM
750	{ SI_KERB_REALM,	"SI_KERB_REALM"		},
751#endif
752	{ 0,			NULL			},
753};
754
755int
756sys_sysinfo(tcp)
757struct tcb *tcp;
758{
759	if (entering(tcp)) {
760		printxval(sysinfo_options, tcp->u_arg[0], "SI_???");
761		tprintf(", ");
762	}
763	else {
764		/* Technically some calls write values.  So what. */
765		if (syserror(tcp))
766			tprintf("%#lx", tcp->u_arg[1]);
767		else
768			printpath(tcp, tcp->u_arg[1]);
769		tprintf(", %lu", tcp->u_arg[2]);
770	}
771	return 0;
772}
773
774#ifdef MIPS
775
776#include <sys/syssgi.h>
777
778static const struct xlat syssgi_options[] = {
779	{ SGI_SYSID,		"SGI_SYSID"		},
780#ifdef SGI_RDUBLK
781	{ SGI_RDUBLK,		"SGI_RDUBLK"		},
782#endif
783	{ SGI_TUNE,		"SGI_TUNE"		},
784	{ SGI_IDBG,		"SGI_IDBG"		},
785	{ SGI_INVENT,		"SGI_INVENT"		},
786	{ SGI_RDNAME,		"SGI_RDNAME"		},
787	{ SGI_SETLED,		"SGI_SETLED"		},
788	{ SGI_SETNVRAM,		"SGI_SETNVRAM"		},
789	{ SGI_GETNVRAM,		"SGI_GETNVRAM"		},
790	{ SGI_QUERY_FTIMER,	"SGI_QUERY_FTIMER"	},
791	{ SGI_QUERY_CYCLECNTR,	"SGI_QUERY_CYCLECNTR"	},
792	{ SGI_PROCSZ,		"SGI_PROCSZ"		},
793	{ SGI_SIGACTION,	"SGI_SIGACTION"		},
794	{ SGI_SIGPENDING,	"SGI_SIGPENDING"	},
795	{ SGI_SIGPROCMASK,	"SGI_SIGPROCMASK"	},
796	{ SGI_SIGSUSPEND,	"SGI_SIGSUSPEND"	},
797	{ SGI_SETSID,		"SGI_SETSID"		},
798	{ SGI_SETPGID,		"SGI_SETPGID"		},
799	{ SGI_SYSCONF,		"SGI_SYSCONF"		},
800	{ SGI_WAIT4,		"SGI_WAIT4"		},
801	{ SGI_PATHCONF,		"SGI_PATHCONF"		},
802	{ SGI_READB,		"SGI_READB"		},
803	{ SGI_WRITEB,		"SGI_WRITEB"		},
804	{ SGI_SETGROUPS,	"SGI_SETGROUPS"		},
805	{ SGI_GETGROUPS,	"SGI_GETGROUPS"		},
806	{ SGI_SETTIMEOFDAY,	"SGI_SETTIMEOFDAY"	},
807	{ SGI_SETTIMETRIM,	"SGI_SETTIMETRIM"	},
808	{ SGI_GETTIMETRIM,	"SGI_GETTIMETRIM"	},
809	{ SGI_SPROFIL,		"SGI_SPROFIL"		},
810	{ SGI_RUSAGE,		"SGI_RUSAGE"		},
811	{ SGI_SIGSTACK,		"SGI_SIGSTACK"		},
812	{ SGI_SIGSTATUS,	"SGI_SIGSTATUS"		},
813	{ SGI_NETPROC,		"SGI_NETPROC"		},
814	{ SGI_SIGALTSTACK,	"SGI_SIGALTSTACK"	},
815	{ SGI_BDFLUSHCNT,	"SGI_BDFLUSHCNT"	},
816	{ SGI_SSYNC,		"SGI_SSYNC"		},
817	{ SGI_NFSCNVT,		"SGI_NFSCNVT"		},
818	{ SGI_GETPGID,		"SGI_GETPGID"		},
819	{ SGI_GETSID,		"SGI_GETSID"		},
820	{ SGI_IOPROBE,		"SGI_IOPROBE"		},
821	{ SGI_CONFIG,		"SGI_CONFIG"		},
822	{ SGI_ELFMAP,		"SGI_ELFMAP"		},
823	{ SGI_MCONFIG,		"SGI_MCONFIG"		},
824	{ SGI_GETPLABEL,	"SGI_GETPLABEL"		},
825	{ SGI_SETPLABEL,	"SGI_SETPLABEL"		},
826	{ SGI_GETLABEL,		"SGI_GETLABEL"		},
827	{ SGI_SETLABEL,		"SGI_SETLABEL"		},
828	{ SGI_SATREAD,		"SGI_SATREAD"		},
829	{ SGI_SATWRITE,		"SGI_SATWRITE"		},
830	{ SGI_SATCTL,		"SGI_SATCTL"		},
831	{ SGI_LOADATTR,		"SGI_LOADATTR"		},
832	{ SGI_UNLOADATTR,	"SGI_UNLOADATTR"	},
833#ifdef SGI_RECVLMSG
834	{ SGI_RECVLMSG,		"SGI_RECVLMSG"		},
835#endif
836	{ SGI_PLANGMOUNT,	"SGI_PLANGMOUNT"	},
837	{ SGI_GETPSOACL,	"SGI_GETPSOACL"		},
838	{ SGI_SETPSOACL,	"SGI_SETPSOACL"		},
839#ifdef SGI_EAG_GET_ATTR
840	{ SGI_EAG_GET_ATTR,	"SGI_EAG_GET_ATTR"	},
841#endif
842#ifdef SGI_EAG_SET_ATTR
843	{ SGI_EAG_SET_ATTR,	"SGI_EAG_SET_ATTR"	},
844#endif
845#ifdef SGI_EAG_GET_PROCATTR
846	{ SGI_EAG_GET_PROCATTR,	"SGI_EAG_GET_PROCATTR"	},
847#endif
848#ifdef SGI_EAG_SET_PROCATTR
849	{ SGI_EAG_SET_PROCATTR,	"SGI_EAG_SET_PROCATTR"	},
850#endif
851#ifdef SGI_FREVOKE
852	{ SGI_FREVOKE,		"SGI_FREVOKE"		},
853#endif
854#ifdef SGI_SBE_GET_INFO
855	{ SGI_SBE_GET_INFO,	"SGI_SBE_GET_INFO"	},
856#endif
857#ifdef SGI_SBE_CLR_INFO
858	{ SGI_SBE_CLR_INFO,	"SGI_SBE_CLR_INFO"	},
859#endif
860	{ SGI_RMI_FIXECC,	"SGI_RMI_FIXECC"	},
861	{ SGI_R4K_CERRS,	"SGI_R4K_CERRS"		},
862	{ SGI_GET_EVCONF,	"SGI_GET_EVCONF"	},
863	{ SGI_MPCWAROFF,	"SGI_MPCWAROFF"		},
864	{ SGI_SET_AUTOPWRON,	"SGI_SET_AUTOPWRON"	},
865	{ SGI_SPIPE,		"SGI_SPIPE"		},
866	{ SGI_SYMTAB,		"SGI_SYMTAB"		},
867#ifdef SGI_SET_FPDEBUG
868	{ SGI_SET_FPDEBUG,	"SGI_SET_FPDEBUG"	},
869#endif
870#ifdef SGI_SET_FP_PRECISE
871	{ SGI_SET_FP_PRECISE,	"SGI_SET_FP_PRECISE"	},
872#endif
873	{ SGI_TOSSTSAVE,	"SGI_TOSSTSAVE"		},
874	{ SGI_FDHI,		"SGI_FDHI"		},
875#ifdef SGI_SET_CONFIG_SMM
876	{ SGI_SET_CONFIG_SMM,	"SGI_SET_CONFIG_SMM"	},
877#endif
878#ifdef SGI_SET_FP_PRESERVE
879	{ SGI_SET_FP_PRESERVE,	"SGI_SET_FP_PRESERVE"	},
880#endif
881	{ SGI_MINRSS,		"SGI_MINRSS"		},
882#ifdef SGI_GRIO
883	{ SGI_GRIO,		"SGI_GRIO"		},
884#endif
885#ifdef SGI_XLV_SET_TAB
886	{ SGI_XLV_SET_TAB,	"SGI_XLV_SET_TAB"	},
887#endif
888#ifdef SGI_XLV_GET_TAB
889	{ SGI_XLV_GET_TAB,	"SGI_XLV_GET_TAB"	},
890#endif
891#ifdef SGI_GET_FP_PRECISE
892	{ SGI_GET_FP_PRECISE,	"SGI_GET_FP_PRECISE"	},
893#endif
894#ifdef SGI_GET_CONFIG_SMM
895	{ SGI_GET_CONFIG_SMM,	"SGI_GET_CONFIG_SMM"	},
896#endif
897#ifdef SGI_FP_IMPRECISE_SUPP
898	{ SGI_FP_IMPRECISE_SUPP,"SGI_FP_IMPRECISE_SUPP"	},
899#endif
900#ifdef SGI_CONFIG_NSMM_SUPP
901	{ SGI_CONFIG_NSMM_SUPP,	"SGI_CONFIG_NSMM_SUPP"	},
902#endif
903#ifdef SGI_RT_TSTAMP_CREATE
904	{ SGI_RT_TSTAMP_CREATE,	"SGI_RT_TSTAMP_CREATE"	},
905#endif
906#ifdef SGI_RT_TSTAMP_DELETE
907	{ SGI_RT_TSTAMP_DELETE,	"SGI_RT_TSTAMP_DELETE"	},
908#endif
909#ifdef SGI_RT_TSTAMP_START
910	{ SGI_RT_TSTAMP_START,	"SGI_RT_TSTAMP_START"	},
911#endif
912#ifdef SGI_RT_TSTAMP_STOP
913	{ SGI_RT_TSTAMP_STOP,	"SGI_RT_TSTAMP_STOP"	},
914#endif
915#ifdef SGI_RT_TSTAMP_ADDR
916	{ SGI_RT_TSTAMP_ADDR,	"SGI_RT_TSTAMP_ADDR"	},
917#endif
918#ifdef SGI_RT_TSTAMP_MASK
919	{ SGI_RT_TSTAMP_MASK,	"SGI_RT_TSTAMP_MASK"	},
920#endif
921#ifdef SGI_RT_TSTAMP_EOB_MODE
922	{ SGI_RT_TSTAMP_EOB_MODE,"SGI_RT_TSTAMP_EOB_MODE"},
923#endif
924#ifdef SGI_USE_FP_BCOPY
925	{ SGI_USE_FP_BCOPY,	"SGI_USE_FP_BCOPY"	},
926#endif
927#ifdef SGI_GET_UST
928	{ SGI_GET_UST,		"SGI_GET_UST"		},
929#endif
930#ifdef SGI_SPECULATIVE_EXEC
931	{ SGI_SPECULATIVE_EXEC,	"SGI_SPECULATIVE_EXEC"	},
932#endif
933#ifdef SGI_XLV_NEXT_RQST
934	{ SGI_XLV_NEXT_RQST,	"SGI_XLV_NEXT_RQST"	},
935#endif
936#ifdef SGI_XLV_ATTR_CURSOR
937	{ SGI_XLV_ATTR_CURSOR,	"SGI_XLV_ATTR_CURSOR"	},
938#endif
939#ifdef SGI_XLV_ATTR_GET
940	{ SGI_XLV_ATTR_GET,	"SGI_XLV_ATTR_GET"	},
941#endif
942#ifdef SGI_XLV_ATTR_SET
943	{ SGI_XLV_ATTR_SET,	"SGI_XLV_ATTR_SET"	},
944#endif
945#ifdef SGI_BTOOLSIZE
946	{ SGI_BTOOLSIZE,	"SGI_BTOOLSIZE"		},
947#endif
948#ifdef SGI_BTOOLGET
949	{ SGI_BTOOLGET,		"SGI_BTOOLGET"		},
950#endif
951#ifdef SGI_BTOOLREINIT
952	{ SGI_BTOOLREINIT,	"SGI_BTOOLREINIT"	},
953#endif
954#ifdef SGI_CREATE_UUID
955	{ SGI_CREATE_UUID,	"SGI_CREATE_UUID"	},
956#endif
957#ifdef SGI_NOFPE
958	{ SGI_NOFPE,		"SGI_NOFPE"		},
959#endif
960#ifdef SGI_OLD_SOFTFP
961	{ SGI_OLD_SOFTFP,	"SGI_OLD_SOFTFP"	},
962#endif
963#ifdef SGI_FS_INUMBERS
964	{ SGI_FS_INUMBERS,	"SGI_FS_INUMBERS"	},
965#endif
966#ifdef SGI_FS_BULKSTAT
967	{ SGI_FS_BULKSTAT,	"SGI_FS_BULKSTAT"	},
968#endif
969#ifdef SGI_RT_TSTAMP_WAIT
970	{ SGI_RT_TSTAMP_WAIT,	"SGI_RT_TSTAMP_WAIT"	},
971#endif
972#ifdef SGI_RT_TSTAMP_UPDATE
973	{ SGI_RT_TSTAMP_UPDATE,	"SGI_RT_TSTAMP_UPDATE"	},
974#endif
975#ifdef SGI_PATH_TO_HANDLE
976	{ SGI_PATH_TO_HANDLE,	"SGI_PATH_TO_HANDLE"	},
977#endif
978#ifdef SGI_PATH_TO_FSHANDLE
979	{ SGI_PATH_TO_FSHANDLE,	"SGI_PATH_TO_FSHANDLE"	},
980#endif
981#ifdef SGI_FD_TO_HANDLE
982	{ SGI_FD_TO_HANDLE,	"SGI_FD_TO_HANDLE"	},
983#endif
984#ifdef SGI_OPEN_BY_HANDLE
985	{ SGI_OPEN_BY_HANDLE,	"SGI_OPEN_BY_HANDLE"	},
986#endif
987#ifdef SGI_READLINK_BY_HANDLE
988	{ SGI_READLINK_BY_HANDLE,"SGI_READLINK_BY_HANDLE"},
989#endif
990#ifdef SGI_READ_DANGID
991	{ SGI_READ_DANGID,	"SGI_READ_DANGID"	},
992#endif
993#ifdef SGI_CONST
994	{ SGI_CONST,		"SGI_CONST"		},
995#endif
996#ifdef SGI_XFS_FSOPERATIONS
997	{ SGI_XFS_FSOPERATIONS,	"SGI_XFS_FSOPERATIONS"	},
998#endif
999#ifdef SGI_SETASH
1000	{ SGI_SETASH,		"SGI_SETASH"		},
1001#endif
1002#ifdef SGI_GETASH
1003	{ SGI_GETASH,		"SGI_GETASH"		},
1004#endif
1005#ifdef SGI_SETPRID
1006	{ SGI_SETPRID,		"SGI_SETPRID"		},
1007#endif
1008#ifdef SGI_GETPRID
1009	{ SGI_GETPRID,		"SGI_GETPRID"		},
1010#endif
1011#ifdef SGI_SETSPINFO
1012	{ SGI_SETSPINFO,	"SGI_SETSPINFO"		},
1013#endif
1014#ifdef SGI_GETSPINFO
1015	{ SGI_GETSPINFO,	"SGI_GETSPINFO"		},
1016#endif
1017#ifdef SGI_SHAREII
1018	{ SGI_SHAREII,		"SGI_SHAREII"		},
1019#endif
1020#ifdef SGI_NEWARRAYSESS
1021	{ SGI_NEWARRAYSESS,	"SGI_NEWARRAYSESS"	},
1022#endif
1023#ifdef SGI_GETDFLTPRID
1024	{ SGI_GETDFLTPRID,	"SGI_GETDFLTPRID"	},
1025#endif
1026#ifdef SGI_SET_DISMISSED_EXC_CNT
1027	{ SGI_SET_DISMISSED_EXC_CNT,"SGI_SET_DISMISSED_EXC_CNT"	},
1028#endif
1029#ifdef SGI_GET_DISMISSED_EXC_CNT
1030	{ SGI_GET_DISMISSED_EXC_CNT,"SGI_GET_DISMISSED_EXC_CNT"	},
1031#endif
1032#ifdef SGI_CYCLECNTR_SIZE
1033	{ SGI_CYCLECNTR_SIZE,	"SGI_CYCLECNTR_SIZE"	},
1034#endif
1035#ifdef SGI_QUERY_FASTTIMER
1036	{ SGI_QUERY_FASTTIMER,	"SGI_QUERY_FASTTIMER"	},
1037#endif
1038#ifdef SGI_PIDSINASH
1039	{ SGI_PIDSINASH,	"SGI_PIDSINASH"		},
1040#endif
1041#ifdef SGI_ULI
1042	{ SGI_ULI,		"SGI_ULI"		},
1043#endif
1044#ifdef SGI_LPG_SHMGET
1045	{ SGI_LPG_SHMGET,	"SGI_LPG_SHMGET"	},
1046#endif
1047#ifdef SGI_LPG_MAP
1048	{ SGI_LPG_MAP,		"SGI_LPG_MAP"		},
1049#endif
1050#ifdef SGI_CACHEFS_SYS
1051	{ SGI_CACHEFS_SYS,	"SGI_CACHEFS_SYS"	},
1052#endif
1053#ifdef SGI_NFSNOTIFY
1054	{ SGI_NFSNOTIFY,	"SGI_NFSNOTIFY"		},
1055#endif
1056#ifdef SGI_LOCKDSYS
1057	{ SGI_LOCKDSYS,		"SGI_LOCKDSYS"		},
1058#endif
1059#ifdef SGI_EVENTCTR
1060	{ SGI_EVENTCTR,		"SGI_EVENTCTR"		},
1061#endif
1062#ifdef SGI_GETPRUSAGE
1063	{ SGI_GETPRUSAGE,	"SGI_GETPRUSAGE"	},
1064#endif
1065#ifdef SGI_PROCMASK_LOCATION
1066	{ SGI_PROCMASK_LOCATION,"SGI_PROCMASK_LOCATION"	},
1067#endif
1068#ifdef SGI_UNUSED
1069	{ SGI_UNUSED,		"SGI_UNUSED"		},
1070#endif
1071#ifdef SGI_CKPT_SYS
1072	{ SGI_CKPT_SYS,		"SGI_CKPT_SYS"		},
1073#endif
1074#ifdef SGI_CKPT_SYS
1075	{ SGI_CKPT_SYS,		"SGI_CKPT_SYS"		},
1076#endif
1077#ifdef SGI_GETGRPPID
1078	{ SGI_GETGRPPID,	"SGI_GETGRPPID"		},
1079#endif
1080#ifdef SGI_GETSESPID
1081	{ SGI_GETSESPID,	"SGI_GETSESPID"		},
1082#endif
1083#ifdef SGI_ENUMASHS
1084	{ SGI_ENUMASHS,		"SGI_ENUMASHS"		},
1085#endif
1086#ifdef SGI_SETASMACHID
1087	{ SGI_SETASMACHID,	"SGI_SETASMACHID"	},
1088#endif
1089#ifdef SGI_GETASMACHID
1090	{ SGI_GETASMACHID,	"SGI_GETASMACHID"	},
1091#endif
1092#ifdef SGI_GETARSESS
1093	{ SGI_GETARSESS,	"SGI_GETARSESS"		},
1094#endif
1095#ifdef SGI_JOINARRAYSESS
1096	{ SGI_JOINARRAYSESS,	"SGI_JOINARRAYSESS"	},
1097#endif
1098#ifdef SGI_SPROC_KILL
1099	{ SGI_SPROC_KILL,	"SGI_SPROC_KILL"	},
1100#endif
1101#ifdef SGI_DBA_CONFIG
1102	{ SGI_DBA_CONFIG,	"SGI_DBA_CONFIG"	},
1103#endif
1104#ifdef SGI_RELEASE_NAME
1105	{ SGI_RELEASE_NAME,	"SGI_RELEASE_NAME"	},
1106#endif
1107#ifdef SGI_SYNCH_CACHE_HANDLER
1108	{ SGI_SYNCH_CACHE_HANDLER,"SGI_SYNCH_CACHE_HANDLER"},
1109#endif
1110#ifdef SGI_SWASH_INIT
1111	{ SGI_SWASH_INIT,	"SGI_SWASH_INIT"	},
1112#endif
1113#ifdef SGI_NUMA_MIGR_PAGE
1114	{ SGI_NUMA_MIGR_PAGE,	"SGI_NUMA_MIGR_PAGE"	},
1115#endif
1116#ifdef SGI_NUMA_MIGR_PAGE_ALT
1117	{ SGI_NUMA_MIGR_PAGE_ALT,"SGI_NUMA_MIGR_PAGE_ALT"},
1118#endif
1119#ifdef SGI_KAIO_USERINIT
1120	{ SGI_KAIO_USERINIT,	"SGI_KAIO_USERINIT"	},
1121#endif
1122#ifdef SGI_KAIO_READ
1123	{ SGI_KAIO_READ,	"SGI_KAIO_READ"		},
1124#endif
1125#ifdef SGI_KAIO_WRITE
1126	{ SGI_KAIO_WRITE,	"SGI_KAIO_WRITE"	},
1127#endif
1128#ifdef SGI_KAIO_SUSPEND
1129	{ SGI_KAIO_SUSPEND,	"SGI_KAIO_SUSPEND"	},
1130#endif
1131#ifdef SGI_KAIO_STATS
1132	{ SGI_KAIO_STATS,	"SGI_KAIO_STATS"	},
1133#endif
1134#ifdef SGI_INITIAL_PT_SPROC
1135	{ SGI_INITIAL_PT_SPROC,	"SGI_INITIAL_PT_SPROC"	},
1136#endif
1137	{ 0,			NULL			},
1138};
1139
1140int
1141sys_syssgi(tcp)
1142struct tcb *tcp;
1143{
1144	int i;
1145
1146	if (entering(tcp)) {
1147		printxval(syssgi_options, tcp->u_arg[0], "SGI_???");
1148		switch (tcp->u_arg[0]) {
1149		default:
1150			for (i = 1; i < tcp->u_nargs; i++)
1151				tprintf(", %#lx", tcp->u_arg[i]);
1152			break;
1153		}
1154	}
1155	return 0;
1156}
1157
1158#include <sys/types.h>
1159#include <rpc/rpc.h>
1160struct cred;
1161struct uio;
1162#include <sys/fsid.h>
1163#include <sys/vnode.h>
1164#include <sys/fs/nfs.h>
1165#include <sys/fs/nfs_clnt.h>
1166
1167static const struct xlat mount_flags[] = {
1168	{ MS_RDONLY,	"MS_RDONLY"	},
1169	{ MS_FSS,	"MS_FSS"	},
1170	{ MS_DATA,	"MS_DATA"	},
1171	{ MS_NOSUID,	"MS_NOSUID"	},
1172	{ MS_REMOUNT,	"MS_REMOUNT"	},
1173	{ MS_NOTRUNC,	"MS_NOTRUNC"	},
1174	{ MS_GRPID,	"MS_GRPID"	},
1175	{ MS_NODEV,	"MS_NODEV"	},
1176	{ MS_BEFORE,	"MS_BEFORE"	},
1177	{ MS_AFTER,	"MS_AFTER"	},
1178	{ 0,		NULL		},
1179};
1180
1181static const struct xlat nfs_flags[] = {
1182	{ NFSMNT_SOFT,		"NFSMNT_SOFT"		},
1183	{ NFSMNT_WSIZE,		"NFSMNT_WSIZE"		},
1184	{ NFSMNT_RSIZE,		"NFSMNT_RSIZE"		},
1185	{ NFSMNT_TIMEO,		"NFSMNT_TIMEO"		},
1186	{ NFSMNT_RETRANS,	"NFSMNT_RETRANS"	},
1187	{ NFSMNT_HOSTNAME,	"NFSMNT_HOSTNAME"	},
1188#ifdef NFSMNT_NOINT	/* IRIX 6 */
1189	{ NFSMNT_NOINT,		"NFSMNT_NOINT"		},
1190#endif
1191#ifdef NFSMNT_INT	/* IRIX 5 */
1192	{ NFSMNT_INT,		"NFSMNT_INT"		},
1193#endif
1194	{ NFSMNT_NOAC,		"NFSMNT_NOAC"		},
1195	{ NFSMNT_ACREGMIN,	"NFSMNT_ACREGMIN"	},
1196	{ NFSMNT_ACREGMAX,	"NFSMNT_ACREGMAX"	},
1197	{ NFSMNT_ACDIRMIN,	"NFSMNT_ACDIRMIN"	},
1198	{ NFSMNT_ACDIRMAX,	"NFSMNT_ACDIRMAX"	},
1199	{ NFSMNT_PRIVATE,	"NFSMNT_PRIVATE"	},
1200	{ NFSMNT_SYMTTL,	"NFSMNT_SYMTTL"		},
1201	{ NFSMNT_LOOPBACK,	"NFSMNT_LOOPBACK"	},
1202	{ NFSMNT_BASETYPE,	"NFSMNT_BASETYPE"	},
1203	{ NFSMNT_NAMEMAX,	"NFSMNT_NAMEMAX"	},
1204#ifdef NFSMNT_SHORTUID	/* IRIX 6 */
1205	{ NFSMNT_SHORTUID,	"NFSMNT_SHORTUID"	},
1206#endif
1207#ifdef NFSMNT_ASYNCNLM	/* IRIX 6 */
1208	{ NFSMNT_ASYNCNLM,	"NFSMNT_ASYNCNLM"	},
1209#endif
1210	{ 0,			NULL			},
1211};
1212
1213int
1214sys_mount(tcp)
1215struct tcb *tcp;
1216{
1217	if (entering(tcp)) {
1218		printpath(tcp, tcp->u_arg[0]);
1219		tprintf(", ");
1220		printpath(tcp, tcp->u_arg[1]);
1221		tprintf(", ");
1222		printflags(mount_flags, tcp->u_arg[2], "MS_???");
1223		if (tcp->u_arg[2] & (MS_FSS | MS_DATA)) {
1224			tprintf(", ");
1225			tprintf("%ld", tcp->u_arg[3]);
1226		}
1227		if (tcp->u_arg[2] & MS_DATA) {
1228			int nfs_type = sysfs(GETFSIND, FSID_NFS);
1229
1230			tprintf(", ");
1231			if (tcp->u_arg[3] == nfs_type) {
1232				struct nfs_args args;
1233				if (umove(tcp, tcp->u_arg[4], &args) < 0)
1234					tprintf("%#lx", tcp->u_arg[4]);
1235				else {
1236					tprintf("addr=");
1237					printsock(tcp, (int) args.addr);
1238					tprintf(", flags=");
1239					printflags(nfs_flags, args.flags, "NFSMNT_???");
1240					tprintf(", hostname=");
1241					printstr(tcp, (int) args.hostname, -1);
1242					tprintf(", ...}");
1243				}
1244			}
1245			else
1246				tprintf("%#lx", tcp->u_arg[4]);
1247			tprintf(", %ld", tcp->u_arg[5]);
1248		}
1249	}
1250	return 0;
1251}
1252
1253#else /* !MIPS */
1254
1255#if UNIXWARE
1256
1257#include <sys/types.h>
1258#include <sys/fstyp.h>
1259#include <sys/mount.h>
1260#include <sys/xti.h>
1261
1262#define NFSCLIENT	1
1263#include <nfs/mount.h>
1264
1265#include <sys/fs/vx_ioctl.h>
1266
1267static const struct xlat mount_flags[] = {
1268	{ MS_RDONLY,	"MS_RDONLY"	},
1269	{ MS_FSS,	"MS_FSS"	},
1270	{ MS_DATA,	"MS_DATA"	},
1271	{ MS_HADBAD,	"MS_HADBAD"	},
1272	{ MS_NOSUID,	"MS_NOSUID"	},
1273	{ MS_REMOUNT,	"MS_REMOUNT"	},
1274	{ MS_NOTRUNC,	"MS_NOTRUNC"	},
1275	{ MS_SOFTMNT,	"MS_SOFTMNT"	},
1276	{ MS_SYSSPACE,	"MS_SYSSPACE"	},
1277	{ 0,		NULL		},
1278};
1279
1280#ifdef VX_MS_MASK
1281static const struct xlat vxfs_flags[] = {
1282	{ VX_MS_NOLOG,		"VX_MS_NOLOG"		},
1283	{ VX_MS_BLKCLEAR,	"VX_MS_BLKCLEAR"	},
1284	{ VX_MS_SNAPSHOT,	"VX_MS_SNAPSHOT"	},
1285	{ VX_MS_NODATAINLOG,	"VX_MS_NODATAINLOG"	},
1286	{ VX_MS_DELAYLOG,	"VX_MS_DELAYLOG"	},
1287	{ VX_MS_TMPLOG,		"VX_MS_TMPLOG"		},
1288	{ VX_MS_FILESET,	"VX_MS_FILESET"		},
1289
1290	{ VX_MS_CACHE_DIRECT,	"VX_MS_CACHE_DIRECT"	},
1291	{ VX_MS_CACHE_DSYNC,	"VX_MS_CACHE_DSYNC"	},
1292	{ VX_MS_CACHE_CLOSESYNC,"VX_MS_CACHE_CLOSESYNC"	},
1293	{ VX_MS_CACHE_TMPCACHE,	"VX_MS_CACHE_TMPCACHE"	},
1294
1295	{ VX_MS_OSYNC_DIRECT,	"VX_MS_OSYNC_DIRECT"	},
1296	{ VX_MS_OSYNC_DSYNC,	"VX_MS_OSYNC_DSYNC"	},
1297	{ VX_MS_OSYNC_CLOSESYNC,"VX_MS_OSYNC_CLOSESYNC"	},
1298	{ VX_MS_OSYNC_DELAY,	"VX_MS_OSYNC_DELAY"	},
1299	{ 0,			NULL,			},
1300};
1301#endif
1302
1303static const struct xlat nfs_flags[] = {
1304	{ NFSMNT_SOFT,		"NFSMNT_SOFT"		},
1305	{ NFSMNT_WSIZE,		"NFSMNT_WSIZE"		},
1306	{ NFSMNT_RSIZE,		"NFSMNT_RSIZE"		},
1307	{ NFSMNT_TIMEO,		"NFSMNT_TIMEO"		},
1308	{ NFSMNT_RETRANS,	"NFSMNT_RETRANS"	},
1309	{ NFSMNT_HOSTNAME,	"NFSMNT_HOSTNAME"	},
1310	{ NFSMNT_INT,		"NFSMNT_INT"		},
1311	{ NFSMNT_NOAC,		"NFSMNT_NOAC"		},
1312	{ NFSMNT_ACREGMIN,	"NFSMNT_ACREGMIN"	},
1313	{ NFSMNT_ACREGMAX,	"NFSMNT_ACREGMAX"	},
1314	{ NFSMNT_ACDIRMIN,	"NFSMNT_ACDIRMIN"	},
1315	{ NFSMNT_ACDIRMAX,	"NFSMNT_ACDIRMAX"	},
1316	{ NFSMNT_SECURE,	"NFSMNT_SECURE"		},
1317	{ NFSMNT_NOCTO,		"NFSMNT_NOCTO"		},
1318	{ NFSMNT_GRPID,		"NFSMNT_GRPID"		},
1319	{ NFSMNT_RPCTIMESYNC,	"NFSMNT_RPCTIMESYNC"	},
1320	{ NFSMNT_LWPSMAX,	"NFSMNT_LWPSMAX"	},
1321	{ 0,			NULL			},
1322};
1323
1324int
1325sys_mount(tcp)
1326struct tcb *tcp;
1327{
1328	if (entering(tcp)) {
1329		char fstyp [FSTYPSZ];
1330		printpath(tcp, tcp->u_arg[0]);
1331		tprintf(", ");
1332		printpath(tcp, tcp->u_arg[1]);
1333		tprintf(", ");
1334		printflags(mount_flags, tcp->u_arg[2], "MS_???");
1335		/* The doc sez that the file system type is given as a
1336		   fsindex, and we should use sysfs to work out the name.
1337		   This appears to be untrue for UW.  Maybe it's untrue
1338		   for all SVR4's? */
1339		if (tcp->u_arg[2] & (MS_FSS | MS_DATA)) {
1340			if (umovestr(tcp, tcp->u_arg[3], FSTYPSZ, fstyp) < 0) {
1341				*fstyp = 0;
1342				tprintf(", %ld", tcp->u_arg[3]);
1343			}
1344			else
1345				tprintf(", \"%s\"", fstyp);
1346		}
1347		if (tcp->u_arg[2] & MS_DATA) {
1348			tprintf(", ");
1349#ifdef VX_MS_MASK
1350			/* On UW7 they don't give us the defines and structs
1351			   we need to see what is going on.  Bummer. */
1352			if (strcmp (fstyp, "vxfs") == 0) {
1353				struct vx_mountargs5 args;
1354				if (umove(tcp, tcp->u_arg[4], &args) < 0)
1355					tprintf("%#lx", tcp->u_arg[4]);
1356				else {
1357					tprintf("{ flags=");
1358					printflags(vxfs_flags, args.mflags, "VX_MS_???");
1359					if (args.mflags & VX_MS_SNAPSHOT) {
1360						tprintf (", snapof=");
1361						printstr (tcp,
1362							  (long) args.primaryspec,
1363							  -1);
1364						if (args.snapsize > 0)
1365							tprintf (", snapsize=%ld", args.snapsize);
1366					}
1367					tprintf(" }");
1368				}
1369			}
1370			else
1371#endif
1372			if (strcmp (fstyp, "specfs") == 0) {
1373				tprintf ("dev=");
1374				printstr (tcp, tcp->u_arg[4], -1);
1375			}
1376			else
1377			if (strcmp (fstyp, "nfs") == 0) {
1378				struct nfs_args args;
1379				if (umove(tcp, tcp->u_arg[4], &args) < 0)
1380					tprintf("%#lx", tcp->u_arg[4]);
1381				else {
1382					struct netbuf addr;
1383					tprintf("{ addr=");
1384					if (umove (tcp, (int) args.addr, &addr) < 0) {
1385						tprintf ("%#lx", (long) args.addr);
1386					}
1387					else {
1388						printsock(tcp, (int) addr.buf, addr.len);
1389					}
1390					tprintf(", flags=");
1391					printflags(nfs_flags, args.flags, "NFSMNT_???");
1392					tprintf(", hostname=");
1393					printstr(tcp, (int) args.hostname, -1);
1394					tprintf(", ...}");
1395				}
1396			}
1397			else
1398				tprintf("%#lx", tcp->u_arg[4]);
1399			tprintf(", %ld", tcp->u_arg[5]);
1400		}
1401	}
1402	return 0;
1403}
1404
1405#else /* !UNIXWARE */
1406
1407int
1408sys_mount(tcp)
1409struct tcb *tcp;
1410{
1411	if (entering(tcp)) {
1412		printpath(tcp, tcp->u_arg[0]);
1413		tprintf(", ");
1414		printpath(tcp, tcp->u_arg[1]);
1415		tprintf(", ...");
1416	}
1417	return 0;
1418}
1419#endif /* !UNIXWARE */
1420
1421#endif /* !MIPS */
1422
1423#endif /* SVR4 */
1424
1425#ifdef SYS_capget
1426
1427static const struct xlat capabilities[] = {
1428	{ 1<<CAP_CHOWN,		"CAP_CHOWN"	},
1429	{ 1<<CAP_DAC_OVERRIDE,	"CAP_DAC_OVERRIDE"},
1430	{ 1<<CAP_DAC_READ_SEARCH,"CAP_DAC_READ_SEARCH"},
1431	{ 1<<CAP_FOWNER,	"CAP_FOWNER"	},
1432	{ 1<<CAP_FSETID,	"CAP_FSETID"	},
1433	{ 1<<CAP_KILL,		"CAP_KILL"	},
1434	{ 1<<CAP_SETGID,	"CAP_SETGID"	},
1435	{ 1<<CAP_SETUID,	"CAP_SETUID"	},
1436	{ 1<<CAP_SETPCAP,	"CAP_SETPCAP"	},
1437	{ 1<<CAP_LINUX_IMMUTABLE,"CAP_LINUX_IMMUTABLE"},
1438	{ 1<<CAP_NET_BIND_SERVICE,"CAP_NET_BIND_SERVICE"},
1439	{ 1<<CAP_NET_BROADCAST,	"CAP_NET_BROADCAST"},
1440	{ 1<<CAP_NET_ADMIN,	"CAP_NET_ADMIN"	},
1441	{ 1<<CAP_NET_RAW,	"CAP_NET_RAW"	},
1442	{ 1<<CAP_IPC_LOCK,	"CAP_IPC_LOCK"	},
1443	{ 1<<CAP_IPC_OWNER,	"CAP_IPC_OWNER"	},
1444	{ 1<<CAP_SYS_MODULE,	"CAP_SYS_MODULE"},
1445	{ 1<<CAP_SYS_RAWIO,	"CAP_SYS_RAWIO"	},
1446	{ 1<<CAP_SYS_CHROOT,	"CAP_SYS_CHROOT"},
1447	{ 1<<CAP_SYS_PTRACE,	"CAP_SYS_PTRACE"},
1448	{ 1<<CAP_SYS_PACCT,	"CAP_SYS_PACCT"	},
1449	{ 1<<CAP_SYS_ADMIN,	"CAP_SYS_ADMIN"	},
1450	{ 1<<CAP_SYS_BOOT,	"CAP_SYS_BOOT"	},
1451	{ 1<<CAP_SYS_NICE,	"CAP_SYS_NICE"	},
1452	{ 1<<CAP_SYS_RESOURCE,	"CAP_SYS_RESOURCE"},
1453	{ 1<<CAP_SYS_TIME,	"CAP_SYS_TIME"	},
1454	{ 1<<CAP_SYS_TTY_CONFIG,"CAP_SYS_TTY_CONFIG"},
1455	{ 0,                    NULL            },
1456};
1457
1458
1459int
1460sys_capget(tcp)
1461struct tcb *tcp;
1462{
1463	static cap_user_header_t       arg0 = NULL;
1464	static cap_user_data_t         arg1 = NULL;
1465
1466	if(!entering(tcp)) {
1467		if (!arg0) {
1468			if ((arg0 = malloc(sizeof(*arg0))) == NULL) {
1469				fprintf(stderr, "out of memory\n");
1470				tprintf("%#lx, %#lx", tcp->u_arg[0], tcp->u_arg[1]);
1471				return -1;
1472			}
1473		}
1474		if (!arg1) {
1475			if ((arg1 = malloc(sizeof(*arg1))) == NULL) {
1476				fprintf(stderr, "out of memory\n");
1477				tprintf("%#lx, %#lx", tcp->u_arg[0], tcp->u_arg[1]);
1478				return -1;
1479			}
1480		}
1481
1482		if (!tcp->u_arg[0])
1483			tprintf("NULL");
1484		else if (!verbose(tcp))
1485			tprintf("%#lx", tcp->u_arg[0]);
1486		else if (umoven(tcp, tcp->u_arg[0], sizeof(*arg0), (char *) arg0) < 0)
1487			tprintf("???");
1488		else {
1489			tprintf("%#x, %d", arg0->version, arg0->pid);
1490		}
1491		tprintf(", ");
1492		if (!tcp->u_arg[1])
1493			tprintf("NULL");
1494		else if (!verbose(tcp))
1495			tprintf("%#lx", tcp->u_arg[1]);
1496		else if (umoven(tcp, tcp->u_arg[1], sizeof(*arg1), (char *) arg1) < 0)
1497			tprintf("???");
1498		else {
1499			tprintf("{");
1500			printflags(capabilities, arg1->effective, "CAP_???");
1501			tprintf(", ");
1502			printflags(capabilities, arg1->permitted, "CAP_???");
1503			tprintf(", ");
1504			printflags(capabilities, arg1->inheritable, "CAP_???");
1505			tprintf("}");
1506		}
1507	}
1508	return 0;
1509}
1510
1511int
1512sys_capset(tcp)
1513struct tcb *tcp;
1514{
1515	static cap_user_header_t       arg0 = NULL;
1516	static cap_user_data_t         arg1 = NULL;
1517
1518	if(entering(tcp)) {
1519		if (!arg0) {
1520			if ((arg0 = malloc(sizeof(*arg0))) == NULL) {
1521				fprintf(stderr, "out of memory\n");
1522				tprintf("%#lx, %#lx", tcp->u_arg[0], tcp->u_arg[1]);
1523				return -1;
1524			}
1525		}
1526		if (!arg1) {
1527			if ((arg1 = malloc(sizeof(*arg1))) == NULL) {
1528				fprintf(stderr, "out of memory\n");
1529				tprintf("%#lx, %#lx", tcp->u_arg[0], tcp->u_arg[1]);
1530				return -1;
1531			}
1532		}
1533
1534		if (!tcp->u_arg[0])
1535			tprintf("NULL");
1536		else if (!verbose(tcp))
1537			tprintf("%#lx", tcp->u_arg[0]);
1538		else if (umoven(tcp, tcp->u_arg[0], sizeof(*arg0), (char *) arg0) < 0)
1539			tprintf("???");
1540		else {
1541			tprintf("%#x, %d", arg0->version, arg0->pid);
1542		}
1543		tprintf(", ");
1544		if (!tcp->u_arg[1])
1545			tprintf("NULL");
1546		else if (!verbose(tcp))
1547			tprintf("%#lx", tcp->u_arg[1]);
1548		else if (umoven(tcp, tcp->u_arg[1], sizeof(*arg1), (char *) arg1) < 0)
1549			tprintf("???");
1550		else {
1551			tprintf("{");
1552			printflags(capabilities, arg1->effective, "CAP_???");
1553			tprintf(", ");
1554			printflags(capabilities, arg1->permitted, "CAP_???");
1555			tprintf(", ");
1556			printflags(capabilities, arg1->inheritable, "CAP_???");
1557			tprintf("}");
1558		}
1559	}
1560	return 0;
1561}
1562
1563#else
1564
1565int sys_capget(tcp)
1566struct tcb *tcp;
1567{
1568	return printargs(tcp);
1569}
1570
1571int sys_capset(tcp)
1572struct tcb *tcp;
1573{
1574	return printargs(tcp);
1575}
1576
1577#endif
1578
1579#ifdef LINUX
1580static const struct xlat sysctl_root[] = {
1581	{ CTL_KERN, "CTL_KERN" },
1582	{ CTL_VM, "CTL_VM" },
1583	{ CTL_NET, "CTL_NET" },
1584	{ CTL_PROC, "CTL_PROC" },
1585	{ CTL_FS, "CTL_FS" },
1586	{ CTL_DEBUG, "CTL_DEBUG" },
1587	{ CTL_DEV, "CTL_DEV" },
1588	{ 0, NULL }
1589};
1590
1591static const struct xlat sysctl_kern[] = {
1592	{ KERN_OSTYPE, "KERN_OSTYPE" },
1593	{ KERN_OSRELEASE, "KERN_OSRELEASE" },
1594	{ KERN_OSREV, "KERN_OSREV" },
1595	{ KERN_VERSION, "KERN_VERSION" },
1596	{ KERN_SECUREMASK, "KERN_SECUREMASK" },
1597	{ KERN_PROF, "KERN_PROF" },
1598	{ KERN_NODENAME, "KERN_NODENAME" },
1599	{ KERN_DOMAINNAME, "KERN_DOMAINNAME" },
1600#ifdef KERN_SECURELVL
1601	{ KERN_SECURELVL, "KERN_SECURELVL" },
1602#endif
1603	{ KERN_PANIC, "KERN_PANIC" },
1604#ifdef KERN_REALROOTDEV
1605	{ KERN_REALROOTDEV, "KERN_REALROOTDEV" },
1606#endif
1607#ifdef KERN_JAVA_INTERPRETER
1608	{ KERN_JAVA_INTERPRETER, "KERN_JAVA_INTERPRETER" },
1609#endif
1610#ifdef KERN_JAVA_APPLETVIEWER
1611	{ KERN_JAVA_APPLETVIEWER, "KERN_JAVA_APPLETVIEWER" },
1612#endif
1613	{ KERN_SPARC_REBOOT, "KERN_SPARC_REBOOT" },
1614	{ KERN_CTLALTDEL, "KERN_CTLALTDEL" },
1615	{ KERN_PRINTK, "KERN_PRINTK" },
1616	{ KERN_NAMETRANS, "KERN_NAMETRANS" },
1617	{ KERN_PPC_HTABRECLAIM, "KERN_PPC_HTABRECLAIM" },
1618	{ KERN_PPC_ZEROPAGED, "KERN_PPC_ZEROPAGED" },
1619	{ KERN_PPC_POWERSAVE_NAP, "KERN_PPC_POWERSAVE_NAP" },
1620	{ KERN_MODPROBE, "KERN_MODPROBE" },
1621	{ KERN_SG_BIG_BUFF, "KERN_SG_BIG_BUFF" },
1622	{ KERN_ACCT, "KERN_ACCT" },
1623	{ KERN_PPC_L2CR, "KERN_PPC_L2CR" },
1624	{ KERN_RTSIGNR, "KERN_RTSIGNR" },
1625	{ KERN_RTSIGMAX, "KERN_RTSIGMAX" },
1626	{ KERN_SHMMAX, "KERN_SHMMAX" },
1627	{ KERN_MSGMAX, "KERN_MSGMAX" },
1628	{ KERN_MSGMNB, "KERN_MSGMNB" },
1629	{ KERN_MSGPOOL, "KERN_MSGPOOL" },
1630	{ 0, NULL }
1631};
1632
1633static const struct xlat sysctl_vm[] = {
1634#ifdef VM_SWAPCTL
1635	{ VM_SWAPCTL, "VM_SWAPCTL" },
1636#endif
1637#ifdef VM_UNUSED1
1638	{ VM_UNUSED1, "VM_UNUSED1" },
1639#endif
1640#ifdef VM_SWAPOUT
1641	{ VM_SWAPOUT, "VM_SWAPOUT" },
1642#endif
1643#ifdef VM_UNUSED2
1644	{ VM_UNUSED2, "VM_UNUSED2" },
1645#endif
1646#ifdef VM_FREEPG
1647	{ VM_FREEPG, "VM_FREEPG" },
1648#endif
1649#ifdef VM_UNUSED3
1650	{ VM_UNUSED3, "VM_UNUSED3" },
1651#endif
1652#ifdef VM_BDFLUSH
1653	{ VM_BDFLUSH, "VM_BDFLUSH" },
1654#endif
1655#ifdef VM_UNUSED4
1656	{ VM_UNUSED4, "VM_UNUSED4" },
1657#endif
1658	{ VM_OVERCOMMIT_MEMORY, "VM_OVERCOMMIT_MEMORY" },
1659#ifdef VM_BUFFERMEM
1660	{ VM_BUFFERMEM, "VM_BUFFERMEM" },
1661#endif
1662#ifdef VM_UNUSED5
1663	{ VM_UNUSED5, "VM_UNUSED5" },
1664#endif
1665#ifdef VM_PAGECACHE
1666	{ VM_PAGECACHE, "VM_PAGECACHE" },
1667#endif
1668#ifdef VM_UNUSED7
1669	{ VM_UNUSED7, "VM_UNUSED7" },
1670#endif
1671#ifdef VM_PAGERDAEMON
1672	{ VM_PAGERDAEMON, "VM_PAGERDAEMON" },
1673#endif
1674#ifdef VM_UNUSED8
1675	{ VM_UNUSED8, "VM_UNUSED8" },
1676#endif
1677#ifdef VM_PGT_CACHE
1678	{ VM_PGT_CACHE, "VM_PGT_CACHE" },
1679#endif
1680#ifdef VM_UNUSED9
1681	{ VM_UNUSED9, "VM_UNUSED9" },
1682#endif
1683	{ VM_PAGE_CLUSTER, "VM_PAGE_CLUSTER" },
1684	{ 0, NULL },
1685};
1686
1687static const struct xlat sysctl_net[] = {
1688	{ NET_CORE, "NET_CORE" },
1689	{ NET_ETHER, "NET_ETHER" },
1690	{ NET_802, "NET_802" },
1691	{ NET_UNIX, "NET_UNIX" },
1692	{ NET_IPV4, "NET_IPV4" },
1693	{ NET_IPX, "NET_IPX" },
1694	{ NET_ATALK, "NET_ATALK" },
1695	{ NET_NETROM, "NET_NETROM" },
1696	{ NET_AX25, "NET_AX25" },
1697	{ NET_BRIDGE, "NET_BRIDGE" },
1698	{ NET_ROSE, "NET_ROSE" },
1699	{ NET_IPV6, "NET_IPV6" },
1700	{ NET_X25, "NET_X25" },
1701	{ NET_TR, "NET_TR" },
1702	{ NET_DECNET, "NET_DECNET" },
1703	{ 0, NULL }
1704};
1705
1706static const struct xlat sysctl_net_core[] = {
1707	{ NET_CORE_WMEM_MAX, "NET_CORE_WMEM_MAX" },
1708	{ NET_CORE_RMEM_MAX, "NET_CORE_RMEM_MAX" },
1709	{ NET_CORE_WMEM_DEFAULT, "NET_CORE_WMEM_DEFAULT" },
1710	{ NET_CORE_RMEM_DEFAULT, "NET_CORE_RMEM_DEFAULT" },
1711	{ NET_CORE_MAX_BACKLOG, "NET_CORE_MAX_BACKLOG" },
1712	{ NET_CORE_FASTROUTE, "NET_CORE_FASTROUTE" },
1713	{ NET_CORE_MSG_COST, "NET_CORE_MSG_COST" },
1714	{ NET_CORE_MSG_BURST, "NET_CORE_MSG_BURST" },
1715	{ NET_CORE_OPTMEM_MAX, "NET_CORE_OPTMEM_MAX" },
1716	{ 0, NULL }
1717};
1718
1719static const struct xlat sysctl_net_unix[] = {
1720	{ NET_UNIX_DESTROY_DELAY, "NET_UNIX_DESTROY_DELAY" },
1721	{ NET_UNIX_DELETE_DELAY, "NET_UNIX_DELETE_DELAY" },
1722	{ 0, NULL }
1723};
1724
1725static const struct xlat sysctl_net_ipv4[] = {
1726	{ NET_IPV4_FORWARD, "NET_IPV4_FORWARD" },
1727	{ NET_IPV4_DYNADDR, "NET_IPV4_DYNADDR" },
1728	{ NET_IPV4_CONF, "NET_IPV4_CONF" },
1729	{ NET_IPV4_NEIGH, "NET_IPV4_NEIGH" },
1730	{ NET_IPV4_ROUTE, "NET_IPV4_ROUTE" },
1731	{ NET_IPV4_FIB_HASH, "NET_IPV4_FIB_HASH" },
1732	{ NET_IPV4_TCP_TIMESTAMPS, "NET_IPV4_TCP_TIMESTAMPS" },
1733	{ NET_IPV4_TCP_WINDOW_SCALING, "NET_IPV4_TCP_WINDOW_SCALING" },
1734	{ NET_IPV4_TCP_SACK, "NET_IPV4_TCP_SACK" },
1735	{ NET_IPV4_TCP_RETRANS_COLLAPSE, "NET_IPV4_TCP_RETRANS_COLLAPSE" },
1736	{ NET_IPV4_DEFAULT_TTL, "NET_IPV4_DEFAULT_TTL" },
1737	{ NET_IPV4_AUTOCONFIG, "NET_IPV4_AUTOCONFIG" },
1738	{ NET_IPV4_NO_PMTU_DISC, "NET_IPV4_NO_PMTU_DISC" },
1739	{ NET_IPV4_TCP_SYN_RETRIES, "NET_IPV4_TCP_SYN_RETRIES" },
1740	{ NET_IPV4_IPFRAG_HIGH_THRESH, "NET_IPV4_IPFRAG_HIGH_THRESH" },
1741	{ NET_IPV4_IPFRAG_LOW_THRESH, "NET_IPV4_IPFRAG_LOW_THRESH" },
1742	{ NET_IPV4_IPFRAG_TIME, "NET_IPV4_IPFRAG_TIME" },
1743	{ NET_IPV4_TCP_MAX_KA_PROBES, "NET_IPV4_TCP_MAX_KA_PROBES" },
1744	{ NET_IPV4_TCP_KEEPALIVE_TIME, "NET_IPV4_TCP_KEEPALIVE_TIME" },
1745	{ NET_IPV4_TCP_KEEPALIVE_PROBES, "NET_IPV4_TCP_KEEPALIVE_PROBES" },
1746	{ NET_IPV4_TCP_RETRIES1, "NET_IPV4_TCP_RETRIES1" },
1747	{ NET_IPV4_TCP_RETRIES2, "NET_IPV4_TCP_RETRIES2" },
1748	{ NET_IPV4_TCP_FIN_TIMEOUT, "NET_IPV4_TCP_FIN_TIMEOUT" },
1749	{ NET_IPV4_IP_MASQ_DEBUG, "NET_IPV4_IP_MASQ_DEBUG" },
1750	{ NET_TCP_SYNCOOKIES, "NET_TCP_SYNCOOKIES" },
1751	{ NET_TCP_STDURG, "NET_TCP_STDURG" },
1752	{ NET_TCP_RFC1337, "NET_TCP_RFC1337" },
1753	{ NET_TCP_SYN_TAILDROP, "NET_TCP_SYN_TAILDROP" },
1754	{ NET_TCP_MAX_SYN_BACKLOG, "NET_TCP_MAX_SYN_BACKLOG" },
1755	{ NET_IPV4_LOCAL_PORT_RANGE, "NET_IPV4_LOCAL_PORT_RANGE" },
1756	{ NET_IPV4_ICMP_ECHO_IGNORE_ALL, "NET_IPV4_ICMP_ECHO_IGNORE_ALL" },
1757	{ NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS, "NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS" },
1758	{ NET_IPV4_ICMP_SOURCEQUENCH_RATE, "NET_IPV4_ICMP_SOURCEQUENCH_RATE" },
1759	{ NET_IPV4_ICMP_DESTUNREACH_RATE, "NET_IPV4_ICMP_DESTUNREACH_RATE" },
1760	{ NET_IPV4_ICMP_TIMEEXCEED_RATE, "NET_IPV4_ICMP_TIMEEXCEED_RATE" },
1761	{ NET_IPV4_ICMP_PARAMPROB_RATE, "NET_IPV4_ICMP_PARAMPROB_RATE" },
1762	{ NET_IPV4_ICMP_ECHOREPLY_RATE, "NET_IPV4_ICMP_ECHOREPLY_RATE" },
1763	{ NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES, "NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES" },
1764	{ NET_IPV4_IGMP_MAX_MEMBERSHIPS, "NET_IPV4_IGMP_MAX_MEMBERSHIPS" },
1765	{  0, NULL }
1766};
1767
1768static const struct xlat sysctl_net_ipv4_route[] = {
1769	{ NET_IPV4_ROUTE_FLUSH, "NET_IPV4_ROUTE_FLUSH" },
1770	{ NET_IPV4_ROUTE_MIN_DELAY, "NET_IPV4_ROUTE_MIN_DELAY" },
1771	{ NET_IPV4_ROUTE_MAX_DELAY, "NET_IPV4_ROUTE_MAX_DELAY" },
1772	{ NET_IPV4_ROUTE_GC_THRESH, "NET_IPV4_ROUTE_GC_THRESH" },
1773	{ NET_IPV4_ROUTE_MAX_SIZE, "NET_IPV4_ROUTE_MAX_SIZE" },
1774	{ NET_IPV4_ROUTE_GC_MIN_INTERVAL, "NET_IPV4_ROUTE_GC_MIN_INTERVAL" },
1775	{ NET_IPV4_ROUTE_GC_TIMEOUT, "NET_IPV4_ROUTE_GC_TIMEOUT" },
1776	{ NET_IPV4_ROUTE_GC_INTERVAL, "NET_IPV4_ROUTE_GC_INTERVAL" },
1777	{ NET_IPV4_ROUTE_REDIRECT_LOAD, "NET_IPV4_ROUTE_REDIRECT_LOAD" },
1778	{ NET_IPV4_ROUTE_REDIRECT_NUMBER, "NET_IPV4_ROUTE_REDIRECT_NUMBER" },
1779	{ NET_IPV4_ROUTE_REDIRECT_SILENCE, "NET_IPV4_ROUTE_REDIRECT_SILENCE" },
1780	{ NET_IPV4_ROUTE_ERROR_COST, "NET_IPV4_ROUTE_ERROR_COST" },
1781	{ NET_IPV4_ROUTE_ERROR_BURST, "NET_IPV4_ROUTE_ERROR_BURST" },
1782	{ NET_IPV4_ROUTE_GC_ELASTICITY, "NET_IPV4_ROUTE_GC_ELASTICITY" },
1783	{ 0, NULL }
1784};
1785
1786static const struct xlat sysctl_net_ipv4_conf[] = {
1787	{ NET_IPV4_CONF_FORWARDING, "NET_IPV4_CONF_FORWARDING" },
1788	{ NET_IPV4_CONF_MC_FORWARDING, "NET_IPV4_CONF_MC_FORWARDING" },
1789	{ NET_IPV4_CONF_PROXY_ARP, "NET_IPV4_CONF_PROXY_ARP" },
1790	{ NET_IPV4_CONF_ACCEPT_REDIRECTS, "NET_IPV4_CONF_ACCEPT_REDIRECTS" },
1791	{ NET_IPV4_CONF_SECURE_REDIRECTS, "NET_IPV4_CONF_SECURE_REDIRECTS" },
1792	{ NET_IPV4_CONF_SEND_REDIRECTS, "NET_IPV4_CONF_SEND_REDIRECTS" },
1793	{ NET_IPV4_CONF_SHARED_MEDIA, "NET_IPV4_CONF_SHARED_MEDIA" },
1794	{ NET_IPV4_CONF_RP_FILTER, "NET_IPV4_CONF_RP_FILTER" },
1795	{ NET_IPV4_CONF_ACCEPT_SOURCE_ROUTE, "NET_IPV4_CONF_ACCEPT_SOURCE_ROUTE" },
1796	{ NET_IPV4_CONF_BOOTP_RELAY, "NET_IPV4_CONF_BOOTP_RELAY" },
1797	{ NET_IPV4_CONF_LOG_MARTIANS, "NET_IPV4_CONF_LOG_MARTIANS" },
1798	{ 0, NULL }
1799};
1800
1801static const struct xlat sysctl_net_ipv6[] = {
1802	{ NET_IPV6_CONF, "NET_IPV6_CONF" },
1803	{ NET_IPV6_NEIGH, "NET_IPV6_NEIGH" },
1804	{ NET_IPV6_ROUTE, "NET_IPV6_ROUTE" },
1805	{ 0, NULL }
1806};
1807
1808static const struct xlat sysctl_net_ipv6_route[] = {
1809	{ NET_IPV6_ROUTE_FLUSH, "NET_IPV6_ROUTE_FLUSH" },
1810	{ NET_IPV6_ROUTE_GC_THRESH, "NET_IPV6_ROUTE_GC_THRESH" },
1811	{ NET_IPV6_ROUTE_MAX_SIZE, "NET_IPV6_ROUTE_MAX_SIZE" },
1812	{ NET_IPV6_ROUTE_GC_MIN_INTERVAL, "NET_IPV6_ROUTE_GC_MIN_INTERVAL" },
1813	{ NET_IPV6_ROUTE_GC_TIMEOUT, "NET_IPV6_ROUTE_GC_TIMEOUT" },
1814	{ NET_IPV6_ROUTE_GC_INTERVAL, "NET_IPV6_ROUTE_GC_INTERVAL" },
1815	{ NET_IPV6_ROUTE_GC_ELASTICITY, "NET_IPV6_ROUTE_GC_ELASTICITY" },
1816	{ 0, NULL }
1817};
1818
1819int
1820sys_sysctl(tcp)
1821struct tcb *tcp;
1822{
1823	struct __sysctl_args info;
1824	int *name;
1825	unsigned long size;
1826
1827	if (umove (tcp, tcp->u_arg[0], &info) < 0)
1828		return printargs(tcp);
1829
1830	size = sizeof (int) * (unsigned long) info.nlen;
1831	name = (size / sizeof (int) != info.nlen) ? NULL : malloc (size);
1832	if (name == NULL ||
1833	    umoven(tcp, (unsigned long) info.name, size, (char *) name) < 0) {
1834		free(name);
1835		if (entering(tcp))
1836			tprintf("{%p, %d, %p, %p, %p, %Zu}",
1837				info.name, info.nlen, info.oldval,
1838				info.oldlenp, info.newval, info.newlen);
1839		return 0;
1840	}
1841
1842	if (entering(tcp)) {
1843		int cnt = 0, max_cnt;
1844
1845		tprintf("{{");
1846
1847		if (info.nlen == 0)
1848			goto out;
1849		printxval(sysctl_root, name[0], "CTL_???");
1850		++cnt;
1851
1852		if (info.nlen == 1)
1853			goto out;
1854		switch (name[0]) {
1855		case CTL_KERN:
1856			tprintf(", ");
1857			printxval(sysctl_kern, name[1], "KERN_???");
1858			++cnt;
1859			break;
1860		case CTL_VM:
1861			tprintf(", ");
1862			printxval(sysctl_vm, name[1], "VM_???");
1863			++cnt;
1864			break;
1865		case CTL_NET:
1866			tprintf(", ");
1867			printxval(sysctl_net, name[1], "NET_???");
1868			++cnt;
1869
1870			if (info.nlen == 2)
1871				goto out;
1872			switch (name[1]) {
1873			case NET_CORE:
1874				tprintf(", ");
1875				printxval(sysctl_net_core, name[2],
1876					  "NET_CORE_???");
1877				break;
1878			case NET_UNIX:
1879				tprintf(", ");
1880				printxval(sysctl_net_unix, name[2],
1881					  "NET_UNIX_???");
1882				break;
1883			case NET_IPV4:
1884				tprintf(", ");
1885				printxval(sysctl_net_ipv4, name[2],
1886					  "NET_IPV4_???");
1887
1888				if (info.nlen == 3)
1889					goto out;
1890				switch (name[2]) {
1891				case NET_IPV4_ROUTE:
1892					tprintf(", ");
1893					printxval(sysctl_net_ipv4_route,
1894						  name[3],
1895						  "NET_IPV4_ROUTE_???");
1896					break;
1897				case NET_IPV4_CONF:
1898					tprintf(", ");
1899					printxval(sysctl_net_ipv4_conf,
1900						  name[3],
1901						  "NET_IPV4_CONF_???");
1902					break;
1903				default:
1904					goto out;
1905				}
1906				break;
1907			case NET_IPV6:
1908				tprintf(", ");
1909				printxval(sysctl_net_ipv6, name[2],
1910					  "NET_IPV6_???");
1911
1912				if (info.nlen == 3)
1913					goto out;
1914				switch (name[2]) {
1915				case NET_IPV6_ROUTE:
1916					tprintf(", ");
1917					printxval(sysctl_net_ipv6_route,
1918						  name[3],
1919						  "NET_IPV6_ROUTE_???");
1920					break;
1921				default:
1922					goto out;
1923				}
1924				break;
1925			default:
1926				goto out;
1927			}
1928			break;
1929		default:
1930			goto out;
1931		}
1932	out:
1933		max_cnt = abbrev(tcp) ? max_strlen : info.nlen;
1934		while (cnt < max_cnt)
1935			tprintf(", %x", name[cnt++]);
1936		if (cnt < info.nlen)
1937			tprintf(", ...");
1938		tprintf("}, %d, ", info.nlen);
1939	} else {
1940		size_t oldlen;
1941		if (umove(tcp, (size_t)info.oldlenp, &oldlen) >= 0
1942		    && info.nlen >= 2
1943		    && ((name[0] == CTL_KERN
1944			 && (name[1] == KERN_OSRELEASE
1945			     || name[1] == KERN_OSTYPE
1946#ifdef KERN_JAVA_INTERPRETER
1947			     || name[1] == KERN_JAVA_INTERPRETER
1948#endif
1949#ifdef KERN_JAVA_APPLETVIEWER
1950			     || name[1] == KERN_JAVA_APPLETVIEWER
1951#endif
1952				 )))) {
1953			printpath(tcp, (size_t)info.oldval);
1954			tprintf(", %Zu, ", oldlen);
1955			if (info.newval == 0)
1956				tprintf("NULL");
1957			else if (syserror(tcp))
1958				tprintf("%p", info.newval);
1959			else
1960				printpath(tcp, (size_t)info.newval);
1961			tprintf(", %Zd", info.newlen);
1962		} else {
1963			tprintf("%p, %Zd, %p, %Zd", info.oldval, oldlen,
1964				info.newval, info.newlen);
1965		}
1966		tprintf("}");
1967	}
1968
1969	free(name);
1970	return 0;
1971}
1972#else
1973int sys_sysctl(tcp)
1974struct tcb *tcp;
1975{
1976	return printargs(tcp);
1977}
1978#endif
1979
1980#ifdef FREEBSD
1981#include <sys/sysctl.h>
1982
1983int sys___sysctl(tcp)
1984struct tcb *tcp;
1985{
1986	int qoid[CTL_MAXNAME+2];
1987	char ctl[1024];
1988	size_t len;
1989	int i, numeric;
1990
1991	if (entering(tcp)) {
1992		if (tcp->u_arg[1] < 0 || tcp->u_arg[1] > CTL_MAXNAME ||
1993		    (umoven(tcp, tcp->u_arg[0], tcp->u_arg[1] * sizeof(int),
1994			    (char *) (qoid + 2)) < 0))
1995			tprintf("[...], ");
1996		else {
1997			/* Use sysctl to ask the name of the current MIB
1998			   This uses the undocumented "Staff-functions" used
1999			   by the sysctl program. See kern_sysctl.c for
2000			   details. */
2001			qoid[0] = 0; /* sysctl */
2002			qoid[1] = 1; /* name */
2003			i = sizeof(ctl);
2004			tprintf("[");
2005			if (sysctl(qoid, tcp->u_arg[1] + 2, ctl, &i, 0, 0) >= 0) {
2006				numeric = !abbrev(tcp);
2007				tprintf("%s%s", ctl, numeric ? ", " : "");
2008			} else
2009				numeric = 1;
2010			if (numeric) {
2011				for (i = 0; i < tcp->u_arg[1]; i++)
2012					tprintf("%s%d", i ? "." : "", qoid[i + 2]);
2013			}
2014			tprintf("], ");
2015			tprintf("%lu, ", tcp->u_arg[1]);
2016		}
2017	} else {
2018		if (!syserror(tcp) && (umove(tcp, tcp->u_arg[3], &len) >= 0)) {
2019			printstr(tcp, tcp->u_arg[2], len);
2020			tprintf(", [%u], ", len);
2021		} else
2022			tprintf("%#lx, %#lx, ", tcp->u_arg[2], tcp->u_arg[3]);
2023		printstr(tcp, tcp->u_arg[4], tcp->u_arg[5]);
2024		tprintf(", %lu", tcp->u_arg[5]);
2025	}
2026	return 0;
2027}
2028#endif
2029
2030#if UNIXWARE >= 2
2031
2032#include <sys/ksym.h>
2033#include <sys/elf.h>
2034
2035static const struct xlat ksym_flags[] = {
2036	{ STT_NOTYPE,	"STT_NOTYPE"	},
2037	{ STT_FUNC,	"STT_FUNC"	},
2038	{ STT_OBJECT,	"STT_OBJECT"	},
2039	{ 0,		NULL		},
2040};
2041
2042int
2043sys_getksym(tcp)
2044struct tcb *tcp;
2045{
2046	if (entering (tcp)) {
2047		printstr(tcp, tcp->u_arg[0], -1);
2048		tprintf(", ");
2049	}
2050	else {
2051		if (syserror(tcp)) {
2052			tprintf("%#lx, %#lx",
2053				tcp->u_arg[1], tcp->u_arg[2]);
2054		}
2055		else {
2056			int val;
2057			printnum (tcp, tcp->u_arg[1], "%#lx");
2058			tprintf(", ");
2059			if (umove(tcp, tcp->u_arg[2], &val) < 0) {
2060				tprintf("%#lx", tcp->u_arg[2]);
2061			}
2062			else {
2063				tprintf("[");
2064				printxval (ksym_flags, val, "STT_???");
2065				tprintf("]");
2066			}
2067		}
2068	}
2069
2070	return 0;
2071}
2072
2073#ifdef HAVE_SYS_NSCSYS_H
2074
2075struct cred;
2076#include <sys/nscsys.h>
2077
2078static const struct xlat ssi_cmd [] = {
2079	{ SSISYS_BADOP,	"SSISYS_BADOP"	},
2080	{ SSISYS_LDLVL_INIT,"SSISYS_LDLVL_INIT"},
2081	{ SSISYS_LDLVL_GETVEC,"SSISYS_LDLVL_GETVEC"},
2082	{ SSISYS_LDLVL_PUTVEC,"SSISYS_LDLVL_PUTVEC"},
2083	{ SSISYS_LDLVL_PUTRCMDS,"SSISYS_LDLVL_PUTRCMDS"},
2084	{ SSISYS_LDLVL_SETREXEC,"SSISYS_LDLVL_SETREXEC"},
2085	{ SSISYS_CMS_CLUSTERID,"SSISYS_CMS_CLUSTERID"},
2086	{ SSISYS_CFS_STATVFS,"SSISYS_CFS_STATVFS"},
2087	{ SSISYS_NODE_GETNUM,"SSISYS_NODE_GETNUM"},
2088	{ SSISYS_NODE_TABLE,"SSISYS_NODE_TABLE"},
2089	{ SSISYS_NODE_DOWN,"SSISYS_NODE_DOWN"},
2090	{ SSISYS_RECLAIM_CHILD,"SSISYS_RECLAIM_CHILD"},
2091	{ SSISYS_IPC_GETINFO,"SSISYS_IPC_GETINFO"},
2092	{ SSISYS_ICS_TEST,"SSISYS_ICS_TEST"},
2093	{ SSISYS_NODE_PID,"SSISYS_NODE_PID"},
2094	{ SSISYS_ISLOCAL,"SSISYS_ISLOCAL"},
2095	{ SSISYS_CFS_ISSTACKED,"SSISYS_CFS_ISSTACKED"},
2096	{ SSISYS_DNET_SYNC,"SSISYS_DNET_SYNC"},
2097	{ SSISYS_CFS_WAIT_MODE,"SSISYS_CFS_WAIT_MODE"},
2098	{ SSISYS_CFS_UMOUNT,"SSISYS_CFS_UMOUNT"},
2099	{ SSISYS_LLSTAT,"SSISYS_LLSTAT"	},
2100	{ SSISYS_LTS_PERFTEST,"SSISYS_LTS_PERFTEST"},
2101	{ SSISYS_LTS_CONFIG,"SSISYS_LTS_CONFIG"},
2102	{ SSISYS_SNET_PERFTEST,"SSISYS_SNET_PERFTEST"},
2103	{ SSISYS_IGNORE_HALFUP,"SSISYS_IGNORE_HALFUP"},
2104	{ SSISYS_NODE_ROOTDEV,"SSISYS_NODE_ROOTDEV"},
2105	{ SSISYS_GET_PRIMARY,"SSISYS_GET_PRIMARY"},
2106	{ SSISYS_GET_SECONDARY,"SSISYS_GET_SECONDARY"},
2107	{ SSISYS_GET_ROOTDISK,"SSISYS_GET_ROOTDISK"},
2108	{ SSISYS_CLUSTERNODE_NUM,"SSISYS_CLUSTERNODE_NUM"},
2109	{ SSISYS_CLUSTER_MEMBERSHIP,"SSISYS_CLUSTER_MEMBERSHIP"},
2110	{ SSISYS_CLUSTER_DETAILEDTRANS,"SSISYS_CLUSTER_DETAILEDTRANS"},
2111	{ SSISYS_CLUSTERNODE_INFO,"SSISYS_CLUSTERNODE_INFO"},
2112	{ SSISYS_CLUSTERNODE_SETINFO,"SSISYS_CLUSTERNODE_SETINFO"},
2113	{ SSISYS_CLUSTERNODE_AVAIL,"SSISYS_CLUSTERNODE_AVAIL"},
2114	{ SSISYS_CLUSTER_MAXNODES,"SSISYS_CLUSTER_MAXNODES"},
2115	{ SSISYS_SET_MEMPRIO,"SSISYS_SET_MEMPRIO"},
2116	{ SSISYS_GET_USERS,"SSISYS_GET_USERS"},
2117	{ SSISYS_FORCE_ROOT_NODE,"SSISYS_FORCE_ROOT_NODE"},
2118	{ SSISYS_CVIP_SET,"SSISYS_CVIP_SET"},
2119	{ SSISYS_CVIP_GET,"SSISYS_CVIP_GET"},
2120	{ SSISYS_GET_NODE_COUNTS,"SSISYS_GET_NODE_COUNTS"},
2121	{ SSISYS_GET_TRANSPORT,"SSISYS_GET_TRANSPORT"},
2122	{ 0,		NULL		},
2123};
2124
2125int sys_ssisys (tcp)
2126struct tcb *tcp;
2127{
2128	struct ssisys_iovec iov;
2129	cls_nodeinfo_args_t cni;
2130	clusternode_info_t info;
2131
2132	if (entering (tcp)) {
2133		ts_reclaim_child_inargs_t trc;
2134		if (tcp->u_arg[1] != sizeof iov ||
2135		    umove (tcp, tcp->u_arg[0], &iov) < 0)
2136		{
2137			tprintf ("%#lx, %ld", tcp->u_arg[0], tcp->u_arg[1]);
2138			return 0;
2139		}
2140		tprintf ("{id=");
2141		printxval(ssi_cmd, iov.tio_id.id_cmd, "SSISYS_???");
2142		tprintf (":%d", iov.tio_id.id_ver);
2143		switch (iov.tio_id.id_cmd) {
2144		    case SSISYS_RECLAIM_CHILD:
2145			if (iov.tio_udatainlen != sizeof trc ||
2146			    umove (tcp, (long) iov.tio_udatain, &trc) < 0)
2147				goto bad;
2148			tprintf (", in={pid=%ld, start=%ld}",
2149				 trc.trc_pid, trc.trc_start);
2150			break;
2151		    case SSISYS_CLUSTERNODE_INFO:
2152			if (iov.tio_udatainlen != sizeof cni ||
2153			    umove (tcp, (long) iov.tio_udatain, &cni) < 0)
2154				goto bad;
2155			tprintf (", in={node=%ld, len=%d}",
2156				 cni.nodenum, cni.info_len);
2157			break;
2158		    default:
2159		    bad:
2160			if (iov.tio_udatainlen) {
2161				tprintf (", in=[/* %d bytes */]",
2162					 iov.tio_udatainlen);
2163			}
2164		}
2165	}
2166	else {
2167		if (tcp->u_arg[1] != sizeof iov ||
2168		    umove (tcp, tcp->u_arg[0], &iov) < 0)
2169		    goto done;
2170		switch (iov.tio_id.id_cmd) {
2171		    case SSISYS_CLUSTERNODE_INFO:
2172			if (iov.tio_udatainlen != sizeof cni ||
2173			    umove (tcp, (long) iov.tio_udatain, &cni) < 0)
2174				goto bad_out;
2175			if (cni.info_len != sizeof info ||
2176			    iov.tio_udataoutlen != sizeof &info ||
2177			    umove (tcp, (long) iov.tio_udataout, &info) < 0)
2178				goto bad_out;
2179			tprintf (", out={node=%ld, cpus=%d, online=%d}",
2180				 info.node_num, info.node_totalcpus,
2181				 info.node_onlinecpus);
2182			break;
2183
2184		    default:
2185		    bad_out:
2186			if (iov.tio_udataoutlen) {
2187				tprintf (", out=[/* %d bytes */]",
2188					 iov.tio_udataoutlen);
2189			}
2190		}
2191	    done:
2192		tprintf ("}, %ld", tcp->u_arg[1]);
2193	}
2194	return 0;
2195}
2196
2197#endif
2198
2199#endif /* UNIXWARE > 2 */
2200
2201#ifdef MIPS
2202
2203#ifndef __NEW_UTS_LEN
2204#define __NEW_UTS_LEN 64
2205#endif
2206
2207static const struct xlat sysmips_operations[] = {
2208	{ SETNAME,		"SETNAME"	},
2209	{ FLUSH_CACHE,		"FLUSH_CACHE"	},
2210	{ MIPS_FIXADE,		"MIPS_FIXADE"	},
2211	{ MIPS_RDNVRAM,		"MIPS_RDNVRAM"	},
2212	{ MIPS_ATOMIC_SET,	"MIPS_ATOMIC_SET"	},
2213	{ 0, NULL }
2214};
2215
2216int sys_sysmips(tcp)
2217struct tcb *tcp;
2218{
2219	if (entering(tcp)) {
2220		printxval(sysmips_operations, tcp->u_arg[0], "???");
2221		if (!verbose(tcp)) {
2222			tprintf("%ld, %ld, %ld", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2223		} else if (tcp->u_arg[0]==SETNAME) {
2224			char nodename[__NEW_UTS_LEN + 1];
2225			if (umovestr(tcp, tcp->u_arg[1], (__NEW_UTS_LEN + 1), nodename) < 0)
2226				tprintf(", %#lx", tcp->u_arg[1]);
2227			else
2228				tprintf(", \"%s\"", nodename);
2229		} else if (tcp->u_arg[0] == MIPS_ATOMIC_SET) {
2230			tprintf(", %#lx, 0x%lx", tcp->u_arg[1], tcp->u_arg[2]);
2231		} else if (tcp->u_arg[0] == MIPS_FIXADE) {
2232			tprintf(", 0x%lx", tcp->u_arg[1]);
2233		} else {
2234			tprintf("%ld, %ld, %ld", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2235		}
2236	}
2237
2238	return 0;
2239}
2240
2241#endif /* MIPS */
2242