[Midnightbsd-cvs] src [11501] trunk/usr.bin/last/last.c: sync last with freebsd.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Jul 7 13:39:34 EDT 2018
Revision: 11501
http://svnweb.midnightbsd.org/src/?rev=11501
Author: laffer1
Date: 2018-07-07 13:39:33 -0400 (Sat, 07 Jul 2018)
Log Message:
-----------
sync last with freebsd.
Modified Paths:
--------------
trunk/usr.bin/last/Makefile
trunk/usr.bin/last/last.1
trunk/usr.bin/last/last.c
Property Changed:
----------------
trunk/usr.bin/last/last.1
Modified: trunk/usr.bin/last/Makefile
===================================================================
--- trunk/usr.bin/last/Makefile 2018-07-07 17:39:19 UTC (rev 11500)
+++ trunk/usr.bin/last/Makefile 2018-07-07 17:39:33 UTC (rev 11501)
@@ -1,8 +1,9 @@
+# $MidnightBSD$
# From: @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $MidnightBSD$
+# $FreeBSD: stable/10/usr.bin/last/Makefile 226361 2011-10-14 07:26:20Z ed $
PROG= last
-WARNS?= 1
+NO_WFORMAT=
.include <bsd.prog.mk>
Modified: trunk/usr.bin/last/last.1
===================================================================
--- trunk/usr.bin/last/last.1 2018-07-07 17:39:19 UTC (rev 11500)
+++ trunk/usr.bin/last/last.1 2018-07-07 17:39:33 UTC (rev 11501)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)last.1 8.1 (Berkeley) 6/6/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.bin/last/last.1 240506 2012-09-14 17:50:42Z eadler $
.\"
.Dd January 21, 2010
.Dt LAST 1
@@ -198,6 +199,7 @@
.El
.Sh SEE ALSO
.Xr lastcomm 1 ,
+.Xr lastlogin 8 ,
.Xr getutxent 3 ,
.Xr ac 8
.Sh HISTORY
Property changes on: trunk/usr.bin/last/last.1
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/last/last.c
===================================================================
--- trunk/usr.bin/last/last.c 2018-07-07 17:39:19 UTC (rev 11500)
+++ trunk/usr.bin/last/last.c 2018-07-07 17:39:33 UTC (rev 11501)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1987, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -37,7 +38,7 @@
static const char sccsid[] = "@(#)last.c 8.2 (Berkeley) 4/2/94";
#endif /* not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/last/last.c 286952 2015-08-20 08:34:13Z ed $");
#include <sys/param.h>
#include <sys/stat.h>
@@ -64,6 +65,7 @@
typedef struct arg {
char *name; /* argument */
+#define REBOOT_TYPE -1
#define HOST_TYPE -2
#define TTY_TYPE -3
#define USER_TYPE -4
@@ -70,20 +72,20 @@
int type; /* type of arg */
struct arg *next; /* linked list pointer */
} ARG;
-ARG *arglist; /* head of linked list */
+static ARG *arglist; /* head of linked list */
-LIST_HEAD(idlisthead, idtab) idlist;
+static SLIST_HEAD(, idtab) idlist;
struct idtab {
time_t logout; /* log out time */
char id[sizeof ((struct utmpx *)0)->ut_id]; /* identifier */
- LIST_ENTRY(idtab) list;
+ SLIST_ENTRY(idtab) list;
};
static const char *crmsg; /* cause of last reboot */
static time_t currentout; /* current logout value */
static long maxrec; /* records to display */
-static const char *file = NULL; /* wtmp file */
+static const char *file = NULL; /* utx.log file */
static int sflag = 0; /* show delta in seconds */
static int width = 5; /* show seconds in delta */
static int yflag; /* show year */
@@ -94,17 +96,17 @@
* at this snapshot time
*/
-void addarg(int, char *);
-time_t dateconv(char *);
-void doentry(struct utmpx *);
-void hostconv(char *);
-void printentry(struct utmpx *, struct idtab *);
-char *ttyconv(char *);
-int want(struct utmpx *);
-void usage(void);
-void wtmp(void);
+static void addarg(int, char *);
+static time_t dateconv(char *);
+static void doentry(struct utmpx *);
+static void hostconv(char *);
+static void printentry(struct utmpx *, struct idtab *);
+static char *ttyconv(char *);
+static int want(struct utmpx *);
+static void usage(void);
+static void wtmp(void);
-void
+static void
usage(void)
{
(void)fprintf(stderr,
@@ -180,6 +182,8 @@
if (argc) {
setlinebuf(stdout);
for (argv += optind; *argv; ++argv) {
+ if (strcmp(*argv, "reboot") == 0)
+ addarg(REBOOT_TYPE, *argv);
#define COMPATIBILITY
#ifdef COMPATIBILITY
/* code to allow "last p5" to work */
@@ -194,9 +198,9 @@
/*
* wtmp --
- * read through the wtmp file
+ * read through the utx.log file
*/
-void
+static void
wtmp(void)
{
struct utmpx *buf = NULL;
@@ -206,7 +210,7 @@
char ct[80];
struct tm *tm;
- LIST_INIT(&idlist);
+ SLIST_INIT(&idlist);
(void)time(&t);
/* Load the last entries from the file. */
@@ -229,27 +233,25 @@
doentry(&buf[--amount]);
tm = localtime(&t);
- (void) strftime(ct, sizeof(ct), "\nwtmp begins %+\n", tm);
- printf("%s", ct);
+ (void) strftime(ct, sizeof(ct), "%+", tm);
+ printf("\n%s begins %s\n", ((file == NULL) ? "utx.log" : file), ct);
}
/*
* doentry --
- * process a single wtmp entry
+ * process a single utx.log entry
*/
-void
+static void
doentry(struct utmpx *bp)
{
- struct idtab *tt, *ttx; /* idlist entry */
+ struct idtab *tt;
/* the machine stopped */
if (bp->ut_type == BOOT_TIME || bp->ut_type == SHUTDOWN_TIME) {
/* everybody just logged out */
- for (tt = LIST_FIRST(&idlist); tt;) {
- LIST_REMOVE(tt, list);
- ttx = tt;
- tt = LIST_NEXT(tt, list);
- free(ttx);
+ while ((tt = SLIST_FIRST(&idlist)) != NULL) {
+ SLIST_REMOVE_HEAD(&idlist, list);
+ free(tt);
}
currentout = -bp->ut_tv.tv_sec;
crmsg = bp->ut_type != SHUTDOWN_TIME ?
@@ -279,7 +281,7 @@
return;
/* find associated identifier */
- LIST_FOREACH(tt, &idlist, list)
+ SLIST_FOREACH(tt, &idlist, list)
if (!memcmp(tt->id, bp->ut_id, sizeof bp->ut_id))
break;
@@ -290,7 +292,7 @@
errx(1, "malloc failure");
tt->logout = currentout;
memcpy(tt->id, bp->ut_id, sizeof bp->ut_id);
- LIST_INSERT_HEAD(&idlist, tt, list);
+ SLIST_INSERT_HEAD(&idlist, tt, list);
}
/*
@@ -313,7 +315,7 @@
* If `tt' is non-NULL, use it and `crmsg' to print the logout time or
* logout type (crash/shutdown) as appropriate.
*/
-void
+static void
printentry(struct utmpx *bp, struct idtab *tt)
{
char ct[80];
@@ -378,7 +380,7 @@
* want --
* see if want this entry
*/
-int
+static int
want(struct utmpx *bp)
{
ARG *step;
@@ -391,6 +393,11 @@
for (step = arglist; step; step = step->next)
switch(step->type) {
+ case REBOOT_TYPE:
+ if (bp->ut_type == BOOT_TIME ||
+ bp->ut_type == SHUTDOWN_TIME)
+ return (YES);
+ break;
case HOST_TYPE:
if (!strcasecmp(step->name, bp->ut_host))
return (YES);
@@ -411,7 +418,7 @@
* addarg --
* add an entry to a linked list of arguments
*/
-void
+static void
addarg(int type, char *arg)
{
ARG *cur;
@@ -430,7 +437,7 @@
* has a domain attached that is the same as the current domain, rip
* off the domain suffix since that's what login(1) does.
*/
-void
+static void
hostconv(char *arg)
{
static int first = 1;
@@ -453,7 +460,7 @@
* ttyconv --
* convert tty to correct name.
*/
-char *
+static char *
ttyconv(char *arg)
{
char *mval;
@@ -485,7 +492,7 @@
* [[CC]YY]MMDDhhmm[.SS]] to a time_t.
* Derived from atime_arg1() in usr.bin/touch/touch.c
*/
-time_t
+static time_t
dateconv(char *arg)
{
time_t timet;
More information about the Midnightbsd-cvs
mailing list