diff options
author | philip <philip@FreeBSD.org> | 2005-12-04 18:25:26 +0000 |
---|---|---|
committer | philip <philip@FreeBSD.org> | 2005-12-04 18:25:26 +0000 |
commit | 097d1b86b3a4c615f8b2519a13fcbf9a625cff4e (patch) | |
tree | 18467e5d9037410be6ae5f89bb058c26446c2bbd /usr.bin/rup | |
parent | 89e7da8869c1c60c8808703a15bbab1e502431e7 (diff) | |
download | FreeBSD-src-097d1b86b3a4c615f8b2519a13fcbf9a625cff4e.zip FreeBSD-src-097d1b86b3a4c615f8b2519a13fcbf9a625cff4e.tar.gz |
Catch up with 64bit time_t on sparc64. The rstat packet expects a 32bit
time_t and times will look incorrect on machines with 64bit time_t.
PR: 88788
Submitted by: Keith White <Keith.White -at- site.uottawa.ca>
MFC after: 1 week
Diffstat (limited to 'usr.bin/rup')
-rw-r--r-- | usr.bin/rup/rup.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/usr.bin/rup/rup.c b/usr.bin/rup/rup.c index 26037a6..239b313 100644 --- a/usr.bin/rup/rup.c +++ b/usr.bin/rup/rup.c @@ -101,6 +101,7 @@ rstat_reply(caddr_t replyp, struct sockaddr_in *raddrp) struct hostent *hp; char *host; statstime *host_stat = (statstime *)replyp; + time_t tmp_time_t; if (search_host(raddrp->sin_addr)) return(0); @@ -118,13 +119,26 @@ rstat_reply(caddr_t replyp, struct sockaddr_in *raddrp) printf("%-*s\t", HOST_WIDTH, host); - tmp_time = localtime((time_t *)&host_stat->curtime.tv_sec); - host_time = *tmp_time; + if (sizeof(time_t) == sizeof(host_stat->curtime.tv_sec)) { + tmp_time = localtime((time_t *)&host_stat->curtime.tv_sec); + host_time = *tmp_time; - host_stat->curtime.tv_sec -= host_stat->boottime.tv_sec; + host_stat->curtime.tv_sec -= host_stat->boottime.tv_sec; - tmp_time = gmtime((time_t *)&host_stat->curtime.tv_sec); - host_uptime = *tmp_time; + tmp_time = gmtime((time_t *)&host_stat->curtime.tv_sec); + host_uptime = *tmp_time; + } + else { /* non-32-bit time_t */ + tmp_time_t = host_stat->curtime.tv_sec; + tmp_time = localtime(&tmp_time_t); + host_time = *tmp_time; + + host_stat->curtime.tv_sec -= host_stat->boottime.tv_sec; + + tmp_time_t = host_stat->curtime.tv_sec; + tmp_time = gmtime(&tmp_time_t); + host_uptime = *tmp_time; + } #define updays (host_stat->curtime.tv_sec / 86400) if (host_uptime.tm_yday != 0) |