From vova@express.ru  Thu Sep 20 04:51:39 2001
Return-Path: <vova@express.ru>
Received: from vbook.express.ru (asplinux.ru [195.133.213.194])
	by hub.freebsd.org (Postfix) with ESMTP
	id D21DF37B421; Thu, 20 Sep 2001 04:51:38 -0700 (PDT)
Received: from vova by vbook.express.ru with local (Exim 3.31 #2)
	id 15k2Nl-0000tr-00; Thu, 20 Sep 2001 15:52:41 +0400
Message-Id: <15273.55432.957586.417711@vbook.express.ru>
Date: Thu, 20 Sep 2001 15:52:40 +0400
From: "Vladimir B. Grebenschikov" <vova@express.ru>
Sender: "Vladimir B. Grebenschikov" <vova@express.ru>
To: Michael Sinz <msinz@wgate.com>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG, freebsd-hackers@FreeBSD.ORG
In-Reply-To: <402390ae04246407d1@[192.168.1.4]>
Subject: Re: uptime and w utilities lie about real uptime
References: <400de87e0423b007d1@[192.168.1.4]>
	<402390ae04246407d1@[192.168.1.4]>

>Number:         30682
>Category:       bin
>Synopsis:       Re: uptime and w utilities lie about real uptime
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep 20 05:00:00 PDT 2001
>Closed-Date:    Sat Sep 22 09:24:56 PDT 2001
>Last-Modified:  Wed Oct 26 05:16:24 GMT 2005
>Originator:     
>Release:        
>Organization:
>Environment:
>Description:
 Michael Sinz writes:
 
  > >         if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 &&
  > >             boottime.tv_sec != 0) {
  > >                 uptime = now - boottime.tv_sec;
  > >                 uptime += 30;
  > > ====================== ^^^^^
  > >                 days = uptime / 86400;
  > >                 uptime %= 86400;
  > >                 hrs = uptime / 3600;
  > >                 uptime %= 3600;
  > >                 mins = uptime / 60;
  > >                 secs = uptime % 60;
  > >                 (void)printf(" up");
  > > 
  > > why utility increases uptime on 30 seconds ??
  > > Is any real reasons for it ?
  > 
  > >From my reading of this, it seems to want to round the uptime to
  > the nearest minute -- afterall, w and uptime both only show the uptime
  > in minutes (well, days, hours, and minutes)
 
 not exactly right:
 
 ...
 DUMMYNET initialized (010124)
 Waiting 2 seconds for SCSI devices to settle
 SMP: AP CPU #1 Launched!
 Mounting root from ufs:/dev/da0s2a
 da0 at ahc0 bus 0 target 12 lun 0
 da0: <IBM DNES-309170W SA30> Fixed Direct Access SCSI-3 device 
 da0: 80.000MB/s transfers (40.000MHz, offset 31, 16bit), Tagged Queueing Enabled
 da0: 8748MB (17916240 512 byte sectors: 255H 63S/T 1115C)
 Enter full pathname of shell or RETURN for /bin/sh: 
 # mount -a
 # uptime
  3:12PM  up 42 secs, 3 users, load averages: 0.21, 0.05, 0.02
 # 
 
 42sec instead of more realistic 12sec
 looking into w.c more:
 
                 if (days > 0)
                         (void)printf(" %d day%s,", days, days > 1 ? "s" : "");
                 if (hrs > 0 && mins > 0)
                         (void)printf(" %2d:%02d,", hrs, mins);
                 else if (hrs > 0)
                         (void)printf(" %d hr%s,", hrs, hrs > 1 ? "s" : "");
                 else if (mins > 0)
                         (void)printf(" %d min%s,", mins, mins > 1 ? "s" : "");
                 else
                         (void)printf(" %d sec%s,", secs, secs > 1 ? "s" : "");
         }
 
 --
 TSB Russian Express, Moscow
 Vladimir B. Grebenschikov, vova@express.ru
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: greid 
State-Changed-When: Sat Sep 22 09:24:56 PDT 2001 
State-Changed-Why:  
Part of another PR's Audit-Trail 


Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: greid 
Responsible-Changed-When: Sat Sep 22 09:24:56 PDT 2001 
Responsible-Changed-Why:  
Misfiled 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=30682 
>Unformatted:
