summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr/src/cmd/sgs/ar/common/ar.msg8
-rw-r--r--usr/src/cmd/sgs/ar/common/cmd.c69
-rw-r--r--usr/src/cmd/sgs/ar/common/main.c51
-rw-r--r--usr/src/man/man1/ar.17
-rw-r--r--usr/src/tools/env/illumos.sh6
5 files changed, 93 insertions, 48 deletions
diff --git a/usr/src/cmd/sgs/ar/common/ar.msg b/usr/src/cmd/sgs/ar/common/ar.msg
index a0da94da04..24daa9dce3 100644
--- a/usr/src/cmd/sgs/ar/common/ar.msg
+++ b/usr/src/cmd/sgs/ar/common/ar.msg
@@ -21,6 +21,7 @@
#
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2021 Oxide Computer Company
#
@ _START_
@@ -34,6 +35,7 @@
ar -p[-vV][-sS] archive [file ...]\n \
ar -q[-cuvSV] [-abi] [posname] [file ...]\n \
ar -r[-cuvSV] [-abi] [posname] [file ...]\n \
+ ar -s[-vV] archive\n \
ar -t[-vV][-sS] archive [file ...]\n \
ar -x[-vV][-sSCT] archive [file ...]\n"
@@ -41,12 +43,14 @@
@ MSG_TOOBIG4G "ar: archive size exceeds capabilities of 32-bit \
process\n"
-@ MSG_USAGE_01 "ar: one of [drqtpmx] must be specified\n"
+@ MSG_USAGE_01 "ar: one of [drqstpmx] must be specified\n"
@ MSG_USAGE_02 "ar: -%c requires an operand\n"
@ MSG_USAGE_03 "ar: bad option: -%c\n"
@ MSG_USAGE_04 "ar: only one of [drqtpmx] allowed\n"
@ MSG_USAGE_05 "ar: abi not allowed with q\n"
@ MSG_USAGE_06 "ar: %s taken as mandatory 'posname' with keys 'abi'\n"
+@ MSG_USAGE_S_BAD_ARG "ar: bad option with -s, only -v and -V allowed\n"
+@ MSG_USAGE_S_EXTRA_AR "ar: -s only supports a single archive file\n"
@ MSG_INTERNAL_01 "ar: internal error: cannot tell whether file is \
included in archive or not\n"
@@ -118,7 +122,7 @@
@ MSG_STR_SYM64 "/SYM64/"
# Format for full member header
-#
+#
@ MSG_MH_FORMAT "%-16s%-12d%-6u%-6u%-8o%-10lld%-2s"
@ MSG_FMT_VERSION "ar: %s %s\n"
diff --git a/usr/src/cmd/sgs/ar/common/cmd.c b/usr/src/cmd/sgs/ar/common/cmd.c
index 4ed18765f6..4c9c25de6e 100644
--- a/usr/src/cmd/sgs/ar/common/cmd.c
+++ b/usr/src/cmd/sgs/ar/common/cmd.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2021 Oxide Computer Company
*/
/*
@@ -33,36 +34,36 @@
*
* The archive file member header used in SunOS 4.1 archive files and
* Solaris archive files are incompatible. The header file is:
- * /usr/include/ar.h, struct ar_hdr.
+ * /usr/include/ar.h, struct ar_hdr.
* The member ar_name[] in Solaris comforms with Standard and the
* member name terminates with '/'. The SunOS's member does not terminate
* with '/' character. A bug 4046054 was filed:
- * The ar command in Solaris 2.5.1 is incompatible with archives
- * created on 4.x.
+ * The ar command in Solaris 2.5.1 is incompatible with archives
+ * created on 4.x.
*
* To handle archive files created in SunOS 4.1 system on Solaris, the
* following changes were made:
*
- * 1. file.c/writefile()
- * Before writing each member files into the output
- * archive file, ar_name[] is checked. If it is NULL,
- * it means that the original archive header for this
- * member was incompatible with Solaris format.
+ * 1. file.c/writefile()
+ * Before writing each member files into the output
+ * archive file, ar_name[] is checked. If it is NULL,
+ * it means that the original archive header for this
+ * member was incompatible with Solaris format.
*
- * The original Solaris ar command ended up having
- * NULL name for the header. The change here uses the
- * ar_rawname, which is much closer to the original
- * name.
+ * The original Solaris ar command ended up having
+ * NULL name for the header. The change here uses the
+ * ar_rawname, which is much closer to the original
+ * name.
*
- * 2. cmd.c
- * For the p command, the code used to use only ar_longname
- * to seach the matching name. The member is set to NULL
- * if the archive member header was incompatible.
- * The ar_rawname is also used to find the matching member name.
+ * 2. cmd.c
+ * For the p command, the code used to use only ar_longname
+ * to seach the matching name. The member is set to NULL
+ * if the archive member header was incompatible.
+ * The ar_rawname is also used to find the matching member name.
*
- * For commands to update the archive file, we do not
- * use ar_rawname, and just use the ar_longname. The commands are
- * r (replace), m (modify the position) and d (delete).
+ * For commands to update the archive file, we do not
+ * use ar_rawname, and just use the ar_longname. The commands are
+ * r (replace), m (modify the position) and d (delete).
*/
#include "inc.h"
@@ -90,7 +91,7 @@ rcmd(Cmd_info *cmd_info)
ARFILE *backptr = NULL;
ARFILE *endptr;
ARFILE *moved_files;
- ARFILE *prev_entry, *new_listhead, *new_listend;
+ ARFILE *prev_entry, *new_listhead, *new_listend;
int deleted;
struct stat stbuf;
char *gfile;
@@ -478,7 +479,8 @@ tcmd(Cmd_info *cmd_info)
* Refer to "Incompatible Archive Header"
* blocked comment at the beginning of this file.
*/
- if (cmd_info->opt_flgs & v_FLAG) {
+ if ((cmd_info->opt_flgs & (t_FLAG | v_FLAG)) ==
+ (t_FLAG | v_FLAG)) {
for (mp = &m[0]; mp < &m[9]; )
ar_select(*mp++, next->ar_mode);
@@ -495,17 +497,20 @@ tcmd(Cmd_info *cmd_info)
(void) fprintf(stdout,
MSG_ORIG(MSG_FMT_SPSTRSP), buf);
}
- if ((next->ar_longname[0] == 0) &&
- (next->ar_rawname[0] != 0))
- (void) fprintf(stdout,
- MSG_ORIG(MSG_FMT_STRNL),
- trim(next->ar_rawname));
- else
- (void) fprintf(stdout,
- MSG_ORIG(MSG_FMT_STRNL),
- trim(next->ar_longname));
+ if (cmd_info->opt_flgs & t_FLAG) {
+ if ((next->ar_longname[0] == 0) &&
+ (next->ar_rawname[0] != 0)) {
+ (void) fprintf(stdout,
+ MSG_ORIG(MSG_FMT_STRNL),
+ trim(next->ar_rawname));
+ } else {
+ (void) fprintf(stdout,
+ MSG_ORIG(MSG_FMT_STRNL),
+ trim(next->ar_longname));
+ }
+ }
}
- } /* for */
+ }
}
void
diff --git a/usr/src/cmd/sgs/ar/common/main.c b/usr/src/cmd/sgs/ar/common/main.c
index e5667aa196..8a73d30209 100644
--- a/usr/src/cmd/sgs/ar/common/main.c
+++ b/usr/src/cmd/sgs/ar/common/main.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/* Copyright (c) 1988 AT&T */
-/* All Rights Reserved */
+/* All Rights Reserved */
/*
* Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
@@ -27,6 +27,7 @@
/*
* Copyright (c) 2018, Joyent, Inc.
+ * Copyright 2021 Oxide Computer Company
*/
#include "inc.h"
@@ -131,20 +132,12 @@ main(int argc, char **argv, char *envp[])
if (cmd_info->opt_flgs & z_FLAG)
check_swap();
- if (cmd_info->comfun == NULL) {
- if ((cmd_info->opt_flgs & (d_FLAG | r_FLAG | q_FLAG |
- t_FLAG | p_FLAG | m_FLAG | x_FLAG)) == 0) {
- (void) fprintf(stderr, MSG_INTL(MSG_USAGE_01));
- exit(1);
- }
- }
-
cmd_info->modified = (cmd_info->opt_flgs & s_FLAG);
fd = getaf(cmd_info);
if ((fd == -1) &&
(cmd_info->opt_flgs &
- (d_FLAG | m_FLAG | p_FLAG | t_FLAG | x_FLAG)) ||
+ (d_FLAG | m_FLAG | p_FLAG | s_FLAG | t_FLAG | x_FLAG)) ||
((cmd_info->opt_flgs & r_FLAG) &&
(cmd_info->opt_flgs & (a_FLAG | b_FLAG)))) {
(void) fprintf(stderr, MSG_INTL(MSG_NOT_FOUND_AR),
@@ -315,6 +308,44 @@ setup(int argc, char *argv[], Cmd_info *cmd_info)
cmd_info->arnam = argv[optind];
cmd_info->namv = &argv[optind+1];
cmd_info->namc = argc - optind - 1;
+
+ /*
+ * GNU ar popularized the use of -s on its own which previously used to
+ * require another command function. As such, we don't set a command
+ * function when we encounter the -s flag because that might otherwise
+ * clobber an existing one being set and would interrupt the detection
+ * of multiple flags being used that way.
+ *
+ * If after processing everything, we find there's no command function
+ * set and the -s flag has been set, then we can finally set a command
+ * function. The command function for -t 'tcmd' is used in this case. It
+ * knows to only print out data if -t has been specified.
+ *
+ * While ar has not traditionally been very stringent about using flags
+ * in circumstances they aren't called for, we go ahead and check for
+ * that now for this newer option.
+ */
+ if (cmd_info->comfun == NULL) {
+ if ((cmd_info->opt_flgs & s_FLAG) != 0) {
+ if ((cmd_info->opt_flgs & ~(s_FLAG | v_FLAG)) != 0) {
+ (void) fprintf(stderr,
+ MSG_INTL(MSG_USAGE_S_BAD_ARG));
+ exit(1);
+ }
+
+ if (cmd_info->namc > 1) {
+ (void) fprintf(stderr,
+ MSG_INTL(MSG_USAGE_S_EXTRA_AR));
+ exit(1);
+ }
+
+ setcom(cmd_info, tcmd);
+ } else if ((cmd_info->opt_flgs & (d_FLAG | r_FLAG | q_FLAG |
+ s_FLAG | t_FLAG | p_FLAG | m_FLAG | x_FLAG)) == 0) {
+ (void) fprintf(stderr, MSG_INTL(MSG_USAGE_01));
+ exit(1);
+ }
+ }
}
diff --git a/usr/src/man/man1/ar.1 b/usr/src/man/man1/ar.1
index 5a2ff989f2..66512b0fb7 100644
--- a/usr/src/man/man1/ar.1
+++ b/usr/src/man/man1/ar.1
@@ -44,7 +44,7 @@
.\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
.\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved.
.\"
-.TH AR 1 "December 28, 2020"
+.TH AR 1 "September 20, 2021"
.SH NAME
ar \- maintain portable archive or library
.SH SYNOPSIS
@@ -74,6 +74,11 @@ ar \- maintain portable archive or library
.LP
.nf
+\fB/usr/bin/ar\fR \fB-s\fR [\fB-Vv\fR] \fIarchive\fR
+.fi
+
+.LP
+.nf
\fB/usr/bin/ar\fR \fB-t\fR [\fB-sVv\fR] \fIarchive\fR [\fIfile\fR]...
.fi
diff --git a/usr/src/tools/env/illumos.sh b/usr/src/tools/env/illumos.sh
index a8c587d072..73583402ab 100644
--- a/usr/src/tools/env/illumos.sh
+++ b/usr/src/tools/env/illumos.sh
@@ -82,8 +82,8 @@ export CODEMGR_WS="`git rev-parse --show-toplevel`"
export GNUC_ROOT=/usr/gcc/7
export PRIMARY_CC=gcc7,$GNUC_ROOT/bin/gcc,gnu
export PRIMARY_CCC=gcc7,$GNUC_ROOT/bin/g++,gnu
-export SHADOW_CCS=gcc4,/opt/gcc/4.4.4/bin/gcc,gnu
-export SHADOW_CCCS=gcc4,/opt/gcc/4.4.4/bin/g++,gnu
+export SHADOW_CCS=gcc10,/usr/gcc/10/bin/gcc,gnu
+export SHADOW_CCCS=gcc10,/usr/gcc/10/bin/g++,gnu
# comment to disable smatch
export ENABLE_SMATCH=1
@@ -227,7 +227,7 @@ export MACH="$(uname -p)"
# totally freed itself, we can remove this reference.
#
# Location of encumbered binaries.
-export ON_CLOSED_BINS="$CODEMGR_WS/closed"
+export ON_CLOSED_BINS="/opt/onbld/closed"
# REF_PROTO_LIST - for comparing the list of stuff in your proto area
# with. Generally this should be left alone, since you want to see differences