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
This commit is contained in:
philip 2005-12-04 18:25:26 +00:00
parent 89e7da8869
commit 097d1b86b3

View File

@ -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)