1 |
solar 10/02/28 19:12:40 |
2 |
|
3 |
Modified: pspax.c |
4 |
Log: |
5 |
Introduce -W,--wide flags to get full cmdline output display for pspax |
6 |
|
7 |
Revision Changes Path |
8 |
1.46 pax-utils/pspax.c |
9 |
|
10 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/pspax.c?rev=1.46&view=markup |
11 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/pspax.c?rev=1.46&content-type=text/plain |
12 |
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/pspax.c?r1=1.45&r2=1.46 |
13 |
|
14 |
Index: pspax.c |
15 |
=================================================================== |
16 |
RCS file: /var/cvsroot/gentoo-projects/pax-utils/pspax.c,v |
17 |
retrieving revision 1.45 |
18 |
retrieving revision 1.46 |
19 |
diff -u -r1.45 -r1.46 |
20 |
--- pspax.c 15 Mar 2009 09:23:30 -0000 1.45 |
21 |
+++ pspax.c 28 Feb 2010 19:12:39 -0000 1.46 |
22 |
@@ -12,7 +12,7 @@ |
23 |
* cc -o pspax pspax.c -DWANT_SYSCAP -lcap |
24 |
*/ |
25 |
|
26 |
-static const char *rcsid = "$Id: pspax.c,v 1.45 2009/03/15 09:23:30 vapier Exp $"; |
27 |
+static const char *rcsid = "$Id: pspax.c,v 1.46 2010/02/28 19:12:39 solar Exp $"; |
28 |
const char * const argv0 = "pspax"; |
29 |
|
30 |
#include "paxinc.h" |
31 |
@@ -36,7 +36,7 @@ |
32 |
static char show_addr = 0; |
33 |
static char noexec = 1; |
34 |
static char writeexec = 1; |
35 |
- |
36 |
+static char wide_output = 0; |
37 |
static pid_t show_pid = 0; |
38 |
static uid_t show_uid = -1; |
39 |
static gid_t show_gid = -1; |
40 |
@@ -49,11 +49,30 @@ |
41 |
return fopen(path, "r"); |
42 |
} |
43 |
|
44 |
+static char *get_proc_name_cmdline(pid_t pid) |
45 |
+{ |
46 |
+ FILE *fp; |
47 |
+ static char str[1024]; |
48 |
+ |
49 |
+ fp = proc_fopen(pid, "cmdline"); |
50 |
+ if (fp == NULL) |
51 |
+ return NULL; |
52 |
+ |
53 |
+ if (fscanf(fp, "%s.1023", str) != 1) { |
54 |
+ fclose(fp); |
55 |
+ return NULL; |
56 |
+ } |
57 |
+ return (str); |
58 |
+} |
59 |
+ |
60 |
static char *get_proc_name(pid_t pid) |
61 |
{ |
62 |
FILE *fp; |
63 |
static char str[BUFSIZ]; |
64 |
|
65 |
+ if (wide_output) |
66 |
+ return get_proc_name_cmdline(pid); |
67 |
+ |
68 |
fp = proc_fopen(pid, "stat"); |
69 |
if (fp == NULL) |
70 |
return NULL; |
71 |
@@ -397,7 +416,7 @@ |
72 |
} |
73 |
|
74 |
/* usage / invocation handling functions */ |
75 |
-#define PARSE_FLAGS "aeip:u:g:nwvBhV" |
76 |
+#define PARSE_FLAGS "aeip:u:g:nwWvBhV" |
77 |
#define a_argument required_argument |
78 |
static struct option const long_opts[] = { |
79 |
{"all", no_argument, NULL, 'a'}, |
80 |
@@ -408,12 +427,14 @@ |
81 |
{"group", a_argument, NULL, 'g'}, |
82 |
{"nx", no_argument, NULL, 'n'}, |
83 |
{"wx", no_argument, NULL, 'w'}, |
84 |
+ {"wide", no_argument, NULL, 'W'}, |
85 |
{"verbose", no_argument, NULL, 'v'}, |
86 |
{"nobanner", no_argument, NULL, 'B'}, |
87 |
{"help", no_argument, NULL, 'h'}, |
88 |
{"version", no_argument, NULL, 'V'}, |
89 |
{NULL, no_argument, NULL, 0x0} |
90 |
}; |
91 |
+ |
92 |
static const char *opts_help[] = { |
93 |
"Show all processes", |
94 |
"Print GNU_STACK/PT_LOAD markings", |
95 |
@@ -423,6 +444,7 @@ |
96 |
"Process group/gid #", |
97 |
"Only display w^x processes", |
98 |
"Only display w|x processes", |
99 |
+ "Wide output display of cmdline", |
100 |
"Be verbose about executable mappings", |
101 |
"Don't display the header", |
102 |
"Print this help and exit", |
103 |
@@ -474,6 +496,7 @@ |
104 |
case 'p': show_pid = atoi(optarg); break; |
105 |
case 'n': noexec = 1; writeexec = 0; break; |
106 |
case 'w': noexec = 0; writeexec = 1; break; |
107 |
+ case 'W': wide_output = 1; break; |
108 |
case 'v': verbose++; break; |
109 |
case 'u': |
110 |
show_uid = atoi(optarg); |