Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-6]: src/usr.bin/last Pull up the following revisions(s) (requeste...
details: https://anonhg.NetBSD.org/src/rev/5e20c3b4519d
branches: netbsd-6
changeset: 773919:5e20c3b4519d
user: sborrill <sborrill%NetBSD.org@localhost>
date: Thu Mar 15 08:53:42 2012 +0000
description:
Pull up the following revisions(s) (requested by dholland in ticket #117):
usr.bin/last/want.c: revision 1.15-116
Keep track of the timestamp of the last (thus oldest) record seen and use
it to print "wtmp[x] begins" at the end. When the wtmp file is empty, use
the last mod time of the wtmp file. Fixes PR/39444.
diffstat:
usr.bin/last/want.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diffs (55 lines):
diff -r 1568364b7c60 -r 5e20c3b4519d usr.bin/last/want.c
--- a/usr.bin/last/want.c Sat Mar 10 21:38:30 2012 +0000
+++ b/usr.bin/last/want.c Thu Mar 15 08:53:42 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: want.c,v 1.14 2011/09/16 15:39:27 joerg Exp $ */
+/* $NetBSD: want.c,v 1.14.4.1 2012/03/15 08:53:42 sborrill Exp $ */
/*
* Copyright (c) 1987, 1993, 1994
@@ -29,6 +29,7 @@
* SUCH DAMAGE.
*/
static struct utmp *buf;
+static time_t seentime;
static void onintr(int);
static int want(struct utmp *, int);
@@ -130,7 +131,7 @@
if (!S_ISREG(stb.st_mode))
errx(EXIT_FAILURE, "%s: Not a regular file", file);
- buf[FIRSTVALID].ut_timefld = time(NULL);
+ seentime = stb.st_mtime;
(void)signal(SIGINT, onintr);
(void)signal(SIGQUIT, onintr);
@@ -157,6 +158,9 @@
NULTERM(name);
NULTERM(line);
NULTERM(host);
+
+ seentime = bp->ut_timefld;
+
/*
* if the terminal line is '~', the machine stopped.
* see utmp(5) for more info.
@@ -250,7 +254,7 @@
}
}
fulltime = 1; /* show full time */
- crmsg = fmttime(buf[FIRSTVALID].ut_timefld, FULLTIME);
+ crmsg = fmttime(seentime, FULLTIME);
if ((ct = strrchr(file, '/')) != NULL)
ct++;
printf("\n%s begins %s\n", ct ? ct : file, crmsg);
@@ -305,8 +309,7 @@
onintr(int signo)
{
/* FIXME: None of this is allowed in a signal handler */
- printf("\ninterrupted %s\n", fmttime(buf[FIRSTVALID].ut_timefld,
- FULLTIME));
+ printf("\ninterrupted %s\n", fmttime(seentime, FULLTIME));
if (signo == SIGINT) {
(void)raise_default_signal(signo);
exit(EXIT_FAILURE);
Home |
Main Index |
Thread Index |
Old Index