From 40d07bddd6e5d2da1a856c36e20f8bda224ae794 Mon Sep 17 00:00:00 2001 From: sef Date: Sat, 6 Dec 1997 06:51:14 +0000 Subject: First cut at printing out ioctl names intelligently. Note that this doesn't handle linux ioctls (yet?). This uses the mkioctl script from kdump, bless its little heart. Reviewed by: Mike Smith --- usr.bin/truss/Makefile | 8 ++++++-- usr.bin/truss/syscall.h | 5 +++-- usr.bin/truss/syscalls.c | 14 +++++++++++++- 3 files changed, 22 insertions(+), 5 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/truss/Makefile b/usr.bin/truss/Makefile index a34501a0..63172a8 100644 --- a/usr.bin/truss/Makefile +++ b/usr.bin/truss/Makefile @@ -1,8 +1,9 @@ PROG= truss SRCS= main.c setup.c i386-fbsd.c i386-linux.c \ - syscalls.c linux_syscalls.h syscalls.h + syscalls.c linux_syscalls.h syscalls.h ioctl.c CFLAGS+= -I${.CURDIR} -I. -CLEANFILES+=i386l-syscalls.master syscalls.master linux_syscalls.h syscalls.h +CLEANFILES+=i386l-syscalls.master syscalls.master linux_syscalls.h \ + syscalls.h ioctl.c .SUFFIXES: .master @@ -20,4 +21,7 @@ syscalls.h: syscalls.master /bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh syscalls.master \ ${.CURDIR}/i386.conf +ioctl.c: ${.CURDIR}/../../usr.bin/kdump/mkioctls + /bin/sh ${.CURDIR}/../../usr.bin/kdump/mkioctls > ioctl.c + .include diff --git a/usr.bin/truss/syscall.h b/usr.bin/truss/syscall.h index 74f8334..5e84178 100644 --- a/usr.bin/truss/syscall.h +++ b/usr.bin/truss/syscall.h @@ -9,16 +9,17 @@ * Ptr -- pointer to some specific structure. Just print as hex for now. * Quad -- a double-word value. e.g., lseek(int, offset_t, int) * Stat -- a pointer to a stat buffer. Currently unused. + * Ioctl -- an ioctl command. Woefully limited. * * In addition, the pointer types (String, Ptr) may have OUT masked in -- * this means that the data is set on *return* from the system call -- or * IN (meaning that the data is passed *into* the system call). */ /* - * $Id$ + * $Id: syscall.h,v 1.1 1997/12/06 05:23:07 sef Exp $ */ -enum Argtype { None = 1, Hex, Octal, Int, String, Ptr, Stat, Quad }; +enum Argtype { None = 1, Hex, Octal, Int, String, Ptr, Stat, Ioctl, Quad }; #define ARG_MASK 0xff #define OUT 0x100 diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c index 98dadca..06baed5 100644 --- a/usr.bin/truss/syscalls.c +++ b/usr.bin/truss/syscalls.c @@ -3,7 +3,7 @@ * arguments. */ /* - * $Id$ + * $Id: syscalls.c,v 1.1 1997/12/06 05:23:10 sef Exp $ */ #include @@ -39,6 +39,8 @@ struct syscall syscalls[] = { { { Int, 0 }, { Ptr | OUT, 1 }}}, { "write", 1, 3, { { Int, 0}, { Ptr | IN, 1 }, { Int, 2 }}}, + { "ioctl", 1, 3, + { { Int, 0}, { Ioctl, 1 }, { Hex, 2 }}}, { "break", 1, 1, { { Hex, 0 }}}, { "exit", 0, 1, { { Hex, 0 }}}, { 0, 0, 0, { 0, 0 } }, @@ -168,6 +170,16 @@ print_arg(int fd, struct syscall_args *sc, unsigned long *args) { tmp = malloc(12); sprintf(tmp, "0x%x", args[sc->offset]); break; + case Ioctl: + { + char *temp = ioctlname(args[sc->offset]); + if (temp) + tmp = strdup(temp); + else { + tmp = malloc(12); + sprintf(tmp, "0x%x", args[sc->offset]); + } + } } return tmp; } -- cgit v1.1