aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-05-23 00:34:42 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-05-23 00:34:42 +0200
commit9e07219c7814972893d1f3bb67b43108fe83212a (patch)
tree81352d21edcc0a021849fe9d4b0978e0595a60e1
parent765b0eed3ef29a80115708c3249d3a541509cd24 (diff)
downloadbusybox-w32-9e07219c7814972893d1f3bb67b43108fe83212a.tar.gz
busybox-w32-9e07219c7814972893d1f3bb67b43108fe83212a.tar.bz2
busybox-w32-9e07219c7814972893d1f3bb67b43108fe83212a.zip
ps: make "ps -o BAD" emit list of good -o params
also make ps help more informative function old new delta find_out_spec 58 103 +45 packed_usage 27039 27079 +40 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--include/usage.h8
-rw-r--r--procps/ps.c22
2 files changed, 22 insertions, 8 deletions
diff --git a/include/usage.h b/include/usage.h
index 8f695f8b8..d53b86731 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -3574,11 +3574,11 @@
3574#if ENABLE_DESKTOP 3574#if ENABLE_DESKTOP
3575 3575
3576#define ps_trivial_usage \ 3576#define ps_trivial_usage \
3577 "" 3577 "[-o COL1,COL2=HEADER]" IF_FEATURE_SHOW_THREADS(" [-T]")
3578#define ps_full_usage "\n\n" \ 3578#define ps_full_usage "\n\n" \
3579 "Report process status\n" \ 3579 "Show list of processes\n" \
3580 "\nOptions:" \ 3580 "\nOptions:" \
3581 "\n -o col1,col2=header Select columns for display" \ 3581 "\n -o COL1,COL2=HEADER Select columns for display" \
3582 IF_FEATURE_SHOW_THREADS( \ 3582 IF_FEATURE_SHOW_THREADS( \
3583 "\n -T Show threads" \ 3583 "\n -T Show threads" \
3584 ) 3584 )
@@ -3594,7 +3594,7 @@
3594#define ps_trivial_usage \ 3594#define ps_trivial_usage \
3595 "" 3595 ""
3596#define ps_full_usage "\n\n" \ 3596#define ps_full_usage "\n\n" \
3597 "Report process status\n" \ 3597 "Show list of processes\n" \
3598 USAGE_PS \ 3598 USAGE_PS \
3599 IF_SELINUX( \ 3599 IF_SELINUX( \
3600 "\n -Z Show selinux context" \ 3600 "\n -Z Show selinux context" \
diff --git a/procps/ps.c b/procps/ps.c
index c3b200866..a3220a926 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -232,7 +232,6 @@ static void func_tty(char *buf, int size, const procps_status_t *ps)
232 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);
233} 233}
234 234
235
236#if ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS 235#if ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS
237 236
238static void func_rgroup(char *buf, int size, const procps_status_t *ps) 237static void func_rgroup(char *buf, int size, const procps_status_t *ps)
@@ -250,9 +249,10 @@ static void func_nice(char *buf, int size, const procps_status_t *ps)
250 sprintf(buf, "%*d", size, ps->niceness); 249 sprintf(buf, "%*d", size, ps->niceness);
251} 250}
252 251
253#endif /* FEATURE_PS_ADDITIONAL_COLUMNS */ 252#endif
254 253
255#if ENABLE_FEATURE_PS_TIME 254#if ENABLE_FEATURE_PS_TIME
255
256static void func_etime(char *buf, int size, const procps_status_t *ps) 256static void func_etime(char *buf, int size, const procps_status_t *ps)
257{ 257{
258 /* elapsed time [[dd-]hh:]mm:ss; here only mm:ss */ 258 /* elapsed time [[dd-]hh:]mm:ss; here only mm:ss */
@@ -278,6 +278,7 @@ static void func_time(char *buf, int size, const procps_status_t *ps)
278 mm /= 60; 278 mm /= 60;
279 snprintf(buf, size+1, "%3lu:%02u", mm, ss); 279 snprintf(buf, size+1, "%3lu:%02u", mm, ss);
280} 280}
281
281#endif 282#endif
282 283
283#if ENABLE_SELINUX 284#if ENABLE_SELINUX
@@ -337,11 +338,24 @@ static ps_out_t* new_out_t(void)
337static const ps_out_t* find_out_spec(const char *name) 338static const ps_out_t* find_out_spec(const char *name)
338{ 339{
339 unsigned i; 340 unsigned i;
341#if ENABLE_DESKTOP
342 char buf[ARRAY_SIZE(out_spec)*7 + 1];
343 char *p = buf;
344#endif
345
340 for (i = 0; i < ARRAY_SIZE(out_spec); i++) { 346 for (i = 0; i < ARRAY_SIZE(out_spec); i++) {
341 if (!strncmp(name, out_spec[i].name6, 6)) 347 if (strncmp(name, out_spec[i].name6, 6) == 0)
342 return &out_spec[i]; 348 return &out_spec[i];
349#if ENABLE_DESKTOP
350 p += sprintf(p, "%.6s,", out_spec[i].name6);
351#endif
343 } 352 }
344 bb_error_msg_and_die("bad -o argument '%s'", name); 353#if ENABLE_DESKTOP
354 p[-1] = '\0';
355 bb_error_msg_and_die("bad -o argument '%s', supported arguments: %s", name, buf);
356#else
357 bb_error_msg_and_die("bad -o argument '%s'");
358#endif
345} 359}
346 360
347static void parse_o(char* opt) 361static void parse_o(char* opt)