summaryrefslogtreecommitdiff
path: root/usr.bin/kdump
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/kdump')
-rw-r--r--usr.bin/kdump/kdump.112
-rw-r--r--usr.bin/kdump/kdump.c80
-rw-r--r--usr.bin/kdump/kdump.h2
-rw-r--r--usr.bin/kdump/kdump_subr.h4
-rw-r--r--usr.bin/kdump/ktrstruct.c91
5 files changed, 109 insertions, 80 deletions
diff --git a/usr.bin/kdump/kdump.1 b/usr.bin/kdump/kdump.1
index b66e0544c3d..a3d10939220 100644
--- a/usr.bin/kdump/kdump.1
+++ b/usr.bin/kdump/kdump.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: kdump.1,v 1.23 2013/06/01 09:51:30 miod Exp $
+.\" $OpenBSD: kdump.1,v 1.24 2014/12/15 01:48:54 guenther Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" from: @(#)kdump.1 8.1 (Berkeley) 6/6/93
.\"
-.Dd $Mdocdate: June 1 2013 $
+.Dd $Mdocdate: December 15 2014 $
.Dt KDUMP 1
.Os
.Sh NAME
@@ -38,7 +38,7 @@
.Sh SYNOPSIS
.Nm kdump
.Bk -words
-.Op Fl dHlnRrTXx
+.Op Fl dHlnRTXx
.Op Fl e Ar emulation
.Op Fl f Ar file
.Op Fl m Ar maxdata
@@ -98,12 +98,6 @@ Show output only for the
specified.
.It Fl R
Display relative timestamps (time since previous entry).
-.It Fl r
-When decoding the name in
-.Xr sysctl 3
-CALL records or structure members in STRU records
-(UIDs, GIDs, dates, etc),
-display symbolically instead of numerically.
.It Fl T
Display absolute timestamps for each entry (seconds since the Epoch).
.It Fl t Op ceinstuw
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c
index 7b2a6406428..5bcab64f48b 100644
--- a/usr.bin/kdump/kdump.c
+++ b/usr.bin/kdump/kdump.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kdump.c,v 1.93 2014/12/09 00:46:43 jsg Exp $ */
+/* $OpenBSD: kdump.c,v 1.94 2014/12/15 01:48:54 guenther Exp $ */
/*-
* Copyright (c) 1988, 1993
@@ -70,7 +70,7 @@
#include "extern.h"
int timestamp, decimal, iohex, fancy = 1, maxdata = INT_MAX;
-int needtid, resolv, tail;
+int needtid, tail;
char *tracefile = DEF_TRACEFILE;
struct ktr_header ktr_header;
pid_t pid_opt = -1;
@@ -143,7 +143,7 @@ static void ktrgenio(struct ktr_genio *, size_t);
static void ktrnamei(const char *, size_t);
static void ktrpsig(struct ktr_psig *);
static void ktrsyscall(struct ktr_syscall *, size_t);
-static const char *kresolvsysctl(int, int *, int);
+static const char *kresolvsysctl(int, const int *);
static void ktrsysret(struct ktr_sysret *);
static void ktruser(struct ktr_user *, size_t);
static void setemul(const char *);
@@ -172,7 +172,7 @@ main(int argc, char *argv[])
def_emul = current = &emulations[0]; /* native */
- while ((ch = getopt(argc, argv, "e:f:dHlm:nrRp:Tt:xX")) != -1)
+ while ((ch = getopt(argc, argv, "e:f:dHlm:nRp:Tt:xX")) != -1)
switch (ch) {
case 'e':
setemul(optarg);
@@ -199,9 +199,6 @@ main(int argc, char *argv[])
case 'p':
pid_opt = atoi(optarg);
break;
- case 'r':
- resolv = 1;
- break;
case 'R':
timestamp = 2; /* relative timestamp */
break;
@@ -582,6 +579,8 @@ static void (*formatters[])(int) = {
ktracefacname,
itimername,
sigset,
+ uidname,
+ gidname,
};
enum {
@@ -663,6 +662,8 @@ enum {
Ktracefacname,
Itimername,
Sigset,
+ Uidname,
+ Gidname,
};
#define Pptr Phexlong
@@ -680,8 +681,6 @@ enum {
#define Psemid Pdecint
#define Pkey_t Pdecint
#define Pucount Pdecuint
-#define Puid_t Pdecuint
-#define Pgid_t Pdecuint
#define Chflagsname Phexlong /* to be added */
#define Sockprotoname Phexlong /* to be added */
#define Swapctlname Phexlong /* to be added */
@@ -704,12 +703,12 @@ static const formatter scargs[][8] = {
[SYS_fchdir] = { Pfd },
[SYS_mknod] = { Ppath, Modename, Pdev_t },
[SYS_chmod] = { Ppath, Modename },
- [SYS_chown] = { Ppath, Puid_t, Pgid_t },
+ [SYS_chown] = { Ppath, Uidname, Gidname },
[SYS_break] = { Pptr },
[SYS_getrusage] = { Rusagewho, Pptr },
[SYS_mount] = { Pptr, Ppath, Mountflagsname, Pptr },
[SYS_unmount] = { Ppath, Mountflagsname },
- [SYS_setuid] = { Puid_t },
+ [SYS_setuid] = { Uidname },
[SYS_ptrace] = { Ptracedecode, Ppid_t, Pptr, Pdecint },
[SYS_recvmsg] = { Pfd, Pptr, Sendrecvflagsname },
[SYS_sendmsg] = { Pfd, Pptr, Sendrecvflagsname },
@@ -790,10 +789,10 @@ static const formatter scargs[][8] = {
[SYS_getsockopt] = { Pfd, PASS_TWO, Sockoptlevelname, Pptr, Pptr },
[SYS_readv] = { Pfd, Pptr, Pcount },
[SYS_writev] = { Pfd, Pptr, Pcount },
- [SYS_fchown] = { Pfd, Puid_t, Pgid_t },
+ [SYS_fchown] = { Pfd, Uidname, Gidname },
[SYS_fchmod] = { Pfd, Modename },
- [SYS_setreuid] = { Puid_t, Puid_t },
- [SYS_setregid] = { Pgid_t, Pgid_t },
+ [SYS_setreuid] = { Uidname, Uidname },
+ [SYS_setregid] = { Gidname, Gidname },
[SYS_rename] = { Ppath, Ppath },
[SYS_flock] = { Pfd, Flockname },
[SYS_mkfifo] = { Ppath, Modename },
@@ -803,15 +802,15 @@ static const formatter scargs[][8] = {
[SYS_mkdir] = { Ppath, Modename },
[SYS_rmdir] = { Ppath },
[SYS_adjtime] = { Pptr, Pptr },
- [SYS_quotactl] = { Ppath, Quotactlname, Puid_t, Pptr },
+ [SYS_quotactl] = { Ppath, Quotactlname, Uidname, Pptr },
[SYS_nfssvc] = { Phexint, Pptr },
[SYS_getfh] = { Ppath, Pptr },
[SYS_sysarch] = { Pdecint, Pptr },
[SYS_pread] = { Pfd, Pptr, Pbigsize, PAD, Poff_t },
[SYS_pwrite] = { Pfd, Pptr, Pbigsize, PAD, Poff_t },
- [SYS_setgid] = { Pgid_t },
- [SYS_setegid] = { Pgid_t },
- [SYS_seteuid] = { Puid_t },
+ [SYS_setgid] = { Gidname },
+ [SYS_setegid] = { Gidname },
+ [SYS_seteuid] = { Uidname },
[SYS_pathconf] = { Ppath, Pathconfname },
[SYS_fpathconf] = { Pfd, Pathconfname },
[SYS_swapctl] = { Swapctlname, Pptr, Pdecint },
@@ -834,7 +833,7 @@ static const formatter scargs[][8] = {
[SYS_shmdt] = { Pptr },
[SYS_minherit] = { Pptr, Pbigsize, Minheritname },
[SYS_poll] = { Pptr, Pucount, Polltimeout },
- [SYS_lchown] = { Ppath, Puid_t, Pgid_t },
+ [SYS_lchown] = { Ppath, Uidname, Gidname },
[SYS_getsid] = { Ppid_t },
[SYS_msync] = { Pptr, Pbigsize, Msyncflagsname },
[SYS_pipe] = { Pptr },
@@ -843,9 +842,9 @@ static const formatter scargs[][8] = {
[SYS_pwritev] = { Pfd, Pptr, Pcount, PAD, Poff_t },
[SYS_mlockall] = { Mlockallname },
[SYS_getresuid] = { Pptr, Pptr, Pptr },
- [SYS_setresuid] = { Puid_t, Puid_t, Puid_t },
+ [SYS_setresuid] = { Uidname, Uidname, Uidname },
[SYS_getresgid] = { Pptr, Pptr, Pptr },
- [SYS_setresgid] = { Pgid_t, Pgid_t, Pgid_t },
+ [SYS_setresgid] = { Gidname, Gidname, Gidname },
[SYS_mquery] = { Pptr, Pbigsize, Mmapprotname, Mmapflagsname, Pfd, PAD, Poff_t },
[SYS_closefrom] = { Pfd },
[SYS_sigaltstack] = { Pptr, Pptr },
@@ -863,7 +862,7 @@ static const formatter scargs[][8] = {
[SYS_setrtable] = { Pdecint },
[SYS_faccessat] = { Atfd, Ppath, Accessmodename, Atflagsname },
[SYS_fchmodat] = { Atfd, Ppath, Modename, Atflagsname },
- [SYS_fchownat] = { Atfd, Ppath, Puid_t, Pgid_t, Atflagsname },
+ [SYS_fchownat] = { Atfd, Ppath, Uidname, Gidname, Atflagsname },
[SYS_linkat] = { Atfd, Ppath, Atfd, Ppath, Atflagsname },
[SYS_mkdirat] = { Atfd, Ppath, Modename },
[SYS_mkfifoat] = { Atfd, Ppath, Modename },
@@ -903,7 +902,7 @@ ktrsyscall(struct ktr_syscall *ktr, size_t ktrlen)
if (ktr->ktr_code == SYS___sysctl) {
const char *s;
- int *np, n, i, *top;
+ int n, i, *top;
if (!fancy)
goto nonnative;
@@ -912,15 +911,21 @@ ktrsyscall(struct ktr_syscall *ktr, size_t ktrlen)
n = CTL_MAXNAME;
if (n < 0)
errx(1, "invalid sysctl length %d", n);
- np = top = (int *)(ap + 6);
- for (i = 0; n--; np++, i++) {
- if (sep)
- putchar(sep);
- if (resolv && (s = kresolvsysctl(i, top, *np)) != NULL)
- printf("%s", s);
- else
- printf("%d", *np);
- sep = '.';
+ if (n > 0) {
+ top = (int *)(ap + 6);
+ printf("%d", top[0]);
+ for (i = 1; i < n; i++)
+ printf(".%d", top[i]);
+ if ((s = kresolvsysctl(0, top)) != NULL) {
+ printf("<%s", s);
+ for (i = 1; i < n; i++) {
+ if ((s = kresolvsysctl(i, top)) != NULL)
+ printf(".%s", s);
+ else
+ printf(".%d", top[i]);
+ }
+ putchar('>');
+ }
}
sep = ',';
@@ -999,10 +1004,11 @@ static struct ctlname ddbname[] = CTL_DDB_NAMES;
#define SETNAME(name) do { names = (name); limit = nitems(name); } while (0)
static const char *
-kresolvsysctl(int depth, int *top, int idx)
+kresolvsysctl(int depth, const int *top)
{
struct ctlname *names;
size_t limit;
+ int idx = top[depth];
names = NULL;
@@ -1109,6 +1115,14 @@ ktrsysret(struct ktr_sysret *ktr)
case SYS___thrsigdivert:
signame(ret);
break;
+ case SYS_getuid:
+ case SYS_geteuid:
+ uidname(ret);
+ break;
+ case SYS_getgid:
+ case SYS_getegid:
+ gidname(ret);
+ break;
case -1: /* non-default emulation */
default:
(void)printf("%ld", (long)ret);
diff --git a/usr.bin/kdump/kdump.h b/usr.bin/kdump/kdump.h
index 28002e8e141..3e9c1facba9 100644
--- a/usr.bin/kdump/kdump.h
+++ b/usr.bin/kdump/kdump.h
@@ -22,3 +22,5 @@ void sigset(int);
/* ktrstruct.c */
void ktrstruct(char *, size_t);
+void uidname(int);
+void gidname(int);
diff --git a/usr.bin/kdump/kdump_subr.h b/usr.bin/kdump/kdump_subr.h
index edcfffb4209..d2b354b418e 100644
--- a/usr.bin/kdump/kdump_subr.h
+++ b/usr.bin/kdump/kdump_subr.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: kdump_subr.h,v 1.15 2014/12/08 21:23:44 guenther Exp $ */
+/* $OpenBSD: kdump_subr.h,v 1.16 2014/12/15 01:48:54 guenther Exp $ */
/*
* Copyright(c) 2006 2006 David Kirchner <dpk@dpk.net>
*
@@ -93,5 +93,5 @@ void sigchld_name(int);
void ktracefacname(int);
void itimername(int);
-extern int decimal, resolv, fancy;
+extern int decimal, fancy;
extern int arg1;
diff --git a/usr.bin/kdump/ktrstruct.c b/usr.bin/kdump/ktrstruct.c
index 09e303cbd71..03910666477 100644
--- a/usr.bin/kdump/ktrstruct.c
+++ b/usr.bin/kdump/ktrstruct.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ktrstruct.c,v 1.7 2014/11/20 18:44:10 krw Exp $ */
+/* $OpenBSD: ktrstruct.c,v 1.8 2014/12/15 01:48:54 guenther Exp $ */
/*-
* Copyright (c) 1988, 1993
@@ -133,17 +133,21 @@ ktrsockaddr(struct sockaddr *sa)
}
static void
-print_time(time_t t, int relative)
+print_time(time_t t, int relative, int have_subsec)
{
char timestr[PATH_MAX + 4];
struct tm *tm;
- if (resolv == 0 || relative)
+ if (t < 0 && have_subsec) {
+ /* negative times with non-zero subsecs require care */
+ printf("-%jd", -(intmax_t)(t + 1));
+ } else
printf("%jd", (intmax_t)t);
- else {
+
+ if (!relative) {
tm = localtime(&t);
(void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
- printf("\"%s\"", timestr);
+ printf("<\"%s\">", timestr);
}
}
@@ -154,15 +158,43 @@ print_timespec(const struct timespec *tsp, int relative)
printf("UTIME_NOW");
else if (tsp->tv_nsec == UTIME_OMIT)
printf("UTIME_OMIT");
- else if ((resolv == 0 || relative) && tsp->tv_sec < 0 &&
- tsp->tv_nsec > 0) {
- /* negative relative times with non-zero nsecs require care */
- printf("-%jd.%09ld", -(intmax_t)(tsp->tv_sec+1),
- 1000000000 - tsp->tv_nsec);
- } else {
- print_time(tsp->tv_sec, relative);
+ else {
+ print_time(tsp->tv_sec, relative, tsp->tv_nsec);
if (tsp->tv_nsec != 0)
- printf(".%09ld", tsp->tv_nsec);
+ printf(".%09ld", tsp->tv_sec >= 0 ? tsp->tv_nsec :
+ 1000000000 - tsp->tv_nsec);
+ }
+}
+
+void
+uidname(int uid)
+{
+ const char *name;
+
+ if (uid == -1)
+ printf("-1");
+ else {
+ printf("%u<", (unsigned)uid);
+ if (uid > UID_MAX || (name = user_from_uid(uid, 1)) == NULL)
+ printf("unknown>");
+ else
+ printf("\"%s\">", name);
+ }
+}
+
+void
+gidname(int gid)
+{
+ const char *name;
+
+ if (gid == -1)
+ printf("-1");
+ else {
+ printf("%u<", (unsigned)gid);
+ if (gid > GID_MAX || (name = group_from_gid(gid, 1)) == NULL)
+ printf("unknown>");
+ else
+ printf("\"%s\">", name);
}
}
@@ -170,8 +202,6 @@ static void
ktrstat(const struct stat *statp)
{
char mode[12];
- struct passwd *pwd;
- struct group *grp;
/*
* note: ktrstruct() has already verified that statp points to a
@@ -179,18 +209,13 @@ ktrstat(const struct stat *statp)
*/
printf("struct stat { ");
strmode(statp->st_mode, mode);
- printf("dev=%d, ino=%llu, mode=%s, nlink=%u, ",
+ printf("dev=%d, ino=%llu, mode=%s, nlink=%u, uid=",
statp->st_dev, (unsigned long long)statp->st_ino,
mode, statp->st_nlink);
- if (resolv == 0 || (pwd = getpwuid(statp->st_uid)) == NULL)
- printf("uid=%u, ", statp->st_uid);
- else
- printf("uid=\"%s\", ", pwd->pw_name);
- if (resolv == 0 || (grp = getgrgid(statp->st_gid)) == NULL)
- printf("gid=%u, ", statp->st_gid);
- else
- printf("gid=\"%s\", ", grp->gr_name);
- printf("rdev=%d, ", statp->st_rdev);
+ uidname(statp->st_uid);
+ printf(", gid=");
+ gidname(statp->st_gid);
+ printf(", rdev=%d, ", statp->st_rdev);
printf("atime=");
print_timespec(&statp->st_atim, 0);
printf(", mtime=");
@@ -214,16 +239,10 @@ ktrtimespec(const struct timespec *tsp, int relative)
static void
print_timeval(const struct timeval *tvp, int relative)
{
- if ((resolv == 0 || relative) && tvp->tv_sec < 0 &&
- tvp->tv_usec > 0) {
- /* negative relative times with non-zero usecs require care */
- printf("-%jd.%06ld", -(intmax_t)(tvp->tv_sec+1),
+ print_time(tvp->tv_sec, relative, tvp->tv_usec);
+ if (tvp->tv_usec != 0)
+ printf(".%06ld", tvp->tv_sec >= 0 ? tvp->tv_usec :
1000000 - tvp->tv_usec);
- } else {
- print_time(tvp->tv_sec, relative);
- if (tvp->tv_usec != 0)
- printf(".%06ld", tvp->tv_usec);
- }
}
static void
@@ -336,9 +355,9 @@ ktrquota(const struct dqblk *quota)
quota->dqb_bhardlimit, quota->dqb_bsoftlimit,
quota->dqb_curblocks, quota->dqb_ihardlimit,
quota->dqb_isoftlimit, quota->dqb_curinodes);
- print_time(quota->dqb_btime, 0);
+ print_time(quota->dqb_btime, 0, 0);
printf(", itime=");
- print_time(quota->dqb_itime, 0);
+ print_time(quota->dqb_itime, 0, 0);
printf(" }\n");
}