diff options
Diffstat (limited to 'procps')
-rw-r--r-- | procps/nmeter.c | 2 | ||||
-rw-r--r-- | procps/powertop.c | 4 | ||||
-rw-r--r-- | procps/ps.c | 33 | ||||
-rw-r--r-- | procps/sysctl.c | 2 | ||||
-rw-r--r-- | procps/top.c | 4 |
5 files changed, 24 insertions, 21 deletions
diff --git a/procps/nmeter.c b/procps/nmeter.c index ed5479024..6a3b32743 100644 --- a/procps/nmeter.c +++ b/procps/nmeter.c | |||
@@ -271,7 +271,7 @@ static int rdval_loadavg(const char* p, ullong *vec, ...) | |||
271 | } | 271 | } |
272 | 272 | ||
273 | // Parses /proc/diskstats | 273 | // Parses /proc/diskstats |
274 | // 1 2 3 4 5 6(rd) 7 8 9 10(wr) 11 12 13 14 | 274 | // 1 2 3 4 5 6(rd) 7 8 9 10(wr) 11 12 13 14 |
275 | // 3 0 hda 51292 14441 841783 926052 25717 79650 843256 3029804 0 148459 3956933 | 275 | // 3 0 hda 51292 14441 841783 926052 25717 79650 843256 3029804 0 148459 3956933 |
276 | // 3 1 hda1 0 0 0 0 <- ignore if only 4 fields | 276 | // 3 1 hda1 0 0 0 0 <- ignore if only 4 fields |
277 | // Linux 3.0 (maybe earlier) started printing full stats for hda1 too. | 277 | // Linux 3.0 (maybe earlier) started printing full stats for hda1 too. |
diff --git a/procps/powertop.c b/procps/powertop.c index b4c45edbc..71988a295 100644 --- a/procps/powertop.c +++ b/procps/powertop.c | |||
@@ -493,7 +493,7 @@ static NOINLINE int process_timer_stats(void) | |||
493 | * Get information about CPU using CPUID opcode. | 493 | * Get information about CPU using CPUID opcode. |
494 | */ | 494 | */ |
495 | static void cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx, | 495 | static void cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx, |
496 | unsigned int *edx) | 496 | unsigned int *edx) |
497 | { | 497 | { |
498 | /* EAX value specifies what information to return */ | 498 | /* EAX value specifies what information to return */ |
499 | __asm__( | 499 | __asm__( |
@@ -650,7 +650,7 @@ static void show_timerstats(void) | |||
650 | } else { | 650 | } else { |
651 | bb_putchar('\n'); | 651 | bb_putchar('\n'); |
652 | bb_error_msg("no stats available; run as root or" | 652 | bb_error_msg("no stats available; run as root or" |
653 | " enable the cpufreq_stats module"); | 653 | " enable the timer_stats module"); |
654 | } | 654 | } |
655 | } | 655 | } |
656 | 656 | ||
diff --git a/procps/ps.c b/procps/ps.c index e14356482..0dfda2039 100644 --- a/procps/ps.c +++ b/procps/ps.c | |||
@@ -70,7 +70,7 @@ | |||
70 | enum { MAX_WIDTH = 2*1024 }; | 70 | enum { MAX_WIDTH = 2*1024 }; |
71 | 71 | ||
72 | #if ENABLE_FEATURE_PS_TIME || ENABLE_FEATURE_PS_LONG | 72 | #if ENABLE_FEATURE_PS_TIME || ENABLE_FEATURE_PS_LONG |
73 | static long get_uptime(void) | 73 | static unsigned long get_uptime(void) |
74 | { | 74 | { |
75 | #ifdef __linux__ | 75 | #ifdef __linux__ |
76 | struct sysinfo info; | 76 | struct sysinfo info; |
@@ -78,12 +78,15 @@ static long get_uptime(void) | |||
78 | return 0; | 78 | return 0; |
79 | return info.uptime; | 79 | return info.uptime; |
80 | #elif 1 | 80 | #elif 1 |
81 | char buf[64]; | 81 | unsigned long uptime; |
82 | long uptime; | 82 | char buf[sizeof(uptime)*3 + 2]; |
83 | /* /proc/uptime is "UPTIME_SEC.NN IDLE_SEC.NN\n" | ||
84 | * (where IDLE is cumulative over all CPUs) | ||
85 | */ | ||
83 | if (open_read_close("/proc/uptime", buf, sizeof(buf)) <= 0) | 86 | if (open_read_close("/proc/uptime", buf, sizeof(buf)) <= 0) |
84 | bb_perror_msg_and_die("can't read %s", "/proc/uptime"); | 87 | bb_perror_msg_and_die("can't read '%s'", "/proc/uptime"); |
85 | buf[sizeof(buf)-1] = '\0'; | 88 | buf[sizeof(buf)-1] = '\0'; |
86 | sscanf(buf, "%l", &uptime); | 89 | sscanf(buf, "%lu", &uptime); |
87 | return uptime; | 90 | return uptime; |
88 | #else | 91 | #else |
89 | struct timespec ts; | 92 | struct timespec ts; |
@@ -138,7 +141,7 @@ struct globals { | |||
138 | unsigned terminal_width; | 141 | unsigned terminal_width; |
139 | #if ENABLE_FEATURE_PS_TIME | 142 | #if ENABLE_FEATURE_PS_TIME |
140 | unsigned kernel_HZ; | 143 | unsigned kernel_HZ; |
141 | unsigned long long seconds_since_boot; | 144 | unsigned long seconds_since_boot; |
142 | #endif | 145 | #endif |
143 | } FIX_ALIASING; | 146 | } FIX_ALIASING; |
144 | #define G (*(struct globals*)&bb_common_bufsiz1) | 147 | #define G (*(struct globals*)&bb_common_bufsiz1) |
@@ -149,14 +152,13 @@ struct globals { | |||
149 | #define buffer (G.buffer ) | 152 | #define buffer (G.buffer ) |
150 | #define terminal_width (G.terminal_width ) | 153 | #define terminal_width (G.terminal_width ) |
151 | #define kernel_HZ (G.kernel_HZ ) | 154 | #define kernel_HZ (G.kernel_HZ ) |
152 | #define seconds_since_boot (G.seconds_since_boot) | ||
153 | #define INIT_G() do { } while (0) | 155 | #define INIT_G() do { } while (0) |
154 | 156 | ||
155 | #if ENABLE_FEATURE_PS_TIME | 157 | #if ENABLE_FEATURE_PS_TIME |
156 | /* for ELF executables, notes are pushed before environment and args */ | 158 | /* for ELF executables, notes are pushed before environment and args */ |
157 | static ptrdiff_t find_elf_note(ptrdiff_t findme) | 159 | static uintptr_t find_elf_note(uintptr_t findme) |
158 | { | 160 | { |
159 | ptrdiff_t *ep = (ptrdiff_t *) environ; | 161 | uintptr_t *ep = (uintptr_t *) environ; |
160 | 162 | ||
161 | while (*ep++) | 163 | while (*ep++) |
162 | continue; | 164 | continue; |
@@ -222,7 +224,6 @@ static inline unsigned get_HZ_by_waiting(void) | |||
222 | 224 | ||
223 | static unsigned get_kernel_HZ(void) | 225 | static unsigned get_kernel_HZ(void) |
224 | { | 226 | { |
225 | |||
226 | if (kernel_HZ) | 227 | if (kernel_HZ) |
227 | return kernel_HZ; | 228 | return kernel_HZ; |
228 | 229 | ||
@@ -231,7 +232,7 @@ static unsigned get_kernel_HZ(void) | |||
231 | if (kernel_HZ == (unsigned)-1) | 232 | if (kernel_HZ == (unsigned)-1) |
232 | kernel_HZ = get_HZ_by_waiting(); | 233 | kernel_HZ = get_HZ_by_waiting(); |
233 | 234 | ||
234 | seconds_since_boot = get_uptime(); | 235 | G.seconds_since_boot = get_uptime(); |
235 | 236 | ||
236 | return kernel_HZ; | 237 | return kernel_HZ; |
237 | } | 238 | } |
@@ -350,7 +351,7 @@ static void func_etime(char *buf, int size, const procps_status_t *ps) | |||
350 | 351 | ||
351 | mm = ps->start_time / get_kernel_HZ(); | 352 | mm = ps->start_time / get_kernel_HZ(); |
352 | /* must be after get_kernel_HZ()! */ | 353 | /* must be after get_kernel_HZ()! */ |
353 | mm = seconds_since_boot - mm; | 354 | mm = G.seconds_since_boot - mm; |
354 | ss = mm % 60; | 355 | ss = mm % 60; |
355 | mm /= 60; | 356 | mm /= 60; |
356 | snprintf(buf, size+1, "%3lu:%02u", mm, ss); | 357 | snprintf(buf, size+1, "%3lu:%02u", mm, ss); |
@@ -598,7 +599,7 @@ int ps_main(int argc UNUSED_PARAM, char **argv) | |||
598 | // -o col1,col2,col3=header | 599 | // -o col1,col2,col3=header |
599 | // Select which columns to display | 600 | // Select which columns to display |
600 | /* We allow (and ignore) most of the above. FIXME. | 601 | /* We allow (and ignore) most of the above. FIXME. |
601 | * -T is picked for threads (POSIX hasn't it standardized). | 602 | * -T is picked for threads (POSIX hasn't standardized it). |
602 | * procps v3.2.7 supports -T and shows tids as SPID column, | 603 | * procps v3.2.7 supports -T and shows tids as SPID column, |
603 | * it also supports -L where it shows tids as LWP column. | 604 | * it also supports -L where it shows tids as LWP column. |
604 | */ | 605 | */ |
@@ -609,7 +610,9 @@ int ps_main(int argc UNUSED_PARAM, char **argv) | |||
609 | parse_o(llist_pop(&opt_o)); | 610 | parse_o(llist_pop(&opt_o)); |
610 | } while (opt_o); | 611 | } while (opt_o); |
611 | } else { | 612 | } else { |
612 | /* Below: parse_o() needs char*, NOT const char*, can't give it default_o */ | 613 | /* Below: parse_o() needs char*, NOT const char*, |
614 | * can't pass it constant string. Need to make a copy first. | ||
615 | */ | ||
613 | #if ENABLE_SELINUX | 616 | #if ENABLE_SELINUX |
614 | if (!(opt & OPT_Z) || !is_selinux_enabled()) { | 617 | if (!(opt & OPT_Z) || !is_selinux_enabled()) { |
615 | /* no -Z or no SELinux: do not show LABEL */ | 618 | /* no -Z or no SELinux: do not show LABEL */ |
@@ -663,7 +666,7 @@ int ps_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
663 | }; | 666 | }; |
664 | #if ENABLE_FEATURE_PS_LONG | 667 | #if ENABLE_FEATURE_PS_LONG |
665 | time_t now = now; | 668 | time_t now = now; |
666 | long uptime; | 669 | unsigned long uptime; |
667 | #endif | 670 | #endif |
668 | /* If we support any options, parse argv */ | 671 | /* If we support any options, parse argv */ |
669 | #if ENABLE_SELINUX || ENABLE_FEATURE_SHOW_THREADS || ENABLE_FEATURE_PS_WIDE || ENABLE_FEATURE_PS_LONG | 672 | #if ENABLE_SELINUX || ENABLE_FEATURE_SHOW_THREADS || ENABLE_FEATURE_PS_WIDE || ENABLE_FEATURE_PS_LONG |
diff --git a/procps/sysctl.c b/procps/sysctl.c index 878656862..c6a1de21d 100644 --- a/procps/sysctl.c +++ b/procps/sysctl.c | |||
@@ -205,7 +205,7 @@ static int sysctl_act_recursive(const char *path) | |||
205 | continue; /* d_name is "." or ".." */ | 205 | continue; /* d_name is "." or ".." */ |
206 | /* if path was ".", drop "./" prefix: */ | 206 | /* if path was ".", drop "./" prefix: */ |
207 | retval |= sysctl_act_recursive((next[0] == '.' && next[1] == '/') ? | 207 | retval |= sysctl_act_recursive((next[0] == '.' && next[1] == '/') ? |
208 | next + 2 : next); | 208 | next + 2 : next); |
209 | free(next); | 209 | free(next); |
210 | } | 210 | } |
211 | closedir(dirp); | 211 | closedir(dirp); |
diff --git a/procps/top.c b/procps/top.c index b08444a76..abee69806 100644 --- a/procps/top.c +++ b/procps/top.c | |||
@@ -294,7 +294,7 @@ static void get_jiffy_counts(void) | |||
294 | * they are used to calculate per process CPU% */ | 294 | * they are used to calculate per process CPU% */ |
295 | prev_jif = cur_jif; | 295 | prev_jif = cur_jif; |
296 | if (read_cpu_jiffy(fp, &cur_jif) < 4) | 296 | if (read_cpu_jiffy(fp, &cur_jif) < 4) |
297 | bb_error_msg_and_die("can't read /proc/stat"); | 297 | bb_error_msg_and_die("can't read '%s'", "/proc/stat"); |
298 | 298 | ||
299 | #if !ENABLE_FEATURE_TOP_SMP_CPU | 299 | #if !ENABLE_FEATURE_TOP_SMP_CPU |
300 | fclose(fp); | 300 | fclose(fp); |
@@ -995,7 +995,7 @@ static unsigned handle_input(unsigned scan_mask, unsigned interval) | |||
995 | } | 995 | } |
996 | # if ENABLE_FEATURE_SHOW_THREADS | 996 | # if ENABLE_FEATURE_SHOW_THREADS |
997 | if (c == 'h' | 997 | if (c == 'h' |
998 | IF_FEATURE_TOPMEM(&& scan_mask != TOPMEM_MASK) | 998 | IF_FEATURE_TOPMEM(&& scan_mask != TOPMEM_MASK) |
999 | ) { | 999 | ) { |
1000 | scan_mask ^= PSSCAN_TASKS; | 1000 | scan_mask ^= PSSCAN_TASKS; |
1001 | continue; | 1001 | continue; |