home *** CD-ROM | disk | FTP | other *** search
- #include <sys/param.h>
- #include <sys/types.h>
- #include <sys/statfs.h>
- #include <sys/stat.h>
- #include <sys/times.h>
- #include <sys/dirent.h>
- #include <sys/swap.h>
- #include <sys/utsname.h>
- #include <sys/termio.h>
- #include <sys/stermio.h>
- #include <sys/stropts.h>
- #include <sys/flio.h>
- #include <sys/mtio.h>
- #include <sys/fs/prfcntl.h>
- #include <sys/ptrace.h>
- #include <sys/immu.h>
- #include <sys/sbd.h>
- #include <sys/region.h>
- #undef PC
- #if defined(LIMITS)
- #include <sys/lnode.h>
- #define LIMITSoffset (320 + SYSVoffset)
- #endif /* defined(LIMITS) */
- #if defined(SHARE)
- #include <sys/share.h>
- #define SHAREoffset (323 + SYSVoffset)
- #endif /* defined(SHARE) */
- #include <sys/proc.h>
- #include <sys/fstyp.h>
- #include <sys/fsid.h>
- #define INKERNEL 1
- #include <signal.h>
- #undef INKERNEL
- #include <poll.h>
- #include <errno.h>
- #include <fcntl.h>
- #include <ustat.h>
- #include <sys.s>
- #if !defined(SYS_setlim)
- #define SYS_setlim (0 + LIMITSoffset)
- #define SYS_getlim (1 + LIMITSoffset)
- #define SYS_limonoff (2 + LIMITSoffset)
- #endif /* !defined(SYS_setlim) */
- #if !defined(SYS_sharecosts)
- #define SYS_sharecosts (0 + SHAREoffset)
- #define SYS_gettab (1 + SHAREoffset)
- #endif /* !defined(SYS_sharecosts) */
- #include <stdio.h>
- #include <unistd.h>
- #include <bsd/sys/types.h>
- #include <bsd/sys/socket.h>
- #include <bsd/sys/uio.h>
- #include <bsd/sys/wait.h>
- #include <bsd/sys/time.h>
- #include <bsd/sys/resource.h>
- #include "register.h"
- #include "symtab.h"
- #include "diblock.h"
- #include "instrn.h"
- #include "process.h"
- #include "sysentry.h"
- #include "nels.h"
- #include "res.h"
- #include "flag.h"
- #include "generic.h"
-
- extern time_t time();
-
- extern int fd_lookup();
- extern int fd_open();
- extern void fd_dopen();
- extern int fd_close();
- extern int fd_invalid();
- extern int fd_nfiles();
- extern int fd_sort();
- extern void histo_dump();
- extern void hist_dump();
- extern char *malloc();
- extern char *strdup();
- extern int bufset();
- extern int mstrlen();
- extern int mgetstring();
- extern int mgets();
- extern char **mgetvp();
- extern int magic_ok();
- extern int interpreter_ok();
- extern int is_a_shared_library();
- extern int augment_execve_args();
- extern void vis_quoted_truncated_buffer();
- extern void say_time();
- extern char *signal_name();
- extern int printval();
- extern int bsd43_sys_ioctl();
- extern int sgttybsize();
-
- extern FILE *outfp;
- extern int errno;
-
- extern int Aflag;
- extern int Fflag;
- extern int Pflag;
- extern int Sflag;
-
- extern unsigned long arg[];
-
- extern int return_errno; /* errno goes here. */
- extern long return_value0; /* Result 1 value goes here. */
- extern long return_value1; /* Result 2 value goes here. */
-
- extern sysentry *current_sysentp;
- extern char *sys_call_buf; /* Scratch buf. */
-
- static int sysv_print_received_signal();
-
- static
- int
- sys_execve(syscallno)
- int syscallno;
- {
- char *filename;
- char **argp;
- char **envp;
- int need_close_on_exec;
-
- if (mgetstring(arg[0]) == -1)
- return -1;
-
- if ((filename = strdup(sys_call_buf)) == (char *)0)
- {
- vcouldnot("execve(): ran out of memory");
- return -1;
- }
-
- if ((argp = mgetvp(arg[1])) == (char **)0)
- return -1;
-
- if ((envp = mgetvp(arg[2])) == (char **)0)
- return -1;
-
- if (fd_sort() == -1)
- return -1;
-
- if (Fflag)
- {
- int mok;
-
- if
- (
- access(filename, X_OK) != 0
- ||
- (mok = magic_ok(filename)) == 0
- ||
- (mok == 2 && interpreter_ok(filename) == 0)
- ||
- is_a_shared_library(filename)
- )
- {
- return_value0 = -1;
- return_errno = errno;
-
- if (mfreevp(envp) == -1)
- return -1;
-
- if (mfreevp(argp) == -1)
- return -1;
-
- (void)free(filename);
-
- return 0;
- }
-
- if (augment_execve_args(&filename, &argp, &envp) == -1)
- {
- (void)mfreevp(envp);
- (void)mfreevp(argp);
- (void)free(filename);
- }
-
- need_close_on_exec = 0;
- }
- else
- {
- histo_dump();
- hist_dump();
-
- if (fcntl(fileno(outfp), F_SETFD, 1) == -1)
- {
- vcouldnot("fcntl(%d, F_SETFD, 1)", fileno(outfp));
- return -1;
- }
-
- need_close_on_exec = 1;
- }
-
- Rstart;
- return_value0 = syscall(syscallno, filename, argp, envp);
- return_errno = errno;
- Rstop;
-
- if (need_close_on_exec)
- {
- if (fcntl(fileno(outfp), F_SETFD, 0) == -1)
- {
- vcouldnot("fcntl(%d, F_SETFD, 0)", fileno(outfp));
- return -1;
- }
- }
-
- if (mfreevp(envp) == -1)
- return -1;
-
- if (mfreevp(argp) == -1)
- return -1;
-
- (void)free(filename);
-
- return 0;
- }
-
- static
- int
- sys_fcntl(syscallno)
- int syscallno;
- {
- int size;
- void *fargp;
-
- switch ((int)arg[1])
- {
- case F_DUPFD:
- Rstart;
- return_value0 = dup(fd_lookup((int)arg[0]));
- return_errno = errno;
- Rstop;
-
- if (return_value0 != -1)
- {
- int newfd;
- int nfiles;
-
- for (nfiles = fd_nfiles(), newfd = (int)arg[2]; newfd < nfiles && fd_lookup(newfd) != -1; newfd++)
- ;
-
- if (newfd >= nfiles)
- {
- (void)close(return_value0);
- errno = EMFILE;
- return 0;
- }
-
- fd_dopen(return_value0, newfd);
-
- return_value0 = newfd;
- }
- return 0;
-
- case F_GETFD:
- case F_SETFD:
- case F_GETFL:
- case F_SETFL:
- case F_SETOWN:
- case PFCSEXEC:
- case PFCREXEC:
- case PFCRUN:
- case PFCSSTEP:
- case PFCCSIG:
- size = -1;
- break;
-
- case PFCWSTOP:
- case PFCGMASK:
- case PFCSMASK:
- case PFCSTOP:
- size = sizeof(unsigned long);
- break;
-
- case PFCGETPR:
- size = sizeof(proc_t);
- break;
-
- case PFCGETUSEG:
- size = sizeof(struct pfcseg);
- break;
-
- case PFCGETREGS:
- size = sizeof(unsigned long) * NPTRC_REGS;
- break;
-
- case F_SETLK:
- case F_SETLKW:
- size = sizeof(struct flock);
- break;
-
- default:
- return -2;
- }
-
- if (size != -1)
- {
- if (bufset(size) == -1)
- return -1;
-
- if (mget(arg[2], sys_call_buf, size, &fargp) == -1)
- return -1;
- }
-
- Rstart;
- return_value0 = syscall(syscallno, fd_lookup((int)arg[0]), (int)arg[1], (size == -1) ? (int)arg[2] : (int)fargp);
- return_errno = errno;
- Rstop;
-
- if (size != -1)
- {
- if (mput(arg[2], fargp, size, return_value0) == -1)
- return -1;
- }
-
- return 0;
- }
-
- static
- int
- sys_fstat(syscallno)
- int syscallno;
- {
- return generic_fstat(syscallno, sizeof(struct stat));
- }
-
- static
- int
- sys_fstatfs(syscallno)
- int syscallno;
- {
- int len;
- struct statfs *bufp;
-
- len = arg[2];
-
- if (dmget(arg[1], len, &bufp) == -1)
- return -1;
-
- Rstart;
- return_value0 = syscall(syscallno, fd_lookup((int)arg[0]), bufp, len, (int)arg[3]);
- return_errno = errno;
- Rstop;
-
- if (dmput(arg[1], bufp, len, return_value0) == -1)
- return -1;
-
- return 0;
- }
-
- static
- int
- sys_getgid(syscallno)
- int syscallno;
- {
- Rstart;
- return_value0 = getgid();
- return_value1 = getegid();
- return_errno = errno;
- Rstop;
-
- return 0;
- }
-
- static
- int
- sys_getgroups(syscallno)
- int syscallno;
- {
- return generic_getgroups(syscallno, NGROUPS);
- }
-
- static
- int
- sys_getitimer(syscallno)
- int syscallno;
- {
- return generic_getitimer(syscallno, sizeof(struct itimerval));
- }
-
- #if defined(LIMITS)
- static
- int
- sys_getlim(syscallno)
- int syscallno;
- {
- int function;
- lnode *address;
- int size;
- int realsize;
-
- function = arg[0];
- size = arg[2];
-
- switch (function)
- {
- case L_GETUID:
- realsize = sizeof(lnode);
- break;
-
- default:
- realsize = size;
- break;
- }
-
- if (dmget(arg[1], realsize, &address) == -1)
- return -1;
-
- Rstart;
- return_value0 = syscall(syscallno, function, address, size);
- return_errno = errno;
- Rstop;
-
- if (dmput(arg[1], address, realsize, return_value0) == -1)
- return -1;
-
- return 0;
- }
- #endif /* defined(LIMITS) */
-
- static
- int
- sys_getrlimit(syscallno)
- int syscallno;
- {
- return generic_getrlimit(syscallno, sizeof(struct rlimit));
- }
-
- static
- int
- sys_getrusage(syscallno)
- int syscallno;
- {
- return generic_getrusage(syscallno, sizeof(struct rusage));
- }
-
- static
- int
- sys_gettimeofday(syscallno)
- int syscallno;
- {
- struct timeval tv;
- struct timezone tz;
-
- return generic_gettimeofday(syscallno, &tv, sizeof(tv), &tz, sizeof(tz));
- }
-
- static
- int
- sys_getuid(syscallno)
- int syscallno;
- {
- Rstart;
- return_value0 = getuid();
- return_value1 = geteuid();
- return_errno = errno;
- Rstop;
-
- return 0;
- }
-
- static
- int
- sys_ioctl(syscallno)
- int syscallno;
- {
- int length;
- int need_copy_in;
- int need_copy_out;
- int arg2_is_arg;
-
- arg2_is_arg = 0;
-
- if ((arg[1] & (unsigned long)(IOC_INOUT | IOC_VOID)) == 0)
- {
- /*
- * Old style.
- */
-
- length = 0;
- need_copy_in = 0;
- need_copy_out = 0;
-
- switch ((int)arg[1])
- {
- case FIONREAD:
- length = sizeof(int);
- need_copy_out = 1;
- break;
-
- case FLIOC_SENSE_DRIVE:
- break;
-
- case I_POP:
- break;
-
- case I_PUSH:
- length = mstrlen(arg[2]) + 1;
- need_copy_in = 1;
- break;
-
- case I_SRDOPT:
- length = sizeof(arg[2]);
- arg2_is_arg = 1;
- break;
-
- case STGET:
- length = sizeof(struct stio);
- need_copy_out = 1;
- break;
-
- case oTCGETA:
- case TCGETA:
- length = sizeof(struct termio);
- need_copy_out = 1;
- break;
-
- case oTIOCGETP:
- length = sgttybsize();
- need_copy_out = 1;
- break;
-
- case oTIOCSETP:
- length = sgttybsize();
- need_copy_in = 1;
- break;
-
- case oTCSETA:
- case TCSETA:
- case oTCSETAF:
- case TCSETAF:
- case oTCSETAW:
- case TCSETAW:
- length = sizeof(struct termio);
- need_copy_in = 1;
- break;
-
- case TCFLSH:
- case TCSBRK:
- case TCXONC:
- length = sizeof(arg[2]);
- arg2_is_arg = 1;
- break;
-
- case oFIOCLEX:
- case oFIONCLEX:
- break;
-
- case oTIOCEXCL:
- case TIOCEXCL:
- break;
-
- case TIOCGPGRP:
- length = sizeof(int);
- need_copy_out = 1;
- break;
-
- case TIOCGWINSZ:
- length = sizeof(struct winsize);
- need_copy_out = 1;
- break;
-
- case MTIOCGET:
- /*
- case oTIOCHPCL:
- * Somebody has stuffed up here...
- * The MTIOCGET returns a struct,
- * the oTIOCHPCL doesn't but
- * they've got the same ioctl encoding.
- * So we try to guess based on the
- * pointer arg...
- */
- if (arg[2] != (unsigned long)0)
- {
- length = sizeof(struct mtget);
- need_copy_out = 1;
- }
- break;
-
- case MTIOCTOP:
- length = sizeof(struct mtop);
- need_copy_in = 1;
- break;
-
- case oTIOCNOTTY:
- case TIOCNOTTY:
- break;
-
- case oTIOCNXCL:
- case TIOCNXCL:
- break;
-
- case TIOCOUTQ:
- length = sizeof(int);
- need_copy_out = 1;
- break;
-
- case TIOCSPGRP:
- length = sizeof(int);
- need_copy_in = 1;
- break;
-
- case oTIOCSTI:
- case TIOCSTI:
- length = sizeof(char);
- need_copy_in = 1;
- break;
-
- case TIOCSWINSZ:
- length = sizeof(struct winsize);
- need_copy_in = 1;
- break;
-
- case LDSETT:
- length = sizeof(struct termcb);
- need_copy_in = 1;
- break;
-
- default:
- return -2;
- }
- }
- else
- {
- /*
- * New style.
- */
-
- need_copy_in = arg[1] & (unsigned long)IOC_IN;
- need_copy_out = arg[1] & (unsigned long)IOC_OUT;
- length = (arg[1] >> (unsigned long)16) & (unsigned long)IOCPARM_MASK;
- }
-
- if (length > 0)
- {
- if (bufset((unsigned int)length) == -1)
- return -1;
-
- if (need_copy_in)
- {
- if (quiet_procmget(GLOBALdipc, (unsigned long)arg[2], sys_call_buf, length) == -1)
- return -1;
- }
- }
-
- /*
- * TODO: But what about fd's hidden in ioctl() args?
- * strioctl() calls, for example.
- */
- Rstart;
- return_value0 = syscall(syscallno, fd_lookup((int)arg[0]), (int)arg[1], arg2_is_arg ? (int)arg[2] : (int)sys_call_buf);
- return_errno = errno;
- Rstop;
-
- if
- (
- need_copy_out
- &&
- return_value0 != -1
- &&
- quiet_procmput(GLOBALdipc, (unsigned long)arg[2], sys_call_buf, length) == -1
- )
- return -1;
-
- return 0;
- }
-
- /*
- * Global entry point so that the bsd43 ioctl()
- * can call the sysv ioctl() when it finds that
- * it is really being called with sysv arguments
- * .. yes, this is fairly gross.
- */
- int
- sysv_sys_ioctl()
- {
- static int ive_been_called_before;
- int result;
-
- if (ive_been_called_before)
- result = -2;
- else
- {
- ive_been_called_before = 1;
- result = sys_ioctl(SYS_ioctl);
- }
-
- ive_been_called_before = 0;
-
- return result;
- }
-
- static
- int
- sys_lstat(syscallno)
- int syscallno;
- {
- struct stat statb;
-
- return generic_lstat(syscallno, &statb, sizeof(statb));
- }
-
- static
- int
- sys_ofcntl(syscallno)
- int syscallno;
- {
- switch ((int)arg[1])
- {
- case F_GETFL:
- case F_SETFL:
- Rstart;
- return_value0 = syscall(syscallno, fd_lookup((int)arg[0]), (int)arg[1], (int)arg[2]);
- return_errno = errno;
- Rstop;
- break;
-
- default:
- return sys_fcntl(SYS_fcntl);
- }
-
- return 0;
- }
-
- static
- int
- sys_pipe(syscallno)
- int syscallno;
- {
- int fds[2];
-
- Rstart;
- return_value0 = pipe(&fds[0]);
- return_errno = errno;
- Rstop;
-
- if (return_value0 != -1)
- {
- return_value0 = fd_open(fds[0]);
- return_value1 = fd_open(fds[1]);
- }
-
- return 0;
- }
-
- static
- int
- sys_poll(syscallno)
- int syscallno;
- {
- unsigned long nfds;
- int timeout;
- int size;
- struct pollfd *fds;
- int fd;
- int *saved_fds;
-
- nfds = arg[1];
- timeout = arg[2];
-
- size = nfds * sizeof(fds[0]);
-
- if (bufset(size) == -1)
- return -1;
-
- if (mget(arg[0], sys_call_buf, size, &fds) == -1)
- return -1;
-
- if (fds != (struct pollfd *)0)
- {
- if ((saved_fds = (int *)malloc(nfds * sizeof(int))) == (int *)0)
- {
- vcouldnot("allocate space for %d poll fds", nfds);
- return -1;
- }
-
- for (fd = 0; fd < nfds; fd++)
- {
- saved_fds[fd] = fds[fd].fd;
- fds[fd].fd = fd_lookup(fds[fd].fd);
- }
- }
-
- Rstart;
- return_value0 = syscall(syscallno, fds, nfds, timeout);
- return_errno = errno;
- Rstop;
-
- if (fds != (struct pollfd *)0)
- {
- for (fd = 0; fd < nfds; fd++)
- fds[fd].fd = saved_fds[fd];
-
- (void)free(saved_fds);
- }
-
- if (mput(arg[0], fds, size, return_value0) == -1)
- return -1;
-
- return 0;
- }
-
- static
- int
- sys_recvfrom(syscallno)
- int syscallno;
- {
- struct sockaddr from;
-
- return generic_recvfrom(syscallno, &from);
- }
-
- static
- int
- sys_recvmsg(syscallno)
- int syscallno;
- {
- struct msghdr local_msghdr;
- struct msghdr saved_local_msghdr;
- struct iovec *saved_msg_iov;
-
- if (quiet_procmget(GLOBALdipc, (unsigned long)arg[1], &local_msghdr, sizeof(local_msghdr)) == -1)
- return -1;
-
- saved_local_msghdr = local_msghdr;
-
- /*
- * Copy in the optional address.
- */
- if (local_msghdr.msg_name != (caddr_t)0)
- {
- caddr_t name;
-
- if ((name = (caddr_t)malloc(local_msghdr.msg_namelen)) == (caddr_t)0)
- {
- vcouldnot("allocate buffer for msg_name of length %d bytes", local_msghdr.msg_namelen);
- return -1;
- }
-
- if (quiet_procmget(GLOBALdipc, (unsigned long)local_msghdr.msg_name, name, (unsigned int)local_msghdr.msg_namelen) == -1)
- return -1;
-
- local_msghdr.msg_name = name;
- }
-
- /*
- * Copy in the scatter/gather array.
- */
- if (local_msghdr.msg_iov != (struct iovec *)0)
- {
- struct iovec *v;
- int i;
-
- if ((v = (struct iovec *)malloc(local_msghdr.msg_iovlen * sizeof(*v))) == (struct iovec *)0)
- {
- vcouldnot("allocate buffer for scatter/gather vector of %d elements", local_msghdr.msg_iovlen);
- return -1;
- }
-
- if (quiet_procmget(GLOBALdipc, (unsigned long)local_msghdr.msg_iov, v, (unsigned int)local_msghdr.msg_iovlen * sizeof(*v)) == -1)
- return -1;
-
- local_msghdr.msg_iov = v;
-
- /*
- * Save a copy of the array.
- */
- if ((saved_msg_iov = (struct iovec *)malloc(local_msghdr.msg_iovlen * sizeof(*v))) == (struct iovec *)0)
- {
- vcouldnot("allocate buffer for saved scatter/gather vector of %d elements", local_msghdr.msg_iovlen);
- return -1;
- }
-
- (void)memcpy(saved_msg_iov, v, local_msghdr.msg_iovlen * sizeof(*v));
-
- /*
- * Copy in each entry of the array.
- */
- for (i = 0; i < local_msghdr.msg_iovlen; i++)
- {
- struct iovec *liovp;
-
- liovp = &(local_msghdr.msg_iov[i]);
-
- if (liovp->iov_base != (caddr_t)0)
- {
- caddr_t b;
-
- if ((b = (caddr_t)malloc(liovp->iov_len)) == (caddr_t)0)
- {
- vcouldnot("allocate buffer for member of scatter/gather vector of %d bytes", liovp->iov_len);
- return -1;
- }
-
- if (quiet_procmget(GLOBALdipc, (unsigned long)liovp->iov_base, b, (unsigned int)liovp->iov_len) == -1)
- return -1;
-
- liovp->iov_base = b;
- }
- }
- }
-
- /*
- * Copy in the optional(?) access rights.
- */
- if (local_msghdr.msg_accrights != (caddr_t)0)
- {
- caddr_t a;
-
- if ((a = (caddr_t)malloc(local_msghdr.msg_accrightslen)) == (caddr_t)0)
- {
- vcouldnot("allocate buffer for access rights of length %d bytes", local_msghdr.msg_accrightslen);
- return -1;
- }
-
- if (quiet_procmget(GLOBALdipc, (unsigned long)local_msghdr.msg_accrights, a, (unsigned int)local_msghdr.msg_accrightslen) == -1)
- return -1;
-
- local_msghdr.msg_accrights = a;
- }
-
- Rstart;
- return_value0 = syscall(syscallno, fd_lookup((int)arg[0]), &local_msghdr, (int)arg[2]);
- return_errno = errno;
- Rstop;
-
- /*
- * Copy out fields to the user, free()'ing as we go.
- */
-
- /*
- * Copy out the access rights.
- */
- if (saved_local_msghdr.msg_accrights != (caddr_t)0)
- {
- if (quiet_procmput(GLOBALdipc, (unsigned long)saved_local_msghdr.msg_accrights, local_msghdr.msg_accrights, (unsigned int)local_msghdr.msg_accrightslen) == -1)
- return -1;
-
- (void)free((char *)local_msghdr.msg_accrights);
- }
-
- /*
- * Copy out the scatter/gather array.
- */
- if (saved_local_msghdr.msg_iov != (struct iovec *)0)
- {
- int i;
-
- /*
- * Copy out each entry of the array.
- */
- for (i = 0; i < local_msghdr.msg_iovlen; i++)
- {
- struct iovec *liovp;
-
- liovp = &(local_msghdr.msg_iov[i]);
-
- if (saved_msg_iov[i].iov_base != (caddr_t)0)
- {
- if (quiet_procmput(GLOBALdipc, (unsigned long)saved_msg_iov[i].iov_base, liovp->iov_base, (unsigned int)liovp->iov_len) == -1)
- return -1;
-
- (void)free(liovp->iov_base);
- }
- }
-
- (void)free(saved_msg_iov);
-
- /*
- * Copy out the reconstructed array itself?
- */
-
- (void)free(local_msghdr.msg_iov);
- }
-
- /*
- * Copy out the received name and its length?
- */
-
- (void)free(local_msghdr.msg_name);
-
- return 0;
- }
-
- #define select_dget(a,d,pp,m,nm) \
- { \
- if (a == 0) \
- pp = (struct fd_set *)0; \
- else \
- { \
- struct fd_set tfds; \
- int fd; \
- \
- if (quiet_procmget(GLOBALdipc, (unsigned long)a, &tfds, howmany(m, NFDBITS) * sizeof(fd_mask)) == -1) \
- return -1; \
- \
- FD_ZERO(&d); \
- \
- for (fd = 0; fd < m; fd++) \
- { \
- int nfd; \
- \
- if \
- ( \
- FD_ISSET(fd, &tfds) \
- && \
- (nfd = fd_lookup(fd)) != -1 \
- ) \
- { \
- FD_SET(nfd, &d); \
- if (nfd >= nm) \
- nm = nfd + 1; \
- } \
- } \
- \
- pp = &d; \
- } \
- }
-
- #define select_tget(a,d,p,t) \
- { \
- if (a == 0) \
- p = (t *)0; \
- else \
- { \
- if (quiet_procmget(GLOBALdipc, (unsigned long)a, &d, sizeof(d)) == -1) \
- return -1; \
- \
- p = &d; \
- } \
- }
-
- #define select_dput(a,pp,nn) \
- { \
- if (a != 0) \
- { \
- struct fd_set tfds; \
- int fd; \
- \
- FD_ZERO(&tfds); \
- \
- for (fd = 0; fd < nn; fd++) \
- { \
- int nfd; \
- \
- if \
- ( \
- (nfd = fd_lookup(fd)) != -1 \
- && \
- FD_ISSET(nfd, pp) \
- ) \
- FD_SET(fd, &tfds); \
- } \
- \
- if (quiet_procmput(GLOBALdipc, (unsigned long)a, &tfds, howmany(nn, NFDBITS) * sizeof(fd_mask)) == -1) \
- return -1; \
- } \
- }
-
- static
- int
- sys_select(syscallno)
- int syscallno;
- {
- struct fd_set rfds;
- struct fd_set *rfdsp;
- struct fd_set wfds;
- struct fd_set *wfdsp;
- struct fd_set efds;
- struct fd_set *efdsp;
- struct timeval timeout;
- struct timeval *timeoutp;
- int nfds;
- int newnfds;
-
- nfds = (int)arg[0];
- if (nfds > fd_nfiles())
- nfds = fd_nfiles();
- newnfds = 0;
-
- select_dget(arg[1], rfds, rfdsp, nfds, newnfds);
- select_dget(arg[2], wfds, wfdsp, nfds, newnfds);
- select_dget(arg[3], efds, efdsp, nfds, newnfds);
- select_tget(arg[4], timeout, timeoutp, struct timeval);
-
- Rstart;
- return_value0 = syscall(syscallno, newnfds, rfdsp, wfdsp, efdsp, timeoutp);
- return_errno = errno;
- Rstop;
-
- if (return_value0 != -1)
- {
- select_dput(arg[3], efdsp, nfds);
- select_dput(arg[2], wfdsp, nfds);
- select_dput(arg[1], rfdsp, nfds);
- }
-
- return 0;
- }
-
- static
- int
- sys_sendmsg(syscallno)
- int syscallno;
- {
- struct msghdr local_msghdr;
-
- if (quiet_procmget(GLOBALdipc, (unsigned long)arg[1], &local_msghdr, sizeof(local_msghdr)) == -1)
- return -1;
-
- #if 0
- fprintf(outfp, "local_msghdr.msg_name = 0x%x\n", local_msghdr.msg_name);
- fprintf(outfp, "local_msghdr.msg_namelen = %d\n", local_msghdr.msg_namelen);
- #endif /* 0 */
-
- /*
- * Copy in the optional address.
- */
- if (local_msghdr.msg_name != (caddr_t)0)
- {
- caddr_t name;
-
- if ((name = (caddr_t)malloc(local_msghdr.msg_namelen)) == (caddr_t)0)
- {
- vcouldnot("allocate buffer for msg_name of length %d bytes", local_msghdr.msg_namelen);
- return -1;
- }
-
- if (quiet_procmget(GLOBALdipc, (unsigned long)local_msghdr.msg_name, name, (unsigned int)local_msghdr.msg_namelen) == -1)
- return -1;
-
- local_msghdr.msg_name = name;
-
- #if 0
- {
- int i;
-
- fprintf(outfp, "msg_name =");
- for (i = 0; i < local_msghdr.msg_namelen; i++)
- fprintf(outfp, "%02x", local_msghdr.msg_name[i] & 0xFF);
- fprintf(outfp, "\n");
- }
- #endif /* 0 */
- }
-
- #if 0
- fprintf(outfp, "local_msghdr.msg_iov = 0x%x\n", local_msghdr.msg_iov);
- fprintf(outfp, "local_msghdr.msg_iovlen = %d\n", local_msghdr.msg_iovlen);
- #endif /* 0 */
-
- /*
- * Copy in the scatter/gather array.
- */
- if (local_msghdr.msg_iov != (struct iovec *)0)
- {
- struct iovec *v;
- int i;
-
- if ((v = (struct iovec *)malloc(local_msghdr.msg_iovlen * sizeof(*v))) == (struct iovec *)0)
- {
- vcouldnot("allocate buffer for scatter/gather vector of %d elements", local_msghdr.msg_iovlen);
- return -1;
- }
-
- if (quiet_procmget(GLOBALdipc, (unsigned long)local_msghdr.msg_iov, v, (unsigned int)local_msghdr.msg_iovlen * sizeof(*v)) == -1)
- return -1;
-
- local_msghdr.msg_iov = v;
-
- /*
- * Copy in each entry in the array.
- */
- for (i = 0; i < local_msghdr.msg_iovlen; i++)
- {
- struct iovec *liovp;
-
- liovp = &(local_msghdr.msg_iov[i]);
-
- #if 0
- fprintf(outfp, "local_msghdr.msg_iov[%d].iov_base = 0x%x\n", i, liovp->iov_base);
- fprintf(outfp, "local_msghdr.msg_iov[%d].iov_len = %d\n", i, liovp->iov_len);
- #endif /* 0 */
-
- if (liovp->iov_base != (caddr_t)0)
- {
- caddr_t b;
-
- if ((b = (caddr_t)malloc(liovp->iov_len)) == (caddr_t)0)
- {
- vcouldnot("allocate buffer for member of scatter/gather vector of %d bytes", liovp->iov_len);
- return -1;
- }
-
- if (quiet_procmget(GLOBALdipc, (unsigned long)liovp->iov_base, b, (unsigned int)liovp->iov_len) == -1)
- return -1;
-
- liovp->iov_base = b;
- }
- }
- }
-
- #if 0
- fprintf(outfp, "local_msghdr.msg_accrights = %d\n", local_msghdr.msg_accrights);
- fprintf(outfp, "local_msghdr.msg_accrightslen = %d\n", local_msghdr.msg_accrightslen);
- #endif /* 0 */
-
- /*
- * Copy in the optional(?) access rights.
- */
- if (local_msghdr.msg_accrights != (caddr_t)0)
- {
- caddr_t a;
-
- if ((a = (caddr_t)malloc(local_msghdr.msg_accrightslen)) == (caddr_t)0)
- {
- vcouldnot("allocate buffer for access rights of length %d bytes", local_msghdr.msg_accrightslen);
- return -1;
- }
-
- if (quiet_procmget(GLOBALdipc, (unsigned long)local_msghdr.msg_accrights, a, (unsigned int)local_msghdr.msg_accrightslen) == -1)
- return -1;
-
- local_msghdr.msg_accrights = a;
- }
-
- Rstart;
- return_value0 = syscall(syscallno, fd_lookup((int)arg[0]), &local_msghdr, (int)arg[2]);
- return_errno = errno;
- Rstop;
-
- /*
- * Should we copy out any of these fields to the user?
- * Assuming "no" until demonstrated otherwise.
- */
-
- /*
- * Free up all the temporary space...
- */
-
- if (local_msghdr.msg_accrights != (caddr_t)0)
- (void)free((char *)local_msghdr.msg_accrights);
-
- if (local_msghdr.msg_iov != (struct iovec *)0)
- {
- int i;
-
- for (i = 0; i < local_msghdr.msg_iovlen; i++)
- {
- struct iovec *liovp;
-
- liovp = &local_msghdr.msg_iov[i];
-
- if (liovp->iov_base != (caddr_t)0)
- (void)free((char *)liovp->iov_base);
- }
-
- (void)free((char *)local_msghdr.msg_iov);
- }
-
- if (local_msghdr.msg_name != (caddr_t)0)
- (void)free((char *)local_msghdr.msg_name);
-
- return 0;
- }
-
- static
- int
- sys_sendto(syscallno)
- int syscallno;
- {
- struct sockaddr to;
-
- return generic_sendto(syscallno, &to);
- }
-
- static
- int
- sys_setitimer(syscallno)
- int syscallno;
- {
- struct itimerval it;
- struct itimerval oit;
-
- return generic_setitimer(syscallno, &it, sizeof(it), &oit, sizeof(oit));
- }
-
- static
- int
- sys_setpgrp(syscallno)
- int syscallno;
- {
- Rstart;
- return_value0 = syscall(syscallno, arg[0]);
- return_errno = errno;
- Rstop;
-
- return 0;
- }
-
- static
- int
- sys_setrlimit(syscallno)
- int syscallno;
- {
- return generic_setrlimit(syscallno, sizeof(struct rlimit));
- }
-
- #if defined(SHARE)
- static
- int
- sys_sharecosts(syscallno)
- int syscallno;
- {
- int function;
- struct sh_consts *address;
- int size;
-
- function = arg[0];
- size = arg[2];
-
- if (dmget(arg[1], size, &address) == -1)
- return -1;
-
- Rstart;
- return_value0 = syscall(syscallno, function, address, size);
- return_errno = errno;
- Rstop;
-
- if (dmput(arg[1], address, size, return_value0) == -1)
- return -1;
-
- return 0;
- }
- #endif /* defined(SHARE) */
-
- #if 0
- #define SIG_DEBUG 1
- #endif /* 0 */
-
- #define SH_DFL 0
- #define SH_HOLD 1
-
- typedef struct siginfo siginfo;
- struct siginfo
- {
- unsigned long sig_handler;
- int sig_handler_type;
- unsigned long sig_tramp;
- int sig_code;
- struct sigcontext sig_context;
- int sig_pending;
- };
-
- static siginfo sinfo[NSIG];
-
- int sigs_pending;
-
- static
- void
- our_handler(sig, code, scp)
- int sig;
- int code;
- struct sigcontext *scp;
- {
- sinfo[sig].sig_pending++;
- sigs_pending++;
-
- sinfo[sig].sig_code = code;
- sinfo[sig].sig_context = *scp;
-
- #if defined(SIG_DEBUG)
- if (sysv_print_received_signal(U_SYSV, "sysv_debug", sinfo[sig].sig_tramp, sinfo[sig].sig_handler, sig, sinfo[sig].sig_code, scp) == -1)
- return -1;
- #endif /* defined(SIG_DEBUG) */
-
- /*
- * All of our handlers are of the "sigset()" kind.
- * Normally this would mean that:
- * 1. during the execution of the handler, any
- * further arrivals of the same signal are held.
- * 2. on return from the handler, the same handler
- * is restored and any held signal is delivered.
- * We want to keep the first property but we want to
- * modify the second property so that, instead of
- * restoring the signal handler and re-enabling signals
- * immediately, we continue to hold signals
- * and only release them and restore the handler at
- * a later time (i.e. when we actually simulate signal delivery).
- * This assignment to "scp->is_sigset" accomplishes this.
- */
- scp->is_sigset = 0;
- }
-
- dinstrn *
- deliver_signal(dipc)
- dinstrn *dipc;
- {
- int i;
- struct sigcontext *sscp;
- int regmask;
- int regbit;
- int regi;
-
- for (i = 0; i < nels(sinfo); i++)
- {
- if (sinfo[i].sig_pending > 0)
- {
- /*
- * Massage saved sigcontext.
- */
- sinfo[i].sig_context.sc_pc = dipc->di_addr;
-
- regmask = 0xFFFFFFFF;
- sinfo[i].sig_context.sc_regmask = regmask;
-
- sinfo[i].sig_context.sc_regs[0] = 0;
- for
- (
- regi = 1, regbit = 1 << 1;
- regi < nels(sinfo[i].sig_context.sc_regs);
- regi++, regbit <<= 1
- )
- {
- if (regmask & regbit)
- {
- int saved_give_warnings;
-
- if (PG(regi) == R_K0 || PG(regi) == R_K1)
- {
- saved_give_warnings = give_warnings;
- give_warnings = 0;
- }
-
- if (quiet_procsget(PG(regi), &sinfo[i].sig_context.sc_regs[regi]) == -1)
- return dipc;
-
- if (PG(regi) == R_K0 || PG(regi) == R_K1)
- give_warnings = saved_give_warnings;
- }
- }
-
- if (quiet_procsget(R_HI, &sinfo[i].sig_context.sc_mdhi) == -1)
- return dipc;
-
- if (quiet_procsget(R_LO, &sinfo[i].sig_context.sc_mdlo) == -1)
- return dipc;
- #if 0
- /*
- * TODO: floating point? exceptions?
- */
- {
- int *srp, *frp;
- uint *urp;
-
- scp->sc_ownedfp = u.u_pcb.pcb_ownedfp;
-
- if ((regmask & 1) && u.u_pcb.pcb_ownedfp)
- {
- checkfp (u.u_procp, 0); /* dump fp to pcb */
- for
- (
- srp = &scp->sc_fpregs[0], frp = u.u_pcb.pcb_fpregs;
- frp < &u.u_pcb.pcb_fpregs[32];
- srp++, frp++
- )
- *srp = *frp;
- scp->sc_fpc_csr = u.u_pcb.pcb_fpc_csr;
- scp->sc_fpc_eir = u.u_pcb.pcb_fpc_eir;
- u.u_pcb.pcb_fpc_csr &= ~FPCSR_EXCEPTIONS;
- }
-
- scp->sc_cause = USER_REG(EF_CAUSE);
- scp->sc_badvaddr = USER_REG(EF_BADVADDR);
- }
- #endif /* 0 */
-
- /*
- * Store massaged sigcontext on stack.
- */
- if (quiet_procsget(R_SP, &sscp) == -1)
- return dipc;
-
- /*
- * Make room.
- */
- sscp--;
-
- /*
- * Ensure quad word aligned.
- */
- sscp = (struct sigcontext *)(((unsigned long)sscp) & ~0xF);
-
- if (quiet_procmput(GLOBALdipc, (unsigned long)sscp, &sinfo[i].sig_context, sizeof(sinfo[i].sig_context)) == -1)
- return dipc;
-
- if (Pflag || Sflag)
- {
- if (sysv_print_received_signal(U_SYSV, "sysv", sinfo[i].sig_tramp, sinfo[i].sig_handler, i, sinfo[i].sig_code, sscp) == -1)
- return dipc;
- }
-
- /*
- * Set up arguments and SP for sig_tramp() call.
- */
- if (quiet_procsput(R_A0, i) == -1)
- return dipc;
-
- if (quiet_procsput(R_A1, sinfo[i].sig_code) == -1)
- return dipc;
-
- if (quiet_procsput(R_A2, sscp) == -1)
- return dipc;
-
- if (quiet_procsput(R_SP, sscp) == -1)
- return dipc;
-
- if (quiet_procsput(R_A3, sinfo[i].sig_handler) == -1)
- return dipc;
-
- /*
- * Set up PC for sig_tramp() call.
- */
- if ((dipc = addr_to_decoded_instrnp(dipc, sinfo[i].sig_tramp)) == (dinstrn *)0)
- return dipc;
-
- dipc--;
-
- sigs_pending--;
- sinfo[i].sig_pending--;
-
- if (sinfo[i].sig_handler_type == SH_DFL)
- (void)sigset(i, SIG_DFL);
-
- break;
- }
- }
-
- return dipc;
- }
-
- static
- int
- sys_signal(syscallno)
- int syscallno;
- {
- int signo;
- int sigbits;
-
- signo = arg[0] & SIGNO_MASK;
- sigbits = arg[0] & ~SIGNO_MASK;
-
- switch ((int)arg[1])
- {
- case SIG_IGN:
- case SIG_DFL:
- case SIG_HOLD:
- return_value0 = (long)sigset(signo, arg[1]);
- if
- (
- return_value0 != (long)SIG_ERR
- &&
- return_value0 != (long)SIG_DFL
- &&
- return_value0 != (long)SIG_IGN
- &&
- return_value0 != (long)SIG_HOLD
- )
- return_value0 = sinfo[signo].sig_handler;
-
- if (return_value0 != (long)SIG_ERR)
- sinfo[signo].sig_handler = arg[1];
- break;
-
- default:
- switch (sigbits)
- {
- case SIGHOLD:
- return_value0 = (long)sighold(signo);
- break;
-
- case SIGRELSE:
- return_value0 = (long)sigrelse(signo);
- break;
-
- case SIGIGNORE:
- return_value0 = (long)sigignore(signo);
- break;
-
- case SIGPAUSE:
- return_value0 = (long)sigpause(signo);
- break;
-
- case SIGDEFER:
- return_value0 = (long)sigset(signo, our_handler);
- if
- (
- return_value0 != (long)SIG_ERR
- &&
- return_value0 != (long)SIG_DFL
- &&
- return_value0 != (long)SIG_IGN
- &&
- return_value0 != (long)SIG_HOLD
- )
- return_value0 = sinfo[signo].sig_handler;
-
- if (return_value0 != (long)SIG_ERR)
- {
- sinfo[signo].sig_handler = arg[1];
- sinfo[signo].sig_handler_type = SH_HOLD;
- sinfo[signo].sig_tramp = arg[2];
- }
- break;
-
- default:
- return_value0 = (long)sigset(signo, our_handler);
- if
- (
- return_value0 != (long)SIG_ERR
- &&
- return_value0 != (long)SIG_DFL
- &&
- return_value0 != (long)SIG_IGN
- &&
- return_value0 != (long)SIG_HOLD
- )
- return_value0 = sinfo[signo].sig_handler;
-
- if (return_value0 != (long)SIG_ERR)
- {
- sinfo[signo].sig_handler = arg[1];
- sinfo[signo].sig_handler_type = SH_DFL;
- sinfo[signo].sig_tramp = arg[2];
- }
- break;
- }
- break;
- }
-
- return_errno = errno;
-
- return 0;
- }
-
- static
- int
- sys_sigreturn(syscallno)
- int syscallno;
- {
- struct sigcontext sc;
- struct sigcontext *scp;
- int regmask;
- int regi;
- int regbit;
-
- if (mget(arg[0], &sc, sizeof(sc), &scp) == -1)
- return -1;
-
- if (scp == (struct sigcontext *)0)
- {
- return_value0 = -1;
- return_errno = EFAULT;
- return 0;
- }
-
- #if 0
- /*
- * TODO: floating point? exceptions?
- */
- {
- int *srp, *frp;
- uint *urp;
-
- scp->sc_ownedfp = u.u_pcb.pcb_ownedfp;
-
- if ((regmask & 1) && u.u_pcb.pcb_ownedfp)
- {
- checkfp (u.u_procp, 0); /* dump fp to pcb */
- for
- (
- srp = &scp->sc_fpregs[0], frp = u.u_pcb.pcb_fpregs;
- frp < &u.u_pcb.pcb_fpregs[32];
- srp++, frp++
- )
- *srp = *frp;
- scp->sc_fpc_csr = u.u_pcb.pcb_fpc_csr;
- scp->sc_fpc_eir = u.u_pcb.pcb_fpc_eir;
- u.u_pcb.pcb_fpc_csr &= ~FPCSR_EXCEPTIONS;
- }
-
- scp->sc_cause = USER_REG(EF_CAUSE);
- scp->sc_badvaddr = USER_REG(EF_BADVADDR);
- }
- #endif /* 0 */
-
- if (quiet_procsput(R_HI, scp->sc_mdhi) == -1)
- return -1;
-
- if (quiet_procsput(R_LO, scp->sc_mdlo) == -1)
- return -1;
-
- regmask = scp->sc_regmask;
-
- for
- (
- regi = 1, regbit = 1 << 1;
- regi < nels(scp->sc_regs);
- regi++, regbit <<= 1
- )
- {
- if (regmask & regbit)
- {
- int saved_give_warnings;
-
- if (PG(regi) == R_K0 || PG(regi) == R_K1)
- {
- saved_give_warnings = give_warnings;
- give_warnings = 0;
- }
-
- if (quiet_procsput(PG(regi), scp->sc_regs[regi]) == -1)
- return -1;
-
- if (PG(regi) == R_K0 || PG(regi) == R_K1)
- give_warnings = saved_give_warnings;
- }
- }
-
- /*
- * Set up PC for return.
- */
- if ((GLOBALdipc = addr_to_decoded_instrnp(GLOBALdipc, scp->sc_pc)) == (dinstrn *)0)
- return -1;
-
- GLOBALdipc--;
-
- if (scp->is_sigset != 0)
- (void)sigrelse(scp->is_sigset & SIGNO_MASK);
-
- /*
- * Set up tidy but unused return values.
- */
- return_value0 = 0;
- return_errno = 0;
-
- return -3;
- }
-
- static
- int
- sys_stat(syscallno)
- int syscallno;
- {
- struct stat statb;
-
- return generic_stat(syscallno, &statb, sizeof(statb));
- }
-
- static
- int
- sys_statfs(syscallno)
- int syscallno;
- {
- char *cp;
- int len;
- struct statfs buf;
- struct statfs *bufp;
-
- if (mgets(arg[0], &cp) == -1)
- return -1;
-
- len = arg[2];
-
- if (mget(arg[1], &buf, len, &bufp) == -1)
- return -1;
-
- Rstart;
- return_value0 = syscall(syscallno, cp, bufp, len, (int)arg[3]);
- return_errno = errno;
- Rstop;
-
- if (mput(arg[1], bufp, len, return_value0) == -1)
- return -1;
-
- return 0;
- }
-
- static
- int
- sys_sysfs(syscallno)
- int syscallno;
- {
- char *cp;
- char buf[FSTYPSZ];
-
- switch (arg[0])
- {
- case GETFSIND:
- if (mgets(arg[1], &cp) == -1)
- return -1;
-
- Rstart;
- return_value0 = syscall(syscallno, arg[0], cp);
- return_errno = errno;
- Rstop;
-
- break;
-
- case GETFSTYP:
- Rstart;
- return_value0 = syscall(syscallno, arg[0], arg[1], &buf[0]);
- return_errno = errno;
- Rstop;
-
- if (mput(arg[2], &buf[0], sizeof(buf), return_value0) == -1)
- return -1;
- break;
-
- case GETNFSTYP:
- Rstart;
- return_value0 = syscall(syscallno, arg[0]);
- return_errno = errno;
- Rstop;
- break;
-
- default:
- return -2;
- }
-
- return 0;
- }
-
- static
- int
- sys_times(syscallno)
- int syscallno;
- {
- return generic_times(syscallno, sizeof(struct tms));
- }
-
- static
- int
- sys_utime(syscallno)
- int syscallno;
- {
- time_t t[2];
-
- return generic_utime(syscallno, &t[0], sizeof(t));
- }
-
- static
- int
- sys_utssys(syscallno)
- int syscallno;
- {
- struct utsname *utsnp;
- struct ustat *ubp;
-
- switch (arg[2])
- {
- case 0: /* uname */
- if (dmget(arg[0], sizeof(*utsnp), &utsnp) == -1)
- return -1;
-
- Rstart;
- return_value0 = syscall(syscallno, utsnp, 0, arg[2]);
- return_errno = errno;
- Rstop;
-
- if (dmput(arg[0], utsnp, sizeof(*utsnp), return_value0) == -1)
- return -1;
- break;
-
- case 2: /* ustat */
- if (dmget(arg[0], sizeof(*ubp), &ubp) == -1)
- return -1;
-
- Rstart;
- return_value0 = syscall(syscallno, ubp, arg[1], arg[2]);
- return_errno = errno;
- Rstop;
-
- if (dmput(arg[0], ubp, sizeof(*ubp), return_value0) == -1)
- return -1;
- break;
-
- default:
- return -2;
- }
-
- return 0;
- }
-
- static
- int
- sys_wait3(syscallno)
- int syscallno;
- {
- union wait s;
- struct rusage r;
-
- return generic_wait3(syscallno, &s, sizeof(s), &r, sizeof(r));
- }
-
- static sysentry sysv_systab[] =
- {
- { "syscall", 1, "d", 'd', (int (*)())0, },
- { "_exit", 1, "d", 'e', generic_exit, },
- { "fork", 0, "", 'Y', generic_fork, },
- { "read", 3, "dRd", 'd', generic_read, },
- { "write", 3, "dWd", 'd', generic_write, },
- { "open", 3, "FOm", 'd', generic_open, },
- { "close", 1, "d", 'd', generic_close, },
- { "Owait", 0, "", '\0', (int (*)())0, },
- { "creat", 2, "Fm", 'd', generic_creat, },
- { "link", 2, "FF", 'd', generic_link, },
-
- { "unlink", 1, "F", 'd', generic_unlink, },
- { "Oexecv", 0, "", '\0', (int (*)())0, },
- { "chdir", 1, "F", 'd', generic_chdir, },
- { "time", 1, "v", 't', generic_time, },
- { "mknod", 3, "Fmx", 'd', generic_mknod, },
- { "chmod", 2, "Fm", 'd', generic_chmod, },
- { "chown", 3, "Fdd", 'd', generic_chown, },
- { "brk", 1, "I", 'd', generic_brk, },
- { "stat", 2, "FS", 'd', sys_stat, },
- { "lseek", 3, "duw", 'u', generic_lseek, },
-
- { "getpid", 0, "", 'd', generic_getpid, },
- { "mount", 0, "", '\0', (int (*)())0, },
- { "umount", 0, "", '\0', (int (*)())0, },
- { "setuid", 1, "d", 'd', generic_setuid, },
- { "getuid", 0, "", 'Y', sys_getuid, },
- { "stime", 1, "v", 'd', generic_stime, },
- { "ptrace", 4, "ddxd", 'd', generic_ptrace, },
- { "alarm", 1, "d", 'd', generic_alarm, },
- { "fstat", 2, "dS", 'd', sys_fstat, },
- { "pause", 0, "", 'd', generic_pause, },
-
- { "utime", 2, "FQ", 'd', sys_utime, },
- { "Ostty", 0, "", '\0', (int (*)())0, },
- { "Ogtty", 0, "", '\0', (int (*)())0, },
- { "access", 2, "FP", 'd', generic_access, },
- { "nice", 1, "d", 'd', generic_nice, },
- { "statfs", 4, "FXdd", 'd', sys_statfs, },
- { "sync", 0, "", 'd', generic_sync, },
- { "kill", 2, "dK", 'd', generic_kill, },
- { "fstatfs", 4, "dXdd", 'd', sys_fstatfs, },
- { "setpgrp", 1, "d", 'd', sys_setpgrp, },
-
- { "", 0, "", '\0', (int (*)())0, },
- { "dup", 1, "d", 'd', generic_dup, },
- { "pipe", 0, "", 'Y', sys_pipe, },
- { "times", 1, "k", 'd', sys_times, },
- { "profil", 4, "Iddd", 'd', generic_profil, },
- { "plock", 1, "d", 'd', generic_plock, },
- { "setgid", 1, "d", 'd', generic_setgid, },
- { "getgid", 0, "", 'Y', sys_getgid, },
- { "signal", 3, "KJI", 'J', sys_signal, },
- { "msgsys", 0, "", '\0', (int (*)())0, },
-
- { "sysmips", 0, "", '\0', (int (*)())0, },
- { "acct", 1, "F", 'd', generic_acct, },
- { "shmsys", 0, "", '\0', (int (*)())0, },
- { "semsys", 0, "", '\0', (int (*)())0, },
- { "ioctl", 3, "dCA", 'd', sys_ioctl, },
- { "uadmin", 3, "ddd", 'd', generic_uadmin, },
- { "", 0, "", '\0', (int (*)())0, },
- { "utssys", 3, "pdd", 'd', sys_utssys, },
- { "", 0, "", '\0', (int (*)())0, },
- { "execve", 3, "FlE", 'e', sys_execve, },
-
- { "umask", 1, "x", 'x', generic_umask, },
- { "chroot", 1, "F", 'd', generic_chroot, },
- { "ofcntl", 3, "dxd", 'd', sys_ofcntl, },
- { "ulimit", 2, "dd", 'd', generic_ulimit, },
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
-
- { "advfs", 0, "", '\0', (int (*)())0, },
- { "unadvfs", 0, "", '\0', (int (*)())0, },
- { "rmount", 0, "", '\0', (int (*)())0, },
- { "rumount", 0, "", '\0', (int (*)())0, },
- { "rfstart", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
- { "rdebug", 0, "", '\0', (int (*)())0, },
- { "rfstop", 0, "", '\0', (int (*)())0, },
- { "rfsys", 0, "", '\0', (int (*)())0, },
- { "rmdir", 1, "F", 'd', generic_rmdir, },
-
- { "mkdir", 2, "Fm", 'd', generic_mkdir, },
- { "getdents", 3, "dRd", 'd', generic_getdents, },
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
- { "sysfs", 3, "dxp", 'd', sys_sysfs, },
- { "getmsg", 0, "", '\0', (int (*)())0, },
- { "putmsg", 0, "", '\0', (int (*)())0, },
- { "poll", 3, "pdd", 'd', sys_poll, },
- { "sigreturn", 1, "y", 'd', sys_sigreturn, },
- { "accept", 3, "dLU", 'd', generic_accept, },
-
- { "bind", 3, "dLd", 'd', generic_bind, },
- { "connect", 3, "dLd", 'd', generic_connect, },
- { "gethostid", 0, "", 'u', generic_gethostid, },
- { "getpeername", 3, "dLU", 'd', generic_getpeername, },
- { "getsockname", 3, "dLU", 'd', generic_getsockname, },
- { "getsockopt", 5, "dddxU", 'd', generic_getsockopt, },
- { "listen", 2, "dd", 'd', generic_listen, },
- { "recv", 4, "dRdN", 'd', generic_recv, },
- { "recvfrom", 6, "dRdNLU", 'd', sys_recvfrom, },
- { "recvmsg", 3, "dpN", 'd', sys_recvmsg, },
-
- { "select", 5, "dDDDT", 'd', sys_select, },
- { "send", 4, "dWdN", 'd', generic_send, },
- { "sendmsg", 3, "dpN", 'd', sys_sendmsg, },
- { "sendto", 6, "dWdNLd", 'd', sys_sendto, },
- { "sethostid", 1, "u", 'd', generic_sethostid, },
- { "setsockopt", 5, "dddpd", 'd', generic_setsockopt, },
- { "shutdown", 2, "dd", 'd', generic_shutdown, },
- { "socket", 3, "abc", 'd', generic_socket, },
- { "gethostname", 2, "xd", 'd', generic_gethostname, },
- { "sethostname", 0, "", '\0', (int (*)())0, },
-
- { "getdomainname", 2, "xd", 'd', generic_getdomainname, },
- { "setdomainname", 2, "xd", 'd', generic_setdomainname, },
- { "truncate", 2, "Fu", 'd', generic_truncate, },
- { "ftruncate", 2, "du", 'd', generic_ftruncate, },
- { "rename", 2, "FF", 'd', generic_rename, },
- { "symlink", 2, "FF", 'd', generic_symlink, },
- { "readlink", 3, "FRd", 'd', generic_readlink, },
- { "lstat", 2, "FS", 'd', sys_lstat, },
- { "nfsmount", 0, "", '\0', (int (*)())0, },
- { "nfssvc", 0, "", 'd', generic_nfssvc, },
-
- { "getfh", 0, "", '\0', (int (*)())0, },
- { "async_daemon", 0, "", 'd', generic_async_daemon, },
- { "old_exportfs", 0, "", '\0', (int (*)())0, },
- { "mmap", 0, "", '\0', (int (*)())0, },
- { "munmap", 0, "", '\0', (int (*)())0, },
- { "getitimer", 2, "dV", 'd', sys_getitimer, },
- { "setitimer", 3, "dVV", 'd', sys_setitimer, },
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
-
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
-
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
- { "", 0, "", '\0', (int (*)())0, },
-
- { "cacheflush", 3, "Idd", 'd', generic_cacheflush, },
- { "cachectl", 3, "Idd", 'd', generic_cachectl, },
- { "fchown", 3, "ddd", 'd', generic_fchown, },
- { "fchmod", 2, "dm", 'd', generic_fchmod, },
- { "wait3", 3, "hij", 'd', sys_wait3, },
- { "mmap", 0, "", '\0', (int (*)())0, },
- { "munmap", 0, "", '\0', (int (*)())0, },
- { "madvise", 0, "", '\0', (int (*)())0, },
- { "getpagesize",0, "", 'd', generic_getpagesize, },
- { "setreuid", 2, "dd", 'd', generic_setreuid, },
-
- { "setregid", 2, "dd", 'd', generic_setregid, },
- { "setpgid", 2, "dd", 'd', generic_setpgid, },
- { "getgroups", 2, "dG", 'd', sys_getgroups, },
- { "setgroups", 2, "dg", 'd', generic_setgroups, },
- { "gettimeofday", 2, "TZ", 'd', sys_gettimeofday, },
- { "getrusage", 2, "dx", 'd', sys_getrusage, },
- { "getrlimit", 2, "dx", 'd', sys_getrlimit, },
- { "setrlimit", 2, "dx", 'd', sys_setrlimit, },
- { "exportfs", 0, "", '\0', (int (*)())0, },
- { "fcntl", 3, "dBH", 'd', sys_fcntl, },
- #if 0
- And then, a long way on at 260, 261 and 262 there are:
- { "netboot", 0, "", '\0', (int (*)())0, },
- { "netunboot", 0, "", '\0', (int (*)())0, },
- { "rdump", 0, "", '\0', (int (*)())0, },
- but they aren't used.
- #endif /* 0 */
- };
-
- #if defined(LIMITS)
- static sysentry limits_sysv_systab[] =
- {
- { "setlim", 2, "", '\0', (int (*)())0, }, /* 320 */
- { "getlim", 3, "dxd", 'd', sys_getlim, }, /* 321 */
- { "limonoff", 1, "", '\0', (int (*)())0, }, /* 322 */
- };
- #endif /* defined(LIMITS) */
-
- #if defined(SHARE)
- static sysentry share_sysv_systab[] =
- {
- { "sharecosts", 3, "dxd", 'd', sys_sharecosts, }, /* 323 */
- { "gettab", 4, "", '\0', (int (*)())0, }, /* 324 */
- };
- #endif /* defined(SHARE) */
-
- sysentry *
- sysv_systab_entry(n)
- int n;
- {
- int nn;
-
- if (n >= 0 && n < nels(sysv_systab))
- return &sysv_systab[n];
-
- #if defined(LIMITS)
- nn = n - (LIMITSoffset - SYSVoffset);
-
- if (nn >= 0 && nn < nels(limits_sysv_systab))
- return &limits_sysv_systab[nn];
- #endif /* defined(LIMITS) */
-
- #if defined(SHARE)
- nn = n - (SHAREoffset - SYSVoffset);
-
- if (nn >= 0 && nn < nels(share_sysv_systab))
- return &share_sysv_systab[nn];
- #endif /* defined(SHARE) */
-
- return (sysentry *)0;
- }
-
- int
- sysv_print_open_flags(arg)
- unsigned long arg;
- {
- need_leading_pipe = 0;
-
- if ((arg & (O_WRONLY | O_RDWR)) == 0)
- {
- say_flag(O_RDONLY, "O_RDONLY", arg);
- }
- else
- {
- say_flag(O_WRONLY, "O_WRONLY", arg);
- say_flag(O_RDWR, "O_RDWR", arg);
- }
-
- say_flag(O_APPEND, "O_APPEND", arg);
- say_flag(O_CREAT, "O_CREAT", arg);
- say_flag(O_EXCL, "O_EXCL", arg);
- say_flag(O_NDELAY, "O_NDELAY", arg);
- say_flag(O_SYNC, "O_SYNC", arg);
- say_flag(O_TRUNC, "O_TRUNC", arg);
-
- say_residual(arg);
-
- return 0;
- }
-
- int
- sysv_print_stat(arg)
- long arg;
- {
- struct stat statbuf;
-
- if (quiet_procmget(GLOBALdipc, (unsigned long)arg, (char *)&statbuf, sizeof(statbuf)) == -1)
- return -1;
-
- fprintf(outfp, "{" /* } */ );
- fprintf(outfp, "st_dev=0x%x,", statbuf.st_dev);
- fprintf(outfp, " st_ino=%d,", statbuf.st_ino);
- fprintf(outfp, " st_mode=0x%x,", statbuf.st_mode);
- fprintf(outfp, " st_nlink=%d,", statbuf.st_nlink);
- fprintf(outfp, " st_uid=%d,", statbuf.st_uid);
- fprintf(outfp, " st_gid=%d,", statbuf.st_gid);
- fprintf(outfp, " st_rdev=0x%x,", statbuf.st_rdev);
- fprintf(outfp, " st_size=%d,", statbuf.st_size);
- fprintf(outfp, " st_atime=");
- say_time(outfp, statbuf.st_atime);
- fprintf(outfp, ",");
- fprintf(outfp, " st_mtime=");
- say_time(outfp, statbuf.st_mtime);
- fprintf(outfp, ",");
- fprintf(outfp, " st_ctime=");
- say_time(outfp, statbuf.st_ctime);
- fprintf(outfp, ",");
- fprintf(outfp, /* { */ "}");
-
- return 0;
- }
-
- int
- sysv_print_ioctl_cmd(cmd)
- unsigned long cmd;
- {
- char *cname;
-
- switch (cmd)
- {
- case FIONREAD:
- cname = "FIONREAD";
- break;
-
- case I_POP:
- cname = "I_POP";
- break;
-
- case I_PUSH:
- cname = "I_PUSH";
- break;
-
- case I_SRDOPT:
- cname = "I_SRDOPT";
- break;
-
- case STGET:
- cname = "STGET";
- break;
-
- case oTCGETA:
- cname = "oTCGETA";
- break;
-
- case TCGETA:
- cname = "TCGETA";
- break;
-
- case oTCSETA:
- cname = "oTCSETA";
- break;
-
- case TCSETA:
- cname = "TCSETA";
- break;
-
- case oTCSETAF:
- cname = "oTCSETAF";
- break;
-
- case TCSETAF:
- cname = "TCSETAF";
- break;
-
- case oTCSETAW:
- cname = "oTCSETAW";
- break;
-
- case TCSETAW:
- cname = "TCSETAW";
- break;
-
- case TCFLSH:
- cname = "TCFLSH";
- break;
-
- case TCSBRK:
- cname = "TCSBRK";
- break;
-
- case TCXONC:
- cname = "TCXONC";
- break;
-
- case oTIOCEXCL:
- cname = "oTIOCEXCL";
- break;
-
- case TIOCEXCL:
- cname = "TIOCEXCL";
- break;
-
- case TIOCGPGRP:
- cname = "TIOCGPGRP";
- break;
-
- case TIOCGWINSZ:
- cname = "TIOCGWINSZ";
- break;
-
- case oTIOCHPCL:
- cname = "oTIOCHPCL";
- break;
-
- case oTIOCNOTTY:
- cname = "oTIOCNOTTY";
- break;
-
- case TIOCNOTTY:
- cname = "TIOCNOTTY";
- break;
-
- case oTIOCNXCL:
- cname = "oTIOCNXCL";
- break;
-
- case TIOCNXCL:
- cname = "TIOCNXCL";
- break;
-
- case TIOCOUTQ:
- cname = "TIOCOUTQ";
- break;
-
- case TIOCSPGRP:
- cname = "TIOCSPGRP";
- break;
-
- case oTIOCSTI:
- cname = "oTIOCSTI";
- break;
-
- case TIOCSTI:
- cname = "TIOCSTI";
- break;
-
- case TIOCSWINSZ:
- cname = "TIOCSWINSZ";
- break;
-
- case LDSETT:
- cname = "LDSETT";
- break;
-
- default:
- cname = (char *)0;
- break;
- }
-
- if (cname == (char *)0)
- fprintf(outfp, "0x%x", cmd);
- else
- fprintf(outfp, "%s", cname);
-
- return 0;
- }
-
- static
- int
- say_termcb(arg)
- unsigned long arg;
- {
- struct termcb tio;
-
- if (quiet_procmget(GLOBALdipc, arg, &tio, sizeof(tio)) == -1)
- return -1;
-
- fprintf(outfp, "{");
-
- /*
- * term flags.
- */
-
- fprintf(outfp, "st_flgs=");
-
- need_leading_pipe = 0;
-
- say_notflag(TM_NONE, "TM_NONE", tio.st_flgs);
- say_flag(TM_SNL, "TM_SNL", tio.st_flgs);
- say_flag(TM_ANL, "TM_ANL", tio.st_flgs);
- say_flag(TM_LCF, "TM_LCF", tio.st_flgs);
- say_flag(TM_CECHO, "TM_CECHO", tio.st_flgs);
- say_flag(TM_CINVIS, "TM_CINVIS", tio.st_flgs);
- say_flag(TM_SET, "TM_SET", tio.st_flgs);
-
- say_residual(tio.st_flgs);
-
- /*
- * term type.
- */
-
- fprintf(outfp, ", st_termt=");
-
- switch (tio.st_termt)
- {
- case TERM_NONE:
- fprintf(outfp, "TERM_NONE");
- break;
-
- case TERM_TEC:
- fprintf(outfp, "TERM_TEC");
- break;
-
- case TERM_V61:
- fprintf(outfp, "TERM_V61");
- break;
-
- case TERM_V10:
- fprintf(outfp, "TERM_V10");
- break;
-
- case TERM_TEX:
- fprintf(outfp, "TERM_TEX");
- break;
-
- case TERM_D40:
- fprintf(outfp, "TERM_D40");
- break;
-
- case TERM_H45:
- fprintf(outfp, "TERM_H45");
- break;
-
- case TERM_D42:
- fprintf(outfp, "TERM_D42");
- break;
-
- default:
- fprintf(outfp, "0x%x", tio.st_termt);
- break;
- }
-
- /*
- * gtty only - current row.
- */
- fprintf(outfp, ", st_crow=%d", tio.st_crow);
-
- /*
- * gtty only - current col.
- */
- fprintf(outfp, ", st_ccol=%d", tio.st_ccol);
-
- /*
- * variable row.
- */
- fprintf(outfp, ", st_vrow=%d", tio.st_vrow);
-
- /*
- * last row.
- */
- fprintf(outfp, ", st_lrow=%d", tio.st_lrow);
-
- fprintf(outfp, "}");
-
- return 0;
- }
-
- static
- int
- say_termiob(arg)
- unsigned long arg;
- {
- struct termio tio;
-
- if (quiet_procmget(GLOBALdipc, arg, &tio, sizeof(tio)) == -1)
- return -1;
-
- fprintf(outfp, "{");
-
- /*
- * Input modes.
- */
-
- fprintf(outfp, "c_iflag=");
-
- need_leading_pipe = 0;
-
- say_flag(IGNBRK, "IGNBRK", tio.c_iflag);
- say_flag(BRKINT, "BRKINT", tio.c_iflag);
- say_flag(IGNPAR, "IGNPAR", tio.c_iflag);
- say_flag(PARMRK, "PARMRK", tio.c_iflag);
- say_flag(INPCK, "INPCK", tio.c_iflag);
- say_flag(ISTRIP, "ISTRIP", tio.c_iflag);
- say_flag(INLCR, "INLCR", tio.c_iflag);
- say_flag(IGNCR, "IGNCR", tio.c_iflag);
- say_flag(ICRNL, "ICRNL", tio.c_iflag);
- say_flag(IUCLC, "IUCLC", tio.c_iflag);
- say_flag(IXON, "IXON", tio.c_iflag);
- say_flag(IXANY, "IXANY", tio.c_iflag);
- say_flag(IXOFF, "IXOFF", tio.c_iflag);
-
- say_residual(tio.c_iflag);
-
- /*
- * Output modes.
- */
-
- fprintf(outfp, ", c_oflag=");
-
- need_leading_pipe = 0;
-
- say_flag(OPOST, "OPOST", tio.c_oflag);
- say_flag(OLCUC, "OLCUC", tio.c_oflag);
- say_flag(ONLCR, "ONLCR", tio.c_oflag);
- say_flag(OCRNL, "OCRNL", tio.c_oflag);
- say_flag(ONOCR, "ONOCR", tio.c_oflag);
- say_flag(ONLRET, "ONLRET", tio.c_oflag);
- say_flag(OFILL, "OFILL", tio.c_oflag);
- say_flag(OFDEL, "OFDEL", tio.c_oflag);
-
- say_notflag(NLDLY, "NL0", tio.c_oflag);
- say_flag(NL1, "NL1", tio.c_oflag);
-
- say_notflag(CRDLY, "CR0", tio.c_oflag);
- say_flag(CR3, "CR3", tio.c_oflag);
- say_flag(CR2, "CR2", tio.c_oflag);
- say_flag(CR1, "CR1", tio.c_oflag);
-
- say_notflag(TABDLY, "TAB0", tio.c_oflag);
- say_flag(TAB3, "TAB3", tio.c_oflag);
- say_flag(TAB2, "TAB2", tio.c_oflag);
- say_flag(TAB1, "TAB1", tio.c_oflag);
-
- say_notflag(BSDLY, "BS0", tio.c_oflag);
- say_flag(BS1, "BS1", tio.c_oflag);
-
- say_notflag(VTDLY, "VT0", tio.c_oflag);
- say_flag(VT1, "VT1", tio.c_oflag);
-
- say_notflag(FFDLY, "FF0", tio.c_oflag);
- say_flag(FF1, "FF1", tio.c_oflag);
-
- say_residual(tio.c_oflag);
-
- /*
- * Hardware control modes.
- */
-
- fprintf(outfp, ", c_cflag=");
-
- switch (tio.c_cflag & CBAUD)
- {
- case B0:
- fprintf(outfp, "B0");
- break;
-
- case B50:
- fprintf(outfp, "B50");
- break;
-
- case B75:
- fprintf(outfp, "B75");
- break;
-
- case B110:
- fprintf(outfp, "B110");
- break;
-
- case B134:
- fprintf(outfp, "B134");
- break;
-
- case B150:
- fprintf(outfp, "B150");
- break;
-
- case B200:
- fprintf(outfp, "B200");
- break;
-
- case B300:
- fprintf(outfp, "B300");
- break;
-
- case B600:
- fprintf(outfp, "B600");
- break;
-
- case B1200:
- fprintf(outfp, "B1200");
- break;
-
- case B1800:
- fprintf(outfp, "B1800");
- break;
-
- case B2400:
- fprintf(outfp, "B2400");
- break;
-
- case B4800:
- fprintf(outfp, "B4800");
- break;
-
- case B9600:
- fprintf(outfp, "B9600");
- break;
-
- case B19200:
- fprintf(outfp, "B19200");
- break;
-
- case B38400:
- fprintf(outfp, "B38400");
- break;
- }
-
- tio.c_cflag &= ~CBAUD;
-
- need_leading_pipe = 1;
-
- say_notflag(CSIZE, "CS5", tio.c_cflag);
- say_flag(CS8, "CS8", tio.c_cflag);
- say_flag(CS7, "CS7", tio.c_cflag);
- say_flag(CS6, "CS6", tio.c_cflag);
-
- say_flag(CSTOPB, "CSTOPB", tio.c_cflag);
- say_flag(CREAD, "CREAD", tio.c_cflag);
- say_flag(PARENB, "PARENB", tio.c_cflag);
- say_flag(PARODD, "PARODD", tio.c_cflag);
- say_flag(HUPCL, "HUPCL", tio.c_cflag);
- say_flag(CLOCAL, "CLOCAL", tio.c_cflag);
- say_flag(CNEW_RTSCTS, "CNEW_RTSCTS", tio.c_cflag);
- say_flag(LOBLK, "LOBLK", tio.c_cflag);
- say_flag(CNEW_MDMBUF, "CNEW_MDMBUF", tio.c_cflag);
-
- say_residual(tio.c_cflag);
-
- /*
- * Local flags.
- */
-
- fprintf(outfp, ", c_lflag=");
-
- need_leading_pipe = 0;
-
- say_flag(ISIG, "ISIG", tio.c_lflag);
- say_flag(ICANON, "ICANON", tio.c_lflag);
- say_flag(XCASE, "XCASE", tio.c_lflag);
- say_flag(ECHO, "ECHO", tio.c_lflag);
- say_flag(ECHOE, "ECHOE", tio.c_lflag);
- say_flag(ECHOK, "ECHOK", tio.c_lflag);
- say_flag(ECHONL, "ECHONL", tio.c_lflag);
- say_flag(NOFLSH, "NOFLSH", tio.c_lflag);
- say_flag(TOSTOP, "TOSTOP", tio.c_lflag);
- say_flag(LNEW_CTLECH, "LNEW_CTLECH", tio.c_lflag);
- say_flag(LNEW_PRTERA, "LNEW_PRTERA", tio.c_lflag);
- say_flag(LNEW_CRTBS, "LNEW_CRTBS", tio.c_lflag);
- say_flag(LNEW_PENDIN, "LNEW_PENDIN", tio.c_lflag);
- say_flag(LNEW_FLUSHO, "LNEW_FLUSHO", tio.c_lflag);
-
- say_residual(tio.c_lflag);
-
- /*
- * Line discipline.
- */
-
- fprintf(outfp, ", c_line=%d", tio.c_line);
-
- /*
- * Control chars.
- */
-
- fprintf(outfp, ", c_cc=[");
- fprintf(outfp, "VINTR=0x%02x,", tio.c_cc[VINTR]);
- fprintf(outfp, "VQUIT=0x%02x,", tio.c_cc[VQUIT]);
- fprintf(outfp, "VERASE=0x%02x,", tio.c_cc[VERASE]);
- fprintf(outfp, "VKILL=0x%02x,", tio.c_cc[VKILL]);
- fprintf(outfp, "VEOF=0x%02x,", tio.c_cc[VEOF]);
- fprintf(outfp, "VEOL=0x%02x,", tio.c_cc[VEOL]);
- fprintf(outfp, "VEOL2=0x%02x,", tio.c_cc[VEOL2]);
- fprintf(outfp, "VSWTCH=0x%02x,", tio.c_cc[VSWTCH]);
- fprintf(outfp, "V_START=0x%02x,", tio.c_cc[V_START]);
- fprintf(outfp, "V_STOP=0x%02x,", tio.c_cc[V_STOP]);
- fprintf(outfp, "V_SUSP=0x%02x,", tio.c_cc[V_SUSP]);
- fprintf(outfp, "V_DSUSP=0x%02x,", tio.c_cc[V_DSUSP]);
- fprintf(outfp, "V_RPRNT=0x%02x,", tio.c_cc[V_RPRNT]);
- fprintf(outfp, "V_FLUSH=0x%02x,", tio.c_cc[V_FLUSH]);
- fprintf(outfp, "V_WERAS=0x%02x,", tio.c_cc[V_WERAS]);
- fprintf(outfp, "V_LNEXT=0x%02x,", tio.c_cc[V_LNEXT]);
- fprintf(outfp, "V_STATUS=0x%02x,", tio.c_cc[V_STATUS]);
- fprintf(outfp, "V_SAVED_EOF=0x%02x,", tio.c_cc[V_SAVED_EOF]);
- fprintf(outfp, "V_SAVED_EOL=0x%02x,", tio.c_cc[V_SAVED_EOL]);
- fprintf(outfp, "19=0x%02x,", tio.c_cc[19]);
- fprintf(outfp, "20=0x%02x,", tio.c_cc[20]);
- fprintf(outfp, "21=0x%02x,", tio.c_cc[21]);
- fprintf(outfp, "22=0x%02x,", tio.c_cc[22]);
- fprintf(outfp, "]");
-
- /*
- * (bsd43) saved flags.
- */
-
- fprintf(outfp, ", c_saved_flags=0x%x", tio.c_saved_flags);
-
- /*
- * Filler.
- */
-
- fprintf(outfp, ", c_filler=0x%x", tio.c_filler);
-
- fprintf(outfp, "}");
-
- return 0;
- }
-
- int
- sysv_print_ioctl_arg(args)
- unsigned long *args;
- {
- int i;
-
- switch (args[1])
- {
- case FIONREAD:
- if (quiet_procmget(GLOBALdipc, (unsigned long)args[2], &i, sizeof(i)) == -1)
- return -1;
-
- fprintf(outfp, "{*(int *)0x%x=%d}", args[2], i);
- break;
-
- case TCGETA:
- case TCSETA:
- case TCSETAW:
- case TCSETAF:
- if (say_termiob(args[2]) == -1)
- return -1;
-
- break;
-
- case LDSETT:
- if (say_termcb(args[2]) == -1)
- return -1;
-
- break;
-
- default:
- fprintf(outfp, "0x%x", args[2]);
- break;
- }
-
- return 0;
- }
-
- int
- sysv_print_fdset(nfds, arg)
- int nfds;
- unsigned long arg;
- {
- if (arg == (unsigned long)0)
- fprintf(outfp, "0x%x", arg);
- else
- {
- struct fd_set tfds;
- int fd;
-
- if (quiet_procmget(GLOBALdipc, arg, &tfds, sizeof(tfds)) == -1)
- return -1;
-
- fprintf(outfp, "{");
-
- for (fd = 0; fd < nfds; fd++)
- {
- if (FD_ISSET(fd, &tfds))
- fprintf(outfp, "%d,", fd);
- }
-
- fprintf(outfp, "}");
- }
-
- return 0;
- }
-
- int
- sysv_print_whence(arg)
- unsigned long arg;
- {
- switch (arg)
- {
- case SEEK_SET:
- fprintf(outfp, "SEEK_SET");
- break;
-
- case SEEK_CUR:
- fprintf(outfp, "SEEK_CUR");
- break;
-
- case SEEK_END:
- fprintf(outfp, "SEEK_END");
- break;
-
- default:
- fprintf(outfp, "0x%x", arg);
- break;
- }
-
- return 0;
- }
-
- int
- sysv_print_statfs(arg)
- unsigned long arg;
- {
- if (arg == (unsigned long)0)
- fprintf(outfp, "0x%x", arg);
- else
- {
- struct statfs t;
-
- if (quiet_procmget(GLOBALdipc, arg, &t, sizeof(t)) == -1)
- return -1;
-
- fprintf(outfp, "{");
- fprintf(outfp, "fstyp=%d,", t.f_fstyp);
- fprintf(outfp, "bsize=%d,", t.f_bsize);
- fprintf(outfp, "frsize=%d,", t.f_frsize);
- fprintf(outfp, "blocks=%d,", t.f_blocks);
- fprintf(outfp, "bfree=%d,", t.f_bfree);
- fprintf(outfp, "files=%d,", t.f_files);
- fprintf(outfp, "ffree=%d,", t.f_ffree);
- vis_quoted_truncated_buffer(outfp, sizeof(t.f_fname), &t.f_fname[0], sizeof(t.f_fname));
- fprintf(outfp, ",");
- vis_quoted_truncated_buffer(outfp, sizeof(t.f_fpack), &t.f_fpack[0], sizeof(t.f_fpack));
- fprintf(outfp, "}");
- }
- return 0;
- }
-
- int
- sysv_print_wait3_union_wait(arg)
- unsigned long arg;
- {
- union wait w;
- union wait *wp;
-
- if (mget(arg, &w, sizeof(w), &wp) == -1)
- return -1;
-
- if (wp == (union wait *)0)
- fprintf(outfp, "0x%x", arg);
- else
- {
- fprintf(outfp, "{" /* } */);
-
- if (w.w_status == WSTOPPED)
- {
- fprintf(outfp, "w_stopval=WSTOPPED,");
- fprintf(outfp, "w_stopsig=%s", signal_name(w.w_stopsig));
- }
- else
- {
- fprintf(outfp, "w_termsig=%s,", signal_name(w.w_termsig));
- fprintf(outfp, "w_coredump=%d,", w.w_coredump);
- fprintf(outfp, "w_retcode=%d", w.w_retcode);
- }
-
- fprintf(outfp, /* { */ "}");
- }
-
- return 0;
- }
-
- int
- sysv_print_wait3_options(arg)
- unsigned long arg;
- {
- if (arg == (unsigned long)0)
- fprintf(outfp, "0x%x", arg);
- else
- {
- need_leading_pipe = 0;
-
- say_flag(WNOHANG, "WNOHANG", arg);
- say_flag(WUNTRACED, "WUNTRACED", arg);
-
- say_residual(arg);
- }
-
- return 0;
- }
-
- int
- sysv_print_wait3_rusage(arg)
- unsigned long arg;
- {
- fprintf(outfp, "0x%x", arg);
-
- return 0;
- }
-
- int
- sysv_print_sigcontext(outfp, p)
- FILE *outfp;
- unsigned long p;
- {
- struct sigcontext sc;
- struct sigcontext *scp;
- int i;
-
- fprintf(outfp, "{" /* } */);
-
- if (mget(p, &sc, sizeof(sc), &scp) == -1)
- return -1;
-
- if (Aflag)
- {
- if (scp != (struct sigcontext *)0)
- {
- fprintf(outfp, "regmask=0x%x,", scp->sc_regmask);
- fprintf(outfp, "mask=0x%x,", scp->sc_mask);
- fprintf(outfp, "pc=%s,", proc_text_address(scp->sc_pc));
-
- for (i = 0; i < nels(scp->sc_regs); i++)
- fprintf(outfp, "regs[%d]=0x%x,", i, scp->sc_regs[i]);
-
- fprintf(outfp, "ownedfp=0x%x,", scp->sc_ownedfp);
-
- for (i = 0; i < nels(scp->sc_fpregs); i++)
- fprintf(outfp, "fpregs[%d]=0x%x,", i, scp->sc_fpregs[i]);
-
- fprintf(outfp, "fpc_csr=0x%x,", scp->sc_fpc_csr);
- fprintf(outfp, "fpc_eir=0x%x,", scp->sc_fpc_eir);
- fprintf(outfp, "mdhi=%d,", scp->sc_mdhi);
- fprintf(outfp, "mdlo=%d,", scp->sc_mdlo);
- fprintf(outfp, "cause=0x%x,", scp->sc_cause);
- fprintf(outfp, "badvaddr=0x%x,", scp->sc_badvaddr);
- fprintf(outfp, "badpaddr=0x%x,", scp->sc_badpaddr);
- fprintf(outfp, "sigset=%s,", signal_name(scp->is_sigset));
- }
- }
- else
- fprintf(outfp, "...");
-
- fprintf(outfp, /* { */ "}");
-
- return 0;
- }
-
- static
- int
- sysv_print_received_signal(universe, universe_name, tramp, handler, sig, code, scp)
- int universe;
- char *universe_name;
- unsigned long tramp;
- unsigned long handler;
- int sig;
- int code;
- struct sigcontext *scp;
- {
- fprintf(outfp, "%6d:", P.p_pid);
-
- fprintf(outfp, "%s_SIGNAL(", universe_name);
-
- if (printval(universe, tramp, 'I', (unsigned long *)0, (unsigned long)0, (unsigned long)0, DIRN_ENTRY) == -1)
- return -1;
-
- fprintf(outfp, ", ");
-
- if (printval(universe, handler, 'I', (unsigned long *)0, (unsigned long)0, (unsigned long)0, DIRN_ENTRY) == -1)
- return -1;
-
- fprintf(outfp, ", ");
-
- if (printval(universe, sig, 'K', (unsigned long *)0, (unsigned long)0, (unsigned long)0, DIRN_ENTRY) == -1)
- return -1;
-
- fprintf(outfp, ", ");
-
- if (printval(universe, code, 'd', (unsigned long *)0, (unsigned long)0, (unsigned long)0, DIRN_ENTRY) == -1)
- return -1;
-
- fprintf(outfp, ", ");
-
- if (printval(universe, scp, 'y', (unsigned long *)0, (unsigned long)0, (unsigned long)0, DIRN_ENTRY) == -1)
- return -1;
-
- fprintf(outfp, ")");
-
- fprintf(outfp, "\n");
-
- return 0;
- }
-