Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Jan 2010 18:15:46 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r202204 - head/usr.sbin/timed/timed
Message-ID:  <201001131815.o0DIFkng084268@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Wed Jan 13 18:15:46 2010
New Revision: 202204
URL: http://svn.freebsd.org/changeset/base/202204

Log:
  Port timed away from logwtmp(3). Let it use utmpx.

Modified:
  head/usr.sbin/timed/timed/master.c
  head/usr.sbin/timed/timed/slave.c

Modified: head/usr.sbin/timed/timed/master.c
==============================================================================
--- head/usr.sbin/timed/timed/master.c	Wed Jan 13 18:14:59 2010	(r202203)
+++ head/usr.sbin/timed/timed/master.c	Wed Jan 13 18:15:46 2010	(r202204)
@@ -44,6 +44,7 @@ static const char rcsid[] =
 #include <sys/types.h>
 #include <sys/times.h>
 #include <setjmp.h>
+#include <utmpx.h>
 #include "pathnames.h"
 
 extern int measure_delta;
@@ -56,8 +57,6 @@ static int slvcount;			/* slaves listeni
 
 static void mchgdate(struct tsp *);
 
-extern void logwtmp(char *, char *, char *);
-
 /*
  * The main function of `master' is to periodically compute the differences
  * (deltas) between its clock and the clocks of the slaves, to compute the
@@ -350,6 +349,7 @@ mchgdate(msg)
 	char tname[MAXHOSTNAMELEN];
 	char olddate[32];
 	struct timeval otime, ntime, tmptv;
+	struct utmpx utx;
 
 	(void)strcpy(tname, msg->tsp_name);
 
@@ -371,9 +371,13 @@ mchgdate(msg)
 		dictate = 3;
 		synch(tvtomsround(ntime));
 	} else {
-		logwtmp("|", "date", "");
+		utx.ut_type = OLD_TIME;
+		gettimeofday(&utx.ut_tv, NULL);
+		pututxline(&utx);
  		(void)settimeofday(&tmptv, 0);
-		logwtmp("{", "date", "");
+		utx.ut_type = NEW_TIME;
+		gettimeofday(&utx.ut_tv, NULL);
+		pututxline(&utx);
 		spreadtime();
 	}
 

Modified: head/usr.sbin/timed/timed/slave.c
==============================================================================
--- head/usr.sbin/timed/timed/slave.c	Wed Jan 13 18:14:59 2010	(r202203)
+++ head/usr.sbin/timed/timed/slave.c	Wed Jan 13 18:15:46 2010	(r202204)
@@ -41,6 +41,7 @@ static const char rcsid[] =
 
 #include "globals.h"
 #include <setjmp.h>
+#include <utmpx.h>
 #include "pathnames.h"
 
 extern jmp_buf jmpenv;
@@ -57,8 +58,6 @@ static void schgdate(struct tsp *, char 
 static void setmaster(struct tsp *);
 static void answerdelay(void);
 
-extern void logwtmp(char *, char *, char *);
-
 int
 slave()
 {
@@ -80,6 +79,7 @@ slave()
 	char newdate[32];
 	struct netinfo *ntp;
 	struct hosttbl *htp;
+	struct utmpx utx;
 
 
 	old_slavenet = 0;
@@ -280,9 +280,13 @@ loop:
 				 */
 				synch(tvtomsround(ntime));
 			} else {
-				logwtmp("|", "date", "");
- 				(void)settimeofday(&tmptv, 0);
-				logwtmp("{", "date", "");
+				utx.ut_type = OLD_TIME;
+				gettimeofday(&utx.ut_tv, NULL);
+				pututxline(&utx);
+				(void)settimeofday(&tmptv, 0);
+				utx.ut_type = NEW_TIME;
+				gettimeofday(&utx.ut_tv, NULL);
+				pututxline(&utx);
 				syslog(LOG_NOTICE,
 				       "date changed by %s from %s",
 					msg->tsp_name, olddate);



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