Module Name: src Committed By: sborrill Date: Thu Mar 15 08:53:43 UTC 2012
Modified Files: src/usr.bin/last [netbsd-6]: want.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.14.4.1 src/usr.bin/last/want.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/last/want.c diff -u src/usr.bin/last/want.c:1.14 src/usr.bin/last/want.c:1.14.4.1 --- src/usr.bin/last/want.c:1.14 Fri Sep 16 15:39:27 2011 +++ src/usr.bin/last/want.c Thu Mar 15 08:53:42 2012 @@ -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 @@ wtmp(const char *file, int namesz, int l 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 @@ wtmp(const char *file, int namesz, int l 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 @@ wtmp(const char *file, int namesz, int l } } 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 @@ static void 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);