summaryrefslogtreecommitdiffstats
path: root/usr.bin/lastcomm
diff options
context:
space:
mode:
authordds <dds@FreeBSD.org>2007-05-14 09:05:22 +0000
committerdds <dds@FreeBSD.org>2007-05-14 09:05:22 +0000
commit60eb6dce11926eeea6db92ba1dfe890b7a47f958 (patch)
tree576ec38e071f7a0cc03cc9ec520b63289f49e555 /usr.bin/lastcomm
parent5b911044f8a912b6fee2003528de934632b99abd (diff)
downloadFreeBSD-src-60eb6dce11926eeea6db92ba1dfe890b7a47f958.zip
FreeBSD-src-60eb6dce11926eeea6db92ba1dfe890b7a47f958.tar.gz
Backout revisions 1.16-1.14.
Backwards compatibility with the new acct(5) format will be implemented through the explicit versioning of acct records, not through an export/import procedure.
Diffstat (limited to 'usr.bin/lastcomm')
-rw-r--r--usr.bin/lastcomm/lastcomm.117
-rw-r--r--usr.bin/lastcomm/lastcomm.c49
2 files changed, 7 insertions, 59 deletions
diff --git a/usr.bin/lastcomm/lastcomm.1 b/usr.bin/lastcomm/lastcomm.1
index b29d0ba..1d714c5 100644
--- a/usr.bin/lastcomm/lastcomm.1
+++ b/usr.bin/lastcomm/lastcomm.1
@@ -32,7 +32,7 @@
.\" From: @(#)lastcomm.1 8.1 (Berkeley) 6/6/93
.\" $FreeBSD$
.\"
-.Dd April 18, 2007
+.Dd May 14, 2007
.Dt LASTCOMM 1
.Os
.Sh NAME
@@ -40,11 +40,7 @@
.Nd show last commands executed
.Sh SYNOPSIS
.Nm
-.Oo
.Op Fl EScesu
-|
-.Op Fl X
-.Oc
.Op Fl f Ar file
.Op Ar command ...\&
.Op Ar user ...\&
@@ -72,17 +68,6 @@ Print the amount of elapsed time used by the process.
Print the amount of system time used by the process.
.It Fl u
Print the amount of user time used by the process.
-.It Fl X
-Export the complete contents of each accounting record in a text format
-that can be parsed by programs.
-The elements are written in the order defined in
-.Xr acct 5 .
-Time intervals are printed in seconds using the C
-.Xr printf 3
-.Ql %g
-format specifier,
-the starting time is printed in seconds since the epoch,
-and the various identifiers are printed using their symbolic names.
.It Fl f Ar file
Read from
.Ar file
diff --git a/usr.bin/lastcomm/lastcomm.c b/usr.bin/lastcomm/lastcomm.c
index f53923f..4b0a40f 100644
--- a/usr.bin/lastcomm/lastcomm.c
+++ b/usr.bin/lastcomm/lastcomm.c
@@ -54,7 +54,6 @@ __FBSDID("$FreeBSD$");
#include <fcntl.h>
#include <grp.h>
#include <pwd.h>
-#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -69,7 +68,6 @@ char *flagbits(int);
const char *getdev(dev_t);
int requested(char *[], struct acct *);
static void usage(void);
-static void export_record(struct acct *acp);
#define AC_UTIME 1 /* user */
#define AC_STIME 2 /* system */
@@ -93,20 +91,17 @@ main(int argc, char *argv[])
int ch;
const char *acctfile;
int flags = 0;
- bool export_text = false;
acctfile = _PATH_ACCT;
- while ((ch = getopt(argc, argv, "f:usecSEX")) != -1)
+ while ((ch = getopt(argc, argv, "f:usecSE")) != -1)
switch((char)ch) {
case 'f':
acctfile = optarg;
break;
+
case 'u':
flags |= AC_UTIME; /* user time */
break;
- case 'X':
- export_text = true; /* export */
- break;
case 's':
flags |= AC_STIME; /* system time */
break;
@@ -131,11 +126,9 @@ main(int argc, char *argv[])
}
/* default user + system time and starting time */
- if (!flags && !export_text)
+ if (!flags) {
flags = AC_CTIME | AC_BTIME;
-
- if (flags && export_text)
- usage();
+ }
argc -= optind;
argv += optind;
@@ -163,7 +156,7 @@ main(int argc, char *argv[])
do {
int rv;
- if (fp != stdin && !export_text) {
+ if (fp != stdin) {
size -= sizeof(struct acct);
if (fseeko(fp, size, SEEK_SET) == -1)
err(1, "seek %s failed", acctfile);
@@ -187,11 +180,6 @@ main(int argc, char *argv[])
if (*argv && !requested(argv, &ab))
continue;
- if (export_text) {
- export_record(&ab);
- continue;
- }
-
(void)printf("%-*.*s %-7s %-*s %-*s",
AC_COMM_LEN, AC_COMM_LEN, ab.ac_comm,
flagbits(ab.ac_flag),
@@ -235,7 +223,6 @@ main(int argc, char *argv[])
printf("\n");
} while (size > 0);
-
if (fflush(stdout))
err(1, "stdout");
exit(0);
@@ -309,30 +296,6 @@ static void
usage(void)
{
(void)fprintf(stderr,
-"usage: lastcomm [[-EScesu] | [-X]] [-f file] [command ...] [user ...] [terminal ...]\n");
+"usage: lastcomm [-EScesu] [-f file] [command ...] [user ...] [terminal ...]\n");
exit(1);
}
-
-static void
-export_record(struct acct *acp)
-{
- (void)printf("%s %g %g %g",
- acp->ac_comm,
- expand(acp->ac_utime) / AC_HZ,
- expand(acp->ac_stime) / AC_HZ,
- expand(acp->ac_etime) / AC_HZ);
-
- /* See if time_t is signed and use appropriate format. */
- if ((time_t)-1 < 0)
- (void)printf(" %ld", (long)(acp->ac_btime));
- else
- (void)printf(" %lu", (unsigned long)(acp->ac_btime));
-
- (void)printf(" %s %s %d %g %s %s\n",
- user_from_uid(acp->ac_uid, 0),
- group_from_gid(acp->ac_gid, 0),
- acp->ac_mem,
- expand(acp->ac_io) / AC_HZ,
- getdev(acp->ac_tty),
- flagbits(acp->ac_flag));
-}
OpenPOWER on IntegriCloud