Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 Jan 2010 15:59:59 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r202007 - in user/ed/utmpx/usr.bin: . last
Message-ID:  <201001101559.o0AFxxw0071842@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Sun Jan 10 15:59:59 2010
New Revision: 202007
URL: http://svn.freebsd.org/changeset/base/202007

Log:
  Make last(1) build. It's still broken.

Modified:
  user/ed/utmpx/usr.bin/Makefile
  user/ed/utmpx/usr.bin/last/last.c

Modified: user/ed/utmpx/usr.bin/Makefile
==============================================================================
--- user/ed/utmpx/usr.bin/Makefile	Sun Jan 10 15:44:48 2010	(r202006)
+++ user/ed/utmpx/usr.bin/Makefile	Sun Jan 10 15:59:59 2010	(r202007)
@@ -94,6 +94,7 @@ SUBDIR=	alias \
 	ktrace \
 	ktrdump \
 	lam \
+	last \
 	lastcomm \
 	ldd \
 	leave \

Modified: user/ed/utmpx/usr.bin/last/last.c
==============================================================================
--- user/ed/utmpx/usr.bin/last/last.c	Sun Jan 10 15:44:48 2010	(r202006)
+++ user/ed/utmpx/usr.bin/last/last.c	Sun Jan 10 15:59:59 2010	(r202007)
@@ -82,13 +82,13 @@ LIST_HEAD(ttylisthead, ttytab) ttylist;
 
 struct ttytab {
 	time_t	logout;				/* log out time */
-	char	tty[UT_LINESIZE + 1];		/* terminal name */
+	char	tty[sizeof ((struct utmpx *)0)->ut_line]; /* terminal name */
 	LIST_ENTRY(ttytab) list;
 };
 
 static const	char *crmsg;			/* cause of last reboot */
-static long	currentout,			/* current logout value */
-		maxrec;				/* records to display */
+static time_t	currentout;			/* current logout value */
+static long	maxrec;				/* records to display */
 static const	char *file = NULL;		/* wtmp file */
 static int	sflag = 0;			/* show delta in seconds */
 static int	width = 5;			/* show seconds in delta */
@@ -206,7 +206,8 @@ main(int argc, char *argv[])
 void
 wtmp(void)
 {
-	struct utmp	*bp;			/* current structure */
+#if 0
+	struct utmpx	*bp;			/* current structure */
 	int	bytes, wfd;
 	char ct[80];
 	struct tm *tm;
@@ -219,7 +220,7 @@ wtmp(void)
 	bl = (stb.st_size + sizeof(buf) - 1) / sizeof(buf);
 
 	(void)time(&t);
-	buf[0].ut_time = _time_to_int(t);
+	buf[0].ut_tv.tv_sec = t;
 	(void)signal(SIGINT, onintr);
 	(void)signal(SIGQUIT, onintr);
 
@@ -230,10 +231,11 @@ wtmp(void)
 		for (bp = &buf[bytes / sizeof(buf[0]) - 1]; bp >= buf; --bp)
 			doentry(bp);
 	}
-	t = _int_to_time(buf[0].ut_time);
+	t = buf[0].ut_tv.tv_sec;
 	tm = localtime(&t);
 	(void) strftime(ct, sizeof(ct), "\nwtmp begins %+\n", tm);
 	printf("%s", ct);
+#endif
 }
 
 /*
@@ -257,8 +259,8 @@ doentry(struct utmpx *bp)
 			tt = LIST_NEXT(tt, list);
 			free(ttx);
 		}
-		currentout = -bp->ut_time;
-		crmsg = strncmp(bp->ut_name, "shutdown", UT_NAMESIZE) ?
+		currentout = -bp->ut_tv.tv_sec;
+		crmsg = strcmp(bp->ut_user, "shutdown") ?
 		    "crash" : "shutdown";
 		/*
 		 * if we're in snapshot mode, we want to exit if this
@@ -286,7 +288,7 @@ doentry(struct utmpx *bp)
 	}
 	/* find associated tty */
 	LIST_FOREACH(tt, &ttylist, list)
-	    if (!strncmp(tt->tty, bp->ut_line, UT_LINESIZE))
+	    if (!strcmp(tt->tty, bp->ut_line))
 		    break;
 
 	if (tt == NULL) {
@@ -295,7 +297,7 @@ doentry(struct utmpx *bp)
 		if (tt == NULL)
 			errx(1, "malloc failure");
 		tt->logout = currentout;
-		strncpy(tt->tty, bp->ut_line, UT_LINESIZE);
+		strcpy(tt->tty, bp->ut_line);
 		LIST_INSERT_HEAD(&ttylist, tt, list);
 	}
 
@@ -303,7 +305,7 @@ doentry(struct utmpx *bp)
 	 * print record if not in snapshot mode and wanted
 	 * or in snapshot mode and in snapshot range
 	 */
-	if (bp->ut_name[0] && (want(bp) || (bp->ut_time < snaptime &&
+	if (bp->ut_user[0] && (want(bp) || (bp->ut_tv.tv_sec < snaptime &&
 	    (tt->logout > snaptime || tt->logout < 1)))) {
 		snapfound = 1;
 		/*
@@ -317,7 +319,7 @@ doentry(struct utmpx *bp)
 			bp->ut_line[4] = '\0';
 		printentry(bp, tt);
 	}
-	tt->logout = bp->ut_time;
+	tt->logout = bp->ut_tv.tv_sec;
 }
 
 /*
@@ -337,15 +339,13 @@ printentry(struct utmpx *bp, struct ttyt
 
 	if (maxrec != -1 && !maxrec--)
 		exit(0);
-	t = _int_to_time(bp->ut_time);
+	t = bp->ut_tv.tv_sec;
 	tm = localtime(&t);
 	(void) strftime(ct, sizeof(ct), d_first ?
 	    (yflag ? "%a %e %b %Y %R" : "%a %e %b %R") :
 	    (yflag ? "%a %b %e %Y %R" : "%a %b %e %R"), tm);
-	printf("%-*.*s %-*.*s %-*.*s %s%c",
-	    UT_NAMESIZE, UT_NAMESIZE, bp->ut_name,
-	    UT_LINESIZE, UT_LINESIZE, bp->ut_line,
-	    UT_HOSTSIZE, UT_HOSTSIZE, bp->ut_host,
+	printf("%-10s %-8s %-24.24s %s%c",
+	    bp->ut_user, bp->ut_line, bp->ut_host,
 	    ct, tt == NULL ? '\n' : ' ');
 	if (tt == NULL)
 		return;
@@ -361,7 +361,7 @@ printentry(struct utmpx *bp, struct ttyt
 		(void) strftime(ct, sizeof(ct), "%R", tm);
 		printf("- %s", ct);
 	}
-	delta = tt->logout - bp->ut_time;
+	delta = tt->logout - bp->ut_tv.tv_sec;
 	if (sflag) {
 		printf("  (%8ld)\n", (long)delta);
 	} else {
@@ -392,15 +392,15 @@ want(struct utmpx *bp)
 	for (step = arglist; step; step = step->next)
 		switch(step->type) {
 		case HOST_TYPE:
-			if (!strncasecmp(step->name, bp->ut_host, UT_HOSTSIZE))
+			if (!strcasecmp(step->name, bp->ut_host))
 				return (YES);
 			break;
 		case TTY_TYPE:
-			if (!strncmp(step->name, bp->ut_line, UT_LINESIZE))
+			if (!strcmp(step->name, bp->ut_line))
 				return (YES);
 			break;
 		case USER_TYPE:
-			if (!strncmp(step->name, bp->ut_name, UT_NAMESIZE))
+			if (!strcmp(step->name, bp->ut_user))
 				return (YES);
 			break;
 		}
@@ -561,7 +561,7 @@ onintr(int signo)
 {
 	char ct[80];
 	struct tm *tm;
-	time_t t = _int_to_time(buf[0].ut_time);
+	time_t t = buf[0].ut_tv.tv_sec;
 
 	tm = localtime(&t);
 	(void) strftime(ct, sizeof(ct),



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001101559.o0AFxxw0071842>