diff options
-rw-r--r-- | bjm.c | 2 | ||||
-rw-r--r-- | block.c | 2 | ||||
-rw-r--r-- | count.c | 2 | ||||
-rw-r--r-- | defs.h | 132 | ||||
-rw-r--r-- | desc.c | 10 | ||||
-rw-r--r-- | file.c | 271 | ||||
-rw-r--r-- | io.c | 120 | ||||
-rw-r--r-- | ioctl.c | 27 | ||||
-rw-r--r-- | ipc.c | 20 | ||||
-rw-r--r-- | mem.c | 22 | ||||
-rw-r--r-- | net.c | 175 | ||||
-rw-r--r-- | pathtrace.c | 8 | ||||
-rw-r--r-- | proc.c | 224 | ||||
-rw-r--r-- | process.c | 575 | ||||
-rw-r--r-- | quota.c | 48 | ||||
-rw-r--r-- | resource.c | 12 | ||||
-rw-r--r-- | scsi.c | 2 | ||||
-rw-r--r-- | signal.c | 290 | ||||
-rw-r--r-- | sock.c | 7 | ||||
-rw-r--r-- | strace.c | 919 | ||||
-rw-r--r-- | stream.c | 914 | ||||
-rw-r--r-- | svr4/dummy.h | 7 | ||||
-rw-r--r-- | svr4/syscall.h | 28 | ||||
-rw-r--r-- | svr4/syscallent.h | 158 | ||||
-rw-r--r-- | syscall.c | 465 | ||||
-rw-r--r-- | system.c | 1358 | ||||
-rw-r--r-- | term.c | 27 | ||||
-rw-r--r-- | time.c | 14 | ||||
-rw-r--r-- | util.c | 395 |
29 files changed, 6 insertions, 6228 deletions
@@ -31,7 +31,6 @@ */ #include "defs.h" -#if defined(LINUX) #include <fcntl.h> #include <sys/stat.h> @@ -208,4 +207,3 @@ sys_init_module(struct tcb *tcp) } return 0; } -#endif /* LINUX */ @@ -26,7 +26,6 @@ */ #include "defs.h" -#ifdef LINUX #include <stdint.h> #include <inttypes.h> #include <linux/blkpg.h> @@ -282,4 +281,3 @@ block_ioctl(struct tcb *tcp, long code, long arg) }; return 1; } -#endif /* LINUX */ @@ -64,7 +64,6 @@ count_syscall(struct tcb *tcp, struct timeval *tv) counts[tcp->scno].errors++; tv_sub(tv, tv, &tcp->etime); -#ifdef LINUX if (tv_cmp(tv, &tcp->dtime) > 0) { static struct timeval one_tick; @@ -88,7 +87,6 @@ count_syscall(struct tcb *tcp, struct timeval *tv) *tv = one_tick; } } -#endif /* LINUX */ if (tv_cmp(tv, &shortest) < 0) shortest = *tv; tv_add(&counts[tcp->scno].time, &counts[tcp->scno].time, tv); @@ -37,9 +37,7 @@ #include <sgidefs.h> #endif -#ifdef linux #include <features.h> -#endif #ifdef _LARGEFILE64_SOURCE /* This is the macro everything checks before using foo64 names. */ @@ -76,20 +74,7 @@ * svr4/syscallent.h: all are MA (MAX_ARGS), it's unclear what the real max is. */ #ifndef MAX_ARGS -# if defined LINUX -# define MAX_ARGS 6 -# elif defined HPPA -# define MAX_ARGS 6 -# elif defined X86_64 || defined I386 -# ifdef FREEBSD -# define MAX_ARGS 8 -# else # define MAX_ARGS 6 -# endif -# else -/* Way too big. Switch your arch to saner size after you tested that it works */ -# define MAX_ARGS 32 -# endif #endif #ifndef DEFAULT_SORTBY @@ -118,7 +103,6 @@ #include <signal.h> #endif -#if defined(LINUX) # if defined(SPARC) || defined(SPARC64) # define LINUXSPARC # endif @@ -142,32 +126,10 @@ # if defined(AVR32) # define LINUX_AVR32 # endif -#endif -#if defined(SVR4) || defined(FREEBSD) -#define USE_PROCFS -#else #undef USE_PROCFS -#endif -#ifdef FREEBSD -#ifndef I386 -#error "FreeBSD support is only for i386 arch right now." -#endif -#include <machine/psl.h> -#include <machine/reg.h> -#include <sys/syscall.h> -#endif -#ifdef USE_PROCFS -# include <sys/procfs.h> -# ifdef HAVE_MP_PROCFS -# include <sys/uio.h> -# endif -# ifdef FREEBSD -# include <sys/pioctl.h> -# endif -#else /* !USE_PROCFS */ # if (defined(LINUXSPARC) || defined(LINUX_X86_64) || defined(LINUX_ARM) || defined(LINUX_AVR32)) && defined(__GLIBC__) # include <sys/ptrace.h> # else @@ -180,15 +142,9 @@ # include <asm/ptrace.h> # undef __KERNEL__ # endif -# ifdef LINUX extern long ptrace(int, int, char *, long); -# else -extern int ptrace(int, int, char *, int, ...); -# endif # endif -#endif /* !USE_PROCFS */ -#ifdef LINUX #if !defined(__GLIBC__) #define PTRACE_PEEKUSER PTRACE_PEEKUSR #define PTRACE_POKEUSER PTRACE_POKEUSR @@ -236,7 +192,6 @@ extern int ptrace(int, int, char *, int, ...); # define REG_PC (0*8) # define REG_SYSCALL (2*8) #endif /* SH64 */ -#endif /* LINUX */ #define SUPPORTED_PERSONALITIES 1 #define DEFAULT_PERSONALITY 0 @@ -281,61 +236,7 @@ extern int ptrace(int, int, char *, int, ...); #define PERSONALITY1_WORDSIZE 4 #endif -#ifdef SVR4 -#ifdef HAVE_MP_PROCFS -extern int mp_ioctl(int f, int c, void *a, int s); -#define IOCTL(f,c,a) mp_ioctl(f, c, a, sizeof *a) -#define IOCTL_STATUS(t) \ - pread(t->pfd_stat, &t->status, sizeof t->status, 0) -#define IOCTL_WSTOP(t) \ - (IOCTL(t->pfd, PCWSTOP, (char *)NULL) < 0 ? -1 : IOCTL_STATUS(t)) -#define PR_WHY pr_lwp.pr_why -#define PR_WHAT pr_lwp.pr_what -#define PR_REG pr_lwp.pr_context.uc_mcontext.gregs -#define PR_FLAGS pr_lwp.pr_flags -#define PR_SYSCALL pr_lwp.pr_syscall -#define PR_INFO pr_lwp.pr_info -#define PIOCSTIP PCSTOP -#define PIOCSET PCSET -#define PIOCRESET PCRESET -#define PIOCSTRACE PCSTRACE -#define PIOCSFAULT PCSFAULT -#define PIOCWSTOP PCWSTOP -#define PIOCSTOP PCSTOP -#define PIOCSENTRY PCSENTRY -#define PIOCSEXIT PCSEXIT -#define PIOCRUN PCRUN -#else -#define IOCTL ioctl -#define IOCTL_STATUS(t) ioctl(t->pfd, PIOCSTATUS, &t->status) -#define IOCTL_WSTOP(t) ioctl(t->pfd, PIOCWSTOP, &t->status) -#define PR_WHY pr_why -#define PR_WHAT pr_what -#define PR_REG pr_reg -#define PR_FLAGS pr_flags -#define PR_SYSCALL pr_syscall -#define PR_INFO pr_info -#endif -#endif -#ifdef FREEBSD -#define IOCTL ioctl -#define IOCTL_STATUS(t) ioctl(t->pfd, PIOCSTATUS, &t->status) -#define IOCTL_WSTOP(t) ioctl(t->pfd, PIOCWAIT, &t->status) -#define PIOCRUN PIOCCONT -#define PIOCWSTOP PIOCWAIT -#define PR_WHY why -#define PR_WHAT val -#define PR_FLAGS state -/* from /usr/src/sys/miscfs/procfs/procfs_vnops.c, - status.state = 0 for running, 1 for stopped */ -#define PR_ASLEEP 1 -#define PR_SYSENTRY S_SCE -#define PR_SYSEXIT S_SCX -#define PR_SIGNALLED S_SIG -#define PR_FAULTED S_CORE -#endif -#ifdef LINUX # if !HAVE_DECL_PTRACE_SETOPTIONS # define PTRACE_SETOPTIONS 0x4200 # endif @@ -401,7 +302,6 @@ extern int mp_ioctl(int f, int c, void *a, int s); # define PTRACE_EVENT_STOP1 128 # endif -#endif /* LINUX */ #if !defined __GNUC__ # define __attribute__(x) /*nothing*/ @@ -409,11 +309,9 @@ extern int mp_ioctl(int f, int c, void *a, int s); #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) -#ifdef LINUX # if defined(I386) extern struct pt_regs i386_regs; # endif -#endif /* LINUX */ /* Trace Control Block */ struct tcb { @@ -443,23 +341,6 @@ struct tcb { /* Support for tracing forked processes */ long baddr; /* `Breakpoint' address */ long inst[2]; /* Instructions on above */ -#ifdef USE_PROCFS - int pfd; /* proc file descriptor */ -#endif -#ifdef SVR4 -# ifdef HAVE_MP_PROCFS - int pfd_stat; - int pfd_as; - pstatus_t status; -# else - prstatus_t status; /* procfs status structure */ -# endif -#endif -#ifdef FREEBSD - struct procfs_status status; - int pfd_reg; - int pfd_status; -#endif }; /* TCB flags */ @@ -495,7 +376,6 @@ struct tcb { #define TCB_BPTSET 00100 /* "Breakpoint" set after fork(2) */ #define TCB_REPRINT 01000 /* We should reprint this syscall on exit */ #define TCB_FILTERED 02000 /* This system call has been filtered out */ -#ifdef LINUX /* x86 does not need TCB_WAITEXECVE. * It can detect SIGTRAP by looking at eax/rax. * See "not a syscall entry (eax = %ld)\n" message @@ -511,7 +391,6 @@ struct tcb { # define TCB_WAITEXECVE 04000 # endif # include <sys/syscall.h> -#endif /* LINUX */ /* qualifier flags */ #define QUAL_TRACE 0001 /* this system call should be traced */ @@ -607,9 +486,6 @@ extern void droptcb(struct tcb *); extern void set_sortby(const char *); extern void set_overhead(int); extern void qualify(const char *); -#ifdef USE_PROCFS -extern int get_scno(struct tcb *); -#endif extern long do_ptrace(int request, struct tcb *tcp, void *addr, void *data); extern int ptrace_restart(int request, struct tcb *tcp, int sig); extern int trace_syscall(struct tcb *); @@ -681,11 +557,9 @@ extern int term_ioctl(struct tcb *, long, long); extern int sock_ioctl(struct tcb *, long, long); extern int proc_ioctl(struct tcb *, int, int); extern int stream_ioctl(struct tcb *, int, int); -#ifdef LINUX extern int rtc_ioctl(struct tcb *, long, long); extern int scsi_ioctl(struct tcb *, long, long); extern int block_ioctl(struct tcb *, long, long); -#endif extern int tv_nz(struct timeval *); extern int tv_cmp(struct timeval *, struct timeval *); @@ -704,16 +578,10 @@ extern void tv_div(struct timeval *, struct timeval *, int); extern char *stpcpy(char *dst, const char *src); #endif -#ifdef SUNOS4 -extern int fixvfork(struct tcb *); -#endif #if !(defined(LINUX) && !defined(SPARC) && !defined(SPARC64) && !defined(IA64) \ && !defined(SH)) extern long getrval2(struct tcb *); #endif -#ifdef USE_PROCFS -extern int proc_open(struct tcb *tcp, int attaching); -#endif #define umove(pid, addr, objp) \ umoven((pid), (addr), sizeof *(objp), (char *) (objp)) @@ -34,9 +34,7 @@ #include <fcntl.h> #include <sys/file.h> -#ifdef LINUX #include <inttypes.h> -#endif #ifdef HAVE_SYS_EPOLL_H #include <sys/epoll.h> #endif @@ -461,13 +459,11 @@ sys_dup2(struct tcb *tcp) return do_dup2(tcp, -1); } -#ifdef LINUX int sys_dup3(struct tcb *tcp) { return do_dup2(tcp, 2); } -#endif #if defined(ALPHA) || defined(FREEBSD) || defined(SUNOS4) int @@ -581,7 +577,6 @@ decode_select(struct tcb *tcp, long *args, enum bitness_t bitness) break; } free(fds); -#ifdef LINUX /* This contains no useful information on SunOS. */ if (args[4]) { if (outptr < end_outstr - (10 + TIMEVAL_TEXT_BUFSIZE)) { @@ -589,7 +584,6 @@ decode_select(struct tcb *tcp, long *args, enum bitness_t bitness) outptr = sprinttv(outptr, tcp, args[4], bitness, /*special:*/ 0); } } -#endif /* LINUX */ *outptr = '\0'; tcp->auxstr = outstr; return RVAL_STR; @@ -598,7 +592,6 @@ decode_select(struct tcb *tcp, long *args, enum bitness_t bitness) return 0; } -#ifdef LINUX int sys_oldselect(struct tcb *tcp) @@ -1028,7 +1021,6 @@ sys_io_getevents(struct tcb *tcp) } return 0; } -#endif /* LINUX */ int sys_select(struct tcb *tcp) @@ -1036,7 +1028,6 @@ sys_select(struct tcb *tcp) return decode_select(tcp, tcp->u_arg, BITNESS_CURRENT); } -#ifdef LINUX int sys_pselect6(struct tcb *tcp) { @@ -1084,4 +1075,3 @@ sys_eventfd2(struct tcb *tcp) { return do_eventfd(tcp, 1); } -#endif @@ -34,18 +34,13 @@ #include <dirent.h> -#ifdef LINUX struct kernel_dirent { unsigned long d_ino; unsigned long d_off; unsigned short d_reclen; char d_name[1]; }; -#else -# define kernel_dirent dirent -#endif -#ifdef LINUX # ifdef LINUXSPARC struct stat { unsigned short st_dev; @@ -141,15 +136,9 @@ struct stat_sparc64 { # ifdef HPPA # define stat64 hpux_stat64 # endif -#else -# include <sys/stat.h> -#endif #include <fcntl.h> -#ifdef SVR4 -# include <sys/cred.h> -#endif /* SVR4 */ #ifdef HAVE_SYS_VFS_H #include <sys/vfs.h> @@ -157,16 +146,11 @@ struct stat_sparc64 { #ifdef HAVE_LINUX_XATTR_H #include <linux/xattr.h> -#elif defined linux +#else #define XATTR_CREATE 1 #define XATTR_REPLACE 2 #endif -#ifdef FREEBSD -#include <sys/param.h> -#include <sys/mount.h> -#include <sys/stat.h> -#endif #if _LFS64_LARGEFILE && (defined(LINUX) || defined(SVR4)) # ifdef HAVE_INTTYPES_H @@ -205,9 +189,6 @@ struct stat_sparc64 { #include <sys/asynch.h> #endif -#ifdef SUNOS4 -#include <ustat.h> -#endif const struct xlat open_access_modes[] = { { O_RDONLY, "O_RDONLY" }, @@ -320,7 +301,6 @@ const struct xlat open_mode_flags[] = { { 0, NULL }, }; -#ifdef LINUX #ifndef AT_FDCWD # define AT_FDCWD -100 @@ -339,7 +319,6 @@ print_dirfd(struct tcb *tcp, int fd) tprints(", "); } } -#endif /* * low bits of the open(2) flags define access mode, @@ -410,7 +389,6 @@ sys_open(struct tcb *tcp) return decode_open(tcp, 0); } -#ifdef LINUX int sys_openat(struct tcb *tcp) { @@ -418,7 +396,6 @@ sys_openat(struct tcb *tcp) print_dirfd(tcp, tcp->u_arg[0]); return decode_open(tcp, 1); } -#endif #ifdef LINUXSPARC static const struct xlat openmodessol[] = { @@ -498,7 +475,6 @@ sys_access(struct tcb *tcp) return decode_access(tcp, 0); } -#ifdef LINUX int sys_faccessat(struct tcb *tcp) { @@ -506,7 +482,6 @@ sys_faccessat(struct tcb *tcp) print_dirfd(tcp, tcp->u_arg[0]); return decode_access(tcp, 1); } -#endif int sys_umask(struct tcb *tcp) @@ -568,7 +543,6 @@ sys_lseek(struct tcb *tcp) #endif /* LINUX_MIPSN32 */ #endif -#ifdef LINUX int sys_llseek(struct tcb *tcp) { @@ -611,7 +585,6 @@ sys_readahead(struct tcb *tcp) } return 0; } -#endif #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T int @@ -923,49 +896,9 @@ printstat_powerpc32(struct tcb *tcp, long addr) #endif /* LINUX && POWERPC64 */ static const struct xlat fileflags[] = { -#ifdef FREEBSD - { UF_NODUMP, "UF_NODUMP" }, - { UF_IMMUTABLE, "UF_IMMUTABLE" }, - { UF_APPEND, "UF_APPEND" }, - { UF_OPAQUE, "UF_OPAQUE" }, - { UF_NOUNLINK, "UF_NOUNLINK" }, - { SF_ARCHIVED, "SF_ARCHIVED" }, - { SF_IMMUTABLE, "SF_IMMUTABLE" }, - { SF_APPEND, "SF_APPEND" }, - { SF_NOUNLINK, "SF_NOUNLINK" }, -#elif UNIXWARE >= 2 -#ifdef _S_ISMLD - { _S_ISMLD, "_S_ISMLD" }, -#endif -#ifdef _S_ISMOUNTED - { _S_ISMOUNTED, "_S_ISMOUNTED" }, -#endif -#endif { 0, NULL }, }; -#ifdef FREEBSD -int -sys_chflags(struct tcb *tcp) -{ - if (entering(tcp)) { - printpath(tcp, tcp->u_arg[0]); - tprints(", "); - printflags(fileflags, tcp->u_arg[1], "UF_???"); - } - return 0; -} - -int -sys_fchflags(struct tcb *tcp) -{ - if (entering(tcp)) { - tprintf("%ld, ", tcp->u_arg[0]); - printflags(fileflags, tcp->u_arg[1], "UF_???"); - } - return 0; -} -#endif #ifndef HAVE_LONG_LONG_OFF_T static void @@ -1312,7 +1245,6 @@ sys_stat64(struct tcb *tcp) #endif } -#ifdef LINUX static const struct xlat fstatatflags[] = { #ifndef AT_SYMLINK_NOFOLLOW # define AT_SYMLINK_NOFOLLOW 0x100 @@ -1345,7 +1277,6 @@ sys_newfstatat(struct tcb *tcp) } return 0; } -#endif #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT) \ && !defined(HAVE_LONG_LONG_OFF_T) @@ -1640,7 +1571,6 @@ sys_aclipc(struct tcb *tcp) #endif /* SVR4 || LINUXSPARC */ -#ifdef LINUX static const struct xlat fsmagic[] = { { 0x73757245, "CODA_SUPER_MAGIC" }, @@ -1675,15 +1605,12 @@ static const struct xlat fsmagic[] = { { 0, NULL }, }; -#endif /* LINUX */ -#ifndef SVR4 static const char * sprintfstype(int magic) { static char buf[32]; -#ifdef LINUX const char *s; s = xlookup(fsmagic, magic); @@ -1691,7 +1618,6 @@ sprintfstype(int magic) sprintf(buf, "\"%s\"", s); return buf; } -#endif /* LINUX */ sprintf(buf, "%#x", magic); return buf; } @@ -1729,9 +1655,7 @@ printstatfs(struct tcb *tcp, long addr) (unsigned long)statbuf.f_files, (unsigned long)statbuf.f_ffree, statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]); -#ifdef LINUX tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen); -#endif /* LINUX */ #endif /* !ALPHA */ #ifdef _STATFS_F_FRSIZE tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize); @@ -1908,38 +1832,7 @@ osf_fstatfs(struct tcb *tcp) } #endif /* LINUX && __alpha */ -#endif /* !SVR4 */ - -#ifdef SUNOS4 -int -sys_ustat(struct tcb *tcp) -{ - struct ustat statbuf; - if (entering(tcp)) { - tprintf("makedev(%lu, %lu), ", - (long) major(tcp->u_arg[0]), - (long) minor(tcp->u_arg[0])); - } - else { - if (syserror(tcp) || !verbose(tcp)) - tprintf("%#lx", tcp->u_arg[1]); - else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0) - tprints("{...}"); - else { - tprintf("{f_tfree=%lu, f_tinode=%lu, ", - statbuf.f_tfree, statbuf.f_tinode); - tprintf("f_fname=\"%.*s\", ", - (int) sizeof(statbuf.f_fname), - statbuf.f_fname); - tprintf("f_fpack=\"%.*s\"}", - (int) sizeof(statbuf.f_fpack), - statbuf.f_fpack); - } - } - return 0; -} -#endif /* SUNOS4 */ /* directory */ int @@ -1967,7 +1860,6 @@ sys_mkdir(struct tcb *tcp) return decode_mkdir(tcp, 0); } -#ifdef LINUX int sys_mkdirat(struct tcb *tcp) { @@ -1975,7 +1867,6 @@ sys_mkdirat(struct tcb *tcp) print_dirfd(tcp, tcp->u_arg[0]); return decode_mkdir(tcp, 1); } -#endif int sys_link(struct tcb *tcp) @@ -1988,7 +1879,6 @@ sys_link(struct tcb *tcp) return 0; } -#ifdef LINUX int sys_linkat(struct tcb *tcp) { @@ -2003,9 +1893,7 @@ sys_linkat(struct tcb *tcp) } return 0; } -#endif -#ifdef LINUX static const struct xlat unlinkatflags[] = { #ifndef AT_REMOVEDIR # define AT_REMOVEDIR 0x200 @@ -2025,9 +1913,7 @@ sys_unlinkat(struct tcb *tcp) } return 0; } -#endif -#ifdef LINUX int sys_symlinkat(struct tcb *tcp) { @@ -2039,7 +1925,6 @@ sys_symlinkat(struct tcb *tcp) } return 0; } -#endif static int decode_readlink(struct tcb *tcp, int offset) @@ -2070,7 +1955,6 @@ sys_readlink(struct tcb *tcp) return decode_readlink(tcp, 0); } -#ifdef LINUX int sys_readlinkat(struct tcb *tcp) { @@ -2078,9 +1962,7 @@ sys_readlinkat(struct tcb *tcp) print_dirfd(tcp, tcp->u_arg[0]); return decode_readlink(tcp, 1); } -#endif -#ifdef LINUX int sys_renameat(struct tcb *tcp) { @@ -2093,7 +1975,6 @@ sys_renameat(struct tcb *tcp) } return 0; } -#endif int sys_chown(struct tcb *tcp) @@ -2106,7 +1987,6 @@ sys_chown(struct tcb *tcp) return 0; } -#ifdef LINUX int sys_fchownat(struct tcb *tcp) { @@ -2120,7 +2000,6 @@ sys_fchownat(struct tcb *tcp) } return 0; } -#endif int sys_fchown(struct tcb *tcp) @@ -2149,7 +2028,6 @@ sys_chmod(struct tcb *tcp) return decode_chmod(tcp, 0); } -#ifdef LINUX int sys_fchmodat(struct tcb *tcp) { @@ -2157,7 +2035,6 @@ sys_fchmodat(struct tcb *tcp) print_dirfd(tcp, tcp->u_arg[0]); return decode_chmod(tcp, 1); } -#endif int sys_fchmod(struct tcb *tcp) @@ -2210,7 +2087,6 @@ sys_utimes(struct tcb *tcp) return decode_utimes(tcp, 0, 0); } -#ifdef LINUX int sys_futimesat(struct tcb *tcp) { @@ -2230,7 +2106,6 @@ sys_utimensat(struct tcb *tcp) } return 0; } -#endif int sys_utime(struct tcb *tcp) @@ -2301,7 +2176,6 @@ sys_mknod(struct tcb *tcp) return decode_mknod(tcp, 0); } -#ifdef LINUX int sys_mknodat(struct tcb *tcp) { @@ -2309,19 +2183,7 @@ sys_mknodat(struct tcb *tcp) print_dirfd(tcp, tcp->u_arg[0]); return decode_mknod(tcp, 1); } -#endif -#ifdef FREEBSD -int -sys_mkfifo(struct tcb *tcp) -{ - if (entering(tcp)) { - printpath(tcp, tcp->u_arg[0]); - tprintf(", %#lo", tcp->u_arg[1]); - } - return 0; -} -#endif /* FREEBSD */ int sys_fsync(struct tcb *tcp) @@ -2332,7 +2194,6 @@ sys_fsync(struct tcb *tcp) return 0; } -#ifdef LINUX static void printdir(struct tcb *tcp, long addr) @@ -2371,9 +2232,7 @@ sys_readdir(struct tcb *tcp) return 0; } -#endif /* LINUX */ -#if defined FREEBSD || defined LINUX static const struct xlat direnttypes[] = { { DT_UNKNOWN, "DT_UNKNOWN" }, { DT_FIFO, "DT_FIFO" }, @@ -2387,7 +2246,6 @@ static const struct xlat direnttypes[] = { { 0, NULL }, }; -#endif int sys_getdents(struct tcb *tcp) @@ -2422,42 +2280,12 @@ sys_getdents(struct tcb *tcp) tprints("{"); for (i = 0; i < len;) { struct kernel_dirent *d = (struct kernel_dirent *) &buf[i]; -#ifdef LINUX if (!abbrev(tcp)) { tprintf("%s{d_ino=%lu, d_off=%lu, ", i ? " " : "", d->d_ino, d->d_off); tprintf("d_reclen=%u, d_name=\"%s\"}", d->d_reclen, d->d_name); } -#endif /* LINUX */ -#ifdef SVR4 - if (!abbrev(tcp)) { - tprintf("%s{d_ino=%lu, d_off=%lu, ", - i ? " " : "", - (unsigned long) d->d_ino, - (unsigned long) d->d_off); - tprintf("d_reclen=%u, d_name=\"%s\"}", - d->d_reclen, d->d_name); - } -#endif /* SVR4 */ -#ifdef SUNOS4 - if (!abbrev(tcp)) { - tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ", - i ? " " : "", d->d_off, d->d_fileno, - d->d_reclen); - tprintf("d_namlen=%u, d_name=\"%.*s\"}", - d->d_namlen, d->d_namlen, d->d_name); - } -#endif /* SUNOS4 */ -#ifdef FREEBSD - if (!abbrev(tcp)) { - tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=", - i ? " " : "", d->d_fileno, d->d_reclen); - printxval(direnttypes, d->d_type, "DT_???"); - tprintf(", d_namlen=%u, d_name=\"%.*s\"}", - d->d_namlen, d->d_namlen, d->d_name); - } -#endif /* FREEBSD */ if (!d->d_reclen) { tprints("/* d_reclen == 0, problem here */"); break; @@ -2511,30 +2339,17 @@ sys_getdents64(struct tcb *tcp) tprints("{"); for (i = 0; i < len;) { struct dirent64 *d = (struct dirent64 *) &buf[i]; -#if defined(LINUX) || defined(SVR4) if (!abbrev(tcp)) { tprintf("%s{d_ino=%" PRIu64 ", d_off=%" PRId64 ", ", i ? " " : "", d->d_ino, d->d_off); -#ifdef LINUX tprints("d_type="); printxval(direnttypes, d->d_type, "DT_???"); tprints(", "); -#endif tprintf("d_reclen=%u, d_name=\"%s\"}", d->d_reclen, d->d_name); } -#endif /* LINUX || SVR4 */ -#ifdef SUNOS4 - if (!abbrev(tcp)) { - tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ", - i ? " " : "", d->d_off, d->d_fileno, - d->d_reclen); - tprintf("d_namlen=%u, d_name=\"%.*s\"}", - d->d_namlen, d->d_namlen, d->d_name); - } -#endif /* SUNOS4 */ if (!d->d_reclen) { tprints("/* d_reclen == 0, problem here */"); break; @@ -2552,72 +2367,7 @@ sys_getdents64(struct tcb *tcp) } #endif -#ifdef FREEBSD -int -sys_getdirentries(struct tcb *tcp) -{ - int i, len, dents = 0; - long basep; - char *buf; - - if (entering(tcp)) { - printfd(tcp, tcp->u_arg[0]); - tprints(", "); - return 0; - } - if (syserror(tcp) || !verbose(tcp)) { - tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]); - return 0; - } - - len = tcp->u_rval; - /* Beware of insanely large or negative tcp->u_rval */ - if (tcp->u_rval > 1024*1024) - len = 1024*1024; - if (tcp->u_rval < 0) - len = 0; - buf = malloc(len); - if (!buf) - die_out_of_memory(); - - if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) { - tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]); - free(buf); - return 0; - } - if (!abbrev(tcp)) - tprints("{"); - for (i = 0; i < len;) { - struct kernel_dirent *d = (struct kernel_dirent *) &buf[i]; - if (!abbrev(tcp)) { - tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=", - i ? " " : "", d->d_fileno, d->d_reclen); - printxval(direnttypes, d->d_type, "DT_???"); - tprintf(", d_namlen=%u, d_name=\"%.*s\"}", - d->d_namlen, d->d_namlen, d->d_name); - } - if (!d->d_reclen) { - tprints("/* d_reclen == 0, problem here */"); - break; - } - i += d->d_reclen; - dents++; - } - if (!abbrev(tcp)) - tprints("}"); - else - tprintf("/* %u entries */", dents); - free(buf); - tprintf(", %lu", tcp->u_arg[2]); - if (umove(tcp, tcp->u_arg[3], &basep) < 0) - tprintf(", %#lx", tcp->u_arg[3]); - else - tprintf(", [%lu]", basep); - return 0; -} -#endif -#ifdef LINUX int sys_getcwd(struct tcb *tcp) { @@ -2630,22 +2380,7 @@ sys_getcwd(struct tcb *tcp) } return 0; } -#endif /* LINUX */ -#ifdef FREEBSD -int -sys___getcwd(struct tcb *tcp) -{ - if (exiting(tcp)) { - if (syserror(tcp)) - tprintf("%#lx", tcp->u_arg[0]); - else - printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]); - tprintf(", %lu", tcp->u_arg[1]); - } - return 0; -} -#endif #ifdef HAVE_SYS_ASYNCH_H @@ -2887,7 +2622,6 @@ static const struct xlat advise[] = { }; -#ifdef LINUX int sys_fadvise64(struct tcb *tcp) { @@ -2901,7 +2635,6 @@ sys_fadvise64(struct tcb *tcp) } return 0; } -#endif int @@ -2926,7 +2659,6 @@ sys_fadvise64_64(struct tcb *tcp) return 0; } -#ifdef LINUX static const struct xlat inotify_modes[] = { { 0x00000001, "IN_ACCESS" }, { 0x00000002, "IN_MODIFY" }, @@ -3001,4 +2733,3 @@ sys_fallocate(struct tcb *tcp) } return 0; } -#endif @@ -168,127 +168,8 @@ sys_writev(struct tcb *tcp) } #endif -#if defined(SVR4) -int -sys_pread(struct tcb *tcp) -{ - if (entering(tcp)) { - printfd(tcp, tcp->u_arg[0]); - tprints(", "); - } else { - if (syserror(tcp)) - tprintf("%#lx", tcp->u_arg[1]); - else - printstr(tcp, tcp->u_arg[1], tcp->u_rval); -#if UNIXWARE - /* off_t is signed int */ - tprintf(", %lu, %ld", tcp->u_arg[2], tcp->u_arg[3]); -#else - tprintf(", %lu, %llu", tcp->u_arg[2], - LONG_LONG(tcp->u_arg[3], tcp->u_arg[4])); -#endif - } - return 0; -} - -int -sys_pwrite(struct tcb *tcp) -{ - if (entering(tcp)) { - printfd(tcp, tcp->u_arg[0]); - tprints(", "); - printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); -#if UNIXWARE - /* off_t is signed int */ - tprintf(", %lu, %ld", tcp->u_arg[2], tcp->u_arg[3]); -#else - tprintf(", %lu, %llu", tcp->u_arg[2], - LONG_LONG(tcp->u_arg[3], tcp->u_arg[4])); -#endif - } - return 0; -} - -#if _LFS64_LARGEFILE -int -sys_pread64(struct tcb *tcp) -{ - if (entering(tcp)) { - printfd(tcp, tcp->u_arg[0]); - tprints(", "); - } else { - if (syserror(tcp)) - tprintf("%#lx", tcp->u_arg[1]); - else - printstr(tcp, tcp->u_arg[1], tcp->u_rval); - tprintf(", %lu, ", tcp->u_arg[2]); - printllval(tcp, "%#llx", 3); - } - return 0; -} - -int -sys_pwrite64(struct tcb *tcp) -{ - if (entering(tcp)) { - printfd(tcp, tcp->u_arg[0]); - tprints(", "); - printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); - tprintf(", %lu, ", tcp->u_arg[2]); - printllval(tcp, "%#llx", 3); - } - return 0; -} -#endif /* _LFS64_LARGEFILE */ - -#endif /* SVR4 */ - -#ifdef FREEBSD -#include <sys/types.h> -#include <sys/socket.h> - -int -sys_sendfile(struct tcb *tcp) -{ - if (entering(tcp)) { - printfd(tcp, tcp->u_arg[0]); - tprints(", "); - printfd(tcp, tcp->u_arg[1]); - tprintf(", %llu, %lu", - LONG_LONG(tcp->u_arg[2], tcp->u_arg[3]), - tcp->u_arg[4]); - } else { - off_t offset; - - if (!tcp->u_arg[5]) - tprints(", NULL"); - else { - struct sf_hdtr hdtr; - - if (umove(tcp, tcp->u_arg[5], &hdtr) < 0) - tprintf(", %#lx", tcp->u_arg[5]); - else { - tprints(", { "); - tprint_iov(tcp, hdtr.hdr_cnt, hdtr.headers, 1); - tprintf(", %u, ", hdtr.hdr_cnt); - tprint_iov(tcp, hdtr.trl_cnt, hdtr.trailers, 1); - tprintf(", %u }", hdtr.hdr_cnt); - } - } - if (!tcp->u_arg[6]) - tprints(", NULL"); - else if (umove(tcp, tcp->u_arg[6], &offset) < 0) - tprintf(", %#lx", tcp->u_arg[6]); - else - tprintf(", [%llu]", offset); - tprintf(", %lu", tcp->u_arg[7]); - } - return 0; -} -#endif /* FREEBSD */ -#ifdef LINUX /* The SH4 ABI does allow long longs in odd-numbered registers, but does not allow them to be split between registers and memory - and @@ -489,7 +370,6 @@ sys_vmsplice(struct tcb *tcp) } return 0; } -#endif /* LINUX */ int sys_ioctl(struct tcb *tcp) @@ -32,9 +32,7 @@ #include "defs.h" -#ifdef LINUX #include <asm/ioctl.h> -#endif static int compare(const void *a, const void *b) @@ -50,9 +48,7 @@ ioctl_lookup(long code) struct ioctlent *iop, ioent; ioent.code = code; -#ifdef LINUX ioent.code &= (_IOC_NRMASK<<_IOC_NRSHIFT) | (_IOC_TYPEMASK<<_IOC_TYPESHIFT); -#endif iop = (struct ioctlent *) bsearch((char *) &ioent, (char *) ioctlent, nioctlents, sizeof(struct ioctlent), compare); while (iop > ioctlent) @@ -78,40 +74,18 @@ int ioctl_decode(struct tcb *tcp, long code, long arg) { switch ((code >> 8) & 0xff) { -#ifdef LINUX #if defined(ALPHA) || defined(POWERPC) case 'f': case 't': case 'T': #else /* !ALPHA */ case 0x54: #endif /* !ALPHA */ -#else /* !LINUX */ - case 'f': case 't': case 'T': -#endif /* !LINUX */ return term_ioctl(tcp, code, arg); -#ifdef LINUX case 0x89: -#else /* !LINUX */ - case 'r': case 's': case 'i': -#ifndef FREEBSD - case 'p': -#endif -#endif /* !LINUX */ return sock_ioctl(tcp, code, arg); -#ifdef USE_PROCFS -#ifndef HAVE_MP_PROCFS -#ifndef FREEBSD - case 'q': -#else - case 'p': -#endif - return proc_ioctl(tcp, code, arg); -#endif -#endif /* USE_PROCFS */ #ifdef HAVE_SYS_STREAM_H case 'S': return stream_ioctl(tcp, code, arg); #endif /* HAVE_SYS_STREAM_H */ -#ifdef LINUX case 'p': return rtc_ioctl(tcp, code, arg); case 0x03: @@ -119,7 +93,6 @@ ioctl_decode(struct tcb *tcp, long code, long arg) return block_ioctl(tcp, code, arg); case 0x22: return scsi_ioctl(tcp, code, arg); -#endif default: break; } @@ -32,7 +32,6 @@ #include "defs.h" -#if defined(LINUX) || defined(SUNOS4) || defined(FREEBSD) # ifdef HAVE_MQUEUE_H # include <mqueue.h> @@ -73,11 +72,9 @@ static const struct xlat msgctl_flags[] = { { IPC_RMID, "IPC_RMID" }, { IPC_SET, "IPC_SET" }, { IPC_STAT, "IPC_STAT" }, -#ifdef LINUX { IPC_INFO, "IPC_INFO" }, { MSG_STAT, "MSG_STAT" }, { MSG_INFO, "MSG_INFO" }, -#endif /* LINUX */ { 0, NULL }, }; @@ -85,11 +82,9 @@ static const struct xlat semctl_flags[] = { { IPC_RMID, "IPC_RMID" }, { IPC_SET, "IPC_SET" }, { IPC_STAT, "IPC_STAT" }, -#ifdef LINUX { IPC_INFO, "IPC_INFO" }, { SEM_STAT, "SEM_STAT" }, { SEM_INFO, "SEM_INFO" }, -#endif /* LINUX */ { GETPID, "GETPID" }, { GETVAL, "GETVAL" }, { GETALL, "GETALL" }, @@ -104,11 +99,9 @@ static const struct xlat shmctl_flags[] = { { IPC_RMID, "IPC_RMID" }, { IPC_SET, "IPC_SET" }, { IPC_STAT, "IPC_STAT" }, -#ifdef LINUX { IPC_INFO, "IPC_INFO" }, { SHM_STAT, "SHM_STAT" }, { SHM_INFO, "SHM_INFO" }, -#endif /* LINUX */ #ifdef SHM_LOCK { SHM_LOCK, "SHM_LOCK" }, #endif @@ -135,9 +128,7 @@ static const struct xlat shm_resource_flags[] = { }; static const struct xlat shm_flags[] = { -#ifdef LINUX { SHM_REMAP, "SHM_REMAP" }, -#endif /* LINUX */ { SHM_RDONLY, "SHM_RDONLY" }, { SHM_RND, "SHM_RND" }, { 0, NULL }, @@ -145,9 +136,7 @@ static const struct xlat shm_flags[] = { static const struct xlat msg_flags[] = { { MSG_NOERROR, "MSG_NOERROR" }, -#ifdef LINUX { MSG_EXCEPT, "MSG_EXCEPT" }, -#endif /* LINUX */ { IPC_NOWAIT, "IPC_NOWAIT" }, { 0, NULL }, }; @@ -184,7 +173,6 @@ int sys_msgget(struct tcb *tcp) static int indirect_ipccall(struct tcb *tcp) { -#ifdef LINUX #ifdef X86_64 return current_personality > 0; #endif @@ -194,7 +182,6 @@ indirect_ipccall(struct tcb *tcp) #if !defined MIPS && !defined HPPA return 1; #endif -#endif /* LINUX */ return 0; } @@ -338,7 +325,6 @@ int sys_semop(struct tcb *tcp) return 0; } -#ifdef LINUX int sys_semtimedop(struct tcb *tcp) { if (entering(tcp)) { @@ -359,7 +345,6 @@ int sys_semtimedop(struct tcb *tcp) } return 0; } -#endif int sys_semget(struct tcb *tcp) { @@ -420,9 +405,7 @@ int sys_shmctl(struct tcb *tcp) int sys_shmat(struct tcb *tcp) { -#ifdef LINUX unsigned long raddr; -#endif /* LINUX */ if (exiting(tcp)) { tprintf("%lu", tcp->u_arg[0]); @@ -460,9 +443,7 @@ int sys_shmdt(struct tcb *tcp) return 0; } -#endif /* defined(LINUX) || defined(SUNOS4) || defined(FREEBSD) */ -#ifdef LINUX int sys_mq_open(struct tcb *tcp) { @@ -559,7 +540,6 @@ sys_mq_getsetattr(struct tcb *tcp) printmqattr(tcp, tcp->u_arg[2]); return 0; } -#endif int sys_ipc(struct tcb *tcp) @@ -34,9 +34,7 @@ #include "defs.h" -#ifdef LINUX #include <asm/mman.h> -#endif #include <sys/mman.h> #if defined(LINUX) && defined(I386) @@ -62,23 +60,9 @@ sys_brk(struct tcb *tcp) if (entering(tcp)) { tprintf("%#lx", tcp->u_arg[0]); } -#ifdef LINUX return RVAL_HEX; -#else - return 0; -#endif } -#if defined(FREEBSD) || defined(SUNOS4) -int -sys_sbrk(struct tcb *tcp) -{ - if (entering(tcp)) { - tprintf("%lu", tcp->u_arg[0]); - } - return RVAL_HEX; -} -#endif /* FREEBSD || SUNOS4 */ static const struct xlat mmap_prot[] = { { PROT_NONE, "PROT_NONE", }, @@ -262,7 +246,6 @@ print_mmap(struct tcb *tcp, long *u_arg, long long offset) return RVAL_HEX; } -#ifdef LINUX int sys_old_mmap(struct tcb *tcp) { #if defined(IA64) @@ -305,7 +288,6 @@ int sys_old_mmap(struct tcb *tcp) return print_mmap(tcp, u_arg, u_arg[5]); } -#endif /* LINUX */ int sys_mmap(struct tcb *tcp) @@ -408,7 +390,6 @@ sys_mprotect(struct tcb *tcp) return 0; } -#ifdef LINUX static const struct xlat mremap_flags[] = { { MREMAP_MAYMOVE, "MREMAP_MAYMOVE" }, @@ -485,7 +466,6 @@ sys_mlockall(struct tcb *tcp) } -#endif /* LINUX */ #ifdef MS_ASYNC @@ -716,7 +696,6 @@ sys_get_thread_area(struct tcb *tcp) } #endif -#if defined(LINUX) int sys_remap_file_pages(struct tcb *tcp) { @@ -930,7 +909,6 @@ sys_move_pages(struct tcb *tcp) } return 0; } -#endif #if defined(LINUX) && defined(POWERPC) int @@ -54,14 +54,12 @@ #endif #include <arpa/inet.h> #include <net/if.h> -#if defined(LINUX) #include <asm/types.h> #if defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC__ + __GLIBC_MINOR__ >= 3) # include <netipx/ipx.h> #else # include <linux/ipx.h> #endif -#endif /* LINUX */ #if defined (__GLIBC__) && (((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1)) || defined(HAVE_SIN6_SCOPE_ID_LINUX)) #if defined(HAVE_LINUX_IN6_H) @@ -105,11 +103,7 @@ #define PF_UNSPEC AF_UNSPEC #endif -#if UNIXWARE >= 7 -#define HAVE_SENDMSG 1 /* HACK - *FIXME* */ -#endif -#ifdef LINUX /* Under Linux these are enums so we can't test for them with ifdef. */ #define IPPROTO_EGP IPPROTO_EGP #define IPPROTO_PUP IPPROTO_PUP @@ -117,7 +111,6 @@ #define IPPROTO_IGMP IPPROTO_IGMP #define IPPROTO_RAW IPPROTO_RAW #define IPPROTO_MAX IPPROTO_MAX -#endif static const struct xlat domains[] = { #ifdef PF_AAL5 @@ -1455,7 +1448,6 @@ printmsghdr(struct tcb *tcp, long addr) do_msghdr(tcp, &msg); } -#ifdef LINUX static void printmmsghdr(struct tcb *tcp, long addr) { @@ -1472,7 +1464,6 @@ printmmsghdr(struct tcb *tcp, long addr) do_msghdr(tcp, &mmsg.msg_hdr); tprintf(", %u}", mmsg.msg_len); } -#endif #endif /* HAVE_SENDMSG */ @@ -1526,32 +1517,6 @@ sys_socket(struct tcb *tcp) return 0; } -#ifdef SVR4 -int -sys_so_socket(struct tcb *tcp) -{ - if (entering(tcp)) { - /* not sure really what these args are... but this - * is how truss prints it - */ - tprintf("%ld, %ld, %ld, ", - tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]); - printpath(tcp, tcp->u_arg[3]); - tprintf(", %ld", tcp->u_arg[4]); - } - return 0; -} - -int -sys_so_socketpair(struct tcb *tcp) -{ - if (entering(tcp)) { - /* not sure what this arg is */ - tprintf("0x%lx", tcp->u_arg[0]); - } - return 0; -} -#endif /* SVR4 */ int sys_bind(struct tcb *tcp) @@ -1613,13 +1578,11 @@ sys_accept(struct tcb *tcp) return do_accept(tcp, -1); } -#ifdef LINUX int sys_accept4(struct tcb *tcp) { return do_accept(tcp, 3); } -#endif int sys_send(struct tcb *tcp) @@ -1749,7 +1712,6 @@ sys_recvmsg(struct tcb *tcp) return 0; } -#ifdef LINUX int sys_recvmmsg(struct tcb *tcp) { @@ -1799,7 +1761,6 @@ sys_recvmmsg(struct tcb *tcp) return RVAL_STR; } } -#endif #endif /* HAVE_SENDMSG */ @@ -1866,20 +1827,16 @@ sys_pipe(struct tcb *tcp) return do_pipe(tcp, -1); } -#ifdef LINUX int sys_pipe2(struct tcb *tcp) { return do_pipe(tcp, 1); } -#endif int sys_socketpair(struct tcb *tcp) { -#ifdef LINUX int fds[2]; -#endif if (entering(tcp)) { printxval(domains, tcp->u_arg[0], "PF_???"); @@ -1907,15 +1864,10 @@ sys_socketpair(struct tcb *tcp) tprintf(", %#lx", tcp->u_arg[3]); return 0; } -#ifdef LINUX if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0) tprints(", [...]"); else tprintf(", [%u, %u]", fds[0], fds[1]); -#endif /* LINUX */ -#if defined(SUNOS4) || defined(SVR4) || defined(FREEBSD) - tprintf(", [%lu, %lu]", tcp->u_rval, getrval2(tcp)); -#endif /* SUNOS4 || SVR4 || FREEBSD */ } return 0; } @@ -2234,130 +2186,3 @@ sys_setsockopt(struct tcb *tcp) return 0; } -#if UNIXWARE >= 7 - -static const struct xlat sock_version[] = { - { __NETLIB_UW211_SVR4, "UW211_SVR4" }, - { __NETLIB_UW211_XPG4, "UW211_XPG4" }, - { __NETLIB_GEMINI_SVR4, "GEMINI_SVR4" }, - { __NETLIB_GEMINI_XPG4, "GEMINI_XPG4" }, - { __NETLIB_FP1_SVR4, "FP1_SVR4" }, - { __NETLIB_FP1_XPG4, "FP1_XPG4" }, - { 0, NULL }, -}; - - -int -netlib_call(struct tcb *tcp, int (*func)()) -{ - if (entering(tcp)) { - int i; - printxval(sock_version, tcp->u_arg[0], "__NETLIB_???"); - tprints(", "); - --tcp->u_nargs; - for (i = 0; i < tcp->u_nargs; i++) - tcp->u_arg[i] = tcp->u_arg[i + 1]; - return func(tcp); - } - - return func(tcp); -} - -int -sys_xsocket(struct tcb *tcp) -{ - return netlib_call(tcp, sys_socket); -} - -int -sys_xsocketpair(struct tcb *tcp) -{ - return netlib_call(tcp, sys_socketpair); -} - -int -sys_xbind(struct tcb *tcp) -{ - return netlib_call(tcp, sys_bind); -} - -int -sys_xconnect(struct tcb *tcp) -{ - return netlib_call(tcp, sys_connect); -} - -int -sys_xlisten(struct tcb *tcp) -{ - return netlib_call(tcp, sys_listen); -} - -int -sys_xaccept(struct tcb *tcp) -{ - return netlib_call(tcp, sys_accept); -} - -int -sys_xsendmsg(struct tcb *tcp) -{ - return netlib_call(tcp, sys_sendmsg); -} - -int -sys_xrecvmsg(struct tcb *tcp) -{ - return netlib_call(tcp, sys_recvmsg); -} - -int -sys_xgetsockaddr(struct tcb *tcp) -{ - if (entering(tcp)) { - printxval(sock_version, tcp->u_arg[0], "__NETLIB_???"); - tprints(", "); - if (tcp->u_arg[1] == 0) { - tprints("LOCALNAME, "); - } - else if (tcp->u_arg[1] == 1) { - tprints("REMOTENAME, "); - } - else { - tprintf("%ld, ", tcp->u_arg[1]); - } - tprintf("%ld, ", tcp->u_arg[2]); - } - else { - if (tcp->u_arg[3] == 0 || syserror(tcp)) { - tprintf("%#lx", tcp->u_arg[3]); - } else { - printsock(tcp, tcp->u_arg[3], tcp->u_arg[4]); - } - tprints(", "); - printnum(tcp, tcp->u_arg[4], "%lu"); - } - - return 0; - -} - -int -sys_xgetsockopt(struct tcb *tcp) -{ - return netlib_call(tcp, sys_getsockopt); -} - -int -sys_xsetsockopt(struct tcb *tcp) -{ - return netlib_call(tcp, sys_setsockopt); -} - -int -sys_xshutdown(struct tcb *tcp) -{ - return netlib_call(tcp, sys_shutdown); -} - -#endif /* UNIXWARE */ diff --git a/pathtrace.c b/pathtrace.c index 5fa8be4..fdb13ba 100644 --- a/pathtrace.c +++ b/pathtrace.c @@ -117,7 +117,6 @@ storepath(const char *path) */ const char *getfdpath(struct tcb *tcp, int fd) { -#ifdef LINUX static char path[PATH_MAX+1]; char linkpath[64]; ssize_t n; @@ -131,9 +130,6 @@ const char *getfdpath(struct tcb *tcp, int fd) return NULL; path[n] = '\0'; return path; -#else - return NULL; -#endif } /* @@ -192,7 +188,6 @@ pathtrace_match(struct tcb *tcp) * other than test arg[0]. */ -#ifdef LINUX if (s->sys_func == sys_dup2 || s->sys_func == sys_dup3 || @@ -358,9 +353,6 @@ pathtrace_match(struct tcb *tcp) */ return 0; } -#else -#warning "path tracing only using arg[0]" -#endif /* * Our fallback position for calls that haven't already @@ -29,228 +29,4 @@ #include "defs.h" -#ifdef SVR4 -#ifndef HAVE_MP_PROCFS -static const struct xlat proc_status_flags[] = { - { PR_STOPPED, "PR_STOPPED" }, - { PR_ISTOP, "PR_ISTOP" }, - { PR_DSTOP, "PR_DSTOP" }, - { PR_ASLEEP, "PR_ASLEEP" }, - { PR_FORK, "PR_FORK" }, - { PR_RLC, "PR_RLC" }, - { PR_PTRACE, "PR_PTRACE" }, - { PR_PCINVAL, "PR_PCINVAL" }, - { PR_ISSYS, "PR_ISSYS" }, -#ifdef PR_STEP - { PR_STEP, "PR_STEP" }, -#endif -#ifdef PR_KLC - { PR_KLC, "PR_KLC" }, -#endif -#ifdef PR_ASYNC - { PR_ASYNC, "PR_ASYNC" }, -#endif -#ifdef PR_PCOMPAT - { PR_PCOMPAT, "PR_PCOMPAT" }, -#endif - { 0, NULL }, -}; - -static const struct xlat proc_status_why[] = { - { PR_REQUESTED, "PR_REQUESTED" }, - { PR_SIGNALLED, "PR_SIGNALLED" }, - { PR_SYSENTRY, "PR_SYSENTRY" }, - { PR_SYSEXIT, "PR_SYSEXIT" }, - { PR_JOBCONTROL,"PR_JOBCONTROL" }, - { PR_FAULTED, "PR_FAULTED" }, -#ifdef PR_SUSPENDED - { PR_SUSPENDED, "PR_SUSPENDED" }, -#endif -#ifdef PR_CHECKPOINT - { PR_CHECKPOINT,"PR_CHECKPOINT" }, -#endif - { 0, NULL }, -}; - -static const struct xlat proc_run_flags[] = { - { PRCSIG, "PRCSIG" }, - { PRCFAULT, "PRCFAULT" }, - { PRSTRACE, "PRSTRACE" }, - { PRSHOLD, "PRSHOLD" }, - { PRSFAULT, "PRSFAULT" }, - { PRSVADDR, "PRSVADDR" }, - { PRSTEP, "PRSTEP" }, - { PRSABORT, "PRSABORT" }, - { PRSTOP, "PRSTOP" }, - { 0, NULL }, -}; - -int -proc_ioctl(struct tcb *tcp, int code, int arg) -{ - int val; - prstatus_t status; - prrun_t run; - - if (entering(tcp)) - return 0; - - switch (code) { - case PIOCSTATUS: - case PIOCSTOP: - case PIOCWSTOP: - if (arg == 0) - tprints(", NULL"); - else if (syserror(tcp)) - tprintf(", %#x", arg); - else if (umove(tcp, arg, &status) < 0) - tprints(", {...}"); - else { - tprints(", {pr_flags="); - printflags(proc_status_flags, status.pr_flags, "PR_???"); - if (status.pr_why) { - tprints(", pr_why="); - printxval(proc_status_why, status.pr_why, - "PR_???"); - } - switch (status.pr_why) { - case PR_SIGNALLED: - case PR_JOBCONTROL: - tprints(", pr_what="); - printsignal(status.pr_what); - break; - case PR_FAULTED: - tprintf(", pr_what=%d", status.pr_what); - break; - case PR_SYSENTRY: - case PR_SYSEXIT: - tprintf(", pr_what=SYS_%s", - sysent[status.pr_what].sys_name); - break; - } - tprints(", ...}"); - } - return 1; - case PIOCRUN: - if (arg == 0) - tprints(", NULL"); - else if (umove(tcp, arg, &run) < 0) - tprints(", {...}"); - else { - tprints(", {pr_flags="); - printflags(proc_run_flags, run.pr_flags, "PR???"); - tprints(", ...}"); - } - return 1; -#ifdef PIOCSET - case PIOCSET: - case PIOCRESET: - if (umove(tcp, arg, &val) < 0) - tprints(", [?]"); - else { - tprints(", ["); - printflags(proc_status_flags, val, "PR_???"); - tprints("]"); - } - return 1; -#endif /* PIOCSET */ - case PIOCKILL: - case PIOCUNKILL: - /* takes a pointer to a signal */ - if (umove(tcp, arg, &val) < 0) - tprints(", [?]"); - else { - tprints(", ["); - printsignal(val); - tprints("]"); - } - return 1; - case PIOCSFORK: - case PIOCRFORK: - case PIOCSRLC: - case PIOCRRLC: - /* doesn't take an arg */ - return 1; - default: - /* ad naseum */ - return 0; - } -} - -#endif /* HAVE_MP_PROCFS */ -#endif /* SVR4 */ - -#ifdef FREEBSD -#include <sys/pioctl.h> - -static const struct xlat proc_status_why[] = { - { S_EXEC, "S_EXEC" }, - { S_SIG, "S_SIG" }, - { S_SCE, "S_SCE" }, - { S_SCX, "S_SCX" }, - { S_CORE, "S_CORE" }, - { S_EXIT, "S_EXIT" }, - { 0, NULL } -}; - -static const struct xlat proc_status_flags[] = { - { PF_LINGER, "PF_LINGER" }, - { PF_ISUGID, "PF_ISUGID" }, - { 0, NULL } -}; - -int -proc_ioctl(struct tcb *tcp, int code, int arg) -{ - int val; - struct procfs_status status; - - if (entering(tcp)) - return 0; - - switch (code) { - case PIOCSTATUS: - case PIOCWAIT: - if (arg == 0) - tprints(", NULL"); - else if (syserror(tcp)) - tprintf(", %x", arg); - else if (umove(tcp, arg, &status) < 0) - tprints(", {...}"); - else { - tprintf(", {state=%d, flags=", status.state); - printflags(proc_status_flags, status.flags, "PF_???"); - tprints(", events="); - printflags(proc_status_why, status.events, "S_???"); - tprints(", why="); - printxval(proc_status_why, status.why, "S_???"); - tprintf(", val=%lu}", status.val); - } - return 1; - case PIOCBIS: - tprints(", "); - printflags(proc_status_why, arg, "S_???"); - return 1; - return 1; - case PIOCSFL: - tprints(", "); - printflags(proc_status_flags, arg, "PF_???"); - return 1; - case PIOCGFL: - if (syserror(tcp)) - tprintf(", %#x", arg); - else if (umove(tcp, arg, &val) < 0) - tprints(", {...}"); - else { - tprints(", ["); - printflags(proc_status_flags, val, "PF_???"); - tprints("]"); - } - return 1; - default: - /* ad naseum */ - return 0; - } -} -#endif @@ -48,13 +48,7 @@ #include <sys/user.h> #include <sys/syscall.h> #include <signal.h> -#ifdef SUNOS4 -#include <machine/reg.h> -#endif /* SUNOS4 */ -#ifdef FREEBSD -#include <sys/ptrace.h> -#endif #ifdef HAVE_SYS_REG_H # include <sys/reg.h> @@ -90,7 +84,6 @@ #ifdef HAVE_LINUX_FUTEX_H # include <linux/futex.h> #endif -#ifdef LINUX # ifndef FUTEX_WAIT # define FUTEX_WAIT 0 # endif @@ -103,16 +96,13 @@ # ifndef FUTEX_REQUEUE # define FUTEX_REQUEUE 3 # endif -#endif /* LINUX */ -#ifdef LINUX #include <sched.h> #include <asm/posix_types.h> #undef GETGROUPS_T #define GETGROUPS_T __kernel_gid_t #undef GETGROUPS32_T #define GETGROUPS32_T __kernel_gid32_t -#endif /* LINUX */ #if defined(LINUX) && defined(IA64) # include <asm/ptrace_offsets.h> @@ -359,15 +349,6 @@ sys_prctl(struct tcb *tcp) } #endif /* HAVE_PRCTL */ -#if defined(FREEBSD) || defined(SUNOS4) || defined(SVR4) -int -sys_gethostid(struct tcb *tcp) -{ - if (exiting(tcp)) - return RVAL_HEX; - return 0; -} -#endif /* FREEBSD || SUNOS4 || SVR4 */ int sys_sethostname(struct tcb *tcp) @@ -404,21 +385,6 @@ sys_setdomainname(struct tcb *tcp) return 0; } -#if !defined(LINUX) - -int -sys_getdomainname(struct tcb *tcp) -{ - if (exiting(tcp)) { - if (syserror(tcp)) - tprintf("%#lx", tcp->u_arg[0]); - else - printpath(tcp, tcp->u_arg[0]); - tprintf(", %lu", tcp->u_arg[1]); - } - return 0; -} -#endif /* !LINUX */ int sys_exit(struct tcb *tcp) @@ -435,66 +401,7 @@ sys_exit(struct tcb *tcp) return 0; } -#ifdef USE_PROCFS - -int -sys_fork(struct tcb *tcp) -{ - if (exiting(tcp) && !syserror(tcp)) { - if (getrval2(tcp)) { - tcp->auxstr = "child process"; - return RVAL_UDECIMAL | RVAL_STR; - } - } - return 0; -} - -#if UNIXWARE > 2 - -int -sys_rfork(struct tcb *tcp) -{ - if (entering(tcp)) { - tprintf("%ld", tcp->u_arg[0]); - } - else if (!syserror(tcp)) { - if (getrval2(tcp)) { - tcp->auxstr = "child process"; - return RVAL_UDECIMAL | RVAL_STR; - } - } - return 0; -} - -#endif - -int -internal_fork(struct tcb *tcp) -{ - struct tcb *tcpchild; - - if (exiting(tcp)) { -#ifdef SYS_rfork - if (tcp->scno == SYS_rfork && !(tcp->u_arg[0]&RFPROC)) - return 0; -#endif - if (getrval2(tcp)) - return 0; - if (!followfork) - return 0; - if (syserror(tcp)) - return 0; - tcpchild = alloctcb(tcp->u_rval); - if (proc_open(tcpchild, 2) < 0) - droptcb(tcpchild); - tcpchild->flags |= TCB_STARTUP; - } - return 0; -} - -#else /* !USE_PROCFS */ -#ifdef LINUX /* defines copied from linux/sched.h since we can't include that * ourselves (it conflicts with *lots* of libc includes) @@ -636,7 +543,6 @@ sys_unshare(struct tcb *tcp) printflags(clone_flags, tcp->u_arg[0], "CLONE_???"); return 0; } -#endif /* LINUX */ int sys_fork(struct tcb *tcp) @@ -649,7 +555,6 @@ sys_fork(struct tcb *tcp) int change_syscall(struct tcb *tcp, int new) { -#ifdef LINUX #if defined(I386) /* Attempt to make vfork into fork, which we can follow. */ if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(ORIG_EAX * 4), new) < 0) @@ -758,11 +663,9 @@ change_syscall(struct tcb *tcp, int new) #else #warning Do not know how to handle change_syscall for this architecture #endif /* architecture */ -#endif /* LINUX */ return -1; } -#ifdef LINUX int internal_fork(struct tcb *tcp) @@ -792,92 +695,8 @@ internal_fork(struct tcb *tcp) return 0; } -#else /* !LINUX */ - -int -internal_fork(struct tcb *tcp) -{ - struct tcb *tcpchild; - int pid; - int dont_follow = 0; - -#ifdef SYS_vfork - if (tcp->scno == SYS_vfork) { - /* Attempt to make vfork into fork, which we can follow. */ - if (change_syscall(tcp, SYS_fork) < 0) - dont_follow = 1; - } -#endif - if (!followfork) - return 0; - if (entering(tcp)) { - if (dont_follow) - return 0; - setbpt(tcp); - } - else { - int bpt = tcp->flags & TCB_BPTSET; - - if (bpt) - clearbpt(tcp); - - if (syserror(tcp)) - return 0; - - pid = tcp->u_rval; - tcpchild = alloctcb(pid); -#ifdef SUNOS4 -#ifdef oldway - /* The child must have run before it can be attached. */ - { - struct timeval tv; - tv.tv_sec = 0; - tv.tv_usec = 10000; - select(0, NULL, NULL, NULL, &tv); - } - if (ptrace(PTRACE_ATTACH, pid, (char *)1, 0) < 0) { - perror("PTRACE_ATTACH"); - fprintf(stderr, "Too late?\n"); - droptcb(tcpchild); - return 0; - } -#else /* !oldway */ - /* Try to catch the new process as soon as possible. */ - { - int i; - for (i = 0; i < 1024; i++) - if (ptrace(PTRACE_ATTACH, pid, (char *) 1, 0) >= 0) - break; - if (i == 1024) { - perror("PTRACE_ATTACH"); - fprintf(stderr, "Too late?\n"); - droptcb(tcpchild); - return 0; - } - } -#endif /* !oldway */ -#endif /* SUNOS4 */ - tcpchild->flags |= TCB_ATTACHED | TCB_STARTUP | TCB_IGNORE_ONE_SIGSTOP; - /* Child has BPT too, must be removed on first occasion */ - if (bpt) { - tcpchild->flags |= TCB_BPTSET; - tcpchild->baddr = tcp->baddr; - memcpy(tcpchild->inst, tcp->inst, - sizeof tcpchild->inst); - } - if (!qflag) - fprintf(stderr, "Process %d attached\n", pid); - } - return 0; -} - -#endif /* !LINUX */ - -#endif /* !USE_PROCFS */ - -#if defined(SUNOS4) || defined(LINUX) || defined(FREEBSD) int sys_vfork(struct tcb *tcp) @@ -887,48 +706,8 @@ sys_vfork(struct tcb *tcp) return 0; } -#endif /* SUNOS4 || LINUX || FREEBSD */ - -#ifndef LINUX -static char idstr[16]; - -int -sys_getpid(struct tcb *tcp) -{ - if (exiting(tcp)) { - sprintf(idstr, "ppid %lu", getrval2(tcp)); - tcp->auxstr = idstr; - return RVAL_STR; - } - return 0; -} -int -sys_getuid(struct tcb *tcp) -{ - if (exiting(tcp)) { - sprintf(idstr, "euid %lu", getrval2(tcp)); - tcp->auxstr = idstr; - return RVAL_STR; - } - return 0; -} - -int -sys_getgid(struct tcb *tcp) -{ - if (exiting(tcp)) { - sprintf(idstr, "egid %lu", getrval2(tcp)); - tcp->auxstr = idstr; - return RVAL_STR; - } - return 0; -} - -#endif /* !LINUX */ - -#ifdef LINUX int sys_getuid(struct tcb *tcp) { @@ -1016,7 +795,6 @@ sys_getresgid(struct tcb *tcp) return 0; } -#endif /* LINUX */ int sys_setreuid(struct tcb *tcp) @@ -1038,7 +816,6 @@ sys_setregid(struct tcb *tcp) return 0; } -#if defined(LINUX) || defined(FREEBSD) int sys_setresuid(struct tcb *tcp) { @@ -1060,7 +837,6 @@ sys_setresgid(struct tcb *tcp) return 0; } -#endif /* LINUX || FREEBSD */ int sys_setgroups(struct tcb *tcp) @@ -1179,7 +955,6 @@ sys_getgroups(struct tcb *tcp) return 0; } -#ifdef LINUX int sys_setgroups32(struct tcb *tcp) { @@ -1292,16 +1067,13 @@ sys_getgroups32(struct tcb *tcp) } return 0; } -#endif /* LINUX */ #if defined(ALPHA) || defined(SUNOS4) || defined(SVR4) int sys_setpgrp(struct tcb *tcp) { if (entering(tcp)) { -#ifndef SVR4 tprintf("%lu, %lu", tcp->u_arg[0], tcp->u_arg[1]); -#endif /* !SVR4 */ } return 0; } @@ -1311,9 +1083,7 @@ int sys_getpgrp(struct tcb *tcp) { if (entering(tcp)) { -#ifndef SVR4 tprintf("%lu", tcp->u_arg[0]); -#endif /* !SVR4 */ } return 0; } @@ -1351,137 +1121,6 @@ sys_setpgid(struct tcb *tcp) return 0; } -#if UNIXWARE >= 2 - -#include <sys/privilege.h> - - -static const struct xlat procpriv_cmds[] = { - { SETPRV, "SETPRV" }, - { CLRPRV, "CLRPRV" }, - { PUTPRV, "PUTPRV" }, - { GETPRV, "GETPRV" }, - { CNTPRV, "CNTPRV" }, - { 0, NULL }, -}; - - -static const struct xlat procpriv_priv[] = { - { P_OWNER, "P_OWNER" }, - { P_AUDIT, "P_AUDIT" }, - { P_COMPAT, "P_COMPAT" }, - { P_DACREAD, "P_DACREAD" }, - { P_DACWRITE, "P_DACWRITE" }, - { P_DEV, "P_DEV" }, - { P_FILESYS, "P_FILESYS" }, - { P_MACREAD, "P_MACREAD" }, - { P_MACWRITE, "P_MACWRITE" }, - { P_MOUNT, "P_MOUNT" }, - { P_MULTIDIR, "P_MULTIDIR" }, - { P_SETPLEVEL, "P_SETPLEVEL" }, - { P_SETSPRIV, "P_SETSPRIV" }, - { P_SETUID, "P_SETUID" }, - { P_SYSOPS, "P_SYSOPS" }, - { P_SETUPRIV, "P_SETUPRIV" }, - { P_DRIVER, "P_DRIVER" }, - { P_RTIME, "P_RTIME" }, - { P_MACUPGRADE, "P_MACUPGRADE" }, - { P_FSYSRANGE, "P_FSYSRANGE" }, - { P_SETFLEVEL, "P_SETFLEVEL" }, - { P_AUDITWR, "P_AUDITWR" }, - { P_TSHAR, "P_TSHAR" }, - { P_PLOCK, "P_PLOCK" }, - { P_CORE, "P_CORE" }, - { P_LOADMOD, "P_LOADMOD" }, - { P_BIND, "P_BIND" }, - { P_ALLPRIVS, "P_ALLPRIVS" }, - { 0, NULL }, -}; - - -static const struct xlat procpriv_type[] = { - { PS_FIX, "PS_FIX" }, - { PS_INH, "PS_INH" }, - { PS_MAX, "PS_MAX" }, - { PS_WKG, "PS_WKG" }, - { 0, NULL }, -}; - - -static void -printpriv(struct tcb *tcp, long addr, int len, const struct xlat *opt) -{ - priv_t buf[128]; - int max = verbose(tcp) ? ARRAY_SIZE(buf) : 10; - int dots = len > max; - int i; - - if (len > max) len = max; - - if (len <= 0 || - umoven(tcp, addr, len * sizeof buf[0], (char *) buf) < 0) - { - tprintf("%#lx", addr); - return; - } - - tprints("["); - - for (i = 0; i < len; ++i) { - const char *t, *p; - - if (i) tprints(", "); - - if ((t = xlookup(procpriv_type, buf[i] & PS_TYPE)) && - (p = xlookup(procpriv_priv, buf[i] & ~PS_TYPE))) - { - tprintf("%s|%s", t, p); - } - else { - tprintf("%#lx", buf[i]); - } - } - - if (dots) tprints(" ..."); - - tprints("]"); -} - - -int -sys_procpriv(struct tcb *tcp) -{ - if (entering(tcp)) { - printxval(procpriv_cmds, tcp->u_arg[0], "???PRV"); - switch (tcp->u_arg[0]) { - case CNTPRV: - tprintf(", %#lx, %ld", tcp->u_arg[1], tcp->u_arg[2]); - break; - - case GETPRV: - break; - - default: - tprints(", "); - printpriv(tcp, tcp->u_arg[1], tcp->u_arg[2]); - tprintf(", %ld", tcp->u_arg[2]); - } - } - else if (tcp->u_arg[0] == GETPRV) { - if (syserror(tcp)) { - tprintf(", %#lx, %ld", tcp->u_arg[1], tcp->u_arg[2]); - } - else { - tprints(", "); - printpriv(tcp, tcp->u_arg[1], tcp->u_rval); - tprintf(", %ld", tcp->u_arg[2]); - } - } - - return 0; -} - -#endif /* UNIXWARE */ static void @@ -1569,27 +1208,11 @@ sys_execve(struct tcb *tcp) return 0; } -#if UNIXWARE > 2 - -int sys_rexecve(struct tcb *tcp) -{ - if (entering(tcp)) { - sys_execve(tcp); - tprintf(", %ld", tcp->u_arg[3]); - } - return 0; -} - -#endif #if defined SUNOS4 || (defined LINUX && defined TCB_WAITEXECVE) int internal_exec(struct tcb *tcp) { -# if defined SUNOS4 - if (exiting(tcp) && !syserror(tcp) && followfork) - fixvfork(tcp); -# endif # if defined LINUX && defined TCB_WAITEXECVE if (exiting(tcp) && syserror(tcp)) tcp->flags &= ~TCB_WAITEXECVE; @@ -1603,7 +1226,6 @@ internal_exec(struct tcb *tcp) } #endif -#ifdef LINUX #ifndef __WNOTHREAD #define __WNOTHREAD 0x20000000 #endif @@ -1613,7 +1235,6 @@ internal_exec(struct tcb *tcp) #ifndef __WCLONE #define __WCLONE 0x80000000 #endif -#endif /* LINUX */ static const struct xlat wait4_options[] = { { WNOHANG, "WNOHANG" }, @@ -1709,12 +1330,8 @@ static int printwaitn(struct tcb *tcp, int n, int bitness) { int status; -#ifdef SUNOS4 - int exited = 0; -#endif if (entering(tcp)) { -#ifdef LINUX /* On Linux, kernel-side pid_t is typedef'ed to int * on all arches. Also, glibc-2.8 truncates wait3 and wait4 * pid argument to int on 64bit arches, producing, @@ -1723,15 +1340,6 @@ printwaitn(struct tcb *tcp, int n, int bitness) */ int pid = tcp->u_arg[0]; tprintf("%d, ", pid); -#else - long pid = tcp->u_arg[0]; -# if SUPPORTED_PERSONALITIES > 1 - /* Sign-extend a 32-bit value when that's what it is. */ - if (personality_wordsize[current_personality] < sizeof pid) - pid = (long) (int) pid; -# endif - tprintf("%ld, ", pid); -#endif } else { /* status */ if (!tcp->u_arg[1]) @@ -1741,9 +1349,6 @@ printwaitn(struct tcb *tcp, int n, int bitness) else if (umove(tcp, tcp->u_arg[1], &status) < 0) tprints("[?]"); else -#ifdef SUNOS4 - exited = -#endif printstatus(status); /* options */ tprints(", "); @@ -1753,7 +1358,6 @@ printwaitn(struct tcb *tcp, int n, int bitness) /* usage */ if (!tcp->u_arg[3]) tprints("NULL"); -#ifdef LINUX else if (tcp->u_rval > 0) { #ifdef ALPHA if (bitness) @@ -1762,11 +1366,6 @@ printwaitn(struct tcb *tcp, int n, int bitness) #endif printrusage(tcp, tcp->u_arg[3]); } -#endif /* LINUX */ -#ifdef SUNOS4 - else if (tcp->u_rval > 0 && exited) - printrusage(tcp, tcp->u_arg[3]); -#endif /* SUNOS4 */ else tprintf("%#lx", tcp->u_arg[3]); } @@ -1774,38 +1373,7 @@ printwaitn(struct tcb *tcp, int n, int bitness) return 0; } -#ifdef SVR4 - -int -sys_wait(struct tcb *tcp) -{ - if (exiting(tcp)) { - /* The library wrapper stuffs this into the user variable. */ - if (!syserror(tcp)) - printstatus(getrval2(tcp)); - } - return 0; -} - -#endif /* SVR4 */ -#ifdef FREEBSD -int -sys_wait(struct tcb *tcp) -{ - int status; - - if (exiting(tcp)) { - if (!syserror(tcp)) { - if (umove(tcp, tcp->u_arg[0], &status) < 0) - tprintf("%#lx", tcp->u_arg[0]); - else - printstatus(status); - } - } - return 0; -} -#endif int sys_waitpid(struct tcb *tcp) @@ -1827,7 +1395,6 @@ sys_osf_wait4(struct tcb *tcp) } #endif -#if defined SVR4 || defined LINUX static const struct xlat waitid_types[] = { { P_PID, "P_PID" }, @@ -1890,7 +1457,6 @@ sys_waitid(struct tcb *tcp) return 0; } -#endif /* SVR4 or LINUX */ int sys_alarm(struct tcb *tcp) @@ -1917,11 +1483,9 @@ sys_uname(struct tcb *tcp) tprintf("release=\"%s\", version=\"%s\", ", uname.release, uname.version); tprintf("machine=\"%s\"", uname.machine); -#ifdef LINUX #ifndef __GLIBC__ tprintf(", domainname=\"%s\"", uname.domainname); #endif -#endif tprints("}"); } else @@ -1931,10 +1495,8 @@ sys_uname(struct tcb *tcp) return 0; } -#ifndef SVR4 static const struct xlat ptrace_cmds[] = { -# ifndef FREEBSD { PTRACE_TRACEME, "PTRACE_TRACEME" }, { PTRACE_PEEKTEXT, "PTRACE_PEEKTEXT" }, { PTRACE_PEEKDATA, "PTRACE_PEEKDATA" }, @@ -2001,62 +1563,11 @@ static const struct xlat ptrace_cmds[] = { # ifdef PTRACE_LISTEN { PTRACE_LISTEN, "PTRACE_LISTEN" }, # endif -# ifdef SUNOS4 - { PTRACE_READDATA, "PTRACE_READDATA" }, - { PTRACE_WRITEDATA, "PTRACE_WRITEDATA" }, - { PTRACE_READTEXT, "PTRACE_READTEXT" }, - { PTRACE_WRITETEXT, "PTRACE_WRITETEXT" }, - { PTRACE_GETFPAREGS, "PTRACE_GETFPAREGS" }, - { PTRACE_SETFPAREGS, "PTRACE_SETFPAREGS" }, -# ifdef SPARC - { PTRACE_GETWINDOW, "PTRACE_GETWINDOW" }, - { PTRACE_SETWINDOW, "PTRACE_SETWINDOW" }, -# else /* !SPARC */ - { PTRACE_22, "PTRACE_22" }, - { PTRACE_23, "PTRACE_3" }, -# endif /* !SPARC */ -# endif /* SUNOS4 */ { PTRACE_SYSCALL, "PTRACE_SYSCALL" }, -# ifdef SUNOS4 - { PTRACE_DUMPCORE, "PTRACE_DUMPCORE" }, -# ifdef I386 - { PTRACE_SETWRBKPT, "PTRACE_SETWRBKPT" }, - { PTRACE_SETACBKPT, "PTRACE_SETACBKPT" }, - { PTRACE_CLRDR7, "PTRACE_CLRDR7" }, -# else /* !I386 */ - { PTRACE_26, "PTRACE_26" }, - { PTRACE_27, "PTRACE_27" }, - { PTRACE_28, "PTRACE_28" }, -# endif /* !I386 */ - { PTRACE_GETUCODE, "PTRACE_GETUCODE" }, -# endif /* SUNOS4 */ - -# else /* FREEBSD */ - - { PT_TRACE_ME, "PT_TRACE_ME" }, - { PT_READ_I, "PT_READ_I" }, - { PT_READ_D, "PT_READ_D" }, - { PT_WRITE_I, "PT_WRITE_I" }, - { PT_WRITE_D, "PT_WRITE_D" }, -# ifdef PT_READ_U - { PT_READ_U, "PT_READ_U" }, -# endif - { PT_CONTINUE, "PT_CONTINUE" }, - { PT_KILL, "PT_KILL" }, - { PT_STEP, "PT_STEP" }, - { PT_ATTACH, "PT_ATTACH" }, - { PT_DETACH, "PT_DETACH" }, - { PT_GETREGS, "PT_GETREGS" }, - { PT_SETREGS, "PT_SETREGS" }, - { PT_GETFPREGS, "PT_GETFPREGS" }, - { PT_SETFPREGS, "PT_SETFPREGS" }, - { PT_GETDBREGS, "PT_GETDBREGS" }, - { PT_SETDBREGS, "PT_SETDBREGS" }, -# endif /* FREEBSD */ + { 0, NULL }, }; -# ifndef FREEBSD # ifdef PTRACE_SETOPTIONS static const struct xlat ptrace_setoptions_flags[] = { # ifdef PTRACE_O_TRACESYSGOOD @@ -2083,11 +1594,8 @@ static const struct xlat ptrace_setoptions_flags[] = { { 0, NULL }, }; # endif /* PTRACE_SETOPTIONS */ -# endif /* !FREEBSD */ -# ifndef FREEBSD const struct xlat struct_user_offsets[] = { -# ifdef LINUX # if defined(S390) || defined(S390X) { PT_PSWMASK, "psw_mask" }, { PT_PSWADDR, "psw_addr" }, @@ -2957,61 +2465,12 @@ const struct xlat struct_user_offsets[] = { # endif # endif /* !defined(many arches) */ -# endif /* LINUX */ -# ifdef SUNOS4 - { uoff(u_pcb), "offsetof(struct user, u_pcb)" }, - { uoff(u_procp), "offsetof(struct user, u_procp)" }, - { uoff(u_ar0), "offsetof(struct user, u_ar0)" }, - { uoff(u_comm[0]), "offsetof(struct user, u_comm[0])" }, - { uoff(u_arg[0]), "offsetof(struct user, u_arg[0])" }, - { uoff(u_ap), "offsetof(struct user, u_ap)" }, - { uoff(u_qsave), "offsetof(struct user, u_qsave)" }, - { uoff(u_rval1), "offsetof(struct user, u_rval1)" }, - { uoff(u_rval2), "offsetof(struct user, u_rval2)" }, - { uoff(u_error), "offsetof(struct user, u_error)" }, - { uoff(u_eosys), "offsetof(struct user, u_eosys)" }, - { uoff(u_ssave), "offsetof(struct user, u_ssave)" }, - { uoff(u_signal[0]), "offsetof(struct user, u_signal)" }, - { uoff(u_sigmask[0]), "offsetof(struct user, u_sigmask)" }, - { uoff(u_sigonstack), "offsetof(struct user, u_sigonstack)" }, - { uoff(u_sigintr), "offsetof(struct user, u_sigintr)" }, - { uoff(u_sigreset), "offsetof(struct user, u_sigreset)" }, - { uoff(u_oldmask), "offsetof(struct user, u_oldmask)" }, - { uoff(u_code), "offsetof(struct user, u_code)" }, - { uoff(u_addr), "offsetof(struct user, u_addr)" }, - { uoff(u_sigstack), "offsetof(struct user, u_sigstack)" }, - { uoff(u_ofile), "offsetof(struct user, u_ofile)" }, - { uoff(u_pofile), "offsetof(struct user, u_pofile)" }, - { uoff(u_ofile_arr[0]), "offsetof(struct user, u_ofile_arr[0])" }, - { uoff(u_pofile_arr[0]),"offsetof(struct user, u_pofile_arr[0])"}, - { uoff(u_lastfile), "offsetof(struct user, u_lastfile)" }, - { uoff(u_cwd), "offsetof(struct user, u_cwd)" }, - { uoff(u_cdir), "offsetof(struct user, u_cdir)" }, - { uoff(u_rdir), "offsetof(struct user, u_rdir)" }, - { uoff(u_cmask), "offsetof(struct user, u_cmask)" }, - { uoff(u_ru), "offsetof(struct user, u_ru)" }, - { uoff(u_cru), "offsetof(struct user, u_cru)" }, - { uoff(u_timer[0]), "offsetof(struct user, u_timer[0])" }, - { uoff(u_XXX[0]), "offsetof(struct user, u_XXX[0])" }, - { uoff(u_ioch), "offsetof(struct user, u_ioch)" }, - { uoff(u_start), "offsetof(struct user, u_start)" }, - { uoff(u_acflag), "offsetof(struct user, u_acflag)" }, - { uoff(u_prof.pr_base), "offsetof(struct user, u_prof.pr_base)" }, - { uoff(u_prof.pr_size), "offsetof(struct user, u_prof.pr_size)" }, - { uoff(u_prof.pr_off), "offsetof(struct user, u_prof.pr_off)" }, - { uoff(u_prof.pr_scale),"offsetof(struct user, u_prof.pr_scale)"}, - { uoff(u_rlimit[0]), "offsetof(struct user, u_rlimit)" }, - { uoff(u_exdata.Ux_A), "offsetof(struct user, u_exdata.Ux_A)" }, - { uoff(u_exdata.ux_shell[0]),"offsetof(struct user, u_exdata.ux_shell[0])"}, - { uoff(u_lofault), "offsetof(struct user, u_lofault)" }, -# endif /* SUNOS4 */ # ifndef HPPA { sizeof(struct user), "sizeof(struct user)" }, # endif { 0, NULL }, }; -# endif /* !FREEBSD */ int sys_ptrace(struct tcb *tcp) @@ -3021,15 +2480,10 @@ sys_ptrace(struct tcb *tcp) if (entering(tcp)) { printxval(ptrace_cmds, tcp->u_arg[0], -# ifndef FREEBSD "PTRACE_???" -# else - "PT_???" -# endif ); tprintf(", %lu, ", tcp->u_arg[1]); addr = tcp->u_arg[2]; -# ifndef FREEBSD if (tcp->u_arg[0] == PTRACE_PEEKUSER || tcp->u_arg[0] == PTRACE_POKEUSER) { for (x = struct_user_offsets; x->str; x++) { @@ -3046,9 +2500,7 @@ sys_ptrace(struct tcb *tcp) tprintf("%s, ", x->str); } else -# endif tprintf("%#lx, ", tcp->u_arg[2]); -# ifdef LINUX switch (tcp->u_arg[0]) { # ifndef IA64 case PTRACE_PEEKDATA: @@ -3117,34 +2569,10 @@ sys_ptrace(struct tcb *tcp) # endif } } -# endif /* LINUX */ -# ifdef SUNOS4 - if (tcp->u_arg[0] == PTRACE_WRITEDATA || - tcp->u_arg[0] == PTRACE_WRITETEXT) { - tprintf("%lu, ", tcp->u_arg[3]); - printstr(tcp, tcp->u_arg[4], tcp->u_arg[3]); - } else if (tcp->u_arg[0] != PTRACE_READDATA && - tcp->u_arg[0] != PTRACE_READTEXT) { - tprintf("%#lx", tcp->u_arg[3]); - } - } else { - if (tcp->u_arg[0] == PTRACE_READDATA || - tcp->u_arg[0] == PTRACE_READTEXT) { - tprintf("%lu, ", tcp->u_arg[3]); - printstr(tcp, tcp->u_arg[4], tcp->u_arg[3]); - } - } -# endif /* SUNOS4 */ -# ifdef FREEBSD - tprintf("%lu", tcp->u_arg[3]); - } -# endif /* FREEBSD */ return 0; } -#endif /* !SVR4 */ -#ifdef LINUX # ifndef FUTEX_CMP_REQUEUE # define FUTEX_CMP_REQUEUE 4 # endif @@ -3491,4 +2919,3 @@ sys_process_vm_readv(struct tcb *tcp) } return 0; } -#endif /* LINUX */ @@ -33,7 +33,6 @@ #include "defs.h" -#ifdef LINUX #include <inttypes.h> @@ -657,51 +656,4 @@ sys_quotactl(struct tcb *tcp) return 0; } -#endif /* Linux */ -#if defined(SUNOS4) || defined(FREEBSD) - -#ifdef SUNOS4 -#include <ufs/quota.h> -#endif - -#ifdef FREEBSD -#include <ufs/ufs/quota.h> -#endif - -static const struct xlat quotacmds[] = { - {Q_QUOTAON, "Q_QUOTAON"}, - {Q_QUOTAOFF, "Q_QUOTAOFF"}, - {Q_GETQUOTA, "Q_GETQUOTA"}, - {Q_SETQUOTA, "Q_SETQUOTA"}, -#ifdef Q_SETQLIM - {Q_SETQLIM, "Q_SETQLIM"}, -#endif -#ifdef Q_SETUSE - {Q_SETUSE, "Q_SETUSE"}, -#endif - {Q_SYNC, "Q_SYNC"}, - {0, NULL}, -}; - -int -sys_quotactl(struct tcb *tcp) -{ - /* fourth arg (addr) not interpreted here */ - if (entering(tcp)) { -#ifdef SUNOS4 - printxval(quotacmds, tcp->u_arg[0], "Q_???"); - tprints(", "); - printstr(tcp, tcp->u_arg[1], -1); -#endif -#ifdef FREEBSD - printpath(tcp, tcp->u_arg[0]); - tprints(", "); - printxval(quotacmds, tcp->u_arg[1], "Q_???"); -#endif - tprintf(", %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]); - } - return 0; -} - -#endif /* SUNOS4 || FREEBSD */ @@ -33,14 +33,8 @@ #include "defs.h" #include <sys/resource.h> -#ifdef LINUX #include <sys/times.h> #include <linux/kernel.h> -#endif /* LINUX */ -#if defined(SVR4) || defined(FREEBSD) -#include <sys/times.h> -#include <sys/time.h> -#endif #if HAVE_LONG_LONG_RLIM_T /* @@ -255,7 +249,6 @@ sys_setrlimit64(struct tcb *tcp) } #endif /* _LFS64_LARGEFILES || HAVE_LONG_LONG_RLIM_T */ -#ifndef SVR4 static const struct xlat usagewho[] = { { RUSAGE_SELF, "RUSAGE_SELF" }, @@ -385,9 +378,7 @@ sys_osf_getrusage(struct tcb *tcp) } #endif /* ALPHA */ -#endif /* !SVR4 */ -#ifdef LINUX int sys_sysinfo(struct tcb *tcp) @@ -415,7 +406,6 @@ sys_sysinfo(struct tcb *tcp) return 0; } -#endif /* LINUX */ static const struct xlat priorities[] = { { PRIO_PROCESS, "PRIO_PROCESS" }, @@ -452,7 +442,6 @@ sys_nice(struct tcb *tcp) return 0; } -#ifndef SUNOS4 int sys_times(struct tcb *tcp) @@ -476,4 +465,3 @@ sys_times(struct tcb *tcp) return 0; } -#endif /* !SUNOS4 */ @@ -1,6 +1,5 @@ #include "defs.h" -#ifdef LINUX #include <sys/ioctl.h> #include <scsi/sg.h> @@ -111,4 +110,3 @@ scsi_ioctl(struct tcb *tcp, long code, long arg) } return 1; } -#endif /* LINUX */ @@ -40,9 +40,6 @@ #include <sys/user.h> #include <fcntl.h> -#ifdef SVR4 -#include <sys/ucontext.h> -#endif /* SVR4 */ #ifdef HAVE_SYS_REG_H # include <sys/reg.h> @@ -66,7 +63,6 @@ #endif -#ifdef LINUX #ifdef IA64 # include <asm/ptrace_offsets.h> @@ -142,19 +138,7 @@ struct sigcontext #define NSIG 32 #endif -#endif /* LINUX */ - -#if defined(SUNOS4) || defined(FREEBSD) - -static const struct xlat sigvec_flags[] = { - { SV_ONSTACK, "SV_ONSTACK" }, - { SV_INTERRUPT, "SV_INTERRUPT" }, - { SV_RESETHAND, "SV_RESETHAND" }, - { SA_NOCLDSTOP, "SA_NOCLDSTOP" }, - { 0, NULL }, -}; -#endif /* SUNOS4 || FREEBSD */ #ifdef HAVE_SIGACTION @@ -279,14 +263,12 @@ signame(int sig) return buf; } -#ifndef UNIXWARE static void long_to_sigset(long l, sigset_t *s) { sigemptyset(s); *(long *)s = l; } -#endif static int copy_sigset_len(struct tcb *tcp, long addr, sigset_t *s, int len) @@ -299,12 +281,8 @@ copy_sigset_len(struct tcb *tcp, long addr, sigset_t *s, int len) return 0; } -#ifdef LINUX /* Original sigset is unsigned long */ #define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(long)) -#else -#define copy_sigset(tcp, addr, s) copy_sigset_len(tcp, addr, s, sizeof(sigset_t)) -#endif static const char * sprintsigmask(const char *str, sigset_t *mask, int rt) @@ -400,7 +378,6 @@ print_sigset(struct tcb *tcp, long addr, int rt) printsigmask(&ss, rt); } -#ifdef LINUX #ifndef ILL_ILLOPC #define ILL_ILLOPC 1 /* illegal opcode */ @@ -534,9 +511,7 @@ typedef struct siginfo #endif -#endif -#if defined (SVR4) || defined (LINUX) static const struct xlat siginfo_codes[] = { #ifdef SI_KERNEL @@ -733,7 +708,6 @@ printsiginfo(siginfo_t *sip, int verbose) tprintf(", si_value=%d", sip->si_int); break; #endif -#ifdef LINUX default: if (!sip->si_ptr) break; @@ -744,7 +718,6 @@ printsiginfo(siginfo_t *sip, int verbose) sip->si_int, (unsigned long) sip->si_ptr); break; -#endif } } else @@ -758,14 +731,12 @@ printsiginfo(siginfo_t *sip, int verbose) tprintf("%d", sip->si_status); else printsignal(sip->si_status); -#if LINUX if (!verbose) tprints(", ..."); else tprintf(", si_utime=%lu, si_stime=%lu", sip->si_utime, sip->si_stime); -#endif break; case SIGILL: case SIGFPE: case SIGSEGV: case SIGBUS: @@ -780,7 +751,6 @@ printsiginfo(siginfo_t *sip, int verbose) break; } break; -#ifdef LINUX default: if (sip->si_pid || sip->si_uid) tprintf(", si_pid=%lu, si_uid=%lu", @@ -795,7 +765,6 @@ printsiginfo(siginfo_t *sip, int verbose) sip->si_int, (unsigned long) sip->si_ptr); } -#endif } } @@ -803,99 +772,8 @@ printsiginfo(siginfo_t *sip, int verbose) tprints("}"); } -#endif /* SVR4 || LINUX */ - -#if defined(SUNOS4) || defined(FREEBSD) - -int -sys_sigvec(struct tcb *tcp) -{ - struct sigvec sv; - long addr; - - if (entering(tcp)) { - printsignal(tcp->u_arg[0]); - tprints(", "); - addr = tcp->u_arg[1]; - } else { - addr = tcp->u_arg[2]; - } - if (addr == 0) - tprints("NULL"); - else if (!verbose(tcp)) - tprintf("%#lx", addr); - else if (umove(tcp, addr, &sv) < 0) - tprints("{...}"); - else { - switch ((int) sv.sv_handler) { - case (int) SIG_ERR: - tprints("{SIG_ERR}"); - break; - case (int) SIG_DFL: - tprints("{SIG_DFL}"); - break; - case (int) SIG_IGN: - tprints("{SIG_IGN}"); - break; - case (int) SIG_HOLD: - tprints("{SIG_HOLD}"); - break; - default: - tprintf("{%#lx, ", (unsigned long) sv.sv_handler); - printsigmask(&sv.sv_mask, 0); - tprints(", "); - printflags(sigvec_flags, sv.sv_flags, "SV_???"); - tprints("}"); - } - } - if (entering(tcp)) - tprints(", "); - return 0; -} - -int -sys_sigpause(struct tcb *tcp) -{ - if (entering(tcp)) { /* WTA: UD had a bug here: he forgot the braces */ - sigset_t sigm; - long_to_sigset(tcp->u_arg[0], &sigm); - printsigmask(&sigm, 0); - } - return 0; -} -int -sys_sigstack(struct tcb *tcp) -{ - struct sigstack ss; - long addr; - if (entering(tcp)) - addr = tcp->u_arg[0]; - else - addr = tcp->u_arg[1]; - if (addr == 0) - tprints("NULL"); - else if (umove(tcp, addr, &ss) < 0) - tprintf("%#lx", addr); - else { - tprintf("{ss_sp %#lx ", (unsigned long) ss.ss_sp); - tprintf("ss_onstack %s}", ss.ss_onstack ? "YES" : "NO"); - } - if (entering(tcp)) - tprints(", "); - return 0; -} - -int -sys_sigcleanup(struct tcb *tcp) -{ - return 0; -} - -#endif /* SUNOS4 || FREEBSD */ - -#ifndef SVR4 int sys_sigsetmask(struct tcb *tcp) @@ -915,19 +793,10 @@ sys_sigsetmask(struct tcb *tcp) return 0; } -#if defined(SUNOS4) || defined(FREEBSD) -int -sys_sigblock(struct tcb *tcp) -{ - return sys_sigsetmask(tcp); -} -#endif /* SUNOS4 || FREEBSD */ -#endif /* !SVR4 */ #ifdef HAVE_SIGACTION -#ifdef LINUX struct old_sigaction { __sighandler_t __sa_handler; unsigned long sa_mask; @@ -935,7 +804,6 @@ struct old_sigaction { void (*sa_restorer)(void); }; #define SA_HANDLER __sa_handler -#endif /* LINUX */ #ifndef SA_HANDLER #define SA_HANDLER sa_handler @@ -945,12 +813,8 @@ int sys_sigaction(struct tcb *tcp) { long addr; -#ifdef LINUX sigset_t sigset; struct old_sigaction sa; -#else - struct sigaction sa; -#endif if (entering(tcp)) { @@ -982,12 +846,8 @@ sys_sigaction(struct tcb *tcp) tprints("{SIG_IGN, "); else tprintf("{%#lx, ", (long) sa.SA_HANDLER); -#ifndef LINUX - printsigmask(&sa.sa_mask, 0); -#else long_to_sigset(sa.sa_mask, &sigset); printsigmask(&sigset, 0); -#endif tprints(", "); printflags(sigact_flags, sa.sa_flags, "SA_???"); #ifdef SA_RESTORER @@ -998,10 +858,8 @@ sys_sigaction(struct tcb *tcp) } if (entering(tcp)) tprints(", "); -#ifdef LINUX else tprintf(", %#lx", (unsigned long) sa.sa_restorer); -#endif return 0; } @@ -1042,20 +900,9 @@ sys_signal(struct tcb *tcp) return 0; } -#ifdef SVR4 -int -sys_sighold(struct tcb *tcp) -{ - if (entering(tcp)) { - printsignal(tcp->u_arg[0]); - } - return 0; -} -#endif /* SVR4 */ #endif /* HAVE_SIGACTION */ -#ifdef LINUX int sys_sigreturn(struct tcb *tcp) @@ -1292,40 +1139,8 @@ sys_sigsuspend(struct tcb *tcp) return 0; } -#endif /* LINUX */ -#if defined(SVR4) || defined(FREEBSD) -int -sys_sigsuspend(struct tcb *tcp) -{ - sigset_t sigset; - - if (entering(tcp)) { - if (umove(tcp, tcp->u_arg[0], &sigset) < 0) - tprints("[?]"); - else - printsigmask(&sigset, 0); - } - return 0; -} -#ifndef FREEBSD -static const struct xlat ucontext_flags[] = { - { UC_SIGMASK, "UC_SIGMASK" }, - { UC_STACK, "UC_STACK" }, - { UC_CPU, "UC_CPU" }, -#ifdef UC_FPU - { UC_FPU, "UC_FPU" }, -#endif -#ifdef UC_INTR - { UC_INTR, "UC_INTR" }, -#endif - { 0, NULL }, -}; -#endif /* !FREEBSD */ -#endif /* SVR4 || FREEBSD */ - -#if defined SVR4 || defined LINUX || defined FREEBSD #if defined LINUX && !defined SS_ONSTACK #define SS_ONSTACK 1 #define SS_DISABLE 2 @@ -1338,82 +1153,14 @@ typedef struct } stack_t; #endif #endif -#ifdef FREEBSD -#define stack_t struct sigaltstack -#endif static const struct xlat sigaltstack_flags[] = { { SS_ONSTACK, "SS_ONSTACK" }, { SS_DISABLE, "SS_DISABLE" }, { 0, NULL }, }; -#endif -#ifdef SVR4 -static void -printcontext(struct tcb *tcp, ucontext_t *ucp) -{ - tprints("{"); - if (!abbrev(tcp)) { - tprints("uc_flags="); - printflags(ucontext_flags, ucp->uc_flags, "UC_???"); - tprintf(", uc_link=%#lx, ", (unsigned long) ucp->uc_link); - } - tprints("uc_sigmask="); - printsigmask(&ucp->uc_sigmask, 0); - if (!abbrev(tcp)) { - tprintf(", uc_stack={ss_sp=%#lx, ss_size=%d, ss_flags=", - (unsigned long) ucp->uc_stack.ss_sp, - ucp->uc_stack.ss_size); - printflags(sigaltstack_flags, ucp->uc_stack.ss_flags, "SS_???"); - tprints("}"); - } - tprints(", ...}"); -} -int -sys_getcontext(struct tcb *tcp) -{ - ucontext_t uc; - - if (exiting(tcp)) { - if (tcp->u_error) - tprintf("%#lx", tcp->u_arg[0]); - else if (!tcp->u_arg[0]) - tprints("NULL"); - else if (umove(tcp, tcp->u_arg[0], &uc) < 0) - tprints("{...}"); - else - printcontext(tcp, &uc); - } - return 0; -} - -int -sys_setcontext(struct tcb *tcp) -{ - ucontext_t uc; - - if (entering(tcp)) { - if (!tcp->u_arg[0]) - tprints("NULL"); - else if (umove(tcp, tcp->u_arg[0], &uc) < 0) - tprints("{...}"); - else - printcontext(tcp, &uc); - } - else { - tcp->u_rval = tcp->u_error = 0; - if (tcp->u_arg[0] == 0) - return 0; - return RVAL_NONE; - } - return 0; -} - -#endif /* SVR4 */ - -#if defined(LINUX) || defined(FREEBSD) static int print_stack_t(struct tcb *tcp, unsigned long addr) @@ -1445,7 +1192,6 @@ sys_sigaltstack(struct tcb *tcp) } return 0; } -#endif #ifdef HAVE_SIGACTION @@ -1464,11 +1210,6 @@ sys_sigprocmask(struct tcb *tcp) } #else /* !ALPHA */ if (entering(tcp)) { -#ifdef SVR4 - if (tcp->u_arg[0] == 0) - tprints("0"); - else -#endif /* SVR4 */ printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???"); tprints(", "); print_sigset(tcp, tcp->u_arg[1], 0); @@ -1503,15 +1244,7 @@ sys_kill(struct tcb *tcp) return 0; } -#if defined(FREEBSD) || defined(SUNOS4) -int -sys_killpg(struct tcb *tcp) -{ - return sys_kill(tcp); -} -#endif /* FREEBSD || SUNOS4 */ -#ifdef LINUX int sys_tgkill(struct tcb *tcp) { @@ -1521,7 +1254,6 @@ sys_tgkill(struct tcb *tcp) } return 0; } -#endif int sys_sigpending(struct tcb *tcp) @@ -1539,28 +1271,7 @@ sys_sigpending(struct tcb *tcp) return 0; } -#ifdef SVR4 -int sys_sigwait(struct tcb *tcp) -{ - sigset_t sigset; - - if (entering(tcp)) { - if (copy_sigset(tcp, tcp->u_arg[0], &sigset) < 0) - tprints("[?]"); - else - printsigmask(&sigset, 0); - } - else { - if (!syserror(tcp)) { - tcp->auxstr = signalent[tcp->u_rval]; - return RVAL_DECIMAL | RVAL_STR; - } - } - return 0; -} -#endif /* SVR4 */ -#ifdef LINUX int sys_rt_sigprocmask(struct tcb *tcp) @@ -1842,4 +1553,3 @@ sys_signalfd4(struct tcb *tcp) { return do_signalfd(tcp, 3); } -#endif /* LINUX */ @@ -29,13 +29,8 @@ #include "defs.h" -#ifdef LINUX #include <sys/socket.h> #include <linux/sockios.h> -#else -#include <sys/socket.h> -#include <sys/sockio.h> -#endif #include <arpa/inet.h> #if defined (ALPHA) || defined(SH) || defined(SH64) @@ -127,7 +122,6 @@ sock_ioctl(struct tcb *tcp, long code, long arg) #endif printnum(tcp, arg, ", %#d"); return 1; -#ifdef LINUX case SIOCGIFNAME: case SIOCSIFNAME: case SIOCGIFINDEX: @@ -286,7 +280,6 @@ sock_ioctl(struct tcb *tcp, long code, long arg) } tprints("}"); return 1; -#endif default: return 0; } @@ -47,7 +47,6 @@ #include <dirent.h> #include <sys/utsname.h> -#ifdef LINUX # include <asm/unistd.h> # if defined __NR_tkill # define my_tkill(tid, sig) syscall(__NR_tkill, (tid), (sig)) @@ -58,24 +57,12 @@ # warning "Neither tkill(2) nor tgkill(2) available, risk of strace hangs!" # define my_tkill(tid, sig) kill((tid), (sig)) # endif -#endif #if defined(IA64) && defined(LINUX) # include <asm/ptrace_offsets.h> #endif -#ifdef USE_PROCFS -#include <poll.h> -#endif -#ifdef SVR4 -#include <sys/stropts.h> -#ifdef HAVE_MP_PROCFS -#ifdef HAVE_SYS_UIO_H -#include <sys/uio.h> -#endif -#endif -#endif extern char **environ; extern int optind; extern char *optarg; @@ -166,35 +153,6 @@ static volatile sig_atomic_t interrupted; static volatile int interrupted; #endif -#ifdef USE_PROCFS - -static struct tcb *pfd2tcb(int pfd); -static void reaper(int sig); -static void rebuild_pollv(void); -static struct pollfd *pollv; - -#ifndef HAVE_POLLABLE_PROCFS - -static void proc_poll_open(void); -static void proc_poller(int pfd); - -struct proc_pollfd { - int fd; - int revents; - int pid; -}; - -static int poller_pid; -static int proc_poll_pipe[2] = { -1, -1 }; - -#endif /* !HAVE_POLLABLE_PROCFS */ - -#ifdef HAVE_MP_PROCFS -#define POLLWANT POLLWRNORM -#else -#define POLLWANT POLLPRI -#endif -#endif /* USE_PROCFS */ static void usage(FILE *ofp, int exitval) @@ -326,14 +284,6 @@ void die_out_of_memory(void) error_msg_and_die("Out of memory"); } -#ifdef SVR4 -#ifdef MIPS -void -foobar() -{ -} -#endif /* MIPS */ -#endif /* SVR4 */ /* Glue for systems without a MMU that cannot provide fork() */ #ifdef HAVE_FORK @@ -389,13 +339,11 @@ set_cloexec_flag(int fd) static void swap_uid(void) { -#ifndef SVR4 int euid = geteuid(), uid = getuid(); if (euid != uid && setreuid(euid, uid) < 0) { perror_msg_and_die("setreuid"); } -#endif } #if _LFS64_LARGEFILE @@ -522,14 +470,6 @@ startup_attach(void) tcp->outf = outf; newoutf(tcp); -#ifdef USE_PROCFS - if (proc_open(tcp, 1) < 0) { - fprintf(stderr, "trouble opening proc file\n"); - droptcb(tcp); - continue; - } -#else /* !USE_PROCFS */ -# ifdef LINUX if (followfork && !daemonized_tracer) { char procdir[sizeof("/proc/%d/task") + sizeof(int) * 3]; DIR *dir; @@ -592,7 +532,6 @@ startup_attach(void) continue; } /* if (opendir worked) */ } /* if (-f) */ -# endif /* LINUX */ if (ptrace_attach_or_seize(tcp->pid) < 0) { perror("attach: ptrace(PTRACE_ATTACH, ...)"); droptcb(tcp); @@ -615,7 +554,6 @@ startup_attach(void) kill(getppid(), SIGKILL); } -#endif /* !USE_PROCFS */ if (!qflag) fprintf(stderr, "Process %u attached - interrupt to quit\n", @@ -701,20 +639,6 @@ startup_child(char **argv) pid = getpid(); if (outf != stderr) close(fileno(outf)); -#ifdef USE_PROCFS -# ifdef MIPS - /* Kludge for SGI, see proc_open for details. */ - sa.sa_handler = foobar; - sa.sa_flags = 0; - sigemptyset(&sa.sa_mask); - sigaction(SIGINT, &sa, NULL); -# endif -# ifndef FREEBSD - pause(); -# else - kill(pid, SIGSTOP); -# endif -#else /* !USE_PROCFS */ if (!daemonized_tracer && !use_seize) { if (ptrace(PTRACE_TRACEME, 0L, 0L, 0L) < 0) { perror_msg_and_die("ptrace(PTRACE_TRACEME, ...)"); @@ -773,7 +697,6 @@ startup_child(char **argv) alarm(0); sigaction(SIGCHLD, &sv_sigchld, NULL); } -#endif /* !USE_PROCFS */ execv(pathname, argv); perror_msg_and_die("exec"); @@ -825,14 +748,8 @@ startup_child(char **argv) /* We want subsequent startup_attach() to attach to it: */ tcp->flags |= TCB_ATTACHED; } -#ifdef USE_PROCFS - if (proc_open(tcp, 0) < 0) { - perror_msg_and_die("trouble opening proc file"); - } -#endif } -#ifdef LINUX static void kill_save_errno(pid_t pid, int sig) { int saved_errno = errno; @@ -1090,7 +1007,6 @@ test_ptrace_seize(void) # define test_ptrace_seize() ((void)0) # endif -#endif /* Noinline: don't want main to have struct utsname permanently on stack */ static void __attribute__ ((noinline)) @@ -1138,9 +1054,7 @@ main(int argc, char *argv[]) qualify("signal=all"); while ((c = getopt(argc, argv, "+cCdfFhiqrtTvVxyz" -#ifndef USE_PROCFS "D" -#endif "a:e:o:O:p:s:S:u:E:P:I:")) != EOF) { switch (c) { case 'c': @@ -1158,11 +1072,9 @@ main(int argc, char *argv[]) case 'd': debug++; break; -#ifndef USE_PROCFS case 'D': daemonized_tracer = 1; break; -#endif case 'F': optF = 1; break; @@ -1308,12 +1220,10 @@ main(int argc, char *argv[]) run_gid = getgid(); } -#ifdef LINUX if (followfork) test_ptrace_setoptions_followfork(); test_ptrace_setoptions_for_all(); test_ptrace_seize(); -#endif /* Check if they want to redirect the output. */ if (outfname) { @@ -1382,10 +1292,6 @@ main(int argc, char *argv[]) sigaddset(&blocked_set, SIGPIPE); sigaddset(&blocked_set, SIGTERM); sa.sa_handler = interrupt; -#ifdef SUNOS4 - /* POSIX signals on sunos4.1 are a little broken. */ - sa.sa_flags = SA_INTERRUPT; -#endif } /* SIG_IGN, or set handler for these */ sigaction(SIGHUP, &sa, NULL); @@ -1394,10 +1300,6 @@ main(int argc, char *argv[]) sigaction(SIGPIPE, &sa, NULL); sigaction(SIGTERM, &sa, NULL); } -#ifdef USE_PROCFS - sa.sa_handler = reaper; - sigaction(SIGCHLD, &sa, NULL); -#else /* Make sure SIGCHLD has the default action so that waitpid definitely works without losing track of children. The user should not have given us a bogus state to inherit, but he might @@ -1405,7 +1307,6 @@ main(int argc, char *argv[]) to children, but probably noone really needs that. */ sa.sa_handler = SIG_DFL; sigaction(SIGCHLD, &sa, NULL); -#endif /* USE_PROCFS */ if (pflag_seen || daemonized_tracer) startup_attach(); @@ -1469,9 +1370,6 @@ alloc_tcb(int pid, int command_options_parsed) #if SUPPORTED_PERSONALITIES > 1 tcp->currpers = current_personality; #endif -#ifdef USE_PROCFS - tcp->pfd = -1; -#endif nprocs++; if (debug) fprintf(stderr, "new tcb for pid %d, active tcbs:%d\n", tcp->pid, nprocs); @@ -1483,292 +1381,6 @@ alloc_tcb(int pid, int command_options_parsed) error_msg_and_die("bug in alloc_tcb"); } -#ifdef USE_PROCFS -int -proc_open(struct tcb *tcp, int attaching) -{ - char proc[32]; - long arg; -#ifdef SVR4 - int i; - sysset_t syscalls; - sigset_t signals; - fltset_t faults; -#endif -#ifndef HAVE_POLLABLE_PROCFS - static int last_pfd; -#endif - -#ifdef HAVE_MP_PROCFS - /* Open the process pseudo-files in /proc. */ - sprintf(proc, "/proc/%d/ctl", tcp->pid); - tcp->pfd = open(proc, O_WRONLY|O_EXCL); - if (tcp->pfd < 0) { - perror("strace: open(\"/proc/...\", ...)"); - return -1; - } - set_cloexec_flag(tcp->pfd); - sprintf(proc, "/proc/%d/status", tcp->pid); - tcp->pfd_stat = open(proc, O_RDONLY|O_EXCL); - if (tcp->pfd_stat < 0) { - perror("strace: open(\"/proc/...\", ...)"); - return -1; - } - set_cloexec_flag(tcp->pfd_stat); - sprintf(proc, "/proc/%d/as", tcp->pid); - tcp->pfd_as = open(proc, O_RDONLY|O_EXCL); - if (tcp->pfd_as < 0) { - perror("strace: open(\"/proc/...\", ...)"); - return -1; - } - set_cloexec_flag(tcp->pfd_as); -#else - /* Open the process pseudo-file in /proc. */ -# ifndef FREEBSD - sprintf(proc, "/proc/%d", tcp->pid); - tcp->pfd = open(proc, O_RDWR|O_EXCL); -# else - sprintf(proc, "/proc/%d/mem", tcp->pid); - tcp->pfd = open(proc, O_RDWR); -# endif - if (tcp->pfd < 0) { - perror("strace: open(\"/proc/...\", ...)"); - return -1; - } - set_cloexec_flag(tcp->pfd); -#endif -#ifdef FREEBSD - sprintf(proc, "/proc/%d/regs", tcp->pid); - tcp->pfd_reg = open(proc, O_RDONLY); - if (tcp->pfd_reg < 0) { - perror("strace: open(\"/proc/.../regs\", ...)"); - return -1; - } - if (cflag) { - sprintf(proc, "/proc/%d/status", tcp->pid); - tcp->pfd_status = open(proc, O_RDONLY); - if (tcp->pfd_status < 0) { - perror("strace: open(\"/proc/.../status\", ...)"); - return -1; - } - } else - tcp->pfd_status = -1; -#endif /* FREEBSD */ - rebuild_pollv(); - if (!attaching) { - /* - * Wait for the child to pause. Because of a race - * condition we have to poll for the event. - */ - for (;;) { - if (IOCTL_STATUS(tcp) < 0) { - perror("strace: PIOCSTATUS"); - return -1; - } - if (tcp->status.PR_FLAGS & PR_ASLEEP) - break; - } - } -#ifndef FREEBSD - /* Stop the process so that we own the stop. */ - if (IOCTL(tcp->pfd, PIOCSTOP, (char *)NULL) < 0) { - perror("strace: PIOCSTOP"); - return -1; - } -#endif -#ifdef PIOCSET - /* Set Run-on-Last-Close. */ - arg = PR_RLC; - if (IOCTL(tcp->pfd, PIOCSET, &arg) < 0) { - perror("PIOCSET PR_RLC"); - return -1; - } - /* Set or Reset Inherit-on-Fork. */ - arg = PR_FORK; - if (IOCTL(tcp->pfd, followfork ? PIOCSET : PIOCRESET, &arg) < 0) { - perror("PIOC{SET,RESET} PR_FORK"); - return -1; - } -#else /* !PIOCSET */ -#ifndef FREEBSD - if (ioctl(tcp->pfd, PIOCSRLC) < 0) { - perror("PIOCSRLC"); - return -1; - } - if (ioctl(tcp->pfd, followfork ? PIOCSFORK : PIOCRFORK) < 0) { - perror("PIOC{S,R}FORK"); - return -1; - } -#else /* FREEBSD */ - /* just unset the PF_LINGER flag for the Run-on-Last-Close. */ - if (ioctl(tcp->pfd, PIOCGFL, &arg) < 0) { - perror("PIOCGFL"); - return -1; - } - arg &= ~PF_LINGER; - if (ioctl(tcp->pfd, PIOCSFL, arg) < 0) { - perror("PIOCSFL"); - return -1; - } -#endif /* FREEBSD */ -#endif /* !PIOCSET */ -#ifndef FREEBSD - /* Enable all syscall entries we care about. */ - premptyset(&syscalls); - for (i = 1; i < MAX_QUALS; ++i) { - if (i > (sizeof syscalls) * CHAR_BIT) break; - if (qual_flags[i] & QUAL_TRACE) praddset(&syscalls, i); - } - praddset(&syscalls, SYS_execve); - if (followfork) { - praddset(&syscalls, SYS_fork); -#ifdef SYS_forkall - praddset(&syscalls, SYS_forkall); -#endif -#ifdef SYS_fork1 - praddset(&syscalls, SYS_fork1); -#endif -#ifdef SYS_rfork1 - praddset(&syscalls, SYS_rfork1); -#endif -#ifdef SYS_rforkall - praddset(&syscalls, SYS_rforkall); -#endif - } - if (IOCTL(tcp->pfd, PIOCSENTRY, &syscalls) < 0) { - perror("PIOCSENTRY"); - return -1; - } - /* Enable the syscall exits. */ - if (IOCTL(tcp->pfd, PIOCSEXIT, &syscalls) < 0) { - perror("PIOSEXIT"); - return -1; - } - /* Enable signals we care about. */ - premptyset(&signals); - for (i = 1; i < MAX_QUALS; ++i) { - if (i > (sizeof signals) * CHAR_BIT) break; - if (qual_flags[i] & QUAL_SIGNAL) praddset(&signals, i); - } - if (IOCTL(tcp->pfd, PIOCSTRACE, &signals) < 0) { - perror("PIOCSTRACE"); - return -1; - } - /* Enable faults we care about */ - premptyset(&faults); - for (i = 1; i < MAX_QUALS; ++i) { - if (i > (sizeof faults) * CHAR_BIT) break; - if (qual_flags[i] & QUAL_FAULT) praddset(&faults, i); - } - if (IOCTL(tcp->pfd, PIOCSFAULT, &faults) < 0) { - perror("PIOCSFAULT"); - return -1; - } -#else /* FREEBSD */ - /* set events flags. */ - arg = S_SIG | S_SCE | S_SCX; - if (ioctl(tcp->pfd, PIOCBIS, arg) < 0) { - perror("PIOCBIS"); - return -1; - } -#endif /* FREEBSD */ - if (!attaching) { -#ifdef MIPS - /* - * The SGI PRSABORT doesn't work for pause() so - * we send it a caught signal to wake it up. - */ - kill(tcp->pid, SIGINT); -#else /* !MIPS */ -#ifdef PRSABORT - /* The child is in a pause(), abort it. */ - arg = PRSABORT; - if (IOCTL(tcp->pfd, PIOCRUN, &arg) < 0) { - perror("PIOCRUN"); - return -1; - } -#endif -#endif /* !MIPS*/ -#ifdef FREEBSD - /* wake up the child if it received the SIGSTOP */ - kill(tcp->pid, SIGCONT); -#endif - for (;;) { - /* Wait for the child to do something. */ - if (IOCTL_WSTOP(tcp) < 0) { - perror("PIOCWSTOP"); - return -1; - } - if (tcp->status.PR_WHY == PR_SYSENTRY) { - tcp->flags &= ~TCB_INSYSCALL; - get_scno(tcp); - if (SCNO_IN_RANGE(tcp->scno) && - sysent[tcp->scno].sys_func == sys_execve) - break; - } - /* Set it running: maybe execve will be next. */ -#ifndef FREEBSD - arg = 0; - if (IOCTL(tcp->pfd, PIOCRUN, &arg) < 0) -#else - if (IOCTL(tcp->pfd, PIOCRUN, 0) < 0) -#endif - { - perror("PIOCRUN"); - return -1; - } -#ifdef FREEBSD - /* handle the case where we "opened" the child before - it did the kill -STOP */ - if (tcp->status.PR_WHY == PR_SIGNALLED && - tcp->status.PR_WHAT == SIGSTOP) - kill(tcp->pid, SIGCONT); -#endif - } - } -#ifdef FREEBSD - else { - if (attaching < 2) { - /* We are attaching to an already running process. - * Try to figure out the state of the process in syscalls, - * to handle the first event well. - * This is done by having a look at the "wchan" property of the - * process, which tells where it is stopped (if it is). */ - FILE * status; - char wchan[20]; /* should be enough */ - - sprintf(proc, "/proc/%d/status", tcp->pid); - status = fopen(proc, "r"); - if (status && - (fscanf(status, "%*s %*d %*d %*d %*d %*d,%*d %*s %*d,%*d" - "%*d,%*d %*d,%*d %19s", wchan) == 1) && - strcmp(wchan, "nochan") && strcmp(wchan, "spread") && - strcmp(wchan, "stopevent")) { - /* The process is asleep in the middle of a syscall. - Fake the syscall entry event */ - tcp->flags &= ~(TCB_INSYSCALL|TCB_STARTUP); - tcp->status.PR_WHY = PR_SYSENTRY; - trace_syscall(tcp); - } - if (status) - fclose(status); - } /* otherwise it's a fork being followed */ - } -#endif /* FREEBSD */ -#ifndef HAVE_POLLABLE_PROCFS - if (proc_poll_pipe[0] != -1) - proc_poller(tcp->pfd); - else if (nprocs > 1) { - proc_poll_open(); - proc_poller(last_pfd); - proc_poller(tcp->pfd); - } - last_pfd = tcp->pfd; -#endif /* !HAVE_POLLABLE_PROCFS */ - return 0; -} - -#endif /* USE_PROCFS */ static struct tcb * pid2tcb(int pid) @@ -1787,37 +1399,6 @@ pid2tcb(int pid) return NULL; } -#ifdef USE_PROCFS - -static struct tcb * -first_used_tcb(void) -{ - int i; - struct tcb *tcp; - for (i = 0; i < tcbtabsize; i++) { - tcp = tcbtab[i]; - if (tcp->flags & TCB_INUSE) - return tcp; - } - return NULL; -} - -static struct tcb * -pfd2tcb(int pfd) -{ - int i; - - for (i = 0; i < tcbtabsize; i++) { - struct tcb *tcp = tcbtab[i]; - if (tcp->pfd != pfd) - continue; - if (tcp->flags & TCB_INUSE) - return tcp; - } - return NULL; -} - -#endif /* USE_PROCFS */ void droptcb(struct tcb *tcp) @@ -1829,24 +1410,6 @@ droptcb(struct tcb *tcp) if (debug) fprintf(stderr, "dropped tcb for pid %d, %d remain\n", tcp->pid, nprocs); -#ifdef USE_PROCFS - if (tcp->pfd != -1) { - close(tcp->pfd); - tcp->pfd = -1; -# ifdef FREEBSD - if (tcp->pfd_reg != -1) { - close(tcp->pfd_reg); - tcp->pfd_reg = -1; - } - if (tcp->pfd_status != -1) { - close(tcp->pfd_status); - tcp->pfd_status = -1; - } -# endif - tcp->flags = 0; /* rebuild_pollv needs it */ - rebuild_pollv(); - } -#endif if (outfname && followfork > 1 && tcp->outf) fclose(tcp->outf); @@ -1863,14 +1426,11 @@ static int detach(struct tcb *tcp) { int error = 0; -#ifdef LINUX int status, catch_sigstop; -#endif if (tcp->flags & TCB_BPTSET) clearbpt(tcp); -#ifdef LINUX /* * Linux wrongly insists the child be stopped * before detaching. Arghh. We go through hoops @@ -1949,12 +1509,7 @@ detach(struct tcb *tcp) break; } } -#endif /* LINUX */ -#if defined(SUNOS4) - /* PTRACE_DETACH won't respect `sig' argument, so we post it here. */ - error = ptrace_restart(PTRACE_DETACH, tcp, 0); -#endif /* SUNOS4 */ if (!qflag) fprintf(stderr, "Process %u detached\n", tcp->pid); @@ -1964,18 +1519,6 @@ detach(struct tcb *tcp) return error; } -#ifdef USE_PROCFS - -static void reaper(int sig) -{ - int pid; - int status; - - while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { - } -} - -#endif /* USE_PROCFS */ static void cleanup(void) @@ -2066,441 +1609,15 @@ strsignal(int sig) #endif /* HAVE_STRSIGNAL */ -#ifdef USE_PROCFS - -static void -rebuild_pollv(void) -{ - int i, j; - - free(pollv); - pollv = malloc(nprocs * sizeof(pollv[0])); - if (!pollv) - die_out_of_memory(); - - for (i = j = 0; i < tcbtabsize; i++) { - struct tcb *tcp = tcbtab[i]; - if (!(tcp->flags & TCB_INUSE)) - continue; - pollv[j].fd = tcp->pfd; - pollv[j].events = POLLWANT; - j++; - } - if (j != nprocs) { - error_msg_and_die("proc miscount"); - } -} - -#ifndef HAVE_POLLABLE_PROCFS - -static void -proc_poll_open(void) -{ - int i; - - if (pipe(proc_poll_pipe) < 0) { - perror_msg_and_die("pipe"); - } - for (i = 0; i < 2; i++) { - set_cloexec_flag(proc_poll_pipe[i]); - } -} - -static int -proc_poll(struct pollfd *pollv, int nfds, int timeout) -{ - int i; - int n; - struct proc_pollfd pollinfo; - - n = read(proc_poll_pipe[0], &pollinfo, sizeof(pollinfo)); - if (n < 0) - return n; - if (n != sizeof(struct proc_pollfd)) { - error_msg_and_die("panic: short read: %d", n); - } - for (i = 0; i < nprocs; i++) { - if (pollv[i].fd == pollinfo.fd) - pollv[i].revents = pollinfo.revents; - else - pollv[i].revents = 0; - } - poller_pid = pollinfo.pid; - return 1; -} - -static void -wakeup_handler(int sig) -{ -} - -static void -proc_poller(int pfd) -{ - struct proc_pollfd pollinfo; - struct sigaction sa; - sigset_t blocked_set, empty_set; - int i; - int n; - struct rlimit rl; -#ifdef FREEBSD - struct procfs_status pfs; -#endif /* FREEBSD */ - - switch (fork()) { - case -1: - perror_msg_and_die("fork"); - case 0: - break; - default: - return; - } - - sa.sa_handler = interactive ? SIG_DFL : SIG_IGN; - sa.sa_flags = 0; - sigemptyset(&sa.sa_mask); - sigaction(SIGHUP, &sa, NULL); - sigaction(SIGINT, &sa, NULL); - sigaction(SIGQUIT, &sa, NULL); - sigaction(SIGPIPE, &sa, NULL); - sigaction(SIGTERM, &sa, NULL); - sa.sa_handler = wakeup_handler; - sigaction(SIGUSR1, &sa, NULL); - sigemptyset(&blocked_set); - sigaddset(&blocked_set, SIGUSR1); - sigprocmask(SIG_BLOCK, &blocked_set, NULL); - sigemptyset(&empty_set); - - if (getrlimit(RLIMIT_NOFILE, &rl) < 0) { - perror_msg_and_die("getrlimit(RLIMIT_NOFILE, ...)"); - } - n = rl.rlim_cur; - for (i = 0; i < n; i++) { - if (i != pfd && i != proc_poll_pipe[1]) - close(i); - } - - pollinfo.fd = pfd; - pollinfo.pid = getpid(); - for (;;) { -#ifndef FREEBSD - if (ioctl(pfd, PIOCWSTOP, NULL) < 0) -#else - if (ioctl(pfd, PIOCWSTOP, &pfs) < 0) -#endif - { - switch (errno) { - case EINTR: - continue; - case EBADF: - pollinfo.revents = POLLERR; - break; - case ENOENT: - pollinfo.revents = POLLHUP; - break; - default: - perror("proc_poller: PIOCWSTOP"); - } - write(proc_poll_pipe[1], &pollinfo, sizeof(pollinfo)); - _exit(0); - } - pollinfo.revents = POLLWANT; - write(proc_poll_pipe[1], &pollinfo, sizeof(pollinfo)); - sigsuspend(&empty_set); - } -} - -#endif /* !HAVE_POLLABLE_PROCFS */ - -static int -choose_pfd() -{ - int i, j; - struct tcb *tcp; - - static int last; - - if (followfork < 2 && - last < nprocs && (pollv[last].revents & POLLWANT)) { - /* - * The previous process is ready to run again. We'll - * let it do so if it is currently in a syscall. This - * heuristic improves the readability of the trace. - */ - tcp = pfd2tcb(pollv[last].fd); - if (tcp && exiting(tcp)) - return pollv[last].fd; - } - - for (i = 0; i < nprocs; i++) { - /* Let competing children run round robin. */ - j = (i + last + 1) % nprocs; - if (pollv[j].revents & (POLLHUP | POLLERR)) { - tcp = pfd2tcb(pollv[j].fd); - if (!tcp) { - error_msg_and_die("lost proc"); - } - droptcb(tcp); - return -1; - } - if (pollv[j].revents & POLLWANT) { - last = j; - return pollv[j].fd; - } - } - error_msg_and_die("nothing ready"); -} static int trace(void) { -#ifdef POLL_HACK - struct tcb *in_syscall = NULL; -#endif - struct tcb *tcp; - int pfd; - int what; - int ioctl_result = 0, ioctl_errno = 0; - long arg; - - for (;;) { - if (interactive) - sigprocmask(SIG_SETMASK, &empty_set, NULL); - - if (nprocs == 0) - break; - - switch (nprocs) { - case 1: -#ifndef HAVE_POLLABLE_PROCFS - if (proc_poll_pipe[0] == -1) { -#endif - tcp = first_used_tcb(); - if (!tcp) - continue; - pfd = tcp->pfd; - if (pfd == -1) - continue; - break; -#ifndef HAVE_POLLABLE_PROCFS - } - /* fall through ... */ -#endif /* !HAVE_POLLABLE_PROCFS */ - default: -#ifdef HAVE_POLLABLE_PROCFS -#ifdef POLL_HACK - /* On some systems (e.g. UnixWare) we get too much ugly - "unfinished..." stuff when multiple proceses are in - syscalls. Here's a nasty hack */ - - if (in_syscall) { - struct pollfd pv; - tcp = in_syscall; - in_syscall = NULL; - pv.fd = tcp->pfd; - pv.events = POLLWANT; - what = poll(&pv, 1, 1); - if (what < 0) { - if (interrupted) - return 0; - continue; - } - else if (what == 1 && pv.revents & POLLWANT) { - goto FOUND; - } - } -#endif - - if (poll(pollv, nprocs, INFTIM) < 0) { - if (interrupted) - return 0; - continue; - } -#else /* !HAVE_POLLABLE_PROCFS */ - if (proc_poll(pollv, nprocs, INFTIM) < 0) { - if (interrupted) - return 0; - continue; - } -#endif /* !HAVE_POLLABLE_PROCFS */ - pfd = choose_pfd(); - if (pfd == -1) - continue; - break; - } - - /* Look up `pfd' in our table. */ - tcp = pfd2tcb(pfd); - if (tcp == NULL) { - error_msg_and_die("unknown pfd: %u", pfd); - } -#ifdef POLL_HACK - FOUND: -#endif - /* Get the status of the process. */ - if (!interrupted) { -#ifndef FREEBSD - ioctl_result = IOCTL_WSTOP(tcp); -#else /* FREEBSD */ - /* Thanks to some scheduling mystery, the first poller - sometimes waits for the already processed end of fork - event. Doing a non blocking poll here solves the problem. */ - if (proc_poll_pipe[0] != -1) - ioctl_result = IOCTL_STATUS(tcp); - else - ioctl_result = IOCTL_WSTOP(tcp); -#endif /* FREEBSD */ - ioctl_errno = errno; -#ifndef HAVE_POLLABLE_PROCFS - if (proc_poll_pipe[0] != -1) { - if (ioctl_result < 0) - kill(poller_pid, SIGKILL); - else - kill(poller_pid, SIGUSR1); - } -#endif /* !HAVE_POLLABLE_PROCFS */ - } - if (interrupted) - return 0; - - if (interactive) - sigprocmask(SIG_BLOCK, &blocked_set, NULL); - - if (ioctl_result < 0) { - /* Find out what happened if it failed. */ - switch (ioctl_errno) { - case EINTR: - case EBADF: - continue; -#ifdef FREEBSD - case ENOTTY: -#endif - case ENOENT: - droptcb(tcp); - continue; - default: - perror_msg_and_die("PIOCWSTOP"); - } - } - -#ifdef FREEBSD - if ((tcp->flags & TCB_STARTUP) && (tcp->status.PR_WHY == PR_SYSEXIT)) { - /* discard first event for a syscall we never entered */ - IOCTL(tcp->pfd, PIOCRUN, 0); - continue; - } -#endif - - /* clear the just started flag */ - tcp->flags &= ~TCB_STARTUP; - - /* set current output file */ - outf = tcp->outf; - curcol = tcp->curcol; - - if (cflag) { - struct timeval stime; -#ifdef FREEBSD - char buf[1024]; - int len; - - len = pread(tcp->pfd_status, buf, sizeof(buf) - 1, 0); - if (len > 0) { - buf[len] = '\0'; - sscanf(buf, - "%*s %*d %*d %*d %*d %*d,%*d %*s %*d,%*d %*d,%*d %ld,%ld", - &stime.tv_sec, &stime.tv_usec); - } else - stime.tv_sec = stime.tv_usec = 0; -#else /* !FREEBSD */ - stime.tv_sec = tcp->status.pr_stime.tv_sec; - stime.tv_usec = tcp->status.pr_stime.tv_nsec/1000; -#endif /* !FREEBSD */ - tv_sub(&tcp->dtime, &stime, &tcp->stime); - tcp->stime = stime; - } - what = tcp->status.PR_WHAT; - switch (tcp->status.PR_WHY) { -#ifndef FREEBSD - case PR_REQUESTED: - if (tcp->status.PR_FLAGS & PR_ASLEEP) { - tcp->status.PR_WHY = PR_SYSENTRY; - if (trace_syscall(tcp) < 0) { - error_msg_and_die("syscall trouble"); - } - } - break; -#endif /* !FREEBSD */ - case PR_SYSENTRY: -#ifdef POLL_HACK - in_syscall = tcp; -#endif - case PR_SYSEXIT: - if (trace_syscall(tcp) < 0) { - error_msg_and_die("syscall trouble"); - } - break; - case PR_SIGNALLED: - if (cflag != CFLAG_ONLY_STATS - && (qual_flags[what] & QUAL_SIGNAL)) { - printleader(tcp); - tprintf("--- %s (%s) ---\n", - signame(what), strsignal(what)); - printing_tcp = NULL; -#ifdef PR_INFO - if (tcp->status.PR_INFO.si_signo == what) { - printleader(tcp); - tprints(" siginfo="); - printsiginfo(&tcp->status.PR_INFO, 1); - tprints("\n"); - printing_tcp = NULL; - } -#endif - } - break; - case PR_FAULTED: - if (cflag != CFLAGS_ONLY_STATS - && (qual_flags[what] & QUAL_FAULT)) { - printleader(tcp); - tprintf("=== FAULT %d ===\n", what); - printing_tcp = NULL; - } - break; -#ifdef FREEBSD - case 0: /* handle case we polled for nothing */ - continue; -#endif - default: - error_msg_and_die("odd stop %d", tcp->status.PR_WHY); - break; - } - /* Remember current print column before continuing. */ - tcp->curcol = curcol; - arg = 0; -#ifndef FREEBSD - if (IOCTL(tcp->pfd, PIOCRUN, &arg) < 0) -#else - if (IOCTL(tcp->pfd, PIOCRUN, 0) < 0) -#endif - { - perror_msg_and_die("PIOCRUN"); - } - } - return 0; -} - -#else /* !USE_PROCFS */ - -static int -trace(void) -{ -#ifdef LINUX struct rusage ru; struct rusage *rup = cflag ? &ru : NULL; # ifdef __WALL static int wait4_options = __WALL; # endif -#endif /* LINUX */ while (nprocs != 0) { int pid; @@ -2514,7 +1631,6 @@ trace(void) return 0; if (interactive) sigprocmask(SIG_SETMASK, &empty_set, NULL); -#ifdef LINUX # ifdef __WALL pid = wait4(-1, &status, wait4_options, rup); if (pid < 0 && (wait4_options & __WALL) && errno == EINVAL) { @@ -2532,10 +1648,6 @@ trace(void) # else pid = wait4(-1, &status, 0, rup); # endif /* __WALL */ -#endif /* LINUX */ -#ifdef SUNOS4 - pid = wait(&status); -#endif wait_errno = errno; if (interactive) sigprocmask(SIG_BLOCK, &blocked_set, NULL); @@ -2567,7 +1679,6 @@ trace(void) event = ((unsigned)status >> 16); if (debug) { char buf[sizeof("WIFEXITED,exitcode=%u") + sizeof(int)*3 /*paranoia:*/ + 16]; -#ifdef LINUX if (event != 0) { static const char *const event_names[] = { [PTRACE_EVENT_CLONE] = "CLONE", @@ -2586,7 +1697,6 @@ trace(void) } fprintf(stderr, " PTRACE_EVENT_%s", e); } -#endif strcpy(buf, "???"); if (WIFSIGNALED(status)) #ifdef WCOREDUMP @@ -2611,7 +1721,6 @@ trace(void) /* Look up 'pid' in our table. */ tcp = pid2tcb(pid); -#ifdef LINUX /* Under Linux, execve changes pid to thread leader's pid, * and we see this changed pid on EVENT_EXEC and later, * execve sysexit. Leader "disappears" without exit @@ -2658,10 +1767,8 @@ trace(void) } } } -#endif if (tcp == NULL) { -#ifdef LINUX if (followfork) { /* This is needed to go with the CLONE_PTRACE changes in process.c/util.c: we might see @@ -2681,7 +1788,6 @@ trace(void) else /* This can happen if a clone call used CLONE_PTRACE itself. */ -#endif { if (WIFSTOPPED(status)) ptrace(PTRACE_CONT, pid, (char *) 1, 0); @@ -2691,12 +1797,10 @@ trace(void) /* set current output file */ outf = tcp->outf; curcol = tcp->curcol; -#ifdef LINUX if (cflag) { tv_sub(&tcp->dtime, &ru.ru_stime, &tcp->stime); tcp->stime = ru.ru_stime; } -#endif if (WIFSIGNALED(status)) { if (pid == strace_child) @@ -2757,7 +1861,6 @@ trace(void) return -1; } } -#ifdef LINUX if (ptrace_setoptions) { if (debug) fprintf(stderr, "setting opts %x on pid %d\n", ptrace_setoptions, tcp->pid); @@ -2768,7 +1871,6 @@ trace(void) } } } -#endif } sig = WSTOPSIG(status); @@ -2923,7 +2025,6 @@ trace(void) return 0; } -#endif /* !USE_PROCFS */ void tprintf(const char *fmt, ...) @@ -3019,23 +2120,3 @@ tabto(void) tprints(acolumn_spaces + curcol); } -#ifdef HAVE_MP_PROCFS - -int -mp_ioctl(int fd, int cmd, void *arg, int size) -{ - struct iovec iov[2]; - int n = 1; - - iov[0].iov_base = &cmd; - iov[0].iov_len = sizeof cmd; - if (arg) { - ++n; - iov[1].iov_base = arg; - iov[1].iov_len = size; - } - - return writev(fd, iov, n); -} - -#endif @@ -50,7 +50,6 @@ #include <sys/tihdr.h> #endif -#if defined(HAVE_SYS_STREAM_H) || defined(LINUX) || defined(FREEBSD) #ifndef HAVE_STROPTS_H #define RS_HIPRI 1 @@ -69,7 +68,6 @@ struct strbuf { #include <sys/timod.h> #endif /* HAVE_SYS_TIUSER_H */ -#ifndef FREEBSD static const struct xlat msgflags[] = { { RS_HIPRI, "RS_HIPRI" }, { 0, NULL }, @@ -257,7 +255,6 @@ sys_getpmsg(struct tcb *tcp) } #endif /* SYS_getpmsg */ -#endif /* !FREEBSD */ #ifdef HAVE_SYS_POLL_H @@ -434,7 +431,6 @@ sys_poll(struct tcb *tcp) return rc; } -#ifdef LINUX int sys_ppoll(struct tcb *tcp) { @@ -447,7 +443,6 @@ sys_ppoll(struct tcb *tcp) } return rc; } -#endif #else /* !HAVE_SYS_POLL_H */ int @@ -457,913 +452,4 @@ sys_poll(struct tcb *tcp) } #endif -#if !defined(LINUX) && !defined(FREEBSD) - -static const struct xlat stream_flush_options[] = { - { FLUSHR, "FLUSHR" }, - { FLUSHW, "FLUSHW" }, - { FLUSHRW, "FLUSHRW" }, -#ifdef FLUSHBAND - { FLUSHBAND, "FLUSHBAND" }, -#endif - { 0, NULL }, -}; - -static const struct xlat stream_setsig_flags[] = { - { S_INPUT, "S_INPUT" }, - { S_HIPRI, "S_HIPRI" }, - { S_OUTPUT, "S_OUTPUT" }, - { S_MSG, "S_MSG" }, -#ifdef S_ERROR - { S_ERROR, "S_ERROR" }, -#endif -#ifdef S_HANGUP - { S_HANGUP, "S_HANGUP" }, -#endif -#ifdef S_RDNORM - { S_RDNORM, "S_RDNORM" }, -#endif -#ifdef S_WRNORM - { S_WRNORM, "S_WRNORM" }, -#endif -#ifdef S_RDBAND - { S_RDBAND, "S_RDBAND" }, -#endif -#ifdef S_WRBAND - { S_WRBAND, "S_WRBAND" }, -#endif -#ifdef S_BANDURG - { S_BANDURG, "S_BANDURG" }, -#endif - { 0, NULL }, -}; - -static const struct xlat stream_read_options[] = { - { RNORM, "RNORM" }, - { RMSGD, "RMSGD" }, - { RMSGN, "RMSGN" }, - { 0, NULL }, -}; - -static const struct xlat stream_read_flags[] = { -#ifdef RPROTDAT - { RPROTDAT, "RPROTDAT" }, -#endif -#ifdef RPROTDIS - { RPROTDIS, "RPROTDIS" }, -#endif -#ifdef RPROTNORM - { RPROTNORM, "RPROTNORM" }, -#endif - { 0, NULL }, -}; - -#ifndef RMODEMASK -#define RMODEMASK (~0) -#endif - -#ifdef I_SWROPT -static const struct xlat stream_write_flags[] = { - { SNDZERO, "SNDZERO" }, - { SNDPIPE, "SNDPIPE" }, - { 0, NULL }, -}; -#endif /* I_SWROPT */ - -#ifdef I_ATMARK -static const struct xlat stream_atmark_options[] = { - { ANYMARK, "ANYMARK" }, - { LASTMARK, "LASTMARK" }, - { 0, NULL }, -}; -#endif /* I_ATMARK */ - -#ifdef TI_BIND -static const struct xlat transport_user_options[] = { - { T_CONN_REQ, "T_CONN_REQ" }, - { T_CONN_RES, "T_CONN_RES" }, - { T_DISCON_REQ, "T_DISCON_REQ" }, - { T_DATA_REQ, "T_DATA_REQ" }, - { T_EXDATA_REQ, "T_EXDATA_REQ" }, - { T_INFO_REQ, "T_INFO_REQ" }, - { T_BIND_REQ, "T_BIND_REQ" }, - { T_UNBIND_REQ, "T_UNBIND_REQ" }, - { T_UNITDATA_REQ,"T_UNITDATA_REQ"}, - { T_OPTMGMT_REQ,"T_OPTMGMT_REQ" }, - { T_ORDREL_REQ, "T_ORDREL_REQ" }, - { 0, NULL }, -}; - -static const struct xlat transport_user_flags[] = { - { 0, "0" }, - { T_MORE, "T_MORE" }, - { T_EXPEDITED, "T_EXPEDITED" }, - { T_NEGOTIATE, "T_NEGOTIATE" }, - { T_CHECK, "T_CHECK" }, - { T_DEFAULT, "T_DEFAULT" }, - { T_SUCCESS, "T_SUCCESS" }, - { T_FAILURE, "T_FAILURE" }, - { T_CURRENT, "T_CURRENT" }, - { T_PARTSUCCESS,"T_PARTSUCCESS" }, - { T_READONLY, "T_READONLY" }, - { T_NOTSUPPORT, "T_NOTSUPPORT" }, - { 0, NULL }, -}; - - -#ifdef HAVE_STRUCT_T_OPTHDR - -static const struct xlat xti_level[] = { - { XTI_GENERIC, "XTI_GENERIC" }, - { 0, NULL }, -}; - -static const struct xlat xti_generic[] = { - { XTI_DEBUG, "XTI_DEBUG" }, - { XTI_LINGER, "XTI_LINGER" }, - { XTI_RCVBUF, "XTI_RCVBUF" }, - { XTI_RCVLOWAT, "XTI_RCVLOWAT" }, - { XTI_SNDBUF, "XTI_SNDBUF" }, - { XTI_SNDLOWAT, "XTI_SNDLOWAT" }, - { 0, NULL }, -}; - - - -void -print_xti_optmgmt(struct tcb *tcp, long addr, int len) -{ - int c = 0; - struct t_opthdr hdr; - - while (len >= (int) sizeof hdr) { - if (umove(tcp, addr, &hdr) < 0) break; - if (c++) { - tprints(", "); - } - else if (len > hdr.len + sizeof hdr) { - tprints("["); - } - tprints("{level="); - printxval(xti_level, hdr.level, "???"); - tprints(", name="); - switch (hdr.level) { - case XTI_GENERIC: - printxval(xti_generic, hdr.name, "XTI_???"); - break; - default: - tprintf("%ld", hdr.name); - break; - } - tprints(", status="); - printxval(transport_user_flags, hdr.status, "T_???"); - addr += sizeof hdr; - len -= sizeof hdr; - if ((hdr.len -= sizeof hdr) > 0) { - if (hdr.len > len) break; - tprints(", val="); - if (len == sizeof(int)) - printnum(tcp, addr, "%d"); - else - printstr(tcp, addr, hdr.len); - addr += hdr.len; - len -= hdr.len; - } - tprints("}"); - } - if (len > 0) { - if (c++) tprints(", "); - printstr(tcp, addr, len); - } - if (c > 1) tprints("]"); -} - -#endif - - -static void -print_optmgmt(struct tcb *tcp, long addr, int len) -{ - /* We don't know how to tell if TLI (socket) or XTI - optmgmt is being used yet, assume TLI. */ -#if defined (HAVE_STRUCT_OPTHDR) - print_sock_optmgmt(tcp, addr, len); -#elif defined (HAVE_STRUCT_T_OPTHDR) - print_xti_optmgmt(tcp, addr, len); -#else - printstr(tcp, addr, len); -#endif -} - - - - -static const struct xlat service_type[] = { - { T_COTS, "T_COTS" }, - { T_COTS_ORD, "T_COTS_ORD" }, - { T_CLTS, "T_CLTS" }, - { 0, NULL }, -}; - -static const struct xlat ts_state[] = { - { TS_UNBND, "TS_UNBND" }, - { TS_WACK_BREQ, "TS_WACK_BREQ" }, - { TS_WACK_UREQ, "TS_WACK_UREQ" }, - { TS_IDLE, "TS_IDLE" }, - { TS_WACK_OPTREQ,"TS_WACK_OPTREQ"}, - { TS_WACK_CREQ, "TS_WACK_CREQ" }, - { TS_WCON_CREQ, "TS_WCON_CREQ" }, - { TS_WRES_CIND, "TS_WRES_CIND" }, - { TS_WACK_CRES, "TS_WACK_CRES" }, - { TS_DATA_XFER, "TS_DATA_XFER" }, - { TS_WIND_ORDREL,"TS_WIND_ORDREL"}, - { TS_WREQ_ORDREL,"TS_WREQ_ORDREL"}, - { TS_WACK_DREQ6,"TS_WACK_DREQ6" }, - { TS_WACK_DREQ7,"TS_WACK_DREQ7" }, - { TS_WACK_DREQ9,"TS_WACK_DREQ9" }, - { TS_WACK_DREQ10,"TS_WACK_DREQ10"}, - { TS_WACK_DREQ11,"TS_WACK_DREQ11"}, - { 0, NULL }, -}; - -static const struct xlat provider_flags[] = { - { 0, "0" }, - { SENDZERO, "SENDZERO" }, - { EXPINLINE, "EXPINLINE" }, - { XPG4_1, "XPG4_1" }, - { 0, NULL }, -}; - - -static const struct xlat tli_errors[] = { - { TBADADDR, "TBADADDR" }, - { TBADOPT, "TBADOPT" }, - { TACCES, "TACCES" }, - { TBADF, "TBADF" }, - { TNOADDR, "TNOADDR" }, - { TOUTSTATE, "TOUTSTATE" }, - { TBADSEQ, "TBADSEQ" }, - { TSYSERR, "TSYSERR" }, - { TLOOK, "TLOOK" }, - { TBADDATA, "TBADDATA" }, - { TBUFOVFLW, "TBUFOVFLW" }, - { TFLOW, "TFLOW" }, - { TNODATA, "TNODATA" }, - { TNODIS, "TNODIS" }, - { TNOUDERR, "TNOUDERR" }, - { TBADFLAG, "TBADFLAG" }, - { TNOREL, "TNOREL" }, - { TNOTSUPPORT, "TNOTSUPPORT" }, - { TSTATECHNG, "TSTATECHNG" }, - { TNOSTRUCTYPE, "TNOSTRUCTYPE" }, - { TBADNAME, "TBADNAME" }, - { TBADQLEN, "TBADQLEN" }, - { TADDRBUSY, "TADDRBUSY" }, - { TINDOUT, "TINDOUT" }, - { TPROVMISMATCH,"TPROVMISMATCH" }, - { TRESQLEN, "TRESQLEN" }, - { TRESADDR, "TRESADDR" }, - { TQFULL, "TQFULL" }, - { TPROTO, "TPROTO" }, - { 0, NULL }, -}; - - -static int -print_transport_message(struct tcb *tcp, int expect, long addr, int len) -{ - union T_primitives m; - int c = 0; - - if (len < sizeof m.type) goto dump; - - if (umove(tcp, addr, &m.type) < 0) goto dump; - -#define GET(type, struct) \ - do { \ - if (len < sizeof m.struct) goto dump; \ - if (umove(tcp, addr, &m.struct) < 0) goto dump; \ - tprints("{"); \ - if (expect != type) { \ - ++c; \ - tprints(#type); \ - } \ - } \ - while (0) - -#define COMMA() \ - do { if (c++) tprints(", "); } while (0) - - -#define STRUCT(struct, elem, print) \ - do { \ - COMMA(); \ - if (m.struct.elem##_length < 0 || \ - m.struct.elem##_offset < sizeof m.struct || \ - m.struct.elem##_offset + m.struct.elem##_length > len) \ - { \ - tprintf(#elem "_length=%ld, " #elem "_offset=%ld",\ - m.struct.elem##_length, \ - m.struct.elem##_offset); \ - } \ - else { \ - tprints(#elem "="); \ - print(tcp, \ - addr + m.struct.elem##_offset, \ - m.struct.elem##_length); \ - } \ - } \ - while (0) - -#define ADDR(struct, elem) STRUCT(struct, elem, printstr) - - switch (m.type) { -#ifdef T_CONN_REQ - case T_CONN_REQ: /* connect request */ - GET(T_CONN_REQ, conn_req); - ADDR(conn_req, DEST); - ADDR(conn_req, OPT); - break; -#endif -#ifdef T_CONN_RES - case T_CONN_RES: /* connect response */ - GET(T_CONN_RES, conn_res); -#ifdef HAVE_STRUCT_T_CONN_RES_QUEUE_PTR - COMMA(); - tprintf("QUEUE=%p", m.conn_res.QUEUE_ptr); -#elif defined HAVE_STRUCT_T_CONN_RES_ACCEPTOR_ID - COMMA(); - tprintf("ACCEPTOR=%#lx", m.conn_res.ACCEPTOR_id); -#endif - ADDR(conn_res, OPT); - COMMA(); - tprintf("SEQ=%ld", m.conn_res.SEQ_number); - break; -#endif -#ifdef T_DISCON_REQ - case T_DISCON_REQ: /* disconnect request */ - GET(T_DISCON_REQ, discon_req); - COMMA(); - tprintf("SEQ=%ld", m.discon_req.SEQ_number); - break; -#endif -#ifdef T_DATA_REQ - case T_DATA_REQ: /* data request */ - GET(T_DATA_REQ, data_req); - COMMA(); - tprintf("MORE=%ld", m.data_req.MORE_flag); - break; -#endif -#ifdef T_EXDATA_REQ - case T_EXDATA_REQ: /* expedited data req */ - GET(T_EXDATA_REQ, exdata_req); - COMMA(); - tprintf("MORE=%ld", m.exdata_req.MORE_flag); - break; -#endif -#ifdef T_INFO_REQ - case T_INFO_REQ: /* information req */ - GET(T_INFO_REQ, info_req); - break; -#endif -#ifdef T_BIND_REQ - case T_BIND_REQ: /* bind request */ -#ifdef O_T_BIND_REQ - case O_T_BIND_REQ: /* Ugly xti/tli hack */ -#endif - GET(T_BIND_REQ, bind_req); - ADDR(bind_req, ADDR); - COMMA(); - tprintf("CONIND=%ld", m.bind_req.CONIND_number); - break; -#endif -#ifdef T_UNBIND_REQ - case T_UNBIND_REQ: /* unbind request */ - GET(T_UNBIND_REQ, unbind_req); - break; -#endif -#ifdef T_UNITDATA_REQ - case T_UNITDATA_REQ: /* unitdata requset */ - GET(T_UNITDATA_REQ, unitdata_req); - ADDR(unitdata_req, DEST); - ADDR(unitdata_req, OPT); - break; -#endif -#ifdef T_OPTMGMT_REQ - case T_OPTMGMT_REQ: /* manage opt req */ - GET(T_OPTMGMT_REQ, optmgmt_req); - COMMA(); - tprints("MGMT="); - printflags(transport_user_flags, m.optmgmt_req.MGMT_flags, - "T_???"); - STRUCT(optmgmt_req, OPT, print_optmgmt); - break; -#endif -#ifdef T_ORDREL_REQ - case T_ORDREL_REQ: /* orderly rel req */ - GET(T_ORDREL_REQ, ordrel_req); - break; -#endif -#ifdef T_CONN_IND - case T_CONN_IND: /* connect indication */ - GET(T_CONN_IND, conn_ind); - ADDR(conn_ind, SRC); - ADDR(conn_ind, OPT); - tprintf(", SEQ=%ld", m.conn_ind.SEQ_number); - break; -#endif -#ifdef T_CONN_CON - case T_CONN_CON: /* connect corfirm */ - GET(T_CONN_CON, conn_con); - ADDR(conn_con, RES); - ADDR(conn_con, OPT); - break; -#endif -#ifdef T_DISCON_IND - case T_DISCON_IND: /* discon indication */ - GET(T_DISCON_IND, discon_ind); - COMMA(); - tprintf("DISCON=%ld, SEQ=%ld", - m.discon_ind.DISCON_reason, m.discon_ind.SEQ_number); - break; -#endif -#ifdef T_DATA_IND - case T_DATA_IND: /* data indication */ - GET(T_DATA_IND, data_ind); - COMMA(); - tprintf("MORE=%ld", m.data_ind.MORE_flag); - break; -#endif -#ifdef T_EXDATA_IND - case T_EXDATA_IND: /* expedited data ind */ - GET(T_EXDATA_IND, exdata_ind); - COMMA(); - tprintf("MORE=%ld", m.exdata_ind.MORE_flag); - break; -#endif -#ifdef T_INFO_ACK - case T_INFO_ACK: /* info ack */ - GET(T_INFO_ACK, info_ack); - COMMA(); - tprintf("TSDU=%ld, ETSDU=%ld, CDATA=%ld, DDATA=%ld, " - "ADDR=%ld, OPT=%ld, TIDU=%ld, SERV=", - m.info_ack.TSDU_size, m.info_ack.ETSDU_size, - m.info_ack.CDATA_size, m.info_ack.DDATA_size, - m.info_ack.ADDR_size, m.info_ack.OPT_size, - m.info_ack.TIDU_size); - printxval(service_type, m.info_ack.SERV_type, "T_???"); - tprints(", CURRENT="); - printxval(ts_state, m.info_ack.CURRENT_state, "TS_???"); - tprints(", PROVIDER="); - printflags(provider_flags, m.info_ack.PROVIDER_flag, "???"); - break; -#endif -#ifdef T_BIND_ACK - case T_BIND_ACK: /* bind ack */ - GET(T_BIND_ACK, bind_ack); - ADDR(bind_ack, ADDR); - tprintf(", CONIND=%ld", m.bind_ack.CONIND_number); - break; -#endif -#ifdef T_ERROR_ACK - case T_ERROR_ACK: /* error ack */ - GET(T_ERROR_ACK, error_ack); - COMMA(); - tprints("ERROR="); - printxval(transport_user_options, - m.error_ack.ERROR_prim, "TI_???"); - tprints(", TLI="); - printxval(tli_errors, m.error_ack.TLI_error, "T???"); - tprintf("UNIX=%s", strerror(m.error_ack.UNIX_error)); - break; -#endif -#ifdef T_OK_ACK - case T_OK_ACK: /* ok ack */ - GET(T_OK_ACK, ok_ack); - COMMA(); - tprints("CORRECT="); - printxval(transport_user_options, - m.ok_ack.CORRECT_prim, "TI_???"); - break; -#endif -#ifdef T_UNITDATA_IND - case T_UNITDATA_IND: /* unitdata ind */ - GET(T_UNITDATA_IND, unitdata_ind); - ADDR(unitdata_ind, SRC); - ADDR(unitdata_ind, OPT); - break; -#endif -#ifdef T_UDERROR_IND - case T_UDERROR_IND: /* unitdata error ind */ - GET(T_UDERROR_IND, uderror_ind); - ADDR(uderror_ind, DEST); - ADDR(uderror_ind, OPT); - tprintf(", ERROR=%ld", m.uderror_ind.ERROR_type); - break; -#endif -#ifdef T_OPTMGMT_ACK - case T_OPTMGMT_ACK: /* manage opt ack */ - GET(T_OPTMGMT_ACK, optmgmt_ack); - COMMA(); - tprints("MGMT="); - printflags(transport_user_flags, m.optmgmt_ack.MGMT_flags, - "T_???"); - STRUCT(optmgmt_ack, OPT, print_optmgmt); - break; -#endif -#ifdef T_ORDREL_IND - case T_ORDREL_IND: /* orderly rel ind */ - GET(T_ORDREL_IND, ordrel_ind); - break; -#endif -#ifdef T_ADDR_REQ - case T_ADDR_REQ: /* address req */ - GET(T_ADDR_REQ, addr_req); - break; -#endif -#ifdef T_ADDR_ACK - case T_ADDR_ACK: /* address response */ - GET(T_ADDR_ACK, addr_ack); - ADDR(addr_ack, LOCADDR); - ADDR(addr_ack, REMADDR); - break; -#endif - default: - dump: - c = -1; - printstr(tcp, addr, len); - break; - } - - if (c >= 0) tprints("}"); - -#undef ADDR -#undef COMMA -#undef STRUCT - - return 0; -} - - -#endif /* TI_BIND */ - - -static int internal_stream_ioctl(struct tcb *tcp, int arg) -{ - struct strioctl si; - struct ioctlent *iop; - int in_and_out; - int timod = 0; -#ifdef SI_GETUDATA - struct si_udata udata; -#endif /* SI_GETUDATA */ - - if (!arg) - return 0; - if (umove(tcp, arg, &si) < 0) { - if (entering(tcp)) - tprints(", {...}"); - return 1; - } - if (entering(tcp)) { - iop = ioctl_lookup(si.ic_cmd); - if (iop) { - tprintf(", {ic_cmd=%s", iop->symbol); - while ((iop = ioctl_next_match(iop))) - tprintf(" or %s", iop->symbol); - } else - tprintf(", {ic_cmd=%#x", si.ic_cmd); - if (si.ic_timout == INFTIM) - tprints(", ic_timout=INFTIM, "); - else - tprintf(" ic_timout=%d, ", si.ic_timout); - } - in_and_out = 1; - switch (si.ic_cmd) { -#ifdef SI_GETUDATA - case SI_GETUDATA: - in_and_out = 0; - break; -#endif /* SI_GETUDATA */ - } - if (in_and_out) { - if (entering(tcp)) - tprints("/* in */ "); - else - tprints(", /* out */ "); - } - if (in_and_out || entering(tcp)) - tprintf("ic_len=%d, ic_dp=", si.ic_len); - switch (si.ic_cmd) { -#ifdef TI_BIND - case TI_BIND: - /* in T_BIND_REQ, out T_BIND_ACK */ - ++timod; - if (entering(tcp)) { - print_transport_message(tcp, - T_BIND_REQ, - si.ic_dp, si.ic_len); - } - else { - print_transport_message(tcp, - T_BIND_ACK, - si.ic_dp, si.ic_len); - } - break; -#endif /* TI_BIND */ -#ifdef TI_UNBIND - case TI_UNBIND: - /* in T_UNBIND_REQ, out T_OK_ACK */ - ++timod; - if (entering(tcp)) { - print_transport_message(tcp, - T_UNBIND_REQ, - si.ic_dp, si.ic_len); - } - else { - print_transport_message(tcp, - T_OK_ACK, - si.ic_dp, si.ic_len); - } - break; -#endif /* TI_UNBIND */ -#ifdef TI_GETINFO - case TI_GETINFO: - /* in T_INFO_REQ, out T_INFO_ACK */ - ++timod; - if (entering(tcp)) { - print_transport_message(tcp, - T_INFO_REQ, - si.ic_dp, si.ic_len); - } - else { - print_transport_message(tcp, - T_INFO_ACK, - si.ic_dp, si.ic_len); - } - break; -#endif /* TI_GETINFO */ -#ifdef TI_OPTMGMT - case TI_OPTMGMT: - /* in T_OPTMGMT_REQ, out T_OPTMGMT_ACK */ - ++timod; - if (entering(tcp)) { - print_transport_message(tcp, - T_OPTMGMT_REQ, - si.ic_dp, si.ic_len); - } - else { - print_transport_message(tcp, - T_OPTMGMT_ACK, - si.ic_dp, si.ic_len); - } - break; -#endif /* TI_OPTMGMT */ -#ifdef SI_GETUDATA - case SI_GETUDATA: - if (entering(tcp)) - break; - if (umove(tcp, (int) si.ic_dp, &udata) < 0) - tprints("{...}"); - else { - tprintf("{tidusize=%d, addrsize=%d, ", - udata.tidusize, udata.addrsize); - tprintf("optsize=%d, etsdusize=%d, ", - udata.optsize, udata.etsdusize); - tprintf("servtype=%d, so_state=%d, ", - udata.servtype, udata.so_state); - tprintf("so_options=%d", udata.so_options); - tprints("}"); - } - break; -#endif /* SI_GETUDATA */ - default: - printstr(tcp, (long) si.ic_dp, si.ic_len); - break; - } - if (exiting(tcp)) { - tprints("}"); - if (timod && tcp->u_rval && !syserror(tcp)) { - tcp->auxstr = xlookup(tli_errors, tcp->u_rval); - return RVAL_STR + 1; - } - } - - return 1; -} - -int -stream_ioctl(struct tcb *tcp, int code, int arg) -{ -#ifdef I_LIST - int i; -#endif - int val; -#ifdef I_FLUSHBAND - struct bandinfo bi; -#endif - struct strpeek sp; - struct strfdinsert sfi; - struct strrecvfd srf; -#ifdef I_LIST - struct str_list sl; -#endif - - /* I_STR is a special case because the data is read & written. */ - if (code == I_STR) - return internal_stream_ioctl(tcp, arg); - if (entering(tcp)) - return 0; - - switch (code) { - case I_PUSH: - case I_LOOK: - case I_FIND: - /* arg is a string */ - tprints(", "); - printpath(tcp, arg); - return 1; - case I_POP: - /* doesn't take an argument */ - return 1; - case I_FLUSH: - /* argument is an option */ - tprints(", "); - printxval(stream_flush_options, arg, "FLUSH???"); - return 1; -#ifdef I_FLUSHBAND - case I_FLUSHBAND: - /* argument is a pointer to a bandinfo struct */ - if (umove(tcp, arg, &bi) < 0) - tprints(", {...}"); - else { - tprintf(", {bi_pri=%d, bi_flag=", bi.bi_pri); - printflags(stream_flush_options, bi.bi_flag, "FLUSH???"); - tprints("}"); - } - return 1; -#endif /* I_FLUSHBAND */ - case I_SETSIG: - /* argument is a set of flags */ - tprints(", "); - printflags(stream_setsig_flags, arg, "S_???"); - return 1; - case I_GETSIG: - /* argument is a pointer to a set of flags */ - if (syserror(tcp)) - return 0; - tprints(", ["); - if (umove(tcp, arg, &val) < 0) - tprints("?"); - else - printflags(stream_setsig_flags, val, "S_???"); - tprints("]"); - return 1; - case I_PEEK: - /* argument is a pointer to a strpeek structure */ - if (syserror(tcp) || !arg) - return 0; - if (umove(tcp, arg, &sp) < 0) { - tprints(", {...}"); - return 1; - } - tprints(", {ctlbuf="); - printstrbuf(tcp, &sp.ctlbuf, 1); - tprints(", databuf="); - printstrbuf(tcp, &sp.databuf, 1); - tprints(", flags="); - printflags(msgflags, sp.flags, "RS_???"); - tprints("}"); - return 1; - case I_SRDOPT: - /* argument is an option with flags */ - tprints(", "); - printxval(stream_read_options, arg & RMODEMASK, "R???"); - addflags(stream_read_flags, arg & ~RMODEMASK); - return 1; - case I_GRDOPT: - /* argument is an pointer to an option with flags */ - if (syserror(tcp)) - return 0; - tprints(", ["); - if (umove(tcp, arg, &val) < 0) - tprints("?"); - else { - printxval(stream_read_options, - arg & RMODEMASK, "R???"); - addflags(stream_read_flags, arg & ~RMODEMASK); - } - tprints("]"); - return 1; - case I_NREAD: -#ifdef I_GETBAND - case I_GETBAND: -#endif -#ifdef I_SETCLTIME - case I_SETCLTIME: -#endif -#ifdef I_GETCLTIME - case I_GETCLTIME: -#endif - /* argument is a pointer to a decimal integer */ - if (syserror(tcp)) - return 0; - tprints(", "); - printnum(tcp, arg, "%d"); - return 1; - case I_FDINSERT: - /* argument is a pointer to a strfdinsert structure */ - if (syserror(tcp) || !arg) - return 0; - if (umove(tcp, arg, &sfi) < 0) { - tprints(", {...}"); - return 1; - } - tprints(", {ctlbuf="); - printstrbuf(tcp, &sfi.ctlbuf, 1); - tprints(", databuf="); - printstrbuf(tcp, &sfi.databuf, 1); - tprints(", flags="); - printflags(msgflags, sfi.flags, "RS_???"); - tprintf(", filedes=%d, offset=%d}", sfi.fildes, sfi.offset); - return 1; -#ifdef I_SWROPT - case I_SWROPT: - /* argument is a set of flags */ - tprints(", "); - printflags(stream_write_flags, arg, "SND???"); - return 1; -#endif /* I_SWROPT */ -#ifdef I_GWROPT - case I_GWROPT: - /* argument is an pointer to an option with flags */ - if (syserror(tcp)) - return 0; - tprints(", ["); - if (umove(tcp, arg, &val) < 0) - tprints("?"); - else - printflags(stream_write_flags, arg, "SND???"); - tprints("]"); - return 1; -#endif /* I_GWROPT */ - case I_SENDFD: -#ifdef I_CKBAND - case I_CKBAND: -#endif -#ifdef I_CANPUT - case I_CANPUT: -#endif - case I_LINK: - case I_UNLINK: - case I_PLINK: - case I_PUNLINK: - /* argument is a decimal integer */ - tprintf(", %d", arg); - return 1; - case I_RECVFD: - /* argument is a pointer to a strrecvfd structure */ - if (syserror(tcp) || !arg) - return 0; - if (umove(tcp, arg, &srf) < 0) { - tprints(", {...}"); - return 1; - } - tprintf(", {fd=%d, uid=%lu, gid=%lu}", srf.fd, - (unsigned long) srf.uid, (unsigned long) srf.gid); - return 1; -#ifdef I_LIST - case I_LIST: - if (syserror(tcp)) - return 0; - if (arg == 0) { - tprints(", NULL"); - return 1; - } - if (umove(tcp, arg, &sl) < 0) { - tprints(", {...}"); - return 1; - } - tprintf(", {sl_nmods=%d, sl_modlist=[", sl.sl_nmods); - for (i = 0; i < tcp->u_rval; i++) { - if (i) - tprints(", "); - printpath(tcp, (int) sl.sl_modlist[i].l_name); - } - tprints("]}"); - return 1; -#endif /* I_LIST */ -#ifdef I_ATMARK - case I_ATMARK: - tprints(", "); - printxval(stream_atmark_options, arg, "???MARK"); - return 1; -#endif /* I_ATMARK */ - default: - return 0; - } -} - -#endif /* !LINUX && !FREEBSD */ -#endif /* HAVE_SYS_STREAM_H || LINUX || FREEBSD */ diff --git a/svr4/dummy.h b/svr4/dummy.h index 8c14c51..8273b1a 100644 --- a/svr4/dummy.h +++ b/svr4/dummy.h @@ -237,13 +237,6 @@ #define sys_fork1 sys_fork #define sys_forkall sys_fork #define sys_memcntl sys_mctl -#if UNIXWARE > 2 -#define sys_rfork1 sys_rfork -#define sys_rforkall sys_rfork -#ifndef HAVE_SYS_NSCSYS_H -#define sys_ssisys printargs -#endif -#endif /* aio */ #define sys_aionotify printargs diff --git a/svr4/syscall.h b/svr4/syscall.h index f366968..587e763 100644 --- a/svr4/syscall.h +++ b/svr4/syscall.h @@ -293,34 +293,6 @@ extern int sys_aclipc(); #ifdef HAVE_SYS_DOOR_H extern int sys_door(); #endif -#if UNIXWARE >= 2 -extern int sys_sigwait(); -extern int sys_truncate(); -extern int sys_ftruncate(); -extern int sys_getksym(); -extern int sys_procpriv(); -#endif -#if UNIXWARE >= 7 -extern int sys_lseek64(); -extern int sys_truncate64(); -extern int sys_ftruncate64(); -extern int sys_xsocket(); -extern int sys_xsocketpair(); -extern int sys_xbind(); -extern int sys_xconnect(); -extern int sys_xlisten(); -extern int sys_xaccept(); -extern int sys_xrecvmsg(); -extern int sys_xsendmsg(); -extern int sys_xgetsockaddr(); -extern int sys_xsetsockaddr(); -extern int sys_xgetsockopt(); -extern int sys_xsetsockopt(); -extern int sys_xshutdown(); -extern int sys_rfork(); -extern int sys_ssisys(); -extern int sys_rexecve(); -#endif #endif /* !MIPS */ #ifdef MIPS diff --git a/svr4/syscallent.h b/svr4/syscallent.h index 3addb35..1c9cefb 100644 --- a/svr4/syscallent.h +++ b/svr4/syscallent.h @@ -328,11 +328,7 @@ { MA, 0, sys_fstatvfs, "fstatvfs" }, /* 104 */ { MA, 0, printargs, "SYS_105" }, /* 105 */ { MA, 0, sys_nfssys, "nfssys" }, /* 106 */ -#if UNIXWARE - { MA, TP, sys_waitsys, "waitsys" }, /* 107 */ -#else { MA, TP, sys_waitid, "waitid" }, /* 107 */ -#endif { MA, 0, sys_sigsendsys, "sigsendsys" }, /* 108 */ { MA, 0, sys_hrtsys, "hrtsys" }, /* 109 */ { MA, 0, sys_acancel, "acancel" }, /* 110 */ @@ -366,159 +362,6 @@ { MA, 0, sys_adjtime, "adjtime" }, /* 138 */ { MA, 0, sys_sysinfo, "sysinfo" }, /* 139 */ { MA, 0, printargs, "SYS_140" }, /* 140 */ -#if UNIXWARE >= 2 - { MA, 0, sys_seteuid, "seteuid" }, /* 141 */ - { MA, 0, printargs, "SYS_142" }, /* 142 */ - { MA, 0, sys_keyctl, "keyctl" }, /* 143 */ - { MA, 0, sys_secsys, "secsys" }, /* 144 */ - { MA, 0, sys_filepriv, "filepriv" }, /* 145 */ - { MA, 0, sys_procpriv, "procpriv" }, /* 146 */ - { MA, 0, sys_devstat, "devstat" }, /* 147 */ - { MA, 0, sys_aclipc, "aclipc" }, /* 148 */ - { MA, 0, sys_fdevstat, "fdevstat" }, /* 149 */ - { MA, 0, sys_flvlfile, "flvlfile" }, /* 150 */ - { MA, 0, sys_lvlfile, "lvlfile" }, /* 151 */ - { MA, 0, printargs, "SYS_152" }, /* 152 */ - { MA, 0, sys_lvlequal, "lvlequal" }, /* 153 */ - { MA, 0, sys_lvlproc, "lvlproc" }, /* 154 */ - { MA, 0, printargs, "SYS_155" }, /* 155 */ - { MA, 0, sys_lvlipc, "lvlipc" }, /* 156 */ - { MA, 0, sys_acl, "acl" }, /* 157 */ - { MA, 0, sys_auditevt, "auditevt" }, /* 158 */ - { MA, 0, sys_auditctl, "auditctl" }, /* 159 */ - { MA, 0, sys_auditdmp, "auditdmp" }, /* 160 */ - { MA, 0, sys_auditlog, "auditlog" }, /* 161 */ - { MA, 0, sys_auditbuf, "auditbuf" }, /* 162 */ - { MA, 0, sys_lvldom, "lvldom" }, /* 163 */ - { MA, 0, sys_lvlvfs, "lvlvfs" }, /* 164 */ - { MA, 0, sys_mkmld, "mkmld" }, /* 165 */ - { MA, 0, sys_mldmode, "mldmode" }, /* 166 */ - { MA, 0, sys_secadvise, "secadvise" }, /* 167 */ - { MA, 0, sys_online, "online" }, /* 168 */ - { MA, 0, sys_setitimer, "setitimer" }, /* 169 */ - { MA, 0, sys_getitimer, "getitimer" }, /* 170 */ - { MA, 0, sys_gettimeofday, "gettimeofday" }, /* 171 */ - { MA, 0, sys_settimeofday, "settimeofday" }, /* 172 */ - { MA, 0, sys_lwp_create, "lwpcreate" }, /* 173 */ - { MA, 0, sys_lwp_exit, "lwpexit" }, /* 174 */ - { MA, 0, sys_lwp_wait, "lwpwait" }, /* 175 */ - { MA, 0, sys_lwp_self, "lwpself" }, /* 176 */ - { MA, 0, sys_lwpinfo, "lwpinfo" }, /* 177 */ - { MA, 0, sys_lwpprivate, "lwpprivate" }, /* 178 */ - { MA, 0, sys_processor_bind, "processor_bind"}, /* 179 */ - { MA, 0, sys_processor_exbind, "processor_exbind"}, /* 180 */ - { MA, 0, printargs, "SYS_181" }, /* 181 */ - { MA, 0, printargs, "SYS_182" }, /* 182 */ - { MA, 0, sys_prepblock, "prepblock" }, /* 183 */ - { MA, 0, sys_block, "block" }, /* 184 */ - { MA, 0, sys_rdblock, "rdblock" }, /* 185 */ - { MA, 0, sys_unblock, "unblock" }, /* 186 */ - { MA, 0, sys_cancelblock, "cancelblock" }, /* 187 */ - { MA, 0, printargs, "SYS_188" }, /* 188 */ - { MA, TD, sys_pread, "pread" }, /* 189 */ - { MA, TD, sys_pwrite, "pwrite" }, /* 190 */ - { MA, TF, sys_truncate, "truncate" }, /* 191 */ - { MA, TD, sys_ftruncate, "ftruncate" }, /* 192 */ - { MA, 0, sys_lwpkill, "lwpkill" }, /* 193 */ - { MA, 0, sys_sigwait, "sigwait" }, /* 194 */ - { MA, 0, sys_fork1, "fork1" }, /* 195 */ - { MA, 0, sys_forkall, "forkall" }, /* 196 */ - { MA, 0, sys_modload, "modload" }, /* 197 */ - { MA, 0, sys_moduload, "moduload" }, /* 198 */ - { MA, 0, sys_modpath, "modpath" }, /* 199 */ - { MA, 0, sys_modstat, "modstat" }, /* 200 */ - { MA, 0, sys_modadm, "modadm" }, /* 201 */ - { MA, 0, sys_getksym, "getksym" }, /* 202 */ - { MA, 0, sys_lwpsuspend, "lwpsuspend" }, /* 203 */ - { MA, 0, sys_lwpcontinue, "lwpcontinue" }, /* 204 */ - { MA, 0, sys_priocntllst, "priocntllst" }, /* 205 */ - { MA, 0, sys_sleep, "sleep" }, /* 206 */ - { MA, 0, sys_lwp_sema_wait, "lwp_sema_wait" }, /* 207 */ - { MA, 0, sys_lwp_sema_post, "lwp_sema_post" }, /* 208 */ - { MA, 0, sys_lwp_sema_trywait, "lwp_sema_trywait"}, /* 209 */ - { MA, 0, printargs, "SYS_210" }, /* 210 */ - { MA, 0, printargs, "SYS_211" }, /* 211 */ - { MA, 0, printargs, "SYS_212" }, /* 212 */ - { MA, 0, printargs, "SYS_213" }, /* 213 */ - { MA, 0, printargs, "SYS_214" }, /* 214 */ - { MA, 0, printargs, "SYS_215" }, /* 215 */ -#if UNIXWARE >= 7 - { MA, 0, sys_fstatvfs64, "fstatvfs64" }, /* 216 */ - { MA, TF, sys_statvfs64, "statvfs64" }, /* 217 */ - { MA, TD, sys_ftruncate64, "ftruncate64" }, /* 218 */ - { MA, TF, sys_truncate64, "truncate64" }, /* 219 */ - { MA, 0, sys_getrlimit64, "getrlimit64" }, /* 220 */ - { MA, 0, sys_setrlimit64, "setrlimit64" }, /* 221 */ - { MA, TF, sys_lseek64, "lseek64" }, /* 222 */ - { MA, TF, sys_mmap64, "mmap64" }, /* 223 */ - { MA, TF, sys_pread64, "pread64" }, /* 224 */ - { MA, TF, sys_pwrite64, "pwrite64" }, /* 225 */ - { MA, TD|TF, sys_creat64, "creat64" }, /* 226 */ - { MA, 0, sys_dshmsys, "dshmsys" }, /* 227 */ - { MA, 0, sys_invlpg, "invlpg" }, /* 228 */ - { MA, 0, sys_rfork1, "rfork1" }, /* 229 */ - { MA, 0, sys_rforkall, "rforkall" }, /* 230 */ - { MA, 0, sys_rexecve, "rexecve" }, /* 231 */ - { MA, 0, sys_migrate, "migrate" }, /* 232 */ - { MA, 0, sys_kill3, "kill3" }, /* 233 */ - { MA, 0, sys_ssisys, "ssisys" }, /* 234 */ - { MA, TN, sys_xaccept, "xaccept" }, /* 235 */ - { MA, TN, sys_xbind, "xbind" }, /* 236 */ - { MA, TN, sys_xbindresvport, "xbindresvport" }, /* 237 */ - { MA, TN, sys_xconnect, "xconnect" }, /* 238 */ - { MA, TN, sys_xgetsockaddr, "xgetsockaddr" }, /* 239 */ - { MA, TN, sys_xgetsockopt, "xgetsockopt" }, /* 240 */ - { MA, TN, sys_xlisten, "xlisten" }, /* 241 */ - { MA, TN, sys_xrecvmsg, "xrecvmsg" }, /* 242 */ - { MA, TN, sys_xsendmsg, "xsendmsg" }, /* 243 */ - { MA, TN, sys_xsetsockaddr, "xsetsockaddr" }, /* 244 */ - { MA, TN, sys_xsetsockopt, "xsetsockopt" }, /* 245 */ - { MA, TN, sys_xshutdown, "xshutdown" }, /* 246 */ - { MA, TN, sys_xsocket, "xsocket" }, /* 247 */ - { MA, TN, sys_xsocketpair, "xsocketpair" }, /* 248 */ -#else /* UNIXWARE 2 */ - { MA, 0, printargs, "SYS_216" }, /* 216 */ - { MA, 0, printargs, "SYS_217" }, /* 217 */ - { MA, 0, printargs, "SYS_218" }, /* 218 */ - { MA, 0, printargs, "SYS_219" }, /* 219 */ - { MA, 0, printargs, "SYS_220" }, /* 220 */ - { MA, 0, printargs, "SYS_221" }, /* 221 */ - { MA, 0, printargs, "SYS_222" }, /* 222 */ - { MA, 0, printargs, "SYS_223" }, /* 223 */ - { MA, 0, printargs, "SYS_224" }, /* 224 */ - { MA, 0, printargs, "SYS_225" }, /* 225 */ - { MA, 0, printargs, "SYS_226" }, /* 226 */ - { MA, 0, printargs, "SYS_227" }, /* 227 */ - { MA, 0, printargs, "SYS_228" }, /* 228 */ - { MA, 0, printargs, "SYS_229" }, /* 229 */ - { MA, 0, printargs, "SYS_230" }, /* 230 */ - { MA, 0, printargs, "SYS_231" }, /* 231 */ - { MA, 0, printargs, "SYS_232" }, /* 232 */ - { MA, 0, printargs, "SYS_233" }, /* 233 */ - { MA, 0, printargs, "SYS_234" }, /* 234 */ - { MA, 0, printargs, "SYS_235" }, /* 235 */ - { MA, 0, printargs, "SYS_236" }, /* 236 */ - { MA, 0, printargs, "SYS_237" }, /* 237 */ - { MA, 0, printargs, "SYS_238" }, /* 238 */ - { MA, 0, printargs, "SYS_239" }, /* 239 */ - { MA, 0, printargs, "SYS_240" }, /* 240 */ - { MA, 0, printargs, "SYS_241" }, /* 241 */ - { MA, 0, printargs, "SYS_242" }, /* 242 */ - { MA, 0, printargs, "SYS_243" }, /* 243 */ - { MA, 0, printargs, "SYS_244" }, /* 244 */ - { MA, 0, printargs, "SYS_245" }, /* 245 */ - { MA, 0, printargs, "SYS_246" }, /* 246 */ - { MA, 0, printargs, "SYS_247" }, /* 247 */ - { MA, 0, printargs, "SYS_248" }, /* 248 */ -#endif /* UNIXWARE 2 */ - { MA, 0, printargs, "SYS_249" }, /* 249 */ - { MA, 0, printargs, "SYS_250" }, /* 250 */ - { MA, 0, printargs, "SYS_251" }, /* 251 */ - { MA, 0, printargs, "SYS_252" }, /* 252 */ - { MA, 0, printargs, "SYS_253" }, /* 253 */ - { MA, 0, printargs, "SYS_254" }, /* 254 */ - { MA, 0, printargs, "SYS_255" }, /* 255 */ -#else /* !UNIXWARE */ { MA, 0, sys_seteuid, "seteuid" }, /* 141 */ { MA, 0, sys_vtrace, "vtrace" }, /* 142 */ { MA, TP, sys_fork1, "fork1" }, /* 143 */ @@ -646,7 +489,6 @@ { MA, 0, printargs, "cladm" }, /* 253 */ { MA, 0, printargs, "lwp_sig_timedwait" }, /* 254 */ { MA, 0, printargs, "umount2" }, /* 255 */ -#endif /* !UNIXWARE */ #endif /* !MIPS */ { MA, 0, printargs, "SYS_256" }, /* 256 */ { MA, 0, printargs, "SYS_257" }, /* 257 */ @@ -72,7 +72,6 @@ # include <asm/rse.h> #endif -#ifdef LINUX #ifndef ERESTARTSYS #define ERESTARTSYS 512 #endif @@ -97,7 +96,6 @@ #undef NSIG #define NSIG 32 #endif -#endif /* LINUX */ #include "syscall.h" @@ -523,27 +521,7 @@ qualify(const char *s) return; } -#ifndef FREEBSD enum subcall_style { shift_style, deref_style, mask_style, door_style }; -#else /* FREEBSD */ -enum subcall_style { shift_style, deref_style, mask_style, door_style, table_style }; - -struct subcall { - int call; - int nsubcalls; - int subcalls[5]; -}; - -static const struct subcall subcalls_table[] = { - { SYS_shmsys, 5, { SYS_shmat, SYS_shmctl, SYS_shmdt, SYS_shmget, SYS_shmctl } }, -#ifdef SYS_semconfig - { SYS_semsys, 4, { SYS___semctl, SYS_semget, SYS_semop, SYS_semconfig } }, -#else - { SYS_semsys, 3, { SYS___semctl, SYS_semget, SYS_semop } }, -#endif - { SYS_msgsys, 4, { SYS_msgctl, SYS_msgget, SYS_msgsnd, SYS_msgrcv } }, -}; -#endif /* FREEBSD */ #if !(defined(LINUX) && ( defined(ALPHA) || defined(MIPS) || defined(__ARM_EABI__) )) @@ -607,18 +585,6 @@ decode_subcall(struct tcb *tcp, int subcall, int nsubcalls, enum subcall_style s tcp->scno = subcall + tcp->u_arg[5]; tcp->u_nargs = sysent[tcp->scno].nargs; break; -#ifdef FREEBSD - case table_style: - for (i = 0; i < ARRAY_SIZE(subcalls_table); i++) - if (subcalls_table[i].call == tcp->scno) break; - if (i < ARRAY_SIZE(subcalls_table) && - tcp->u_arg[0] >= 0 && tcp->u_arg[0] < subcalls_table[i].nsubcalls) { - tcp->scno = subcalls_table[i].subcalls[tcp->u_arg[0]]; - for (i = 0; i < tcp->u_nargs; i++) - tcp->u_arg[i] = tcp->u_arg[i + 1]; - } - break; -#endif /* FREEBSD */ } } #endif @@ -640,7 +606,6 @@ getrval2(struct tcb *tcp) { long val = -1; -#ifdef LINUX #if defined (SPARC) || defined (SPARC64) struct pt_regs regs; if (ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) @@ -653,66 +618,16 @@ getrval2(struct tcb *tcp) if (upeek(tcp, PT_R9, &val) < 0) return -1; #endif -#endif /* LINUX */ -#ifdef SUNOS4 - if (upeek(tcp, uoff(u_rval2), &val) < 0) - return -1; -#endif /* SUNOS4 */ - -#ifdef SVR4 -#ifdef SPARC - val = tcp->status.PR_REG[R_O1]; -#endif /* SPARC */ -#ifdef I386 - val = tcp->status.PR_REG[EDX]; -#endif /* I386 */ -#ifdef X86_64 - val = tcp->status.PR_REG[RDX]; -#endif /* X86_64 */ -#ifdef MIPS - val = tcp->status.PR_REG[CTX_V1]; -#endif /* MIPS */ -#endif /* SVR4 */ - -#ifdef FREEBSD - struct reg regs; - pread(tcp->pfd_reg, ®s, sizeof(regs), 0); - val = regs.r_edx; -#endif - return val; -} -#ifdef SUNOS4 -/* - * Apparently, indirect system calls have already be converted by ptrace(2), - * so if you see "indir" this program has gone astray. - */ -int -sys_indir(struct tcb *tcp) -{ - int i, nargs; - long scno; - if (entering(tcp)) { - scno = tcp->u_arg[0]; - if (!SCNO_IN_RANGE(scno)) { - fprintf(stderr, "Bogus syscall: %ld\n", scno); - return 0; - } - nargs = sysent[scno].nargs; - tprints(sysent[scno].sys_name); - for (i = 0; i < nargs; i++) - tprintf(", %#lx", tcp->u_arg[i+1]); - } - return 0; + return val; } -#endif /* SUNOS4 */ + int is_restart_error(struct tcb *tcp) { -#ifdef LINUX switch (tcp->u_error) { case ERESTARTSYS: case ERESTARTNOINTR: @@ -722,11 +637,9 @@ is_restart_error(struct tcb *tcp) default: break; } -#endif /* LINUX */ return 0; } -#ifdef LINUX # if defined(I386) struct pt_regs i386_regs; # elif defined(X86_64) @@ -777,10 +690,6 @@ static long r10; # elif defined(MICROBLAZE) static long r3; # endif -#endif /* LINUX */ -#ifdef FREEBSD -struct reg regs; /* TODO: make static? */ -#endif /* FREEBSD */ /* Returns: * 0: "ignore this ptrace stop", bail out of trace_syscall() silently. @@ -788,15 +697,12 @@ struct reg regs; /* TODO: make static? */ * other: error, trace_syscall() should print error indicator * ("????" etc) and bail out. */ -#ifndef USE_PROCFS static -#endif int get_scno(struct tcb *tcp) { long scno = 0; -#ifdef LINUX # if defined(S390) || defined(S390X) if (upeek(tcp, PT_GPR2, &syscall_mode) < 0) return -1; @@ -1180,12 +1086,8 @@ get_scno(struct tcb *tcp) if (upeek(tcp, 0, &scno) < 0) return -1; # endif -#endif /* LINUX */ -#ifdef SUNOS4 - if (upeek(tcp, uoff(u_arg[7]), &scno) < 0) - return -1; -#elif defined(SH) +#if defined(SH) /* new syscall ABI returns result in R0 */ if (upeek(tcp, 4*REG_REG0, (long *)&r0) < 0) return -1; @@ -1195,29 +1097,6 @@ get_scno(struct tcb *tcp) return -1; #endif -#ifdef USE_PROCFS -# ifdef HAVE_PR_SYSCALL - scno = tcp->status.PR_SYSCALL; -# else -# ifndef FREEBSD - scno = tcp->status.PR_WHAT; -# else - if (pread(tcp->pfd_reg, ®s, sizeof(regs), 0) < 0) { - perror("pread"); - return -1; - } - switch (regs.r_eax) { - case SYS_syscall: - case SYS___syscall: - pread(tcp->pfd, &scno, sizeof(scno), regs.r_esp + sizeof(int)); - break; - default: - scno = regs.r_eax; - break; - } -# endif /* FREEBSD */ -# endif /* !HAVE_PR_SYSCALL */ -#endif /* USE_PROCFS */ tcp->scno = scno; return 1; @@ -1233,48 +1112,8 @@ get_scno(struct tcb *tcp) static int syscall_fixup_on_sysenter(struct tcb *tcp) { -#ifdef USE_PROCFS - int scno = tcp->scno; - - if (tcp->status.PR_WHY != PR_SYSENTRY) { - if ( - scno == SYS_fork -#ifdef SYS_vfork - || scno == SYS_vfork -#endif -#ifdef SYS_fork1 - || scno == SYS_fork1 -#endif -#ifdef SYS_forkall - || scno == SYS_forkall -#endif -#ifdef SYS_rfork1 - || scno == SYS_rfork1 -#endif -#ifdef SYS_rforkall - || scno == SYS_rforkall -#endif - ) { - /* We are returning in the child, fake it. */ - tcp->status.PR_WHY = PR_SYSENTRY; - trace_syscall(tcp); - tcp->status.PR_WHY = PR_SYSEXIT; - } - else { - fprintf(stderr, "syscall: missing entry\n"); - tcp->flags |= TCB_INSYSCALL; - } - } -#endif /* USE_PROCFS */ -#ifdef SUNOS4 - if (scno == 0) { - fprintf(stderr, "syscall: missing entry\n"); - tcp->flags |= TCB_INSYSCALL; - } -#endif -#ifdef LINUX /* A common case of "not a syscall entry" is post-execve SIGTRAP */ #if defined (I386) if (i386_regs.eax != -ENOSYS) { @@ -1343,7 +1182,6 @@ syscall_fixup_on_sysenter(struct tcb *tcp) return 0; } #endif -#endif /* LINUX */ return 1; } @@ -1363,15 +1201,8 @@ internal_syscall(struct tcb *tcp) func = sysent[tcp->scno].sys_func; if ( sys_fork == func -#if defined(FREEBSD) || defined(LINUX) || defined(SUNOS4) || sys_vfork == func -#endif -#ifdef LINUX || sys_clone == func -#endif -#if UNIXWARE > 2 - || sys_rfork == func -#endif ) return internal_fork(tcp); @@ -1380,9 +1211,6 @@ internal_syscall(struct tcb *tcp) # if defined(SPARC) || defined(SPARC64) || defined(SUNOS4) || sys_execv == func # endif -# if UNIXWARE > 2 - || sys_rexecve == func -# endif ) return internal_exec(tcp); #endif @@ -1393,7 +1221,6 @@ internal_syscall(struct tcb *tcp) static int syscall_enter(struct tcb *tcp) { -#ifdef LINUX int i, nargs; if (SCNO_IN_RANGE(tcp->scno)) @@ -1583,96 +1410,6 @@ syscall_enter(struct tcb *tcp) if (upeek(tcp, i*4, &tcp->u_arg[i]) < 0) return -1; # endif -#endif /* LINUX */ -#ifdef SUNOS4 - int i, nargs; - if (SCNO_IN_RANGE(tcp->scno)) - nargs = tcp->u_nargs = sysent[tcp->scno].nargs; - else - nargs = tcp->u_nargs = MAX_ARGS; - for (i = 0; i < nargs; i++) { - struct user *u; - - if (upeek(tcp, uoff(u_arg[0]) + - (i * sizeof(u->u_arg[0])), &tcp->u_arg[i]) < 0) - return -1; - } -#endif /* SUNOS4 */ -#ifdef SVR4 -# ifdef MIPS - /* - * SGI is broken: even though it has pr_sysarg, it doesn't - * set them on system call entry. Get a clue. - */ - if (SCNO_IN_RANGE(tcp->scno)) - tcp->u_nargs = sysent[tcp->scno].nargs; - else - tcp->u_nargs = tcp->status.pr_nsysarg; - if (tcp->u_nargs > 4) { - memcpy(tcp->u_arg, &tcp->status.pr_reg[CTX_A0], - 4 * sizeof(tcp->u_arg[0])); - umoven(tcp, tcp->status.pr_reg[CTX_SP] + 16, - (tcp->u_nargs - 4) * sizeof(tcp->u_arg[0]), (char *) (tcp->u_arg + 4)); - } - else { - memcpy(tcp->u_arg, &tcp->status.pr_reg[CTX_A0], - tcp->u_nargs * sizeof(tcp->u_arg[0])); - } -# elif UNIXWARE >= 2 - /* - * Like SGI, UnixWare doesn't set pr_sysarg until system call exit - */ - if (SCNO_IN_RANGE(tcp->scno)) - tcp->u_nargs = sysent[tcp->scno].nargs; - else - tcp->u_nargs = tcp->status.pr_lwp.pr_nsysarg; - umoven(tcp, tcp->status.PR_REG[UESP] + 4, - tcp->u_nargs * sizeof(tcp->u_arg[0]), (char *) tcp->u_arg); -# elif defined(HAVE_PR_SYSCALL) - int i; - if (SCNO_IN_RANGE(tcp->scno)) - tcp->u_nargs = sysent[tcp->scno].nargs; - else - tcp->u_nargs = tcp->status.pr_nsysarg; - for (i = 0; i < tcp->u_nargs; i++) - tcp->u_arg[i] = tcp->status.pr_sysarg[i]; -# elif defined(I386) - if (SCNO_IN_RANGE(tcp->scno)) - tcp->u_nargs = sysent[tcp->scno].nargs; - else - tcp->u_nargs = 5; - if (tcp->u_nargs > 0) - umoven(tcp, tcp->status.PR_REG[UESP] + 4, - tcp->u_nargs * sizeof(tcp->u_arg[0]), (char *) tcp->u_arg); -# else - I DONT KNOW WHAT TO DO -# endif -#endif /* SVR4 */ -#ifdef FREEBSD - if (SCNO_IN_RANGE(tcp->scno) && - sysent[tcp->scno].nargs > tcp->status.val) - tcp->u_nargs = sysent[tcp->scno].nargs; - else - tcp->u_nargs = tcp->status.val; - if (tcp->u_nargs < 0) - tcp->u_nargs = 0; - if (tcp->u_nargs > MAX_ARGS) - tcp->u_nargs = MAX_ARGS; - switch (regs.r_eax) { - case SYS___syscall: - pread(tcp->pfd, &tcp->u_arg, tcp->u_nargs * sizeof(unsigned long), - regs.r_esp + sizeof(int) + sizeof(quad_t)); - break; - case SYS_syscall: - pread(tcp->pfd, &tcp->u_arg, tcp->u_nargs * sizeof(unsigned long), - regs.r_esp + 2 * sizeof(int)); - break; - default: - pread(tcp->pfd, &tcp->u_arg, tcp->u_nargs * sizeof(unsigned long), - regs.r_esp + sizeof(int)); - break; - } -#endif /* FREEBSD */ return 1; } @@ -1737,83 +1474,6 @@ trace_syscall_entering(struct tcb *tcp) } #endif /* SYS_socket_subcall || SYS_ipc_subcall */ -#if defined(SVR4) || defined(FREEBSD) || defined(SUNOS4) - switch (tcp->scno) { -#ifdef SVR4 -#ifdef SYS_pgrpsys_subcall - case SYS_pgrpsys: - decode_subcall(tcp, SYS_pgrpsys_subcall, - SYS_pgrpsys_nsubcalls, shift_style); - break; -#endif /* SYS_pgrpsys_subcall */ -#ifdef SYS_sigcall_subcall - case SYS_sigcall: - decode_subcall(tcp, SYS_sigcall_subcall, - SYS_sigcall_nsubcalls, mask_style); - break; -#endif /* SYS_sigcall_subcall */ - case SYS_msgsys: - decode_subcall(tcp, SYS_msgsys_subcall, - SYS_msgsys_nsubcalls, shift_style); - break; - case SYS_shmsys: - decode_subcall(tcp, SYS_shmsys_subcall, - SYS_shmsys_nsubcalls, shift_style); - break; - case SYS_semsys: - decode_subcall(tcp, SYS_semsys_subcall, - SYS_semsys_nsubcalls, shift_style); - break; - case SYS_sysfs: - decode_subcall(tcp, SYS_sysfs_subcall, - SYS_sysfs_nsubcalls, shift_style); - break; - case SYS_spcall: - decode_subcall(tcp, SYS_spcall_subcall, - SYS_spcall_nsubcalls, shift_style); - break; -#ifdef SYS_context_subcall - case SYS_context: - decode_subcall(tcp, SYS_context_subcall, - SYS_context_nsubcalls, shift_style); - break; -#endif /* SYS_context_subcall */ -#ifdef SYS_door_subcall - case SYS_door: - decode_subcall(tcp, SYS_door_subcall, - SYS_door_nsubcalls, door_style); - break; -#endif /* SYS_door_subcall */ -#ifdef SYS_kaio_subcall - case SYS_kaio: - decode_subcall(tcp, SYS_kaio_subcall, - SYS_kaio_nsubcalls, shift_style); - break; -#endif -#endif /* SVR4 */ -#ifdef FREEBSD - case SYS_msgsys: - case SYS_shmsys: - case SYS_semsys: - decode_subcall(tcp, 0, 0, table_style); - break; -#endif -#ifdef SUNOS4 - case SYS_semsys: - decode_subcall(tcp, SYS_semsys_subcall, - SYS_semsys_nsubcalls, shift_style); - break; - case SYS_msgsys: - decode_subcall(tcp, SYS_msgsys_subcall, - SYS_msgsys_nsubcalls, shift_style); - break; - case SYS_shmsys: - decode_subcall(tcp, SYS_shmsys_subcall, - SYS_shmsys_nsubcalls, shift_style); - break; -#endif - } -#endif /* SVR4 || FREEBSD || SUNOS4 */ internal_syscall(tcp); @@ -1863,7 +1523,6 @@ trace_syscall_entering(struct tcb *tcp) static int get_syscall_result(struct tcb *tcp) { -#ifdef LINUX # if defined(S390) || defined(S390X) if (upeek(tcp, PT_GPR2, &gpr2) < 0) return -1; @@ -1940,10 +1599,8 @@ get_syscall_result(struct tcb *tcp) if (upeek(tcp, 3 * 4, &r3) < 0) return -1; # endif -#endif /* LINUX */ -#ifdef SUNOS4 -#elif defined(SH) +#if defined(SH) /* new syscall ABI returns result in R0 */ if (upeek(tcp, 4*REG_REG0, (long *)&r0) < 0) return -1; @@ -1953,16 +1610,6 @@ get_syscall_result(struct tcb *tcp) return -1; #endif -#ifdef USE_PROCFS -# ifndef HAVE_PR_SYSCALL -# ifdef FREEBSD - if (pread(tcp->pfd_reg, ®s, sizeof(regs), 0) < 0) { - perror("pread"); - return -1; - } -# endif /* FREEBSD */ -# endif /* !HAVE_PR_SYSCALL */ -#endif /* USE_PROCFS */ return 1; } @@ -1977,31 +1624,8 @@ get_syscall_result(struct tcb *tcp) static int syscall_fixup_on_sysexit(struct tcb *tcp) { -#ifdef USE_PROCFS - if (tcp->status.PR_WHY != PR_SYSEXIT) { - fprintf(stderr, "syscall: missing exit\n"); - tcp->flags &= ~TCB_INSYSCALL; - } -#endif /* USE_PROCFS */ -#ifdef SUNOS4 - { - int scno = tcp->scno; - if (scno != 0) { - if (debug) { - /* - * This happens when a signal handler - * for a signal which interrupted a - * a system call makes another system call. - */ - fprintf(stderr, "syscall: missing exit\n"); - } - tcp->flags &= ~TCB_INSYSCALL; - } - } -#endif /* SUNOS4 */ -#ifdef LINUX # if defined (S390) || defined (S390X) if (syscall_mode != -ENOSYS) syscall_mode = tcp->scno; @@ -2015,11 +1639,9 @@ syscall_fixup_on_sysexit(struct tcb *tcp) gpr2 = 0; } # endif -#endif /* LINUX */ return 1; } -#ifdef LINUX /* * Check the syscall return value register value for whether it is * a negated errno code indicating an error, or a success return value. @@ -2036,13 +1658,11 @@ is_negated_errno(unsigned long int val) # endif return val > max; } -#endif static int get_error(struct tcb *tcp) { int u_error = 0; -#ifdef LINUX int check_errno = 1; if (SCNO_IN_RANGE(tcp->scno) && sysent[tcp->scno].sys_flags & SYSCALL_NEVER_FAILS) { @@ -2214,71 +1834,6 @@ get_error(struct tcb *tcp) tcp->u_rval = r3; } # endif -#endif /* LINUX */ -#ifdef SUNOS4 - /* get error code from user struct */ - if (upeek(tcp, uoff(u_error), &u_error) < 0) - return -1; - u_error >>= 24; /* u_error is a char */ - - /* get system call return value */ - if (upeek(tcp, uoff(u_rval1), &tcp->u_rval) < 0) - return -1; -#endif /* SUNOS4 */ -#ifdef SVR4 -# ifdef SPARC - /* Judicious guessing goes a long way. */ - if (tcp->status.pr_reg[R_PSR] & 0x100000) { - tcp->u_rval = -1; - u_error = tcp->status.pr_reg[R_O0]; - } - else { - tcp->u_rval = tcp->status.pr_reg[R_O0]; - } -# endif /* SPARC */ -# ifdef I386 - if (tcp->status.PR_REG[EFL] & 0x1) { - tcp->u_rval = -1; - u_error = tcp->status.PR_REG[EAX]; - } - else { - tcp->u_rval = tcp->status.PR_REG[EAX]; -# ifdef HAVE_LONG_LONG - tcp->u_lrval = - ((unsigned long long) tcp->status.PR_REG[EDX] << 32) + - tcp->status.PR_REG[EAX]; -# endif - } -# endif /* I386 */ -# ifdef X86_64 - if (tcp->status.PR_REG[EFLAGS] & 0x1) { - tcp->u_rval = -1; - u_error = tcp->status.PR_REG[RAX]; - } - else { - tcp->u_rval = tcp->status.PR_REG[RAX]; - } -# endif /* X86_64 */ -# ifdef MIPS - if (tcp->status.pr_reg[CTX_A3]) { - tcp->u_rval = -1; - u_error = tcp->status.pr_reg[CTX_V0]; - } - else { - tcp->u_rval = tcp->status.pr_reg[CTX_V0]; - } -# endif /* MIPS */ -#endif /* SVR4 */ -#ifdef FREEBSD - if (regs.r_eflags & PSL_C) { - tcp->u_rval = -1; - u_error = regs.r_eax; - } else { - tcp->u_rval = regs.r_eax; - tcp->u_lrval = - ((unsigned long long) regs.r_edx << 32) + regs.r_eax; - } -#endif /* FREEBSD */ tcp->u_error = u_error; return 1; } @@ -2297,11 +1852,6 @@ dumpio(struct tcb *tcp) if (qual_flags[tcp->u_arg[0]] & QUAL_READ) { if (sysent[tcp->scno].sys_func == sys_read || sysent[tcp->scno].sys_func == sys_pread || -#ifdef SVR4 -#if _LFS64_LARGEFILE - sysent[tcp->scno].sys_func == sys_pread64 || -#endif -#endif sysent[tcp->scno].sys_func == sys_recv || sysent[tcp->scno].sys_func == sys_recvfrom) dumpstr(tcp, tcp->u_arg[1], tcp->u_rval); @@ -2312,11 +1862,6 @@ dumpio(struct tcb *tcp) if (qual_flags[tcp->u_arg[0]] & QUAL_WRITE) { if (sysent[tcp->scno].sys_func == sys_write || sysent[tcp->scno].sys_func == sys_pwrite || -#ifdef SVR4 -#if _LFS64_LARGEFILE - sysent[tcp->scno].sys_func == sys_pwrite64 || -#endif -#endif sysent[tcp->scno].sys_func == sys_send || sysent[tcp->scno].sys_func == sys_sendto) dumpstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); @@ -2413,7 +1958,6 @@ trace_syscall_exiting(struct tcb *tcp) } else if (!(sys_res & RVAL_NONE) && u_error) { switch (u_error) { -#ifdef LINUX /* Blocked signals do not interrupt any syscalls. * In this case syscalls don't return ERESTARTfoo codes. * @@ -2466,7 +2010,6 @@ trace_syscall_exiting(struct tcb *tcp) */ tprints("= ? ERESTART_RESTARTBLOCK (Interrupted by signal)"); break; -#endif /* LINUX */ default: if (u_error < 0) tprintf("= -1 E??? (errno %ld)", u_error); @@ -32,7 +32,6 @@ #include "defs.h" -#ifdef LINUX #define _LINUX_SOCKET_H #define _LINUX_FS_H @@ -382,1143 +381,9 @@ sys_cacheflush(struct tcb *tcp) } #endif /* SH */ -#endif /* LINUX */ -#ifdef SUNOS4 -#include <sys/reboot.h> -#define NFSCLIENT -#define LOFS -#define RFS -#define PCFS -#include <sys/mount.h> -#include <sys/socket.h> -#include <nfs/export.h> -#include <rpc/types.h> -#include <rpc/auth.h> - -/*ARGSUSED*/ -int -sys_sync(struct tcb *tcp) -{ - return 0; -} - -static const struct xlat bootflags[] = { - { RB_AUTOBOOT, "RB_AUTOBOOT" }, /* for system auto-booting itself */ - { RB_ASKNAME, "RB_ASKNAME" }, /* ask for file name to reboot from */ - { RB_SINGLE, "RB_SINGLE" }, /* reboot to single user only */ - { RB_NOSYNC, "RB_NOSYNC" }, /* dont sync before reboot */ - { RB_HALT, "RB_HALT" }, /* don't reboot, just halt */ - { RB_INITNAME, "RB_INITNAME" }, /* name given for /etc/init */ - { RB_NOBOOTRC, "RB_NOBOOTRC" }, /* don't run /etc/rc.boot */ - { RB_DEBUG, "RB_DEBUG" }, /* being run under debugger */ - { RB_DUMP, "RB_DUMP" }, /* dump system core */ - { RB_WRITABLE, "RB_WRITABLE" }, /* mount root read/write */ - { RB_STRING, "RB_STRING" }, /* pass boot args to prom monitor */ - { 0, NULL }, -}; - -int -sys_reboot(struct tcb *tcp) -{ - if (entering(tcp)) { - printflags(bootflags, tcp->u_arg[0], "RB_???"); - if (tcp->u_arg[0] & RB_STRING) { - printstr(tcp, tcp->u_arg[1], -1); - } - } - return 0; -} - -int -sys_sysacct(struct tcb *tcp) -{ - if (entering(tcp)) { - printstr(tcp, tcp->u_arg[0], -1); - } - return 0; -} - -int -sys_swapon(struct tcb *tcp) -{ - if (entering(tcp)) { - printstr(tcp, tcp->u_arg[0], -1); - } - return 0; -} - -int -sys_nfs_svc(struct tcb *tcp) -{ - if (entering(tcp)) { - printsock(tcp, tcp->u_arg[0]); - } - return 0; -} - -static const struct xlat mountflags[] = { - { M_RDONLY, "M_RDONLY" }, - { M_NOSUID, "M_NOSUID" }, - { M_NEWTYPE, "M_NEWTYPE" }, - { M_GRPID, "M_GRPID" }, -#ifdef M_REMOUNT - { M_REMOUNT, "M_REMOUNT" }, -#endif -#ifdef M_NOSUB - { M_NOSUB, "M_NOSUB" }, -#endif -#ifdef M_MULTI - { M_MULTI, "M_MULTI" }, -#endif -#ifdef M_SYS5 - { M_SYS5, "M_SYS5" }, -#endif - { 0, NULL }, -}; - -static const struct xlat nfsflags[] = { - { NFSMNT_SOFT, "NFSMNT_SOFT" }, - { NFSMNT_WSIZE, "NFSMNT_WSIZE" }, - { NFSMNT_RSIZE, "NFSMNT_RSIZE" }, - { NFSMNT_TIMEO, "NFSMNT_TIMEO" }, - { NFSMNT_RETRANS, "NFSMNT_RETRANS" }, - { NFSMNT_HOSTNAME, "NFSMNT_HOSTNAME" }, - { NFSMNT_INT, "NFSMNT_INT" }, - { NFSMNT_NOAC, "NFSMNT_NOAC" }, - { NFSMNT_ACREGMIN, "NFSMNT_ACREGMIN" }, - { NFSMNT_ACREGMAX, "NFSMNT_ACREGMAX" }, - { NFSMNT_ACDIRMIN, "NFSMNT_ACDIRMIN" }, - { NFSMNT_ACDIRMAX, "NFSMNT_ACDIRMAX" }, -#ifdef NFSMNT_SECURE - { NFSMNT_SECURE, "NFSMNT_SECURE" }, -#endif -#ifdef NFSMNT_NOCTO - { NFSMNT_NOCTO, "NFSMNT_NOCTO" }, -#endif -#ifdef NFSMNT_POSIX - { NFSMNT_POSIX, "NFSMNT_POSIX" }, -#endif - { 0, NULL }, -}; - -int -sys_mount(struct tcb *tcp) -{ - char type[4]; - - if (entering(tcp)) { - if (!(tcp->u_arg[2] & M_NEWTYPE) || umovestr(tcp, - tcp->u_arg[0], sizeof type, type) < 0) { - tprintf("OLDTYPE:#%lx", tcp->u_arg[0]); - } else { - tprintf("\"%.4s\", ", type); - } - printstr(tcp, tcp->u_arg[1], -1); - tprints(", "); - printflags(mountflags, tcp->u_arg[2] & ~M_NEWTYPE, "M_???"); - tprints(", "); - - if (strcmp(type, "4.2") == 0) { - struct ufs_args a; - if (umove(tcp, tcp->u_arg[3], &a) < 0) - return 0; - printstr(tcp, (int)a.fspec, -1); - } else if (strcmp(type, "lo") == 0) { - struct lo_args a; - if (umove(tcp, tcp->u_arg[3], &a) < 0) - return 0; - printstr(tcp, (int)a.fsdir, -1); - } else if (strcmp(type, "nfs") == 0) { - struct nfs_args a; - if (umove(tcp, tcp->u_arg[3], &a) < 0) - return 0; - tprints("["); - printsock(tcp, (int) a.addr); - tprints(", "); - printflags(nfsflags, a.flags, "NFSMNT_???"); - tprintf(", ws:%u,rs:%u,to:%u,re:%u,", - a.wsize, a.rsize, a.timeo, a.retrans); - if (a.flags & NFSMNT_HOSTNAME && a.hostname) - printstr(tcp, (int)a.hostname, -1); - else - tprintf("%#lx", (unsigned long) a.hostname); - tprintf(",reg-min:%u,max:%u,dir-min:%u,max:%u,", - a.acregmin, a.acregmax, a.acdirmin, a.acdirmax); - if ((a.flags & NFSMNT_SECURE) && a.netname) - printstr(tcp, (int) a.netname, -1); - else - tprintf("%#lx", (unsigned long) a.netname); - tprints("]"); - } else if (strcmp(type, "rfs") == 0) { - struct rfs_args a; - struct token t; - if (umove(tcp, tcp->u_arg[3], &a) < 0) - return 0; - tprints("["); - printstr(tcp, (int)a.rmtfs, -1); - if (umove(tcp, (int)a.token, &t) < 0) - return 0; - tprintf(", %u, %s]", t.t_id, t.t_uname); - } else if (strcmp(type, "pcfs") == 0) { - struct pc_args a; - if (umove(tcp, tcp->u_arg[3], &a) < 0) - return 0; - printstr(tcp, (int)a.fspec, -1); - } - } - return 0; -} - -int -sys_unmount(struct tcb *tcp) -{ - if (entering(tcp)) { - printstr(tcp, tcp->u_arg[0], -1); - } - return 0; -} - -int -sys_umount(struct tcb *tcp) -{ - return sys_unmount(tcp); -} - -int -sys_auditsys(struct tcb *tcp) -{ - /* XXX - no information available */ - return printargs(tcp); -} - -static const struct xlat ex_auth_flags[] = { - { AUTH_UNIX, "AUTH_UNIX" }, - { AUTH_DES, "AUTH_DES" }, - { 0, NULL }, -}; - -int -sys_exportfs(struct tcb *tcp) -{ - struct export e; - int i; - - if (entering(tcp)) { - printstr(tcp, tcp->u_arg[0], -1); - if (umove(tcp, tcp->u_arg[1], &e) < 0) { - tprintf("%#lx", tcp->u_arg[1]); - return 0; - } - tprintf("{fl:%u, anon:%u, ", e.ex_flags, e.ex_anon); - printxval(ex_auth_flags, e.ex_auth, "AUTH_???"); - tprints(", roots:["); - if (e.ex_auth == AUTH_UNIX) { - for (i = 0; i < e.ex_u.exunix.rootaddrs.naddrs; i++) { - printsock(tcp, - (int)&e.ex_u.exunix.rootaddrs.addrvec[i]); - } - tprints("], writers:["); - for (i = 0; i < e.ex_writeaddrs.naddrs; i++) { - printsock(tcp, - (int)&e.ex_writeaddrs.addrvec[i]); - } - tprints("]"); - } else { - for (i = 0; i < e.ex_u.exdes.nnames; i++) { - printsock(tcp, - (int)&e.ex_u.exdes.rootnames[i]); - tprints(", "); - } - tprintf("], window:%u", e.ex_u.exdes.window); - } - tprints("}"); - } - return 0; -} - -static const struct xlat sysconflimits[] = { -#ifdef _SC_ARG_MAX - { _SC_ARG_MAX, "_SC_ARG_MAX" }, /* space for argv & envp */ -#endif -#ifdef _SC_CHILD_MAX - { _SC_CHILD_MAX, "_SC_CHILD_MAX" }, /* maximum children per process??? */ -#endif -#ifdef _SC_CLK_TCK - { _SC_CLK_TCK, "_SC_CLK_TCK" }, /* clock ticks/sec */ -#endif -#ifdef _SC_NGROUPS_MAX - { _SC_NGROUPS_MAX, "_SC_NGROUPS_MAX" }, /* number of groups if multple supp. */ -#endif -#ifdef _SC_OPEN_MAX - { _SC_OPEN_MAX, "_SC_OPEN_MAX" }, /* max open files per process */ -#endif -#ifdef _SC_JOB_CONTROL - { _SC_JOB_CONTROL, "_SC_JOB_CONTROL" }, /* do we have job control */ -#endif -#ifdef _SC_SAVED_IDS - { _SC_SAVED_IDS, "_SC_SAVED_IDS" }, /* do we have saved uid/gids */ -#endif -#ifdef _SC_VERSION - { _SC_VERSION, "_SC_VERSION" }, /* POSIX version supported */ -#endif - { 0, NULL }, -}; - -int -sys_sysconf(struct tcb *tcp) -{ - if (entering(tcp)) { - printxval(sysconflimits, tcp->u_arg[0], "_SC_???"); - } - return 0; -} - -#endif /* SUNOS4 */ - -#if defined(SUNOS4) || defined(FREEBSD) -static const struct xlat pathconflimits[] = { -#ifdef _PC_LINK_MAX - { _PC_LINK_MAX, "_PC_LINK_MAX" }, /* max links to file/dir */ -#endif -#ifdef _PC_MAX_CANON - { _PC_MAX_CANON, "_PC_MAX_CANON" }, /* max line length */ -#endif -#ifdef _PC_MAX_INPUT - { _PC_MAX_INPUT, "_PC_MAX_INPUT" }, /* max "packet" to a tty device */ -#endif -#ifdef _PC_NAME_MAX - { _PC_NAME_MAX, "_PC_NAME_MAX" }, /* max pathname component length */ -#endif -#ifdef _PC_PATH_MAX - { _PC_PATH_MAX, "_PC_PATH_MAX" }, /* max pathname length */ -#endif -#ifdef _PC_PIPE_BUF - { _PC_PIPE_BUF, "_PC_PIPE_BUF" }, /* size of a pipe */ -#endif -#ifdef _PC_CHOWN_RESTRICTED - { _PC_CHOWN_RESTRICTED, "_PC_CHOWN_RESTRICTED" }, /* can we give away files */ -#endif -#ifdef _PC_NO_TRUNC - { _PC_NO_TRUNC, "_PC_NO_TRUNC" }, /* trunc or error on >NAME_MAX */ -#endif -#ifdef _PC_VDISABLE - { _PC_VDISABLE, "_PC_VDISABLE" }, /* best char to shut off tty c_cc */ -#endif - { 0, NULL }, -}; - - -int -sys_pathconf(struct tcb *tcp) -{ - if (entering(tcp)) { - printstr(tcp, tcp->u_arg[0], -1); - tprints(", "); - printxval(pathconflimits, tcp->u_arg[1], "_PC_???"); - } - return 0; -} - -int -sys_fpathconf(struct tcb *tcp) -{ - if (entering(tcp)) { - tprintf("%lu, ", tcp->u_arg[0]); - printxval(pathconflimits, tcp->u_arg[1], "_PC_???"); - } - return 0; -} - -#endif /* SUNOS4 || FREEBSD */ - -#ifdef SVR4 - -#ifdef HAVE_SYS_SYSCONFIG_H -#include <sys/sysconfig.h> -#endif /* HAVE_SYS_SYSCONFIG_H */ - -#include <sys/mount.h> -#include <sys/systeminfo.h> -#include <sys/utsname.h> - -static const struct xlat sysconfig_options[] = { -#ifdef _CONFIG_NGROUPS - { _CONFIG_NGROUPS, "_CONFIG_NGROUPS" }, -#endif -#ifdef _CONFIG_CHILD_MAX - { _CONFIG_CHILD_MAX, "_CONFIG_CHILD_MAX" }, -#endif -#ifdef _CONFIG_OPEN_FILES - { _CONFIG_OPEN_FILES, "_CONFIG_OPEN_FILES" }, -#endif -#ifdef _CONFIG_POSIX_VER - { _CONFIG_POSIX_VER, "_CONFIG_POSIX_VER" }, -#endif -#ifdef _CONFIG_PAGESIZE - { _CONFIG_PAGESIZE, "_CONFIG_PAGESIZE" }, -#endif -#ifdef _CONFIG_CLK_TCK - { _CONFIG_CLK_TCK, "_CONFIG_CLK_TCK" }, -#endif -#ifdef _CONFIG_XOPEN_VER - { _CONFIG_XOPEN_VER, "_CONFIG_XOPEN_VER" }, -#endif -#ifdef _CONFIG_PROF_TCK - { _CONFIG_PROF_TCK, "_CONFIG_PROF_TCK" }, -#endif -#ifdef _CONFIG_NPROC_CONF - { _CONFIG_NPROC_CONF, "_CONFIG_NPROC_CONF" }, -#endif -#ifdef _CONFIG_NPROC_ONLN - { _CONFIG_NPROC_ONLN, "_CONFIG_NPROC_ONLN" }, -#endif -#ifdef _CONFIG_AIO_LISTIO_MAX - { _CONFIG_AIO_LISTIO_MAX, "_CONFIG_AIO_LISTIO_MAX" }, -#endif -#ifdef _CONFIG_AIO_MAX - { _CONFIG_AIO_MAX, "_CONFIG_AIO_MAX" }, -#endif -#ifdef _CONFIG_AIO_PRIO_DELTA_MAX - { _CONFIG_AIO_PRIO_DELTA_MAX, "_CONFIG_AIO_PRIO_DELTA_MAX" }, -#endif -#ifdef _CONFIG_CONFIG_DELAYTIMER_MAX - { _CONFIG_DELAYTIMER_MAX, "_CONFIG_DELAYTIMER_MAX" }, -#endif -#ifdef _CONFIG_MQ_OPEN_MAX - { _CONFIG_MQ_OPEN_MAX, "_CONFIG_MQ_OPEN_MAX" }, -#endif -#ifdef _CONFIG_MQ_PRIO_MAX - { _CONFIG_MQ_PRIO_MAX, "_CONFIG_MQ_PRIO_MAX" }, -#endif -#ifdef _CONFIG_RTSIG_MAX - { _CONFIG_RTSIG_MAX, "_CONFIG_RTSIG_MAX" }, -#endif -#ifdef _CONFIG_SEM_NSEMS_MAX - { _CONFIG_SEM_NSEMS_MAX, "_CONFIG_SEM_NSEMS_MAX" }, -#endif -#ifdef _CONFIG_SEM_VALUE_MAX - { _CONFIG_SEM_VALUE_MAX, "_CONFIG_SEM_VALUE_MAX" }, -#endif -#ifdef _CONFIG_SIGQUEUE_MAX - { _CONFIG_SIGQUEUE_MAX, "_CONFIG_SIGQUEUE_MAX" }, -#endif -#ifdef _CONFIG_SIGRT_MIN - { _CONFIG_SIGRT_MIN, "_CONFIG_SIGRT_MIN" }, -#endif -#ifdef _CONFIG_SIGRT_MAX - { _CONFIG_SIGRT_MAX, "_CONFIG_SIGRT_MAX" }, -#endif -#ifdef _CONFIG_TIMER_MAX - { _CONFIG_TIMER_MAX, "_CONFIG_TIMER_MAX" }, -#endif -#ifdef _CONFIG_CONFIG_PHYS_PAGES - { _CONFIG_PHYS_PAGES, "_CONFIG_PHYS_PAGES" }, -#endif -#ifdef _CONFIG_AVPHYS_PAGES - { _CONFIG_AVPHYS_PAGES, "_CONFIG_AVPHYS_PAGES" }, -#endif - { 0, NULL }, -}; - -int -sys_sysconfig(struct tcb *tcp) -{ - if (entering(tcp)) - printxval(sysconfig_options, tcp->u_arg[0], "_CONFIG_???"); - return 0; -} - -static const struct xlat sysinfo_options[] = { - { SI_SYSNAME, "SI_SYSNAME" }, - { SI_HOSTNAME, "SI_HOSTNAME" }, - { SI_RELEASE, "SI_RELEASE" }, - { SI_VERSION, "SI_VERSION" }, - { SI_MACHINE, "SI_MACHINE" }, - { SI_ARCHITECTURE, "SI_ARCHITECTURE" }, - { SI_HW_SERIAL, "SI_HW_SERIAL" }, - { SI_HW_PROVIDER, "SI_HW_PROVIDER" }, - { SI_SRPC_DOMAIN, "SI_SRPC_DOMAIN" }, -#ifdef SI_SET_HOSTNAME - { SI_SET_HOSTNAME, "SI_SET_HOSTNAME" }, -#endif -#ifdef SI_SET_SRPC_DOMAIN - { SI_SET_SRPC_DOMAIN, "SI_SET_SRPC_DOMAIN" }, -#endif -#ifdef SI_SET_KERB_REALM - { SI_SET_KERB_REALM, "SI_SET_KERB_REALM" }, -#endif -#ifdef SI_KERB_REALM - { SI_KERB_REALM, "SI_KERB_REALM" }, -#endif - { 0, NULL }, -}; - -int -sys_sysinfo(struct tcb *tcp) -{ - if (entering(tcp)) { - printxval(sysinfo_options, tcp->u_arg[0], "SI_???"); - tprints(", "); - } - else { - /* Technically some calls write values. So what. */ - if (syserror(tcp)) - tprintf("%#lx", tcp->u_arg[1]); - else - printpath(tcp, tcp->u_arg[1]); - tprintf(", %lu", tcp->u_arg[2]); - } - return 0; -} - -#ifdef MIPS - -#include <sys/syssgi.h> - -static const struct xlat syssgi_options[] = { - { SGI_SYSID, "SGI_SYSID" }, -#ifdef SGI_RDUBLK - { SGI_RDUBLK, "SGI_RDUBLK" }, -#endif - { SGI_TUNE, "SGI_TUNE" }, - { SGI_IDBG, "SGI_IDBG" }, - { SGI_INVENT, "SGI_INVENT" }, - { SGI_RDNAME, "SGI_RDNAME" }, - { SGI_SETLED, "SGI_SETLED" }, - { SGI_SETNVRAM, "SGI_SETNVRAM" }, - { SGI_GETNVRAM, "SGI_GETNVRAM" }, - { SGI_QUERY_FTIMER, "SGI_QUERY_FTIMER" }, - { SGI_QUERY_CYCLECNTR, "SGI_QUERY_CYCLECNTR" }, - { SGI_PROCSZ, "SGI_PROCSZ" }, - { SGI_SIGACTION, "SGI_SIGACTION" }, - { SGI_SIGPENDING, "SGI_SIGPENDING" }, - { SGI_SIGPROCMASK, "SGI_SIGPROCMASK" }, - { SGI_SIGSUSPEND, "SGI_SIGSUSPEND" }, - { SGI_SETSID, "SGI_SETSID" }, - { SGI_SETPGID, "SGI_SETPGID" }, - { SGI_SYSCONF, "SGI_SYSCONF" }, - { SGI_WAIT4, "SGI_WAIT4" }, - { SGI_PATHCONF, "SGI_PATHCONF" }, - { SGI_READB, "SGI_READB" }, - { SGI_WRITEB, "SGI_WRITEB" }, - { SGI_SETGROUPS, "SGI_SETGROUPS" }, - { SGI_GETGROUPS, "SGI_GETGROUPS" }, - { SGI_SETTIMEOFDAY, "SGI_SETTIMEOFDAY" }, - { SGI_SETTIMETRIM, "SGI_SETTIMETRIM" }, - { SGI_GETTIMETRIM, "SGI_GETTIMETRIM" }, - { SGI_SPROFIL, "SGI_SPROFIL" }, - { SGI_RUSAGE, "SGI_RUSAGE" }, - { SGI_SIGSTACK, "SGI_SIGSTACK" }, - { SGI_SIGSTATUS, "SGI_SIGSTATUS" }, - { SGI_NETPROC, "SGI_NETPROC" }, - { SGI_SIGALTSTACK, "SGI_SIGALTSTACK" }, - { SGI_BDFLUSHCNT, "SGI_BDFLUSHCNT" }, - { SGI_SSYNC, "SGI_SSYNC" }, - { SGI_NFSCNVT, "SGI_NFSCNVT" }, - { SGI_GETPGID, "SGI_GETPGID" }, - { SGI_GETSID, "SGI_GETSID" }, - { SGI_IOPROBE, "SGI_IOPROBE" }, - { SGI_CONFIG, "SGI_CONFIG" }, - { SGI_ELFMAP, "SGI_ELFMAP" }, - { SGI_MCONFIG, "SGI_MCONFIG" }, - { SGI_GETPLABEL, "SGI_GETPLABEL" }, - { SGI_SETPLABEL, "SGI_SETPLABEL" }, - { SGI_GETLABEL, "SGI_GETLABEL" }, - { SGI_SETLABEL, "SGI_SETLABEL" }, - { SGI_SATREAD, "SGI_SATREAD" }, - { SGI_SATWRITE, "SGI_SATWRITE" }, - { SGI_SATCTL, "SGI_SATCTL" }, - { SGI_LOADATTR, "SGI_LOADATTR" }, - { SGI_UNLOADATTR, "SGI_UNLOADATTR" }, -#ifdef SGI_RECVLMSG - { SGI_RECVLMSG, "SGI_RECVLMSG" }, -#endif - { SGI_PLANGMOUNT, "SGI_PLANGMOUNT" }, - { SGI_GETPSOACL, "SGI_GETPSOACL" }, - { SGI_SETPSOACL, "SGI_SETPSOACL" }, -#ifdef SGI_EAG_GET_ATTR - { SGI_EAG_GET_ATTR, "SGI_EAG_GET_ATTR" }, -#endif -#ifdef SGI_EAG_SET_ATTR - { SGI_EAG_SET_ATTR, "SGI_EAG_SET_ATTR" }, -#endif -#ifdef SGI_EAG_GET_PROCATTR - { SGI_EAG_GET_PROCATTR, "SGI_EAG_GET_PROCATTR" }, -#endif -#ifdef SGI_EAG_SET_PROCATTR - { SGI_EAG_SET_PROCATTR, "SGI_EAG_SET_PROCATTR" }, -#endif -#ifdef SGI_FREVOKE - { SGI_FREVOKE, "SGI_FREVOKE" }, -#endif -#ifdef SGI_SBE_GET_INFO - { SGI_SBE_GET_INFO, "SGI_SBE_GET_INFO" }, -#endif -#ifdef SGI_SBE_CLR_INFO - { SGI_SBE_CLR_INFO, "SGI_SBE_CLR_INFO" }, -#endif - { SGI_RMI_FIXECC, "SGI_RMI_FIXECC" }, - { SGI_R4K_CERRS, "SGI_R4K_CERRS" }, - { SGI_GET_EVCONF, "SGI_GET_EVCONF" }, - { SGI_MPCWAROFF, "SGI_MPCWAROFF" }, - { SGI_SET_AUTOPWRON, "SGI_SET_AUTOPWRON" }, - { SGI_SPIPE, "SGI_SPIPE" }, - { SGI_SYMTAB, "SGI_SYMTAB" }, -#ifdef SGI_SET_FPDEBUG - { SGI_SET_FPDEBUG, "SGI_SET_FPDEBUG" }, -#endif -#ifdef SGI_SET_FP_PRECISE - { SGI_SET_FP_PRECISE, "SGI_SET_FP_PRECISE" }, -#endif - { SGI_TOSSTSAVE, "SGI_TOSSTSAVE" }, - { SGI_FDHI, "SGI_FDHI" }, -#ifdef SGI_SET_CONFIG_SMM - { SGI_SET_CONFIG_SMM, "SGI_SET_CONFIG_SMM" }, -#endif -#ifdef SGI_SET_FP_PRESERVE - { SGI_SET_FP_PRESERVE, "SGI_SET_FP_PRESERVE" }, -#endif - { SGI_MINRSS, "SGI_MINRSS" }, -#ifdef SGI_GRIO - { SGI_GRIO, "SGI_GRIO" }, -#endif -#ifdef SGI_XLV_SET_TAB - { SGI_XLV_SET_TAB, "SGI_XLV_SET_TAB" }, -#endif -#ifdef SGI_XLV_GET_TAB - { SGI_XLV_GET_TAB, "SGI_XLV_GET_TAB" }, -#endif -#ifdef SGI_GET_FP_PRECISE - { SGI_GET_FP_PRECISE, "SGI_GET_FP_PRECISE" }, -#endif -#ifdef SGI_GET_CONFIG_SMM - { SGI_GET_CONFIG_SMM, "SGI_GET_CONFIG_SMM" }, -#endif -#ifdef SGI_FP_IMPRECISE_SUPP - { SGI_FP_IMPRECISE_SUPP,"SGI_FP_IMPRECISE_SUPP" }, -#endif -#ifdef SGI_CONFIG_NSMM_SUPP - { SGI_CONFIG_NSMM_SUPP, "SGI_CONFIG_NSMM_SUPP" }, -#endif -#ifdef SGI_RT_TSTAMP_CREATE - { SGI_RT_TSTAMP_CREATE, "SGI_RT_TSTAMP_CREATE" }, -#endif -#ifdef SGI_RT_TSTAMP_DELETE - { SGI_RT_TSTAMP_DELETE, "SGI_RT_TSTAMP_DELETE" }, -#endif -#ifdef SGI_RT_TSTAMP_START - { SGI_RT_TSTAMP_START, "SGI_RT_TSTAMP_START" }, -#endif -#ifdef SGI_RT_TSTAMP_STOP - { SGI_RT_TSTAMP_STOP, "SGI_RT_TSTAMP_STOP" }, -#endif -#ifdef SGI_RT_TSTAMP_ADDR - { SGI_RT_TSTAMP_ADDR, "SGI_RT_TSTAMP_ADDR" }, -#endif -#ifdef SGI_RT_TSTAMP_MASK - { SGI_RT_TSTAMP_MASK, "SGI_RT_TSTAMP_MASK" }, -#endif -#ifdef SGI_RT_TSTAMP_EOB_MODE - { SGI_RT_TSTAMP_EOB_MODE,"SGI_RT_TSTAMP_EOB_MODE"}, -#endif -#ifdef SGI_USE_FP_BCOPY - { SGI_USE_FP_BCOPY, "SGI_USE_FP_BCOPY" }, -#endif -#ifdef SGI_GET_UST - { SGI_GET_UST, "SGI_GET_UST" }, -#endif -#ifdef SGI_SPECULATIVE_EXEC - { SGI_SPECULATIVE_EXEC, "SGI_SPECULATIVE_EXEC" }, -#endif -#ifdef SGI_XLV_NEXT_RQST - { SGI_XLV_NEXT_RQST, "SGI_XLV_NEXT_RQST" }, -#endif -#ifdef SGI_XLV_ATTR_CURSOR - { SGI_XLV_ATTR_CURSOR, "SGI_XLV_ATTR_CURSOR" }, -#endif -#ifdef SGI_XLV_ATTR_GET - { SGI_XLV_ATTR_GET, "SGI_XLV_ATTR_GET" }, -#endif -#ifdef SGI_XLV_ATTR_SET - { SGI_XLV_ATTR_SET, "SGI_XLV_ATTR_SET" }, -#endif -#ifdef SGI_BTOOLSIZE - { SGI_BTOOLSIZE, "SGI_BTOOLSIZE" }, -#endif -#ifdef SGI_BTOOLGET - { SGI_BTOOLGET, "SGI_BTOOLGET" }, -#endif -#ifdef SGI_BTOOLREINIT - { SGI_BTOOLREINIT, "SGI_BTOOLREINIT" }, -#endif -#ifdef SGI_CREATE_UUID - { SGI_CREATE_UUID, "SGI_CREATE_UUID" }, -#endif -#ifdef SGI_NOFPE - { SGI_NOFPE, "SGI_NOFPE" }, -#endif -#ifdef SGI_OLD_SOFTFP - { SGI_OLD_SOFTFP, "SGI_OLD_SOFTFP" }, -#endif -#ifdef SGI_FS_INUMBERS - { SGI_FS_INUMBERS, "SGI_FS_INUMBERS" }, -#endif -#ifdef SGI_FS_BULKSTAT - { SGI_FS_BULKSTAT, "SGI_FS_BULKSTAT" }, -#endif -#ifdef SGI_RT_TSTAMP_WAIT - { SGI_RT_TSTAMP_WAIT, "SGI_RT_TSTAMP_WAIT" }, -#endif -#ifdef SGI_RT_TSTAMP_UPDATE - { SGI_RT_TSTAMP_UPDATE, "SGI_RT_TSTAMP_UPDATE" }, -#endif -#ifdef SGI_PATH_TO_HANDLE - { SGI_PATH_TO_HANDLE, "SGI_PATH_TO_HANDLE" }, -#endif -#ifdef SGI_PATH_TO_FSHANDLE - { SGI_PATH_TO_FSHANDLE, "SGI_PATH_TO_FSHANDLE" }, -#endif -#ifdef SGI_FD_TO_HANDLE - { SGI_FD_TO_HANDLE, "SGI_FD_TO_HANDLE" }, -#endif -#ifdef SGI_OPEN_BY_HANDLE - { SGI_OPEN_BY_HANDLE, "SGI_OPEN_BY_HANDLE" }, -#endif -#ifdef SGI_READLINK_BY_HANDLE - { SGI_READLINK_BY_HANDLE,"SGI_READLINK_BY_HANDLE"}, -#endif -#ifdef SGI_READ_DANGID - { SGI_READ_DANGID, "SGI_READ_DANGID" }, -#endif -#ifdef SGI_CONST - { SGI_CONST, "SGI_CONST" }, -#endif -#ifdef SGI_XFS_FSOPERATIONS - { SGI_XFS_FSOPERATIONS, "SGI_XFS_FSOPERATIONS" }, -#endif -#ifdef SGI_SETASH - { SGI_SETASH, "SGI_SETASH" }, -#endif -#ifdef SGI_GETASH - { SGI_GETASH, "SGI_GETASH" }, -#endif -#ifdef SGI_SETPRID - { SGI_SETPRID, "SGI_SETPRID" }, -#endif -#ifdef SGI_GETPRID - { SGI_GETPRID, "SGI_GETPRID" }, -#endif -#ifdef SGI_SETSPINFO - { SGI_SETSPINFO, "SGI_SETSPINFO" }, -#endif -#ifdef SGI_GETSPINFO - { SGI_GETSPINFO, "SGI_GETSPINFO" }, -#endif -#ifdef SGI_SHAREII - { SGI_SHAREII, "SGI_SHAREII" }, -#endif -#ifdef SGI_NEWARRAYSESS - { SGI_NEWARRAYSESS, "SGI_NEWARRAYSESS" }, -#endif -#ifdef SGI_GETDFLTPRID - { SGI_GETDFLTPRID, "SGI_GETDFLTPRID" }, -#endif -#ifdef SGI_SET_DISMISSED_EXC_CNT - { SGI_SET_DISMISSED_EXC_CNT,"SGI_SET_DISMISSED_EXC_CNT" }, -#endif -#ifdef SGI_GET_DISMISSED_EXC_CNT - { SGI_GET_DISMISSED_EXC_CNT,"SGI_GET_DISMISSED_EXC_CNT" }, -#endif -#ifdef SGI_CYCLECNTR_SIZE - { SGI_CYCLECNTR_SIZE, "SGI_CYCLECNTR_SIZE" }, -#endif -#ifdef SGI_QUERY_FASTTIMER - { SGI_QUERY_FASTTIMER, "SGI_QUERY_FASTTIMER" }, -#endif -#ifdef SGI_PIDSINASH - { SGI_PIDSINASH, "SGI_PIDSINASH" }, -#endif -#ifdef SGI_ULI - { SGI_ULI, "SGI_ULI" }, -#endif -#ifdef SGI_LPG_SHMGET - { SGI_LPG_SHMGET, "SGI_LPG_SHMGET" }, -#endif -#ifdef SGI_LPG_MAP - { SGI_LPG_MAP, "SGI_LPG_MAP" }, -#endif -#ifdef SGI_CACHEFS_SYS - { SGI_CACHEFS_SYS, "SGI_CACHEFS_SYS" }, -#endif -#ifdef SGI_NFSNOTIFY - { SGI_NFSNOTIFY, "SGI_NFSNOTIFY" }, -#endif -#ifdef SGI_LOCKDSYS - { SGI_LOCKDSYS, "SGI_LOCKDSYS" }, -#endif -#ifdef SGI_EVENTCTR - { SGI_EVENTCTR, "SGI_EVENTCTR" }, -#endif -#ifdef SGI_GETPRUSAGE - { SGI_GETPRUSAGE, "SGI_GETPRUSAGE" }, -#endif -#ifdef SGI_PROCMASK_LOCATION - { SGI_PROCMASK_LOCATION,"SGI_PROCMASK_LOCATION" }, -#endif -#ifdef SGI_UNUSED - { SGI_UNUSED, "SGI_UNUSED" }, -#endif -#ifdef SGI_CKPT_SYS - { SGI_CKPT_SYS, "SGI_CKPT_SYS" }, -#endif -#ifdef SGI_CKPT_SYS - { SGI_CKPT_SYS, "SGI_CKPT_SYS" }, -#endif -#ifdef SGI_GETGRPPID - { SGI_GETGRPPID, "SGI_GETGRPPID" }, -#endif -#ifdef SGI_GETSESPID - { SGI_GETSESPID, "SGI_GETSESPID" }, -#endif -#ifdef SGI_ENUMASHS - { SGI_ENUMASHS, "SGI_ENUMASHS" }, -#endif -#ifdef SGI_SETASMACHID - { SGI_SETASMACHID, "SGI_SETASMACHID" }, -#endif -#ifdef SGI_GETASMACHID - { SGI_GETASMACHID, "SGI_GETASMACHID" }, -#endif -#ifdef SGI_GETARSESS - { SGI_GETARSESS, "SGI_GETARSESS" }, -#endif -#ifdef SGI_JOINARRAYSESS - { SGI_JOINARRAYSESS, "SGI_JOINARRAYSESS" }, -#endif -#ifdef SGI_SPROC_KILL - { SGI_SPROC_KILL, "SGI_SPROC_KILL" }, -#endif -#ifdef SGI_DBA_CONFIG - { SGI_DBA_CONFIG, "SGI_DBA_CONFIG" }, -#endif -#ifdef SGI_RELEASE_NAME - { SGI_RELEASE_NAME, "SGI_RELEASE_NAME" }, -#endif -#ifdef SGI_SYNCH_CACHE_HANDLER - { SGI_SYNCH_CACHE_HANDLER,"SGI_SYNCH_CACHE_HANDLER"}, -#endif -#ifdef SGI_SWASH_INIT - { SGI_SWASH_INIT, "SGI_SWASH_INIT" }, -#endif -#ifdef SGI_NUMA_MIGR_PAGE - { SGI_NUMA_MIGR_PAGE, "SGI_NUMA_MIGR_PAGE" }, -#endif -#ifdef SGI_NUMA_MIGR_PAGE_ALT - { SGI_NUMA_MIGR_PAGE_ALT,"SGI_NUMA_MIGR_PAGE_ALT"}, -#endif -#ifdef SGI_KAIO_USERINIT - { SGI_KAIO_USERINIT, "SGI_KAIO_USERINIT" }, -#endif -#ifdef SGI_KAIO_READ - { SGI_KAIO_READ, "SGI_KAIO_READ" }, -#endif -#ifdef SGI_KAIO_WRITE - { SGI_KAIO_WRITE, "SGI_KAIO_WRITE" }, -#endif -#ifdef SGI_KAIO_SUSPEND - { SGI_KAIO_SUSPEND, "SGI_KAIO_SUSPEND" }, -#endif -#ifdef SGI_KAIO_STATS - { SGI_KAIO_STATS, "SGI_KAIO_STATS" }, -#endif -#ifdef SGI_INITIAL_PT_SPROC - { SGI_INITIAL_PT_SPROC, "SGI_INITIAL_PT_SPROC" }, -#endif - { 0, NULL }, -}; - -int -sys_syssgi(struct tcb *tcp) -{ - int i; - - if (entering(tcp)) { - printxval(syssgi_options, tcp->u_arg[0], "SGI_???"); - switch (tcp->u_arg[0]) { - default: - for (i = 1; i < tcp->u_nargs; i++) - tprintf(", %#lx", tcp->u_arg[i]); - break; - } - } - return 0; -} - -#include <sys/types.h> -#include <rpc/rpc.h> -struct cred; -struct uio; -#include <sys/fsid.h> -#include <sys/vnode.h> -#include <sys/fs/nfs.h> -#include <sys/fs/nfs_clnt.h> - -static const struct xlat mount_flags[] = { - { MS_RDONLY, "MS_RDONLY" }, - { MS_FSS, "MS_FSS" }, - { MS_DATA, "MS_DATA" }, - { MS_NOSUID, "MS_NOSUID" }, - { MS_REMOUNT, "MS_REMOUNT" }, - { MS_NOTRUNC, "MS_NOTRUNC" }, - { MS_GRPID, "MS_GRPID" }, - { MS_NODEV, "MS_NODEV" }, - { MS_BEFORE, "MS_BEFORE" }, - { MS_AFTER, "MS_AFTER" }, - { 0, NULL }, -}; - -static const struct xlat nfs_flags[] = { - { NFSMNT_SOFT, "NFSMNT_SOFT" }, - { NFSMNT_WSIZE, "NFSMNT_WSIZE" }, - { NFSMNT_RSIZE, "NFSMNT_RSIZE" }, - { NFSMNT_TIMEO, "NFSMNT_TIMEO" }, - { NFSMNT_RETRANS, "NFSMNT_RETRANS" }, - { NFSMNT_HOSTNAME, "NFSMNT_HOSTNAME" }, -#ifdef NFSMNT_NOINT /* IRIX 6 */ - { NFSMNT_NOINT, "NFSMNT_NOINT" }, -#endif -#ifdef NFSMNT_INT /* IRIX 5 */ - { NFSMNT_INT, "NFSMNT_INT" }, -#endif - { NFSMNT_NOAC, "NFSMNT_NOAC" }, - { NFSMNT_ACREGMIN, "NFSMNT_ACREGMIN" }, - { NFSMNT_ACREGMAX, "NFSMNT_ACREGMAX" }, - { NFSMNT_ACDIRMIN, "NFSMNT_ACDIRMIN" }, - { NFSMNT_ACDIRMAX, "NFSMNT_ACDIRMAX" }, - { NFSMNT_PRIVATE, "NFSMNT_PRIVATE" }, - { NFSMNT_SYMTTL, "NFSMNT_SYMTTL" }, - { NFSMNT_LOOPBACK, "NFSMNT_LOOPBACK" }, - { NFSMNT_BASETYPE, "NFSMNT_BASETYPE" }, - { NFSMNT_NAMEMAX, "NFSMNT_NAMEMAX" }, -#ifdef NFSMNT_SHORTUID /* IRIX 6 */ - { NFSMNT_SHORTUID, "NFSMNT_SHORTUID" }, -#endif -#ifdef NFSMNT_ASYNCNLM /* IRIX 6 */ - { NFSMNT_ASYNCNLM, "NFSMNT_ASYNCNLM" }, -#endif - { 0, NULL }, -}; - -int -sys_mount(struct tcb *tcp) -{ - if (entering(tcp)) { - printpath(tcp, tcp->u_arg[0]); - tprints(", "); - printpath(tcp, tcp->u_arg[1]); - tprints(", "); - printflags(mount_flags, tcp->u_arg[2], "MS_???"); - if (tcp->u_arg[2] & (MS_FSS | MS_DATA)) { - tprints(", "); - tprintf("%ld", tcp->u_arg[3]); - } - if (tcp->u_arg[2] & MS_DATA) { - int nfs_type = sysfs(GETFSIND, FSID_NFS); - - tprints(", "); - if (tcp->u_arg[3] == nfs_type) { - struct nfs_args args; - if (umove(tcp, tcp->u_arg[4], &args) < 0) - tprintf("%#lx", tcp->u_arg[4]); - else { - tprints("addr="); - printsock(tcp, (int) args.addr); - tprints(", flags="); - printflags(nfs_flags, args.flags, "NFSMNT_???"); - tprints(", hostname="); - printstr(tcp, (int) args.hostname, -1); - tprints(", ...}"); - } - } - else - tprintf("%#lx", tcp->u_arg[4]); - tprintf(", %ld", tcp->u_arg[5]); - } - } - return 0; -} - -#else /* !MIPS */ - -#if UNIXWARE - -#include <sys/types.h> -#include <sys/fstyp.h> -#include <sys/mount.h> -#include <sys/xti.h> - -#define NFSCLIENT 1 -#include <nfs/mount.h> - -#include <sys/fs/vx_ioctl.h> -static const struct xlat mount_flags[] = { - { MS_RDONLY, "MS_RDONLY" }, - { MS_FSS, "MS_FSS" }, - { MS_DATA, "MS_DATA" }, - { MS_HADBAD, "MS_HADBAD" }, - { MS_NOSUID, "MS_NOSUID" }, - { MS_REMOUNT, "MS_REMOUNT" }, - { MS_NOTRUNC, "MS_NOTRUNC" }, - { MS_SOFTMNT, "MS_SOFTMNT" }, - { MS_SYSSPACE, "MS_SYSSPACE" }, - { 0, NULL }, -}; - -#ifdef VX_MS_MASK -static const struct xlat vxfs_flags[] = { - { VX_MS_NOLOG, "VX_MS_NOLOG" }, - { VX_MS_BLKCLEAR, "VX_MS_BLKCLEAR" }, - { VX_MS_SNAPSHOT, "VX_MS_SNAPSHOT" }, - { VX_MS_NODATAINLOG, "VX_MS_NODATAINLOG" }, - { VX_MS_DELAYLOG, "VX_MS_DELAYLOG" }, - { VX_MS_TMPLOG, "VX_MS_TMPLOG" }, - { VX_MS_FILESET, "VX_MS_FILESET" }, - - { VX_MS_CACHE_DIRECT, "VX_MS_CACHE_DIRECT" }, - { VX_MS_CACHE_DSYNC, "VX_MS_CACHE_DSYNC" }, - { VX_MS_CACHE_CLOSESYNC,"VX_MS_CACHE_CLOSESYNC" }, - { VX_MS_CACHE_TMPCACHE, "VX_MS_CACHE_TMPCACHE" }, - - { VX_MS_OSYNC_DIRECT, "VX_MS_OSYNC_DIRECT" }, - { VX_MS_OSYNC_DSYNC, "VX_MS_OSYNC_DSYNC" }, - { VX_MS_OSYNC_CLOSESYNC,"VX_MS_OSYNC_CLOSESYNC" }, - { VX_MS_OSYNC_DELAY, "VX_MS_OSYNC_DELAY" }, - { 0, NULL, }, -}; -#endif - -static const struct xlat nfs_flags[] = { - { NFSMNT_SOFT, "NFSMNT_SOFT" }, - { NFSMNT_WSIZE, "NFSMNT_WSIZE" }, - { NFSMNT_RSIZE, "NFSMNT_RSIZE" }, - { NFSMNT_TIMEO, "NFSMNT_TIMEO" }, - { NFSMNT_RETRANS, "NFSMNT_RETRANS" }, - { NFSMNT_HOSTNAME, "NFSMNT_HOSTNAME" }, - { NFSMNT_INT, "NFSMNT_INT" }, - { NFSMNT_NOAC, "NFSMNT_NOAC" }, - { NFSMNT_ACREGMIN, "NFSMNT_ACREGMIN" }, - { NFSMNT_ACREGMAX, "NFSMNT_ACREGMAX" }, - { NFSMNT_ACDIRMIN, "NFSMNT_ACDIRMIN" }, - { NFSMNT_ACDIRMAX, "NFSMNT_ACDIRMAX" }, - { NFSMNT_SECURE, "NFSMNT_SECURE" }, - { NFSMNT_NOCTO, "NFSMNT_NOCTO" }, - { NFSMNT_GRPID, "NFSMNT_GRPID" }, - { NFSMNT_RPCTIMESYNC, "NFSMNT_RPCTIMESYNC" }, - { NFSMNT_LWPSMAX, "NFSMNT_LWPSMAX" }, - { 0, NULL }, -}; - -int -sys_mount(struct tcb *tcp) -{ - if (entering(tcp)) { - char fstyp[FSTYPSZ]; - printpath(tcp, tcp->u_arg[0]); - tprints(", "); - printpath(tcp, tcp->u_arg[1]); - tprints(", "); - printflags(mount_flags, tcp->u_arg[2], "MS_???"); - /* The doc sez that the file system type is given as a - fsindex, and we should use sysfs to work out the name. - This appears to be untrue for UW. Maybe it's untrue - for all SVR4's? */ - if (tcp->u_arg[2] & (MS_FSS | MS_DATA)) { - if (umovestr(tcp, tcp->u_arg[3], FSTYPSZ, fstyp) < 0) { - fstyp[0] = '\0'; - tprintf(", %ld", tcp->u_arg[3]); - } - else - tprintf(", \"%.*s\"", (int)FSTYPSZ, fstyp); - } - if (tcp->u_arg[2] & MS_DATA) { - tprints(", "); -#ifdef VX_MS_MASK - /* On UW7 they don't give us the defines and structs - we need to see what is going on. Bummer. */ - if (strcmp(fstyp, "vxfs") == 0) { - struct vx_mountargs5 args; - if (umove(tcp, tcp->u_arg[4], &args) < 0) - tprintf("%#lx", tcp->u_arg[4]); - else { - tprints("{ flags="); - printflags(vxfs_flags, args.mflags, "VX_MS_???"); - if (args.mflags & VX_MS_SNAPSHOT) { - tprints(", snapof="); - printstr(tcp, - (long) args.primaryspec, - -1); - if (args.snapsize > 0) - tprintf(", snapsize=%ld", args.snapsize); - } - tprints(" }"); - } - } - else -#endif - if (strcmp(fstyp, "specfs") == 0) { - tprints("dev="); - printstr(tcp, tcp->u_arg[4], -1); - } - else - if (strcmp(fstyp, "nfs") == 0) { - struct nfs_args args; - if (umove(tcp, tcp->u_arg[4], &args) < 0) - tprintf("%#lx", tcp->u_arg[4]); - else { - struct netbuf addr; - tprints("{ addr="); - if (umove(tcp, (int) args.addr, &addr) < 0) { - tprintf("%#lx", (long) args.addr); - } - else { - printsock(tcp, (int) addr.buf, addr.len); - } - tprints(", flags="); - printflags(nfs_flags, args.flags, "NFSMNT_???"); - tprints(", hostname="); - printstr(tcp, (int) args.hostname, -1); - tprints(", ...}"); - } - } - else - tprintf("%#lx", tcp->u_arg[4]); - tprintf(", %ld", tcp->u_arg[5]); - } - } - return 0; -} - -#else /* !UNIXWARE */ - -int -sys_mount(struct tcb *tcp) -{ - if (entering(tcp)) { - printpath(tcp, tcp->u_arg[0]); - tprints(", "); - printpath(tcp, tcp->u_arg[1]); - tprints(", ..."); - } - return 0; -} -#endif /* !UNIXWARE */ - -#endif /* !MIPS */ - -#endif /* SVR4 */ #ifdef SYS_capget @@ -1666,7 +531,6 @@ int sys_capset(struct tcb *tcp) #endif -#ifdef LINUX /* Linux 2.6.18+ headers removed CTL_PROC enum. */ # define CTL_PROC 4 # define CTL_CPU 10 /* older headers lack */ @@ -2066,230 +930,8 @@ sys_sysctl(struct tcb *tcp) free(name); return 0; } -#else -int sys_sysctl(struct tcb *tcp) -{ - return printargs(tcp); -} -#endif - -#ifdef FREEBSD -#include <sys/sysctl.h> - -int sys___sysctl(struct tcb *tcp) -{ - int qoid[CTL_MAXNAME+2]; - char ctl[1024]; - size_t len; - int i, numeric; - - if (entering(tcp)) { - if (tcp->u_arg[1] < 0 || tcp->u_arg[1] > CTL_MAXNAME || - (umoven(tcp, tcp->u_arg[0], tcp->u_arg[1] * sizeof(int), - (char *) (qoid + 2)) < 0)) - tprints("[...], "); - else { - /* Use sysctl to ask the name of the current MIB - This uses the undocumented "Staff-functions" used - by the sysctl program. See kern_sysctl.c for - details. */ - qoid[0] = 0; /* sysctl */ - qoid[1] = 1; /* name */ - i = sizeof(ctl); - tprints("["); - if (sysctl(qoid, tcp->u_arg[1] + 2, ctl, &i, 0, 0) >= 0) { - numeric = !abbrev(tcp); - tprintf("%s%s", ctl, numeric ? ", " : ""); - } else - numeric = 1; - if (numeric) { - for (i = 0; i < tcp->u_arg[1]; i++) - tprintf("%s%d", i ? "." : "", qoid[i + 2]); - } - tprints("], "); - tprintf("%lu, ", tcp->u_arg[1]); - } - } else { - if (!syserror(tcp) && (umove(tcp, tcp->u_arg[3], &len) >= 0)) { - printstr(tcp, tcp->u_arg[2], len); - tprintf(", [%u], ", len); - } else - tprintf("%#lx, %#lx, ", tcp->u_arg[2], tcp->u_arg[3]); - printstr(tcp, tcp->u_arg[4], tcp->u_arg[5]); - tprintf(", %lu", tcp->u_arg[5]); - } - return 0; -} -#endif - -#if UNIXWARE >= 2 - -#include <sys/ksym.h> -#include <sys/elf.h> - -static const struct xlat ksym_flags[] = { - { STT_NOTYPE, "STT_NOTYPE" }, - { STT_FUNC, "STT_FUNC" }, - { STT_OBJECT, "STT_OBJECT" }, - { 0, NULL }, -}; - -int -sys_getksym(struct tcb *tcp) -{ - if (entering(tcp)) { - printstr(tcp, tcp->u_arg[0], -1); - tprints(", "); - } - else { - if (syserror(tcp)) { - tprintf("%#lx, %#lx", - tcp->u_arg[1], tcp->u_arg[2]); - } - else { - int val; - printnum(tcp, tcp->u_arg[1], "%#lx"); - tprints(", "); - if (umove(tcp, tcp->u_arg[2], &val) < 0) { - tprintf("%#lx", tcp->u_arg[2]); - } - else { - tprints("["); - printxval(ksym_flags, val, "STT_???"); - tprints("]"); - } - } - } - - return 0; -} - -#ifdef HAVE_SYS_NSCSYS_H - -struct cred; -#include <sys/nscsys.h> - -static const struct xlat ssi_cmd[] = { - { SSISYS_BADOP, "SSISYS_BADOP" }, - { SSISYS_LDLVL_INIT,"SSISYS_LDLVL_INIT"}, - { SSISYS_LDLVL_GETVEC,"SSISYS_LDLVL_GETVEC"}, - { SSISYS_LDLVL_PUTVEC,"SSISYS_LDLVL_PUTVEC"}, - { SSISYS_LDLVL_PUTRCMDS,"SSISYS_LDLVL_PUTRCMDS"}, - { SSISYS_LDLVL_SETREXEC,"SSISYS_LDLVL_SETREXEC"}, - { SSISYS_CMS_CLUSTERID,"SSISYS_CMS_CLUSTERID"}, - { SSISYS_CFS_STATVFS,"SSISYS_CFS_STATVFS"}, - { SSISYS_NODE_GETNUM,"SSISYS_NODE_GETNUM"}, - { SSISYS_NODE_TABLE,"SSISYS_NODE_TABLE"}, - { SSISYS_NODE_DOWN,"SSISYS_NODE_DOWN"}, - { SSISYS_RECLAIM_CHILD,"SSISYS_RECLAIM_CHILD"}, - { SSISYS_IPC_GETINFO,"SSISYS_IPC_GETINFO"}, - { SSISYS_ICS_TEST,"SSISYS_ICS_TEST"}, - { SSISYS_NODE_PID,"SSISYS_NODE_PID"}, - { SSISYS_ISLOCAL,"SSISYS_ISLOCAL"}, - { SSISYS_CFS_ISSTACKED,"SSISYS_CFS_ISSTACKED"}, - { SSISYS_DNET_SYNC,"SSISYS_DNET_SYNC"}, - { SSISYS_CFS_WAIT_MODE,"SSISYS_CFS_WAIT_MODE"}, - { SSISYS_CFS_UMOUNT,"SSISYS_CFS_UMOUNT"}, - { SSISYS_LLSTAT,"SSISYS_LLSTAT" }, - { SSISYS_LTS_PERFTEST,"SSISYS_LTS_PERFTEST"}, - { SSISYS_LTS_CONFIG,"SSISYS_LTS_CONFIG"}, - { SSISYS_SNET_PERFTEST,"SSISYS_SNET_PERFTEST"}, - { SSISYS_IGNORE_HALFUP,"SSISYS_IGNORE_HALFUP"}, - { SSISYS_NODE_ROOTDEV,"SSISYS_NODE_ROOTDEV"}, - { SSISYS_GET_PRIMARY,"SSISYS_GET_PRIMARY"}, - { SSISYS_GET_SECONDARY,"SSISYS_GET_SECONDARY"}, - { SSISYS_GET_ROOTDISK,"SSISYS_GET_ROOTDISK"}, - { SSISYS_CLUSTERNODE_NUM,"SSISYS_CLUSTERNODE_NUM"}, - { SSISYS_CLUSTER_MEMBERSHIP,"SSISYS_CLUSTER_MEMBERSHIP"}, - { SSISYS_CLUSTER_DETAILEDTRANS,"SSISYS_CLUSTER_DETAILEDTRANS"}, - { SSISYS_CLUSTERNODE_INFO,"SSISYS_CLUSTERNODE_INFO"}, - { SSISYS_CLUSTERNODE_SETINFO,"SSISYS_CLUSTERNODE_SETINFO"}, - { SSISYS_CLUSTERNODE_AVAIL,"SSISYS_CLUSTERNODE_AVAIL"}, - { SSISYS_CLUSTER_MAXNODES,"SSISYS_CLUSTER_MAXNODES"}, - { SSISYS_SET_MEMPRIO,"SSISYS_SET_MEMPRIO"}, - { SSISYS_GET_USERS,"SSISYS_GET_USERS"}, - { SSISYS_FORCE_ROOT_NODE,"SSISYS_FORCE_ROOT_NODE"}, - { SSISYS_CVIP_SET,"SSISYS_CVIP_SET"}, - { SSISYS_CVIP_GET,"SSISYS_CVIP_GET"}, - { SSISYS_GET_NODE_COUNTS,"SSISYS_GET_NODE_COUNTS"}, - { SSISYS_GET_TRANSPORT,"SSISYS_GET_TRANSPORT"}, - { 0, NULL }, -}; - -int sys_ssisys(struct tcb *tcp) -{ - struct ssisys_iovec iov; - cls_nodeinfo_args_t cni; - clusternode_info_t info; - - if (entering(tcp)) { - ts_reclaim_child_inargs_t trc; - if (tcp->u_arg[1] != sizeof iov || - umove(tcp, tcp->u_arg[0], &iov) < 0) - { - tprintf("%#lx, %ld", tcp->u_arg[0], tcp->u_arg[1]); - return 0; - } - tprints("{id="); - printxval(ssi_cmd, iov.tio_id.id_cmd, "SSISYS_???"); - tprintf(":%d", iov.tio_id.id_ver); - switch (iov.tio_id.id_cmd) { - case SSISYS_RECLAIM_CHILD: - if (iov.tio_udatainlen != sizeof trc || - umove(tcp, (long) iov.tio_udatain, &trc) < 0) - goto bad; - tprintf(", in={pid=%ld, start=%ld}", - trc.trc_pid, trc.trc_start); - break; - case SSISYS_CLUSTERNODE_INFO: - if (iov.tio_udatainlen != sizeof cni || - umove(tcp, (long) iov.tio_udatain, &cni) < 0) - goto bad; - tprintf(", in={node=%ld, len=%d}", - cni.nodenum, cni.info_len); - break; - default: - bad: - if (iov.tio_udatainlen) { - tprintf(", in=[/* %d bytes */]", - iov.tio_udatainlen); - } - } - } - else { - if (tcp->u_arg[1] != sizeof iov || - umove(tcp, tcp->u_arg[0], &iov) < 0) - goto done; - switch (iov.tio_id.id_cmd) { - case SSISYS_CLUSTERNODE_INFO: - if (iov.tio_udatainlen != sizeof cni || - umove(tcp, (long) iov.tio_udatain, &cni) < 0) - goto bad_out; - if (cni.info_len != sizeof info || - iov.tio_udataoutlen != sizeof &info || - umove(tcp, (long) iov.tio_udataout, &info) < 0) - goto bad_out; - tprintf(", out={node=%ld, cpus=%d, online=%d}", - info.node_num, info.node_totalcpus, - info.node_onlinecpus); - break; - default: - bad_out: - if (iov.tio_udataoutlen) { - tprintf(", out=[/* %d bytes */]", - iov.tio_udataoutlen); - } - } - done: - tprintf("}, %ld", tcp->u_arg[1]); - } - return 0; -} - -#endif -#endif /* UNIXWARE > 2 */ #ifdef MIPS @@ -29,20 +29,11 @@ #include "defs.h" -#ifdef LINUX /* * The C library's definition of struct termios might differ from * the kernel one, and we need to use the kernel layout. */ #include <linux/termios.h> -#else - -#ifdef HAVE_TERMIO_H -#include <termio.h> -#endif /* HAVE_TERMIO_H */ - -#include <termios.h> -#endif #ifdef HAVE_SYS_FILIO_H #include <sys/filio.h> @@ -181,14 +172,7 @@ static const struct xlat modem_flags[] = { int term_ioctl(struct tcb *tcp, long code, long arg) { struct termios tios; -#ifndef FREEBSD struct termio tio; -#else - #define TCGETS TIOCGETA - #define TCSETS TIOCSETA - #define TCSETSW TIOCSETAW - #define TCSETSF TIOCSETAF -#endif struct winsize ws; #ifdef TIOCGSIZE struct ttysize ts; @@ -213,16 +197,7 @@ int term_ioctl(struct tcb *tcp, long code, long arg) return 0; if (abbrev(tcp)) { tprints(", {"); -#ifndef FREEBSD printxval(baud_options, tios.c_cflag & CBAUD, "B???"); -#else - printxval(baud_options, tios.c_ispeed, "B???"); - if (tios.c_ispeed != tios.c_ospeed) { - tprints(" (in)"); - printxval(baud_options, tios.c_ospeed, "B???"); - tprints(" (out)"); - } -#endif tprintf(" %sopost %sisig %sicanon %secho ...}", (tios.c_oflag & OPOST) ? "" : "-", (tios.c_lflag & ISIG) ? "" : "-", @@ -234,9 +209,7 @@ int term_ioctl(struct tcb *tcp, long code, long arg) (long) tios.c_iflag, (long) tios.c_oflag); tprintf("c_cflags=%#lx, c_lflags=%#lx, ", (long) tios.c_cflag, (long) tios.c_lflag); -#if !defined(SVR4) && !defined(FREEBSD) tprintf("c_line=%u, ", tios.c_line); -#endif if (!(tios.c_lflag & ICANON)) tprintf("c_cc[VMIN]=%d, c_cc[VTIME]=%d, ", tios.c_cc[VMIN], tios.c_cc[VTIME]); @@ -31,7 +31,6 @@ #include "defs.h" -#ifdef LINUX #include <linux/version.h> #include <sys/timex.h> #include <linux/ioctl.h> @@ -43,7 +42,6 @@ #ifndef UTIME_OMIT #define UTIME_OMIT ((1l << 30) - 2l) #endif -#endif /* LINUX */ struct timeval32 { @@ -167,9 +165,7 @@ int sys_time(struct tcb *tcp) { if (exiting(tcp)) { -#ifndef SVR4 printnum(tcp, tcp->u_arg[0], "%ld"); -#endif /* SVR4 */ } return 0; } @@ -193,10 +189,8 @@ sys_gettimeofday(struct tcb *tcp) return 0; } printtv(tcp, tcp->u_arg[0]); -#ifndef SVR4 tprints(", "); printtv(tcp, tcp->u_arg[1]); -#endif /* !SVR4 */ } return 0; } @@ -212,10 +206,8 @@ sys_osf_gettimeofday(struct tcb *tcp) return 0; } printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0); -#ifndef SVR4 tprints(", "); printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0); -#endif /* !SVR4 */ } return 0; } @@ -226,10 +218,8 @@ sys_settimeofday(struct tcb *tcp) { if (entering(tcp)) { printtv(tcp, tcp->u_arg[0]); -#ifndef SVR4 tprints(", "); printtv(tcp, tcp->u_arg[1]); -#endif /* !SVR4 */ } return 0; } @@ -240,10 +230,8 @@ sys_osf_settimeofday(struct tcb *tcp) { if (entering(tcp)) { printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0); -#ifndef SVR4 tprints(", "); printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0); -#endif /* !SVR4 */ } return 0; } @@ -409,7 +397,6 @@ sys_osf_setitimer(struct tcb *tcp) } #endif -#ifdef LINUX static const struct xlat adjtimex_modes[] = { { 0, "0" }, @@ -976,4 +963,3 @@ sys_timerfd_gettime(struct tcb *tcp) return 0; } -#endif /* LINUX */ @@ -43,11 +43,6 @@ #if HAVE_SYS_UIO_H #include <sys/uio.h> #endif -#ifdef SUNOS4 -#include <machine/reg.h> -#include <a.out.h> -#include <link.h> -#endif /* SUNOS4 */ #if defined(linux) && (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1)) #include <linux/ptrace.h> @@ -74,9 +69,6 @@ # undef pt_all_user_regs #endif -#ifdef SUNOS4_KERNEL_ARCH_KLUDGE -#include <sys/utsname.h> -#endif /* SUNOS4_KERNEL_ARCH_KLUDGE */ #if defined(LINUXSPARC) && defined (SPARC64) # undef PTRACE_GETREGS @@ -254,13 +246,6 @@ printxval(const struct xlat *xlat, int val, const char *dflt) int printllval(struct tcb *tcp, const char *format, int llarg) { -# if defined(FREEBSD) \ - || (defined(LINUX) && defined(POWERPC) && !defined(POWERPC64)) \ - || defined(LINUX_MIPSO32) \ - || defined(__ARM_EABI__) - /* Align 64bit argument to 64bit boundary. */ - llarg = (llarg + 1) & 0x1e; -# endif # if defined LINUX && (defined X86_64 || defined POWERPC64) if (current_personality == 0) { tprintf(format, tcp->u_arg[llarg]); @@ -822,7 +807,6 @@ static bool process_vm_readv_not_supported = 1; int umoven(struct tcb *tcp, long addr, int len, char *laddr) { -#ifdef LINUX int pid = tcp->pid; int n, m; int started; @@ -895,39 +879,8 @@ umoven(struct tcb *tcp, long addr, int len, char *laddr) memcpy(laddr, u.x, m); addr += sizeof(long), laddr += m, len -= m; } -#endif /* LINUX */ -#ifdef SUNOS4 - int pid = tcp->pid; - int n; - - while (len) { - n = MIN(len, PAGSIZ); - n = MIN(n, ((addr + PAGSIZ) & PAGMASK) - addr); - if (ptrace(PTRACE_READDATA, pid, - (char *) addr, len, laddr) < 0) { - if (errno != ESRCH) { - perror("umoven: ptrace(PTRACE_READDATA, ...)"); - abort(); - } - return -1; - } - len -= n; - addr += n; - laddr += n; - } -#endif /* SUNOS4 */ -#ifdef USE_PROCFS -#ifdef HAVE_MP_PROCFS - int fd = tcp->pfd_as; -#else - int fd = tcp->pfd; -#endif - lseek(fd, addr, SEEK_SET); - if (read(fd, laddr, len) == -1) - return -1; -#endif /* USE_PROCFS */ return 0; } @@ -947,40 +900,6 @@ umoven(struct tcb *tcp, long addr, int len, char *laddr) int umovestr(struct tcb *tcp, long addr, int len, char *laddr) { -#ifdef USE_PROCFS -# ifdef HAVE_MP_PROCFS - int fd = tcp->pfd_as; -# else - int fd = tcp->pfd; -# endif - /* Some systems (e.g. FreeBSD) can be upset if we read off the - end of valid memory, avoid this by trying to read up - to page boundaries. But we don't know what a page is (and - getpagesize(2) (if it exists) doesn't necessarily return - hardware page size). Assume all pages >= 1024 (a-historical - I know) */ - - int page = 1024; /* How to find this? */ - int move = page - (addr & (page - 1)); - int left = len; - - lseek(fd, addr, SEEK_SET); - - while (left) { - if (move > left) - move = left; - move = read(fd, laddr, move); - if (move <= 0) - return left != len ? 0 : -1; - if (memchr(laddr, 0, move)) - return 1; - left -= move; - laddr += move; - addr += move; - move = page; - } - return 0; -#else /* !USE_PROCFS */ int started; int pid = tcp->pid; int i, n, m; @@ -1083,113 +1002,21 @@ umovestr(struct tcb *tcp, long addr, int len, char *laddr) return 1; addr += sizeof(long), laddr += m, len -= m; } -#endif /* !USE_PROCFS */ return 0; } -#ifdef LINUX # if !defined (SPARC) && !defined(SPARC64) # define PTRACE_WRITETEXT 101 # define PTRACE_WRITEDATA 102 # endif /* !SPARC && !SPARC64 */ -#endif /* LINUX */ -#ifdef SUNOS4 -static int -uload(int cmd, int pid, long addr, int len, char *laddr) -{ - int peek, poke; - int n, m; - union { - long val; - char x[sizeof(long)]; - } u; - - if (cmd == PTRACE_WRITETEXT) { - peek = PTRACE_PEEKTEXT; - poke = PTRACE_POKETEXT; - } - else { - peek = PTRACE_PEEKDATA; - poke = PTRACE_POKEDATA; - } - if (addr & (sizeof(long) - 1)) { - /* addr not a multiple of sizeof(long) */ - n = addr - (addr & -sizeof(long)); /* residue */ - addr &= -sizeof(long); - errno = 0; - u.val = ptrace(peek, pid, (char *) addr, 0); - if (errno) { - perror("uload: POKE"); - return -1; - } - m = MIN(sizeof(long) - n, len); - memcpy(&u.x[n], laddr, m); - if (ptrace(poke, pid, (char *)addr, u.val) < 0) { - perror("uload: POKE"); - return -1; - } - addr += sizeof(long), laddr += m, len -= m; - } - while (len) { - if (len < sizeof(long)) - u.val = ptrace(peek, pid, (char *) addr, 0); - m = MIN(sizeof(long), len); - memcpy(u.x, laddr, m); - if (ptrace(poke, pid, (char *) addr, u.val) < 0) { - perror("uload: POKE"); - return -1; - } - addr += sizeof(long), laddr += m, len -= m; - } - return 0; -} - -int -tload(int pid, int addr, int len, char *laddr) -{ - return uload(PTRACE_WRITETEXT, pid, addr, len, laddr); -} - -int -dload(int pid, int addr, int len, char *laddr) -{ - return uload(PTRACE_WRITEDATA, pid, addr, len, laddr); -} - -#endif /* SUNOS4 */ - -#ifndef USE_PROCFS int upeek(struct tcb *tcp, long off, long *res) { long val; -# ifdef SUNOS4_KERNEL_ARCH_KLUDGE - { - static int is_sun4m = -1; - struct utsname name; - - /* Round up the usual suspects. */ - if (is_sun4m == -1) { - if (uname(&name) < 0) { - perror("upeek: uname?"); - exit(1); - } - is_sun4m = strcmp(name.machine, "sun4m") == 0; - if (is_sun4m) { - const struct xlat *x; - - for (x = struct_user_offsets; x->str; x++) - x->val += 1024; - } - } - if (is_sun4m) - off += 1024; - } -# endif /* SUNOS4_KERNEL_ARCH_KLUDGE */ errno = 0; val = do_ptrace(PTRACE_PEEKUSER, tcp, (char *) off, 0); if (val == -1 && errno) { @@ -1204,7 +1031,6 @@ upeek(struct tcb *tcp, long off, long *res) return 0; } -#endif /* !USE_PROCFS */ void printcall(struct tcb *tcp) @@ -1213,7 +1039,6 @@ printcall(struct tcb *tcp) sizeof(long) == 8 ? "[????????????????] " : \ NULL /* crash */) -#ifdef LINUX # ifdef I386 long eip; @@ -1363,29 +1188,9 @@ printcall(struct tcb *tcp) } tprintf("[%08lx] ", pc); # endif /* architecture */ -#endif /* LINUX */ -#ifdef SUNOS4 - struct regs regs; - if (ptrace(PTRACE_GETREGS, tcp->pid, (char *) ®s, 0) < 0) { - perror("printcall: ptrace(PTRACE_GETREGS, ...)"); - PRINTBADPC; - return; - } - tprintf("[%08x] ", regs.r_o7); -#endif /* SUNOS4 */ - -#ifdef SVR4 - /* XXX */ - PRINTBADPC; -#endif -#ifdef FREEBSD - struct reg regs; - pread(tcp->pfd_reg, ®s, sizeof(regs), 0); - tprintf("[%08x] ", regs.r_eip); -#endif /* FREEBSD */ } @@ -1393,9 +1198,7 @@ printcall(struct tcb *tcp) * These #if's are huge, please indent them correctly. * It's easy to get confused otherwise. */ -#ifndef USE_PROCFS -# ifdef LINUX # include "syscall.h" @@ -1694,204 +1497,6 @@ clearbpt(struct tcb *tcp) return 0; } -# else /* !defined LINUX */ -int -setbpt(struct tcb *tcp) -{ -# ifdef SUNOS4 -# ifdef SPARC /* This code is slightly sparc specific */ - - struct regs regs; -# define BPT 0x91d02001 /* ta 1 */ -# define LOOP 0x10800000 /* ba 0 */ -# define LOOPA 0x30800000 /* ba,a 0 */ -# define NOP 0x01000000 -# if LOOPA - static int loopdeloop[1] = {LOOPA}; -# else - static int loopdeloop[2] = {LOOP, NOP}; -# endif - if (tcp->flags & TCB_BPTSET) { - fprintf(stderr, "PANIC: TCB already set in pid %u\n", tcp->pid); - return -1; - } - if (ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) { - perror("setbpt: ptrace(PTRACE_GETREGS, ...)"); - return -1; - } - tcp->baddr = regs.r_o7 + 8; - if (ptrace(PTRACE_READTEXT, tcp->pid, (char *)tcp->baddr, - sizeof tcp->inst, (char *)tcp->inst) < 0) { - perror("setbpt: ptrace(PTRACE_READTEXT, ...)"); - return -1; - } - - /* - * XXX - BRUTAL MODE ON - * We cannot set a real BPT in the child, since it will not be - * traced at the moment it will reach the trap and would probably - * die with a core dump. - * Thus, we are force our way in by taking out two instructions - * and insert an eternal loop in stead, in expectance of the SIGSTOP - * generated by out PTRACE_ATTACH. - * Of cause, if we evaporate ourselves in the middle of all this... - */ - if (ptrace(PTRACE_WRITETEXT, tcp->pid, (char *) tcp->baddr, - sizeof loopdeloop, (char *) loopdeloop) < 0) { - perror("setbpt: ptrace(PTRACE_WRITETEXT, ...)"); - return -1; - } - tcp->flags |= TCB_BPTSET; - -# endif /* SPARC */ -# endif /* SUNOS4 */ - - return 0; -} - -int -clearbpt(struct tcb *tcp) -{ -# ifdef SUNOS4 -# ifdef SPARC - -# if !LOOPA - struct regs regs; -# endif - - if (!(tcp->flags & TCB_BPTSET)) { - fprintf(stderr, "PANIC: TCB not set in pid %u\n", tcp->pid); - return -1; - } - if (ptrace(PTRACE_WRITETEXT, tcp->pid, (char *) tcp->baddr, - sizeof tcp->inst, (char *) tcp->inst) < 0) { - perror("clearbtp: ptrace(PTRACE_WRITETEXT, ...)"); - return -1; - } - tcp->flags &= ~TCB_BPTSET; - -# if !LOOPA - /* - * Since we don't have a single instruction breakpoint, we may have - * to adjust the program counter after removing our `breakpoint'. - */ - if (ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) { - perror("clearbpt: ptrace(PTRACE_GETREGS, ...)"); - return -1; - } - if ((regs.r_pc < tcp->baddr) || - (regs.r_pc > tcp->baddr + 4)) { - /* The breakpoint has not been reached yet */ - if (debug) - fprintf(stderr, - "NOTE: PC not at bpt (pc %#x baddr %#x)\n", - regs.r_pc, tcp->baddr); - return 0; - } - if (regs.r_pc != tcp->baddr) - if (debug) - fprintf(stderr, "NOTE: PC adjusted (%#x -> %#x\n", - regs.r_pc, tcp->baddr); - - regs.r_pc = tcp->baddr; - if (ptrace(PTRACE_SETREGS, tcp->pid, (char *)®s, 0) < 0) { - perror("clearbpt: ptrace(PTRACE_SETREGS, ...)"); - return -1; - } -# endif /* LOOPA */ -# endif /* SPARC */ -# endif /* SUNOS4 */ - - return 0; -} - -# endif /* !defined LINUX */ - -#endif /* !USE_PROCFS */ - - -#ifdef SUNOS4 - -static int -getex(struct tcb *tcp, struct exec *hdr) -{ - int n; - - for (n = 0; n < sizeof *hdr; n += 4) { - long res; - if (upeek(tcp, uoff(u_exdata) + n, &res) < 0) - return -1; - memcpy(((char *) hdr) + n, &res, 4); - } - if (debug) { - fprintf(stderr, "[struct exec: magic: %o version %u Mach %o\n", - hdr->a_magic, hdr->a_toolversion, hdr->a_machtype); - fprintf(stderr, "Text %lu Data %lu Bss %lu Syms %lu Entry %#lx]\n", - hdr->a_text, hdr->a_data, hdr->a_bss, hdr->a_syms, hdr->a_entry); - } - return 0; -} - -int -fixvfork(struct tcb *tcp) -{ - int pid = tcp->pid; - /* - * Change `vfork' in a freshly exec'ed dynamically linked - * executable's (internal) symbol table to plain old `fork' - */ - - struct exec hdr; - struct link_dynamic dyn; - struct link_dynamic_2 ld; - char *strtab, *cp; - - if (getex(tcp, &hdr) < 0) - return -1; - if (!hdr.a_dynamic) - return -1; - - if (umove(tcp, (int) N_DATADDR(hdr), &dyn) < 0) { - fprintf(stderr, "Cannot read DYNAMIC\n"); - return -1; - } - if (umove(tcp, (int) dyn.ld_un.ld_2, &ld) < 0) { - fprintf(stderr, "Cannot read link_dynamic_2\n"); - return -1; - } - strtab = malloc((unsigned)ld.ld_symb_size); - if (!strtab) - die_out_of_memory(); - if (umoven(tcp, (int)ld.ld_symbols+(int)N_TXTADDR(hdr), - (int)ld.ld_symb_size, strtab) < 0) - goto err; - - for (cp = strtab; cp < strtab + ld.ld_symb_size; ) { - if (strcmp(cp, "_vfork") == 0) { - if (debug) - fprintf(stderr, "fixvfork: FOUND _vfork\n"); - strcpy(cp, "_fork"); - break; - } - cp += strlen(cp)+1; - } - if (cp < strtab + ld.ld_symb_size) - /* - * Write entire symbol table back to avoid - * memory alignment bugs in ptrace - */ - if (tload(pid, (int)ld.ld_symbols+(int)N_TXTADDR(hdr), - (int)ld.ld_symb_size, strtab) < 0) - goto err; - - free(strtab); - return 0; - -err: - free(strtab); - return -1; -} -#endif /* SUNOS4 */ |