diff options
author | wpaul <wpaul@FreeBSD.org> | 1995-11-19 05:33:30 +0000 |
---|---|---|
committer | wpaul <wpaul@FreeBSD.org> | 1995-11-19 05:33:30 +0000 |
commit | 669aa3b9da95a774196630658684387a02e64fef (patch) | |
tree | 998741cc795d2b2a6b4585c28bdcb13422037699 /usr.bin/rup | |
parent | 89f4ad04aef4f071a50ecf3ac148ff27a9479ae2 (diff) | |
download | FreeBSD-src-669aa3b9da95a774196630658684387a02e64fef.zip FreeBSD-src-669aa3b9da95a774196630658684387a02e64fef.tar.gz |
Rup uses tm_yday in its uptime printout, but ignores tm_year. This means
that if you do an rup on a machine that's been running longer than a year,
you get the wrong day count. Now we factor in 365 * (curtime.tm_year -
boottime.tm_year) to get the correct value. (I noticed this while running
rup on a SunOS machine I have that's been up 525 days. My FreeBSD
machines all said it had only been up for 160 (525-365) days. :)
Diffstat (limited to 'usr.bin/rup')
-rw-r--r-- | usr.bin/rup/rup.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/usr.bin/rup/rup.c b/usr.bin/rup/rup.c index e248be1..c9b3365 100644 --- a/usr.bin/rup/rup.c +++ b/usr.bin/rup/rup.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: rup.c,v 1.1.1.1 1994/08/28 15:01:31 csgr Exp $"; +static char rcsid[] = "$Id: rup.c,v 1.2 1995/05/30 06:33:26 rgrimes Exp $"; #endif /* not lint */ #include <stdio.h> @@ -95,6 +95,7 @@ rstat_reply(char *replyp, struct sockaddr_in *raddrp) struct hostent *hp; char *host; statstime *host_stat = (statstime *)replyp; + int year1, year2; if (search_host(raddrp->sin_addr)) return(0); @@ -115,14 +116,21 @@ rstat_reply(char *replyp, struct sockaddr_in *raddrp) tmp_time = localtime((time_t *)&host_stat->curtime.tv_sec); host_time = *tmp_time; + tmp_time = gmtime((time_t *)&host_stat->curtime.tv_sec); + year1 = tmp_time->tm_year; + tmp_time = gmtime((time_t *)&host_stat->boottime.tv_sec); + year2 = tmp_time->tm_year; + host_stat->curtime.tv_sec -= host_stat->boottime.tv_sec; tmp_time = gmtime((time_t *)&host_stat->curtime.tv_sec); host_uptime = *tmp_time; if (host_uptime.tm_yday != 0) - sprintf(days_buf, "%3d day%s, ", host_uptime.tm_yday, - (host_uptime.tm_yday > 1) ? "s" : ""); + sprintf(days_buf, "%3d day%s, ", host_uptime.tm_yday + + (365 * (year1 - year2)), + ((host_uptime.tm_yday + (365*(year1 - year2)))> 1) ? + "s" : ""); else days_buf[0] = '\0'; |