aboutsummaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
Diffstat (limited to 'procps')
-rw-r--r--procps/Kbuild.src2
-rw-r--r--procps/free.c2
-rw-r--r--procps/fuser.c2
-rw-r--r--procps/iostat.c2
-rw-r--r--procps/kill.c6
-rw-r--r--procps/mpstat.c12
-rw-r--r--procps/nmeter.c11
-rw-r--r--procps/pgrep.c2
-rw-r--r--procps/pidof.c2
-rw-r--r--procps/pmap.c111
-rw-r--r--procps/ps.c2
-rw-r--r--procps/renice.c4
-rw-r--r--procps/sysctl.c2
-rw-r--r--procps/top.c18
-rw-r--r--procps/uptime.c2
-rw-r--r--procps/watch.c2
16 files changed, 147 insertions, 35 deletions
diff --git a/procps/Kbuild.src b/procps/Kbuild.src
index c41f12b15..791d65670 100644
--- a/procps/Kbuild.src
+++ b/procps/Kbuild.src
@@ -2,7 +2,7 @@
2# 2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org> 3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4# 4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball. 5# Licensed under GPLv2, see file LICENSE in this source tree.
6 6
7lib-y:= 7lib-y:=
8 8
diff --git a/procps/free.c b/procps/free.c
index db70712cf..be65f46f1 100644
--- a/procps/free.c
+++ b/procps/free.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> 5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
6 * 6 *
7 * Licensed under the GPL version 2, see the file LICENSE in this tarball. 7 * Licensed under GPLv2, see file LICENSE in this source tree.
8 */ 8 */
9 9
10/* getopt not needed */ 10/* getopt not needed */
diff --git a/procps/fuser.c b/procps/fuser.c
index 85523c31c..addf1a7d8 100644
--- a/procps/fuser.c
+++ b/procps/fuser.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * Copyright 2004 Tony J. White 5 * Copyright 2004 Tony J. White
6 * 6 *
7 * Licensed under GPLv2, see file LICENSE in this tarball for details. 7 * Licensed under GPLv2, see file LICENSE in this source tree.
8 */ 8 */
9 9
10#include "libbb.h" 10#include "libbb.h"
diff --git a/procps/iostat.c b/procps/iostat.c
index 05c758b6c..5d829861e 100644
--- a/procps/iostat.c
+++ b/procps/iostat.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * Copyright (C) 2010 Marek Polacek <mmpolacek@gmail.com> 5 * Copyright (C) 2010 Marek Polacek <mmpolacek@gmail.com>
6 * 6 *
7 * Licensed under GPLv2, see file LICENSE in this tarball for details. 7 * Licensed under GPLv2, see file LICENSE in this source tree.
8 */ 8 */
9 9
10//applet:IF_IOSTAT(APPLET(iostat, _BB_DIR_BIN, _BB_SUID_DROP)) 10//applet:IF_IOSTAT(APPLET(iostat, _BB_DIR_BIN, _BB_SUID_DROP))
diff --git a/procps/kill.c b/procps/kill.c
index 1d343edff..b51d44a70 100644
--- a/procps/kill.c
+++ b/procps/kill.c
@@ -5,7 +5,7 @@
5 * Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>. 5 * Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
6 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> 6 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
7 * 7 *
8 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 8 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
9 */ 9 */
10 10
11#include "libbb.h" 11#include "libbb.h"
@@ -153,7 +153,7 @@ int kill_main(int argc, char **argv)
153 arg = argv[i]; 153 arg = argv[i];
154 omit = bb_strtoi(arg, NULL, 10); 154 omit = bb_strtoi(arg, NULL, 10);
155 if (errno) { 155 if (errno) {
156 bb_error_msg("bad pid '%s'", arg); 156 bb_error_msg("invalid number '%s'", arg);
157 ret = 1; 157 ret = 1;
158 goto resume; 158 goto resume;
159 } 159 }
@@ -211,7 +211,7 @@ int kill_main(int argc, char **argv)
211 arg++; 211 arg++;
212 pid = bb_strtoi(arg, NULL, 10); 212 pid = bb_strtoi(arg, NULL, 10);
213 if (errno) { 213 if (errno) {
214 bb_error_msg("bad pid '%s'", arg); 214 bb_error_msg("invalid number '%s'", arg);
215 errors++; 215 errors++;
216 } else if (kill(pid, signo) != 0) { 216 } else if (kill(pid, signo) != 0) {
217 bb_perror_msg("can't kill pid %d", (int)pid); 217 bb_perror_msg("can't kill pid %d", (int)pid);
diff --git a/procps/mpstat.c b/procps/mpstat.c
index bf0f593f7..f1a0b00b8 100644
--- a/procps/mpstat.c
+++ b/procps/mpstat.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * Copyright (C) 2010 Marek Polacek <mmpolacek@gmail.com> 5 * Copyright (C) 2010 Marek Polacek <mmpolacek@gmail.com>
6 * 6 *
7 * Licensed under GPLv2, see file LICENSE in this tarball for details. 7 * Licensed under GPLv2, see file LICENSE in this source tree.
8 */ 8 */
9 9
10//applet:IF_MPSTAT(APPLET(mpstat, _BB_DIR_BIN, _BB_SUID_DROP)) 10//applet:IF_MPSTAT(APPLET(mpstat, _BB_DIR_BIN, _BB_SUID_DROP))
@@ -61,7 +61,7 @@ typedef long idata_t;
61 61
62 62
63struct stats_irqcpu { 63struct stats_irqcpu {
64 unsigned interrupt; 64 unsigned interrupts;
65 char irq_name[MAX_IRQNAME_LEN]; 65 char irq_name[MAX_IRQNAME_LEN];
66}; 66};
67 67
@@ -265,7 +265,7 @@ static void write_irqcpu_stats(struct stats_irqcpu *per_cpu_stats[],
265 p = &per_cpu_stats[current][(cpu - 1) * total_irqs + j]; 265 p = &per_cpu_stats[current][(cpu - 1) * total_irqs + j];
266 q = &per_cpu_stats[prev][(cpu - 1) * total_irqs + offset]; 266 q = &per_cpu_stats[prev][(cpu - 1) * total_irqs + offset];
267 printf("%"INTRATE_SCRWIDTH_STR".2f", 267 printf("%"INTRATE_SCRWIDTH_STR".2f",
268 (double)(p->interrupt - q->interrupt) / itv * G.hz); 268 (double)(p->interrupts - q->interrupts) / itv * G.hz);
269 } else { 269 } else {
270 printf(" N/A"); 270 printf(" N/A");
271 } 271 }
@@ -617,12 +617,12 @@ static void get_irqs_from_interrupts(const char *fname,
617 char *next; 617 char *next;
618 ic = &per_cpu_stats[current][cpu_index[cpu] * irqs_per_cpu + irq]; 618 ic = &per_cpu_stats[current][cpu_index[cpu] * irqs_per_cpu + irq];
619 irq_i = &G.st_irq[current][cpu_index[cpu] + 1]; 619 irq_i = &G.st_irq[current][cpu_index[cpu] + 1];
620 ic->interrupt = strtoul(cp, &next, 10); 620 ic->interrupts = strtoul(cp, &next, 10);
621 /* Count only numerical IRQs */ 621 /* Count only numerical IRQs */
622 if (isdigit(last_char)) { 622 if (isdigit(last_char)) {
623 irq_i->irq_nr += ic->interrupt; 623 irq_i->irq_nr += ic->interrupts;
624 //bb_error_msg("G.st_irq[%u][%u].irq_nr + %u = %lld", 624 //bb_error_msg("G.st_irq[%u][%u].irq_nr + %u = %lld",
625 // current, cpu_index[cpu] + 1, ic->interrupt, irq_i->irq_nr); 625 // current, cpu_index[cpu] + 1, ic->interrupts, irq_i->irq_nr);
626 } 626 }
627 cp = next; 627 cp = next;
628 } 628 }
diff --git a/procps/nmeter.c b/procps/nmeter.c
index 930585695..7836a90d5 100644
--- a/procps/nmeter.c
+++ b/procps/nmeter.c
@@ -1,9 +1,10 @@
1/* 1/*
2** Licensed under the GPL v2, see the file LICENSE in this tarball 2 * Licensed under GPLv2, see file LICENSE in this source tree.
3** 3 *
4** Based on nanotop.c from floppyfw project 4 * Based on nanotop.c from floppyfw project
5** 5 *
6** Contact me: vda.linux@googlemail.com */ 6 * Contact me: vda.linux@googlemail.com
7 */
7 8
8//TODO: 9//TODO:
9// simplify code 10// simplify code
diff --git a/procps/pgrep.c b/procps/pgrep.c
index 45de8bcda..5d388a87d 100644
--- a/procps/pgrep.c
+++ b/procps/pgrep.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * Copyright (C) 2007 Loic Grenie <loic.grenie@gmail.com> 5 * Copyright (C) 2007 Loic Grenie <loic.grenie@gmail.com>
6 * 6 *
7 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 8 */
9#include "libbb.h" 9#include "libbb.h"
10#include "xregex.h" 10#include "xregex.h"
diff --git a/procps/pidof.c b/procps/pidof.c
index bf5e7841a..49e469ca5 100644
--- a/procps/pidof.c
+++ b/procps/pidof.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> 5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
6 * 6 *
7 * Licensed under the GPL version 2, see the file LICENSE in this tarball. 7 * Licensed under GPLv2, see file LICENSE in this source tree.
8 */ 8 */
9 9
10#include "libbb.h" 10#include "libbb.h"
diff --git a/procps/pmap.c b/procps/pmap.c
new file mode 100644
index 000000000..cfa94ed82
--- /dev/null
+++ b/procps/pmap.c
@@ -0,0 +1,111 @@
1/*
2 * pmap implementation for busybox
3 *
4 * Copyright (C) 2010 Nokia Corporation. All rights reserved.
5 * Written by Alexander Shishkin <virtuoso@slind.org>
6 *
7 * Licensed under GPLv2 or later, see the LICENSE file in this source tree
8 * for details.
9 */
10
11//applet:IF_PMAP(APPLET(pmap, _BB_DIR_USR_BIN, _BB_SUID_DROP))
12//kbuild:lib-$(CONFIG_PMAP) += pmap.o
13
14//config:config PMAP
15//config: bool "pmap"
16//config: default y
17//config: help
18//config: Display processes' memory mappings.
19
20//usage:#define pmap_trivial_usage
21//usage: "[-x][-q] PID"
22//usage:#define pmap_full_usage "\n\n"
23//usage: "Display detailed precesses' memory usage\n"
24//usage: "\nOptions:"
25//usage: "\n -x show details"
26//usage: "\n -q quiet"
27
28#include "libbb.h"
29
30#if ULONG_MAX == 0xffffffff
31# define TABS "\t"
32# define AFMT "8"
33# define DASHES ""
34#else
35# define TABS "\t\t"
36# define AFMT "16"
37# define DASHES "--------"
38#endif
39
40enum {
41 OPT_x = 1 << 0,
42 OPT_q = 1 << 1,
43};
44
45static void print_smaprec(struct smaprec *currec, void *data)
46{
47 unsigned opt = (unsigned)data;
48
49 printf("%0" AFMT "lx ", currec->smap_start);
50
51 if (opt & OPT_x)
52 printf("%7lu %7lu %7lu %7lu ",
53 currec->smap_size,
54 currec->smap_pss,
55 currec->private_dirty,
56 currec->smap_swap);
57 else
58 printf("%7luK", currec->smap_size);
59
60 printf(" %.4s %s\n", currec->smap_mode, currec->smap_name);
61}
62
63static int procps_get_maps(pid_t pid, unsigned opt)
64{
65 struct smaprec total;
66 int ret;
67 char buf[256];
68
69 read_cmdline(buf, sizeof(buf), pid, "no such process");
70 printf("%u: %s\n", (int)pid, buf);
71
72 if (!(opt & OPT_q) && (opt & OPT_x))
73 puts("Address" TABS " Kbytes PSS Dirty Swap Mode Mapping");
74
75 memset(&total, 0, sizeof(total));
76
77 ret = procps_read_smaps(pid, &total, print_smaprec, (void*)opt);
78 if (ret)
79 return ret;
80
81 if (!(opt & OPT_q)) {
82 if (opt & OPT_x)
83 printf("--------" DASHES " ------ ------ ------ ------\n"
84 "total" TABS " %7lu %7lu %7lu %7lu\n",
85 total.smap_size, total.smap_pss, total.private_dirty, total.smap_swap);
86 else
87 printf("mapped: %luK\n", total.smap_size);
88 }
89
90 return 0;
91}
92
93int pmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
94int pmap_main(int argc UNUSED_PARAM, char **argv)
95{
96 unsigned opts;
97 int ret;
98
99 opts = getopt32(argv, "xq");
100 argv += optind;
101
102 ret = 0;
103 while (*argv) {
104 pid_t pid = xatoi_positive(*argv++);
105 /* GNU pmap returns 42 if any of the pids failed */
106 if (procps_get_maps(pid, opts) != 0)
107 ret = 42;
108 }
109
110 return ret;
111}
diff --git a/procps/ps.c b/procps/ps.c
index a3220a926..305381eb9 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -6,7 +6,7 @@
6 * Fix for SELinux Support:(c)2007 Hiroshi Shinji <shiroshi@my.email.ne.jp> 6 * Fix for SELinux Support:(c)2007 Hiroshi Shinji <shiroshi@my.email.ne.jp>
7 * (c)2007 Yuichi Nakamura <ynakam@hitachisoft.jp> 7 * (c)2007 Yuichi Nakamura <ynakam@hitachisoft.jp>
8 * 8 *
9 * Licensed under the GPL version 2, see the file LICENSE in this tarball. 9 * Licensed under GPLv2, see file LICENSE in this source tree.
10 */ 10 */
11 11
12#include "libbb.h" 12#include "libbb.h"
diff --git a/procps/renice.c b/procps/renice.c
index ea5fc703e..0a73cbeeb 100644
--- a/procps/renice.c
+++ b/procps/renice.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * Copyright (C) 2005 Manuel Novoa III <mjn3@codepoet.org> 5 * Copyright (C) 2005 Manuel Novoa III <mjn3@codepoet.org>
6 * 6 *
7 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 8 */
9 9
10/* Notes: 10/* Notes:
@@ -91,7 +91,7 @@ int renice_main(int argc UNUSED_PARAM, char **argv)
91 } else { 91 } else {
92 who = bb_strtou(arg, NULL, 10); 92 who = bb_strtou(arg, NULL, 10);
93 if (errno) { 93 if (errno) {
94 bb_error_msg("bad value: %s", arg); 94 bb_error_msg("invalid number '%s'", arg);
95 goto HAD_ERROR; 95 goto HAD_ERROR;
96 } 96 }
97 } 97 }
diff --git a/procps/sysctl.c b/procps/sysctl.c
index fc601d637..20b372c54 100644
--- a/procps/sysctl.c
+++ b/procps/sysctl.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * Copyright 1999 George Staikos 5 * Copyright 1999 George Staikos
6 * 6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 * 8 *
9 * Changelog: 9 * Changelog:
10 * v1.01 - added -p <preload> to preload values from a file 10 * v1.01 - added -p <preload> to preload values from a file
diff --git a/procps/top.c b/procps/top.c
index ec8437442..4f37878de 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -28,7 +28,7 @@
28 * Copyright (C) 1994-1996 Charles L. Blake. 28 * Copyright (C) 1994-1996 Charles L. Blake.
29 * Copyright (C) 1992-1998 Michael K. Johnson 29 * Copyright (C) 1992-1998 Michael K. Johnson
30 * 30 *
31 * Licensed under GPLv2, see file LICENSE in this tarball for details. 31 * Licensed under GPLv2, see file LICENSE in this source tree.
32 */ 32 */
33 33
34#include "libbb.h" 34#include "libbb.h"
@@ -942,20 +942,20 @@ int top_main(int argc UNUSED_PARAM, char **argv)
942 } 942 }
943#if ENABLE_FEATURE_TOPMEM 943#if ENABLE_FEATURE_TOPMEM
944 else { /* TOPMEM */ 944 else { /* TOPMEM */
945 if (!(p->mapped_ro | p->mapped_rw)) 945 if (!(p->smaps.mapped_ro | p->smaps.mapped_rw))
946 continue; /* kernel threads are ignored */ 946 continue; /* kernel threads are ignored */
947 n = ntop; 947 n = ntop;
948 /* No bug here - top and topmem are the same */ 948 /* No bug here - top and topmem are the same */
949 top = xrealloc_vector(topmem, 6, ntop++); 949 top = xrealloc_vector(topmem, 6, ntop++);
950 strcpy(topmem[n].comm, p->comm); 950 strcpy(topmem[n].comm, p->comm);
951 topmem[n].pid = p->pid; 951 topmem[n].pid = p->pid;
952 topmem[n].vsz = p->mapped_rw + p->mapped_ro; 952 topmem[n].vsz = p->smaps.mapped_rw + p->smaps.mapped_ro;
953 topmem[n].vszrw = p->mapped_rw; 953 topmem[n].vszrw = p->smaps.mapped_rw;
954 topmem[n].rss_sh = p->shared_clean + p->shared_dirty; 954 topmem[n].rss_sh = p->smaps.shared_clean + p->smaps.shared_dirty;
955 topmem[n].rss = p->private_clean + p->private_dirty + topmem[n].rss_sh; 955 topmem[n].rss = p->smaps.private_clean + p->smaps.private_dirty + topmem[n].rss_sh;
956 topmem[n].dirty = p->private_dirty + p->shared_dirty; 956 topmem[n].dirty = p->smaps.private_dirty + p->smaps.shared_dirty;
957 topmem[n].dirty_sh = p->shared_dirty; 957 topmem[n].dirty_sh = p->smaps.shared_dirty;
958 topmem[n].stack = p->stack; 958 topmem[n].stack = p->smaps.stack;
959 } 959 }
960#endif 960#endif
961 } /* end of "while we read /proc" */ 961 } /* end of "while we read /proc" */
diff --git a/procps/uptime.c b/procps/uptime.c
index d9aa1d037..5c48795bf 100644
--- a/procps/uptime.c
+++ b/procps/uptime.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> 5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
6 * 6 *
7 * Licensed under the GPL version 2, see the file LICENSE in this tarball. 7 * Licensed under GPLv2, see file LICENSE in this source tree.
8 */ 8 */
9 9
10/* This version of uptime doesn't display the number of users on the system, 10/* This version of uptime doesn't display the number of users on the system,
diff --git a/procps/watch.c b/procps/watch.c
index a1cde9ea0..36f71c469 100644
--- a/procps/watch.c
+++ b/procps/watch.c
@@ -5,7 +5,7 @@
5 * Copyright (C) 2001 by Michael Habermann <mhabermann@gmx.de> 5 * Copyright (C) 2001 by Michael Habermann <mhabermann@gmx.de>
6 * Copyrigjt (C) Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org) 6 * Copyrigjt (C) Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
7 * 7 *
8 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 8 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
9 */ 9 */
10 10
11/* BB_AUDIT SUSv3 N/A */ 11/* BB_AUDIT SUSv3 N/A */