summaryrefslogtreecommitdiff
path: root/usr.sbin/sa
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2022-02-22 17:22:30 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2022-02-22 17:22:30 +0000
commit41b73aeefc1e5e3759c9de149288b489d467f431 (patch)
tree37eb0178fa55c24153f9c84c0dd661e9088f3146 /usr.sbin/sa
parent1416b84930b999dd5250039614b9af8ed164b47a (diff)
Since other exported commandnames were increased to 24 and graduated into
proper strings, adapt struct acct's ac_comm similarily. While here increase ac_mem to 32-bits, increase ac_flag from 8 to 32 bits for future extensions, add ac_pid for forensics, and reorder the structure to avoid compiler pads. More work remains in the sa(8) command to use ac_pid better. This is a flag day for the acct file format, new/old files/tools are incompatible. ok bluhm millert
Diffstat (limited to 'usr.sbin/sa')
-rw-r--r--usr.sbin/sa/extern.h9
-rw-r--r--usr.sbin/sa/main.c7
2 files changed, 9 insertions, 7 deletions
diff --git a/usr.sbin/sa/extern.h b/usr.sbin/sa/extern.h
index e7d22341adf..4ab2142daa9 100644
--- a/usr.sbin/sa/extern.h
+++ b/usr.sbin/sa/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.6 2019/01/17 06:21:46 tedu Exp $ */
+/* $OpenBSD: extern.h,v 1.7 2022/02/22 17:22:29 deraadt Exp $ */
/*
* Copyright (c) 1994 Christopher G. Demetriou
* All rights reserved.
@@ -30,21 +30,22 @@
*
*/
-#include <sys/param.h> /* MAXCOMLEN */
+#include <sys/sysctl.h>
#include <db.h>
/* structures */
struct cmdinfo {
- char ci_comm[MAXCOMLEN+2]; /* command name (+ '*') */
+ char ci_comm[KI_MAXCOMLEN+1]; /* command name (+ '*') */
uid_t ci_uid; /* user id */
+ pid_t ci_pid; /* pid */
uint64_t ci_calls; /* number of calls */
uint64_t ci_etime; /* elapsed time */
uint64_t ci_utime; /* user time */
uint64_t ci_stime; /* system time */
uint64_t ci_mem; /* memory use */
uint64_t ci_io; /* number of disk i/o ops */
- u_int ci_flags; /* flags; see below */
+ uint32_t ci_flags; /* flags; see below */
};
#define CI_UNPRINTABLE 0x0001 /* unprintable chars in name */
diff --git a/usr.sbin/sa/main.c b/usr.sbin/sa/main.c
index ac83714c3d0..fa7cb2fde79 100644
--- a/usr.sbin/sa/main.c
+++ b/usr.sbin/sa/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.17 2021/10/24 21:24:19 deraadt Exp $ */
+/* $OpenBSD: main.c,v 1.18 2022/02/22 17:22:29 deraadt Exp $ */
/*
* Copyright (c) 1994 Christopher G. Demetriou
* All rights reserved.
@@ -339,6 +339,7 @@ acct_load(char *pn, int wr)
ci.ci_uid = ac.ac_uid;
ci.ci_mem = ac.ac_mem;
ci.ci_io = decode_comp_t(ac.ac_io) / AHZ;
+ ci.ci_pid = ac.ac_pid;
if (!uflag) {
/* and enter it into the usracct and pacct databases */
@@ -347,10 +348,10 @@ acct_load(char *pn, int wr)
if (sflag || (mflag && !qflag))
usracct_add(&ci);
} else if (!qflag)
- printf("%6u %12.2f cpu %12lluk mem %12llu io %s\n",
+ printf("%6u %12.2f cpu %12lluk mem %12llu io pid %u %s\n",
ci.ci_uid,
(ci.ci_utime + ci.ci_stime) / (double) AHZ,
- ci.ci_mem, ci.ci_io, ci.ci_comm);
+ ci.ci_mem, ci.ci_io, ci.ci_pid, ci.ci_comm);
}
/* finally, return the file descriptor for possible truncation */