Automated removal of non-Linux code
This change is generated by running every source through the following command: unifdef -DLINUX -Dlinux -USUNOS4 -USVR4 -UUNIXWARE -UFREEBSD -USUNOS4_KERNEL_ARCH_KLUDGE -UHAVE_MP_PROCFS -UHAVE_POLLABLE_PROCFS -UHAVE_PR_SYSCALL -UUSE_PROCFS file.c Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
d2a660f534
commit
ed720fda5d
2
bjm.c
2
bjm.c
@ -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 */
|
||||
|
2
block.c
2
block.c
@ -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 */
|
||||
|
2
count.c
2
count.c
@ -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);
|
||||
|
132
defs.h
132
defs.h
@ -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))
|
||||
|
10
desc.c
10
desc.c
@ -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
|
||||
|
271
file.c
271
file.c
@ -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
|
||||
|
120
io.c
120
io.c
@ -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)
|
||||
|
27
ioctl.c
27
ioctl.c
@ -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;
|
||||
}
|
||||
|
20
ipc.c
20
ipc.c
@ -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)
|
||||
|
22
mem.c
22
mem.c
@ -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
|
||||
|
175
net.c
175
net.c
@ -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 */
|
||||
|
@ -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
|
||||
|
224
proc.c
224
proc.c
@ -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
|
||||
|
573
process.c
573
process.c
@ -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,10 +1483,8 @@ 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("}");
|
||||
}
|
||||
@ -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 */
|
||||
|
48
quota.c
48
quota.c
@ -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 */
|
||||
|
12
resource.c
12
resource.c
@ -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 */
|
||||
|
2
scsi.c
2
scsi.c
@ -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 */
|
||||
|
290
signal.c
290
signal.c
@ -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 */
|
||||
|
7
sock.c
7
sock.c
@ -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;
|
||||
}
|
||||
|
914
stream.c
914
stream.c
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
461
syscall.c
461
syscall.c
@ -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;
|
||||
}
|
||||
#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);
|
||||
|
||||
@ -1379,9 +1210,6 @@ internal_syscall(struct tcb *tcp)
|
||||
if ( sys_execve == func
|
||||
# if defined(SPARC) || defined(SPARC64) || defined(SUNOS4)
|
||||
|| sys_execv == func
|
||||
# endif
|
||||
# if UNIXWARE > 2
|
||||
|| sys_rexecve == func
|
||||
# endif
|
||||
)
|
||||
return internal_exec(tcp);
|
||||
@ -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);
|
||||
|
27
term.c
27
term.c
@ -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]);
|
||||
|
14
time.c
14
time.c
@ -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 */
|
||||
|
395
util.c
395
util.c
@ -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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user