changeset 21408:e6f8a373226a

10946 Want penv and pauxv Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com> Reviewed by: Toomas Soome <toomas@me.com> Reviewed by: Peter Tribble <peter.tribble@gmail.com> Approved by: Richard Lowe <richlowe@richlowe.net>
author Robert Mustacchi <rm@joyent.com>
date Thu, 09 May 2019 17:19:27 +0000
parents 067682ab8452
children de7115fb7b83
files usr/src/cmd/ptools/Makefile.amd64 usr/src/cmd/ptools/Makefile.bld usr/src/cmd/ptools/Makefile.i386 usr/src/cmd/ptools/Makefile.ptool usr/src/cmd/ptools/Makefile.sparcv9 usr/src/cmd/ptools/pargs/pargs.c usr/src/man/man1/Makefile usr/src/man/man1/pargs.1 usr/src/man/man1/proc.1 usr/src/pkg/manifests/system-extended-system-utilities.mf
diffstat 10 files changed, 91 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/ptools/Makefile.amd64	Sun Aug 26 00:01:52 2018 +0000
+++ b/usr/src/cmd/ptools/Makefile.amd64	Thu May 09 17:19:27 2019 +0000
@@ -23,8 +23,6 @@
 # Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
 
 include ../../../Makefile.cmd
 include ../../../Makefile.cmd.64
@@ -33,6 +31,7 @@
 CFLAGS64 += $(CCVERBOSE)
 
 ROOTISAPROG=$(ROOTBIN64)/$(PROG)
+ROOTISALN=$(LN_$(PROG):%=$(ROOTBIN64)/%)
 
 include ../../Makefile.bld
 
--- a/usr/src/cmd/ptools/Makefile.bld	Sun Aug 26 00:01:52 2018 +0000
+++ b/usr/src/cmd/ptools/Makefile.bld	Thu May 09 17:19:27 2019 +0000
@@ -95,6 +95,8 @@
 OBJS_pmadvise =		pmap_common.o
 SRCS_pmadvise =		$(PMAP)/pmap_common.c
 
+LN_pargs =		penv pauxv
+
 CPPFLAGS +=	$(CPPFLAGS_$(PROG))
 OBJS +=		$(OBJS_$(PROG))
 SRCS +=		$(SRCS_$(PROG))
@@ -114,8 +116,9 @@
 %.o:	../%.c
 	$(COMPILE.c) $<
 
-all:	$(PROG)
+all:	$(PROG) $(LN_$(PROG))
 
+ROOTBINLN=$(LN_$(PROG):%=$(ROOTBIN)/%)
 ROOTBINPROG=$(ROOTBIN)/$(PROG)
 ROOTPROCBINSYMLINK=$(ROOT)/usr/proc/bin/$(PROG)
 
@@ -127,11 +130,23 @@
 # Install the ptool, symlinking it into /usr/proc/bin if PTOOL_TYPE is set
 # to LEGACY.
 #
-install: all $(ROOTISAPROG)
+install: all $(ROOTISAPROG) $(ROOTISALN) $(ROOTBINLN)
 	-$(RM) $(ROOTBINPROG)
 	-$(LN) $(ISAEXEC) $(ROOTBINPROG)
 	-$(INSTALL_$(PTOOL_TYPE))
 
+$(ROOTBINLN):
+	-$(RM) $@
+	-$(LN) $(ISAEXEC) $@
+
+$(ROOTISALN): $(ROOTISAPROG)
+	-$(RM) $@
+	-$(LN) $(ROOTISAPROG) $@
+
+$(LN_$(PROG)): $(PROG)
+	-$(RM) $@
+	-$(LN) $(PROG) $@
+
 clean:
 	$(RM) $(OBJS)
 
--- a/usr/src/cmd/ptools/Makefile.i386	Sun Aug 26 00:01:52 2018 +0000
+++ b/usr/src/cmd/ptools/Makefile.i386	Thu May 09 17:19:27 2019 +0000
@@ -20,8 +20,6 @@
 # CDDL HEADER END
 #
 #
-#ident	"%Z%%M%	%I%	%E% SMI"
-#
 # Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
@@ -31,6 +29,7 @@
 CFLAGS += $(CCVERBOSE)
 
 ROOTISAPROG=$(ROOTBIN32)/$(PROG)
+ROOTISALN=$(LN_$(PROG):%=$(ROOTBIN32)/%)
 
 include ../../Makefile.bld
 
--- a/usr/src/cmd/ptools/Makefile.ptool	Sun Aug 26 00:01:52 2018 +0000
+++ b/usr/src/cmd/ptools/Makefile.ptool	Thu May 09 17:19:27 2019 +0000
@@ -20,8 +20,6 @@
 # CDDL HEADER END
 #
 #
-#ident	"%Z%%M%	%I%	%E% SMI"
-#
 # Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
--- a/usr/src/cmd/ptools/Makefile.sparcv9	Sun Aug 26 00:01:52 2018 +0000
+++ b/usr/src/cmd/ptools/Makefile.sparcv9	Thu May 09 17:19:27 2019 +0000
@@ -23,8 +23,6 @@
 # Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
 
 include ../../../Makefile.cmd
 include ../../../Makefile.cmd.64
@@ -33,6 +31,7 @@
 CFLAGS64 += $(CCVERBOSE)
 
 ROOTISAPROG=$(ROOTBIN64)/$(PROG)
+ROOTISALN=$(LN_$(PROG):%=$(ROOTBIN64)/%)
 
 include ../../Makefile.bld
 
--- a/usr/src/cmd/ptools/pargs/pargs.c	Sun Aug 26 00:01:52 2018 +0000
+++ b/usr/src/cmd/ptools/pargs/pargs.c	Thu May 09 17:19:27 2019 +0000
@@ -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 */
@@ -1288,19 +1295,24 @@
 	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++;
@@ -1308,13 +1320,19 @@
 		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':
 			/*
@@ -1331,8 +1349,19 @@
 
 	/* -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 */
--- a/usr/src/man/man1/Makefile	Sun Aug 26 00:01:52 2018 +0000
+++ b/usr/src/man/man1/Makefile	Thu May 09 17:19:27 2019 +0000
@@ -479,8 +479,10 @@
 		notify.1	\
 		onintr.1	\
 		page.1		\
+		pauxv.1		\
 		pcat.1		\
 		pcred.1		\
+		penv.1		\
 		pfcsh.1		\
 		pfiles.1	\
 		pfksh.1		\
@@ -660,6 +662,9 @@
 pcat.1		:= LINKSRC = pack.1
 unpack.1	:= LINKSRC = pack.1
 
+pauxv.1		:= LINKSRC = pargs.1
+penv.1		:= LINKSRC = pargs.1
+
 pfcsh.1		:= LINKSRC = pfexec.1
 pfksh.1		:= LINKSRC = pfexec.1
 pfsh.1		:= LINKSRC = pfexec.1
--- a/usr/src/man/man1/pargs.1	Sun Aug 26 00:01:52 2018 +0000
+++ b/usr/src/man/man1/pargs.1	Thu May 09 17:19:27 2019 +0000
@@ -1,20 +1,22 @@
 '\" te
 .\"  Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved
+.\"  Copyright 2015 Joyent, Inc.
 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH PARGS 1 "Jun 19, 2006"
+.TH PARGS 1 "Oct 5, 2015"
 .SH NAME
-pargs \- print  process  arguments,  environment  variables,  or auxiliary
+pargs, penv, pauxv \- print  process  arguments,  environment  variables,  or auxiliary
 vector
 .SH SYNOPSIS
 .LP
 .nf
 \fBpargs\fR [\fB-aceFlx\fR] [\fIpid\fR | \fIcore\fR]...
+\fBpauxv\fR [\fB-cF\fR] [\fIpid\fR | \fIcore\fR]...
+\fBpenv\fR [\fB-cF\fR] [\fIpid\fR | \fIcore\fR]...
 .fi
 
 .SH DESCRIPTION
-.sp
 .LP
 The \fBpargs\fR utility examines a target process or process core file and
 prints arguments, environment variables and values, or the process auxiliary
@@ -32,10 +34,18 @@
 encoding, \fBpargs\fR attempts to employ the \fBiconv\fR(3C) facility to
 generate a printable version of the extracted  strings. In the event that such
 a conversion is impossible, strings are displayed as 7-bit \fBASCII\fR.
-.SH OPTIONS
+.sp
+.LP
+The \fBpauxv\fR command is equivalent to running \fBpargs\fR with the
+\fB-x\fR option.
 .sp
 .LP
-The following options are supported:
+The \fBpenv\fR command is equivalent to running \fBpargs\fR with the
+\fB-e\fR option.
+.SH OPTIONS
+.LP
+The following options are supported by \fBpargs\fR. Only the \fB-c\fR
+and \fB-F\fR options are supported by \fBpauxv\fR and \fBpenv\fR:
 .sp
 .ne 2
 .na
@@ -98,7 +108,6 @@
 .RE
 
 .SH OPERANDS
-.sp
 .LP
 The following operands are supported:
 .sp
@@ -120,7 +129,6 @@
 .RE
 
 .SH USAGE
-.sp
 .LP
 Caution should be exercised when using the \fB-F\fR flag. Imposing two
 controlling processes on one victim process can lead to chaos. Safety is
@@ -128,7 +136,6 @@
 stopped the victim process and the primary controlling process is doing nothing
 at the moment of application of the \fBproc\fR tool in question.
 .SH EXIT STATUS
-.sp
 .LP
 The following exit values are returned:
 .sp
@@ -151,7 +158,6 @@
 .RE
 
 .SH FILES
-.sp
 .ne 2
 .na
 \fB\fB/proc/pid/*\fR\fR
@@ -161,7 +167,6 @@
 .RE
 
 .SH ATTRIBUTES
-.sp
 .LP
 See \fBattributes\fR(5) for descriptions of the following attributes:
 .sp
@@ -177,7 +182,6 @@
 .TE
 
 .SH SEE ALSO
-.sp
 .LP
 \fBproc\fR(1), \fBiconv\fR(3C), \fBproc\fR(4), \fBascii\fR(5),
 \fBattributes\fR(5), \fBenviron\fR(5), \fBformats\fR(5)
--- a/usr/src/man/man1/proc.1	Sun Aug 26 00:01:52 2018 +0000
+++ b/usr/src/man/man1/proc.1	Thu May 09 17:19:27 2019 +0000
@@ -539,12 +539,12 @@
 The human readable output is Uncommitted. The options are Committed.
 .SH SEE ALSO
 .LP
-\fBgcore\fR(1), \fBldd\fR(1), \fBpargs\fR(1), \fBpgrep\fR(1), \fBpkill\fR(1),
-\fBplimit\fR(1), \fBpmap\fR(1), \fBpreap\fR(1), \fBps\fR(1), \fBptree\fR(1),
-\fBppgsz\fR(1), \fBpwd\fR(1), \fBrlogin\fR(1), \fBtime\fR(1), \fBtruss\fR(1),
-\fBwait\fR(1), \fBfcntl\fR(2), \fBfstat\fR(2), \fBsetuid\fR(2),
-\fBdlopen\fR(3C), \fBsignal.h\fR(3HEAD), \fBcore\fR(4), \fBproc\fR(4),
-\fBprocess\fR(4), \fBattributes\fR(5), \fBzones\fR(5)
+\fBgcore\fR(1), \fBldd\fR(1), \fBpargs\fR(1), \fBpauxv\fR(1), \fBpenv\fR(1),
+\fBpgrep\fR(1), \fBpkill\fR(1), \fBplimit\fR(1), \fBpmap\fR(1), \fBpreap\fR(1),
+\fBps\fR(1), \fBptree\fR(1), \fBppgsz\fR(1), \fBpwd\fR(1), \fBrlogin\fR(1),
+\fBtime\fR(1), \fBtruss\fR(1), \fBwait\fR(1), \fBfcntl\fR(2), \fBfstat\fR(2),
+\fBsetuid\fR(2), \fBdlopen\fR(3C), \fBsignal.h\fR(3HEAD), \fBcore\fR(4),
+\fBproc\fR(4), \fBprocess\fR(4), \fBattributes\fR(5), \fBzones\fR(5)
 .SH WARNINGS
 .LP
 The following \fBproc\fR tools stop their target processes while inspecting
--- a/usr/src/pkg/manifests/system-extended-system-utilities.mf	Sun Aug 26 00:01:52 2018 +0000
+++ b/usr/src/pkg/manifests/system-extended-system-utilities.mf	Thu May 09 17:19:27 2019 +0000
@@ -216,9 +216,17 @@
 file path=usr/share/man/man1m/projadd.1m
 file path=usr/share/man/man1m/projdel.1m
 file path=usr/share/man/man1m/projmod.1m
+$(i386_ONLY)hardlink path=usr/bin/$(ARCH32)/pauxv \
+    target=../../../usr/bin/$(ARCH32)/pargs
+$(i386_ONLY)hardlink path=usr/bin/$(ARCH32)/penv \
+    target=../../../usr/bin/$(ARCH32)/pargs
+hardlink path=usr/bin/$(ARCH64)/pauxv target=../../../usr/bin/$(ARCH64)/pargs
+hardlink path=usr/bin/$(ARCH64)/penv target=../../../usr/bin/$(ARCH64)/pargs
 hardlink path=usr/bin/oawk target=../../usr/bin/awk
 hardlink path=usr/bin/pargs target=../../usr/lib/isaexec
+hardlink path=usr/bin/pauxv target=../../usr/lib/isaexec
 hardlink path=usr/bin/pcred target=../../usr/lib/isaexec
+hardlink path=usr/bin/penv target=../../usr/lib/isaexec
 hardlink path=usr/bin/pfiles target=../../usr/lib/isaexec
 hardlink path=usr/bin/pflags target=../../usr/lib/isaexec
 hardlink path=usr/bin/pldd target=../../usr/lib/isaexec
@@ -275,7 +283,9 @@
 link path=usr/proc/bin/pwdx target=../../bin/pwdx
 link path=usr/share/man/man1/hashcheck.1 target=spell.1
 link path=usr/share/man/man1/hashmake.1 target=spell.1
+link path=usr/share/man/man1/pauxv.1 target=pargs.1
 link path=usr/share/man/man1/pcat.1 target=pack.1
+link path=usr/share/man/man1/penv.1 target=pargs.1
 link path=usr/share/man/man1/spellin.1 target=spell.1
 link path=usr/share/man/man1/uncompress.1 target=compress.1
 link path=usr/share/man/man1/unexpand.1 target=expand.1