From 6dbef339c2e2f911849d1e5ee418a570d4bd18b1 Mon Sep 17 00:00:00 2001 From: albert <> Date: Sat, 6 Sep 2003 05:11:04 +0000 Subject: [PATCH] fix 4 GB wrap-around in top --- NEWS | 3 +++ ps/ps.1 | 3 +-- top.c | 10 +++++++++- top.h | 5 ----- w.1 | 2 +- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index d364938a..bbd9738c 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ procps-3.1.11 --> procps-3.1.12 +top: fixed 4 GB wrap-around +ps: comes with tests +man page: /var/run/utmp, not /etc/utmp #206583 required flags moved out of CFLAGS #205429 RPM generation handles /lib64 WCHAN skips leading '.' diff --git a/ps/ps.1 b/ps/ps.1 index 789a8867..b22288a6 100644 --- a/ps/ps.1 +++ b/ps/ps.1 @@ -240,8 +240,7 @@ will be destroyed by init(8) if the parent process exits. PROCESS FLAGS FORKNOEXEC 1 forked but didn't exec -SUPERPRIV 2 used super-user privileges -DUMPCORE 4 dumped core +SUPERPRIV 4 used super-user privileges PROCESS STATE CODES diff --git a/top.c b/top.c index 3e6fe2a8..3a48937b 100644 --- a/top.c +++ b/top.c @@ -71,7 +71,8 @@ static char Rc_name [OURPATHSZ]; static RCF_t Rc = DEF_RCFILE; /* The run-time acquired page size */ -static int Page_size; +static unsigned Page_size; +static unsigned page_to_kb_shift; /* SMP, Irix/Solaris mode, Linux 2.5.xx support */ static int Cpu_tot, @@ -1567,6 +1568,11 @@ static void before (char *me) /* get virtual page size -- nearing huge! */ Page_size = getpagesize(); + i = Page_size; + while(i>1024){ + i >>= 1; + page_to_kb_shift++; + } } @@ -2874,6 +2880,8 @@ static proc_t **summary_show (void) } +#define PAGES_2K(n) (unsigned)( (n) << page_to_kb_shift ) + /* * Display information for a single task row. */ static void task_show (const WIN_t *q, const proc_t *p) diff --git a/top.h b/top.h index 4c8bde91..90f1a7ea 100644 --- a/top.h +++ b/top.h @@ -82,11 +82,6 @@ /* Yield table size as 'int' */ #define MAXTBL(t) (int)(sizeof(t) / sizeof(t[0])) - /* Convert some proc stuff into vaules we can actually use */ -#define BYTES_2K(n) (unsigned)( (n) >> 10 ) -#define PAGES_2B(n) (unsigned)( (n) * Page_size ) -#define PAGES_2K(n) BYTES_2K(PAGES_2B(n)) - /* Used as return arguments in *some* of the sort callbacks */ #define SORT_lt ( Frame_srtflg > 0 ? 1 : -1 ) #define SORT_gt ( Frame_srtflg > 0 ? -1 : 1 ) diff --git a/w.1 b/w.1 index d8a32c01..d57a9b58 100644 --- a/w.1 +++ b/w.1 @@ -60,7 +60,7 @@ Show information about the specified user only. .SH FILES .TP -.I /etc/utmp +.I /var/run/utmp information about who is currently logged on .TP .I /proc