summaryrefslogtreecommitdiff
path: root/usr/src/cmd/ptools/pargs/pargs.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/cmd/ptools/pargs/pargs.c')
-rw-r--r--usr/src/cmd/ptools/pargs/pargs.c49
1 files changed, 41 insertions, 8 deletions
diff --git a/usr/src/cmd/ptools/pargs/pargs.c b/usr/src/cmd/ptools/pargs/pargs.c
index c363b34a7c..fd2be024f3 100644
--- a/usr/src/cmd/ptools/pargs/pargs.c
+++ b/usr/src/cmd/ptools/pargs/pargs.c
@@ -23,7 +23,7 @@
* Use is subject to license terms.
*/
/*
- * Copyright (c) 2013, Joyent, Inc. All rights reserved.
+ * Copyright 2016 Joyent, Inc.
*/
/*
@@ -73,6 +73,13 @@
#include <wctype.h>
#include <widec.h>
#include <elfcap.h>
+#include <libgen.h>
+
+typedef enum pargs_cmd {
+ PARGS_ARGV,
+ PARGS_ENV,
+ PARGS_AUXV
+} pargs_cmd_t;
typedef struct pargs_data {
struct ps_prochandle *pd_proc; /* target proc handle */
@@ -797,6 +804,7 @@ static struct aux_id aux_arr[] = {
{ AT_BASE, "AT_BASE", at_null },
{ AT_FLAGS, "AT_FLAGS", at_null },
{ AT_ENTRY, "AT_ENTRY", at_null },
+ { AT_RANDOM, "AT_RANDOM", at_null },
{ AT_SUN_UID, "AT_SUN_UID", at_uid },
{ AT_SUN_RUID, "AT_SUN_RUID", at_uid },
{ AT_SUN_GID, "AT_SUN_GID", at_gid },
@@ -816,9 +824,12 @@ static struct aux_id aux_arr[] = {
{ AT_SUN_AUXFLAGS, "AT_SUN_AUXFLAGS", at_flags },
{ AT_SUN_EMULATOR, "AT_SUN_EMULATOR", at_str },
{ AT_SUN_BRANDNAME, "AT_SUN_BRANDNAME", at_str },
+ { AT_SUN_BRAND_NROOT, "AT_SUN_BRAND_NROOT", at_str },
{ AT_SUN_BRAND_AUX1, "AT_SUN_BRAND_AUX1", at_null },
{ AT_SUN_BRAND_AUX2, "AT_SUN_BRAND_AUX2", at_null },
- { AT_SUN_BRAND_AUX3, "AT_SUN_BRAND_AUX3", at_null }
+ { AT_SUN_BRAND_AUX3, "AT_SUN_BRAND_AUX3", at_null },
+ { AT_SUN_BRAND_AUX4, "AT_SUN_BRAND_AUX4", at_null },
+ { AT_SUN_COMMPAGE, "AT_SUN_COMMPAGE", at_null }
};
#define N_AT_ENTS (sizeof (aux_arr) / sizeof (struct aux_id))
@@ -1279,19 +1290,24 @@ main(int argc, char *argv[])
int opt;
int error = 1;
core_content_t content = 0;
+ pargs_cmd_t cmd = PARGS_ARGV;
(void) setlocale(LC_ALL, "");
- if ((command = strrchr(argv[0], '/')) != NULL)
- command++;
- else
- command = argv[0];
+ command = basename(argv[0]);
+
+ if (strcmp(command, "penv") == 0)
+ cmd = PARGS_ENV;
+ else if (strcmp(command, "pauxv") == 0)
+ cmd = PARGS_AUXV;
while ((opt = getopt(argc, argv, "acelxF")) != EOF) {
switch (opt) {
case 'a': /* show process arguments */
content |= CC_CONTENT_STACK;
aflag++;
+ if (cmd != PARGS_ARGV)
+ errflg++;
break;
case 'c': /* force 7-bit ascii */
cflag++;
@@ -1299,13 +1315,19 @@ main(int argc, char *argv[])
case 'e': /* show environment variables */
content |= CC_CONTENT_STACK;
eflag++;
+ if (cmd != PARGS_ARGV)
+ errflg++;
break;
case 'l':
lflag++;
aflag++; /* -l implies -a */
+ if (cmd != PARGS_ARGV)
+ errflg++;
break;
case 'x': /* show aux vector entries */
xflag++;
+ if (cmd != PARGS_ARGV)
+ errflg++;
break;
case 'F':
/*
@@ -1322,8 +1344,19 @@ main(int argc, char *argv[])
/* -a is the default if no options are specified */
if ((aflag + eflag + xflag + lflag) == 0) {
- aflag++;
- content |= CC_CONTENT_STACK;
+ switch (cmd) {
+ case PARGS_ARGV:
+ aflag++;
+ content |= CC_CONTENT_STACK;
+ break;
+ case PARGS_ENV:
+ content |= CC_CONTENT_STACK;
+ eflag++;
+ break;
+ case PARGS_AUXV:
+ xflag++;
+ break;
+ }
}
/* -l cannot be used with the -x or -e flags */