diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-07-03 22:16:17 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-07-03 22:16:17 +0200 |
commit | fca70a8cce579ce8cc8caf246c22f0c6e6c6e139 (patch) | |
tree | 2c17970b64b12c34624a18cf42b2c39a2cb5329d /procps | |
parent | c5d07fba29a477569a96777c9cab73e53b1ddd5c (diff) | |
download | busybox-w32-fca70a8cce579ce8cc8caf246c22f0c6e6c6e139.tar.gz busybox-w32-fca70a8cce579ce8cc8caf246c22f0c6e6c6e139.tar.bz2 busybox-w32-fca70a8cce579ce8cc8caf246c22f0c6e6c6e139.zip |
ps: conditionally support additional -o FIELDs
function old new delta
procps_scan 1409 1642 +233
out_spec 220 300 +80
func_ruser - 36 +36
func_rgroup - 36 +36
func_group 13 49 +36
func_nice - 29 +29
buffer_fill_and_print 179 196 +17
send_tree 355 360 +5
mkfs_vfat_main 1604 1609 +5
display_speed 85 90 +5
scriptreplay_main 194 197 +3
find_out_spec 55 58 +3
changepath 192 195 +3
sha1_process_block64 497 484 -13
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 10/1 up/down: 491/-13) Total: 478 bytes
Signed-off-by: David Krakov <krakov@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'procps')
-rw-r--r-- | procps/Config.in | 13 | ||||
-rw-r--r-- | procps/ps.c | 41 | ||||
-rw-r--r-- | procps/top.c | 2 |
3 files changed, 44 insertions, 12 deletions
diff --git a/procps/Config.in b/procps/Config.in index 702442a52..9146ff6bf 100644 --- a/procps/Config.in +++ b/procps/Config.in | |||
@@ -91,13 +91,13 @@ config PS | |||
91 | ps gives a snapshot of the current processes. | 91 | ps gives a snapshot of the current processes. |
92 | 92 | ||
93 | config FEATURE_PS_WIDE | 93 | config FEATURE_PS_WIDE |
94 | bool "Enable argument for wide output (-w)" | 94 | bool "Enable wide output option (-w)" |
95 | default n | 95 | default n |
96 | depends on PS | 96 | depends on PS |
97 | help | 97 | help |
98 | Support argument 'w' for wide output. | 98 | Support argument 'w' for wide output. |
99 | If given once, 132 chars are printed and given more than | 99 | If given once, 132 chars are printed, and if given more |
100 | one, the length is unlimited. | 100 | than once, the length is unlimited. |
101 | 101 | ||
102 | config FEATURE_PS_TIME | 102 | config FEATURE_PS_TIME |
103 | bool "Enable time and elapsed time output" | 103 | bool "Enable time and elapsed time output" |
@@ -106,6 +106,13 @@ config FEATURE_PS_TIME | |||
106 | help | 106 | help |
107 | Support -o time and -o etime output specifiers. | 107 | Support -o time and -o etime output specifiers. |
108 | 108 | ||
109 | config FEATURE_PS_ADDITIONAL_COLUMNS | ||
110 | bool "Enable additional ps columns" | ||
111 | default n | ||
112 | depends on PS && DESKTOP | ||
113 | help | ||
114 | Support -o rgroup, -o ruser, -o nice output specifiers. | ||
115 | |||
109 | config FEATURE_PS_UNUSUAL_SYSTEMS | 116 | config FEATURE_PS_UNUSUAL_SYSTEMS |
110 | bool "Support Linux prior to 2.4.0 and non-ELF systems" | 117 | bool "Support Linux prior to 2.4.0 and non-ELF systems" |
111 | default n | 118 | default n |
diff --git a/procps/ps.c b/procps/ps.c index b9a4aef15..4a6b60bdc 100644 --- a/procps/ps.c +++ b/procps/ps.c | |||
@@ -32,7 +32,7 @@ enum { MAX_WIDTH = 2*1024 }; | |||
32 | 32 | ||
33 | typedef struct { | 33 | typedef struct { |
34 | uint16_t width; | 34 | uint16_t width; |
35 | char name[6]; | 35 | char name6[6]; |
36 | const char *header; | 36 | const char *header; |
37 | void (*f)(char *buf, int size, const procps_status_t *ps); | 37 | void (*f)(char *buf, int size, const procps_status_t *ps); |
38 | int ps_flags; | 38 | int ps_flags; |
@@ -174,6 +174,11 @@ static void func_user(char *buf, int size, const procps_status_t *ps) | |||
174 | #endif | 174 | #endif |
175 | } | 175 | } |
176 | 176 | ||
177 | static void func_group(char *buf, int size, const procps_status_t *ps) | ||
178 | { | ||
179 | safe_strncpy(buf, get_cached_groupname(ps->gid), size+1); | ||
180 | } | ||
181 | |||
177 | static void func_comm(char *buf, int size, const procps_status_t *ps) | 182 | static void func_comm(char *buf, int size, const procps_status_t *ps) |
178 | { | 183 | { |
179 | safe_strncpy(buf, ps->comm, size+1); | 184 | safe_strncpy(buf, ps->comm, size+1); |
@@ -227,6 +232,26 @@ static void func_tty(char *buf, int size, const procps_status_t *ps) | |||
227 | snprintf(buf, size+1, "%u,%u", ps->tty_major, ps->tty_minor); | 232 | snprintf(buf, size+1, "%u,%u", ps->tty_major, ps->tty_minor); |
228 | } | 233 | } |
229 | 234 | ||
235 | |||
236 | #if ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS | ||
237 | |||
238 | static void func_rgroup(char *buf, int size, const procps_status_t *ps) | ||
239 | { | ||
240 | safe_strncpy(buf, get_cached_groupname(ps->rgid), size+1); | ||
241 | } | ||
242 | |||
243 | static void func_ruser(char *buf, int size, const procps_status_t *ps) | ||
244 | { | ||
245 | safe_strncpy(buf, get_cached_username(ps->ruid), size+1); | ||
246 | } | ||
247 | |||
248 | static void func_nice(char *buf, int size, const procps_status_t *ps) | ||
249 | { | ||
250 | sprintf(buf, "%*d", size, ps->niceness); | ||
251 | } | ||
252 | |||
253 | #endif /* FEATURE_PS_ADDITIONAL_COLUMNS */ | ||
254 | |||
230 | #if ENABLE_FEATURE_PS_TIME | 255 | #if ENABLE_FEATURE_PS_TIME |
231 | static void func_etime(char *buf, int size, const procps_status_t *ps) | 256 | static void func_etime(char *buf, int size, const procps_status_t *ps) |
232 | { | 257 | { |
@@ -276,6 +301,7 @@ static void func_pcpu(char *buf, int size, const procps_status_t *ps) | |||
276 | static const ps_out_t out_spec[] = { | 301 | static const ps_out_t out_spec[] = { |
277 | // Mandated by POSIX: | 302 | // Mandated by POSIX: |
278 | { 8 , "user" ,"USER" ,func_user ,PSSCAN_UIDGID }, | 303 | { 8 , "user" ,"USER" ,func_user ,PSSCAN_UIDGID }, |
304 | { 8 , "group" ,"GROUP" ,func_group ,PSSCAN_UIDGID }, | ||
279 | { 16 , "comm" ,"COMMAND",func_comm ,PSSCAN_COMM }, | 305 | { 16 , "comm" ,"COMMAND",func_comm ,PSSCAN_COMM }, |
280 | { 256 , "args" ,"COMMAND",func_args ,PSSCAN_COMM }, | 306 | { 256 , "args" ,"COMMAND",func_args ,PSSCAN_COMM }, |
281 | { 5 , "pid" ,"PID" ,func_pid ,PSSCAN_PID }, | 307 | { 5 , "pid" ,"PID" ,func_pid ,PSSCAN_PID }, |
@@ -284,11 +310,12 @@ static const ps_out_t out_spec[] = { | |||
284 | #if ENABLE_FEATURE_PS_TIME | 310 | #if ENABLE_FEATURE_PS_TIME |
285 | { sizeof("ELAPSED")-1, "etime" ,"ELAPSED",func_etime ,PSSCAN_START_TIME }, | 311 | { sizeof("ELAPSED")-1, "etime" ,"ELAPSED",func_etime ,PSSCAN_START_TIME }, |
286 | #endif | 312 | #endif |
287 | // { sizeof("GROUP" )-1, "group" ,"GROUP" ,func_group ,PSSCAN_UIDGID }, | 313 | #if ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS |
288 | // { sizeof("NI" )-1, "nice" ,"NI" ,func_nice ,PSSCAN_ }, | 314 | { 5 , "nice" ,"NI" ,func_nice ,PSSCAN_NICE }, |
289 | // { sizeof("%CPU" )-1, "pcpu" ,"%CPU" ,func_pcpu ,PSSCAN_ }, | 315 | { 8 , "rgroup","RGROUP" ,func_rgroup,PSSCAN_RUIDGID }, |
290 | // { sizeof("RGROUP" )-1, "rgroup","RGROUP" ,func_rgroup,PSSCAN_UIDGID }, | 316 | { 8 , "ruser" ,"RUSER" ,func_ruser ,PSSCAN_RUIDGID }, |
291 | // { sizeof("RUSER" )-1, "ruser" ,"RUSER" ,func_ruser ,PSSCAN_UIDGID }, | 317 | // { 5 , "pcpu" ,"%CPU" ,func_pcpu ,PSSCAN_ }, |
318 | #endif | ||
292 | #if ENABLE_FEATURE_PS_TIME | 319 | #if ENABLE_FEATURE_PS_TIME |
293 | { 6 , "time" ,"TIME" ,func_time ,PSSCAN_STIME | PSSCAN_UTIME }, | 320 | { 6 , "time" ,"TIME" ,func_time ,PSSCAN_STIME | PSSCAN_UTIME }, |
294 | #endif | 321 | #endif |
@@ -311,7 +338,7 @@ static const ps_out_t* find_out_spec(const char *name) | |||
311 | { | 338 | { |
312 | unsigned i; | 339 | unsigned i; |
313 | for (i = 0; i < ARRAY_SIZE(out_spec); i++) { | 340 | for (i = 0; i < ARRAY_SIZE(out_spec); i++) { |
314 | if (!strcmp(name, out_spec[i].name)) | 341 | if (!strncmp(name, out_spec[i].name6, 6)) |
315 | return &out_spec[i]; | 342 | return &out_spec[i]; |
316 | } | 343 | } |
317 | bb_error_msg_and_die("bad -o argument '%s'", name); | 344 | bb_error_msg_and_die("bad -o argument '%s'", name); |
diff --git a/procps/top.c b/procps/top.c index 8738156e1..62b9c1e1b 100644 --- a/procps/top.c +++ b/procps/top.c | |||
@@ -871,9 +871,7 @@ enum { | |||
871 | | PSSCAN_UTIME | 871 | | PSSCAN_UTIME |
872 | | PSSCAN_STATE | 872 | | PSSCAN_STATE |
873 | | PSSCAN_COMM | 873 | | PSSCAN_COMM |
874 | #if ENABLE_FEATURE_TOP_SMP_PROCESS | ||
875 | | PSSCAN_CPU | 874 | | PSSCAN_CPU |
876 | #endif | ||
877 | | PSSCAN_UIDGID, | 875 | | PSSCAN_UIDGID, |
878 | TOPMEM_MASK = 0 | 876 | TOPMEM_MASK = 0 |
879 | | PSSCAN_PID | 877 | | PSSCAN_PID |