aboutsummaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2011-06-18 15:49:47 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2011-06-18 15:49:47 +0200
commit12ac6287eedf45d896557b95270a6e0323951917 (patch)
treede5833ccd888a768836df1353409f7b0f01501d2 /procps
parentda947607625bc5510ec56b27e04445db300f4418 (diff)
downloadbusybox-w32-12ac6287eedf45d896557b95270a6e0323951917.tar.gz
busybox-w32-12ac6287eedf45d896557b95270a6e0323951917.tar.bz2
busybox-w32-12ac6287eedf45d896557b95270a6e0323951917.zip
procps: remove PSSCAN_STAT define, users were using it incorrectly
Also contains small cleanups ps. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'procps')
-rw-r--r--procps/ps.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/procps/ps.c b/procps/ps.c
index 279f25e88..7537118f6 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -87,13 +87,6 @@ enum { MAX_WIDTH = 2*1024 };
87 * TIME The cumulative execution time for the process 87 * TIME The cumulative execution time for the process
88 * CMD The command name; the full command line is shown with -f 88 * CMD The command name; the full command line is shown with -f
89 */ 89 */
90#if ENABLE_SELINUX
91# define SELINUX_O_PREFIX "label,"
92# define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args")
93#else
94# define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args")
95#endif
96
97typedef struct { 90typedef struct {
98 uint16_t width; 91 uint16_t width;
99 char name6[6]; 92 char name6[6];
@@ -113,7 +106,6 @@ struct globals {
113 unsigned kernel_HZ; 106 unsigned kernel_HZ;
114 unsigned long long seconds_since_boot; 107 unsigned long long seconds_since_boot;
115#endif 108#endif
116 char default_o[sizeof(DEFAULT_O_STR)];
117} FIX_ALIASING; 109} FIX_ALIASING;
118#define G (*(struct globals*)&bb_common_bufsiz1) 110#define G (*(struct globals*)&bb_common_bufsiz1)
119#define out (G.out ) 111#define out (G.out )
@@ -124,7 +116,6 @@ struct globals {
124#define terminal_width (G.terminal_width ) 116#define terminal_width (G.terminal_width )
125#define kernel_HZ (G.kernel_HZ ) 117#define kernel_HZ (G.kernel_HZ )
126#define seconds_since_boot (G.seconds_since_boot) 118#define seconds_since_boot (G.seconds_since_boot)
127#define default_o (G.default_o )
128#define INIT_G() do { } while (0) 119#define INIT_G() do { } while (0)
129 120
130#if ENABLE_FEATURE_PS_TIME 121#if ENABLE_FEATURE_PS_TIME
@@ -250,7 +241,7 @@ static void func_comm(char *buf, int size, const procps_status_t *ps)
250 safe_strncpy(buf, ps->comm, size+1); 241 safe_strncpy(buf, ps->comm, size+1);
251} 242}
252 243
253static void func_stat(char *buf, int size, const procps_status_t *ps) 244static void func_state(char *buf, int size, const procps_status_t *ps)
254{ 245{
255 safe_strncpy(buf, ps->state, size+1); 246 safe_strncpy(buf, ps->state, size+1);
256} 247}
@@ -394,7 +385,7 @@ static const ps_out_t out_spec[] = {
394 { 6 , "tty" ,"TT" ,func_tty ,PSSCAN_TTY }, 385 { 6 , "tty" ,"TT" ,func_tty ,PSSCAN_TTY },
395 { 4 , "vsz" ,"VSZ" ,func_vsz ,PSSCAN_VSZ }, 386 { 4 , "vsz" ,"VSZ" ,func_vsz ,PSSCAN_VSZ },
396/* Not mandated, but useful: */ 387/* Not mandated, but useful: */
397 { 4 , "stat" ,"STAT" ,func_stat ,PSSCAN_STAT }, 388 { 4 , "stat" ,"STAT" ,func_state ,PSSCAN_STATE },
398 { 4 , "rss" ,"RSS" ,func_rss ,PSSCAN_RSS }, 389 { 4 , "rss" ,"RSS" ,func_rss ,PSSCAN_RSS },
399#if ENABLE_SELINUX 390#if ENABLE_SELINUX
400 { 35 , "label" ,"LABEL" ,func_label ,PSSCAN_CONTEXT }, 391 { 35 , "label" ,"LABEL" ,func_label ,PSSCAN_CONTEXT },
@@ -531,11 +522,19 @@ static void format_process(const procps_status_t *ps)
531 printf("%.*s\n", terminal_width, buffer); 522 printf("%.*s\n", terminal_width, buffer);
532} 523}
533 524
525#if ENABLE_SELINUX
526# define SELINUX_O_PREFIX "label,"
527# define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args")
528#else
529# define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args")
530#endif
531
534int ps_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 532int ps_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
535int ps_main(int argc UNUSED_PARAM, char **argv) 533int ps_main(int argc UNUSED_PARAM, char **argv)
536{ 534{
537 procps_status_t *p; 535 procps_status_t *p;
538 llist_t* opt_o = NULL; 536 llist_t* opt_o = NULL;
537 char default_o[sizeof(DEFAULT_O_STR)];
539 int opt; 538 int opt;
540 enum { 539 enum {
541 OPT_Z = (1 << 0), 540 OPT_Z = (1 << 0),
@@ -573,7 +572,7 @@ int ps_main(int argc UNUSED_PARAM, char **argv)
573 parse_o(llist_pop(&opt_o)); 572 parse_o(llist_pop(&opt_o));
574 } while (opt_o); 573 } while (opt_o);
575 } else { 574 } else {
576 /* Below: parse_o() needs char*, NOT const char*... */ 575 /* Below: parse_o() needs char*, NOT const char*, can't give it default_o */
577#if ENABLE_SELINUX 576#if ENABLE_SELINUX
578 if (!(opt & OPT_Z) || !is_selinux_enabled()) { 577 if (!(opt & OPT_Z) || !is_selinux_enabled()) {
579 /* no -Z or no SELinux: do not show LABEL */ 578 /* no -Z or no SELinux: do not show LABEL */