summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--exception_lists/check_rtime5
-rw-r--r--exception_lists/packaging.deps1
-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/cmd/sgs/libld/common/ldentry.c2
-rw-r--r--usr/src/cmd/sgs/libld/common/outfile.c4
-rw-r--r--usr/src/cmd/sgs/libld/common/unwind.c14
-rw-r--r--usr/src/cmd/sgs/libld/common/update.c6
-rw-r--r--usr/src/cmd/sgs/tools/SUNWonld-README1
-rw-r--r--usr/src/cmd/zhack/Makefile49
-rw-r--r--usr/src/cmd/zhack/Makefile.com76
-rw-r--r--usr/src/cmd/zhack/amd64/Makefile30
-rw-r--r--usr/src/cmd/zhack/i386/Makefile29
-rw-r--r--usr/src/cmd/zhack/sparcv9/Makefile30
-rw-r--r--usr/src/cmd/zinject/Makefile42
-rw-r--r--usr/src/cmd/zinject/Makefile.com71
-rw-r--r--usr/src/cmd/zinject/amd64/Makefile31
-rw-r--r--usr/src/cmd/zinject/i386/Makefile30
-rw-r--r--usr/src/cmd/zinject/sparcv9/Makefile31
-rw-r--r--usr/src/cmd/zlook/Makefile31
-rw-r--r--usr/src/cmd/zlook/Makefile.com51
-rw-r--r--usr/src/cmd/zlook/amd64/Makefile30
-rw-r--r--usr/src/cmd/zlook/i386/Makefile29
-rw-r--r--usr/src/cmd/zlook/sparcv9/Makefile30
-rw-r--r--usr/src/cmd/zpool/zpool_main.c7
-rw-r--r--usr/src/cmd/ztest/Makefile58
-rw-r--r--usr/src/cmd/ztest/Makefile.com84
-rw-r--r--usr/src/cmd/ztest/amd64/Makefile32
-rw-r--r--usr/src/cmd/ztest/i386/Makefile31
-rw-r--r--usr/src/cmd/ztest/sparcv9/Makefile32
-rw-r--r--usr/src/cmd/ztest/ztest.c20
-rw-r--r--usr/src/lib/krb5/plugins/kdb/ldap/Makefile.com1
-rw-r--r--usr/src/lib/krb5/plugins/kdb/ldap/sparc/Makefile8
-rw-r--r--usr/src/lib/libproc/common/libproc.h1
-rw-r--r--usr/src/lib/libproc/common/mapfile-vers1
-rw-r--r--usr/src/lib/libproc/common/proc_get_info.c19
-rw-r--r--usr/src/lib/libzfs/common/libzfs_util.c12
-rw-r--r--usr/src/man/man1/ar.17
-rw-r--r--usr/src/man/man3c/clock_settime.3c378
-rw-r--r--usr/src/man/man3c/timer_create.3c20
-rw-r--r--usr/src/man/man3head/time.h.3head351
-rw-r--r--usr/src/man/man3lib/libproc.3lib20
-rw-r--r--usr/src/man/man3proc/Makefile1
-rw-r--r--usr/src/man/man3proc/proc_get_lwpsinfo.3proc65
-rw-r--r--usr/src/pkg/manifests/system-file-system-zfs-tests.mf18
-rw-r--r--usr/src/pkg/manifests/system-library.man3proc.inc1
-rw-r--r--usr/src/pkg/manifests/system-test-ostest.mf4
-rw-r--r--usr/src/test/os-tests/runfiles/default.run3
-rw-r--r--usr/src/test/os-tests/tests/Makefile6
-rw-r--r--usr/src/test/os-tests/tests/clock_gettime.c355
-rw-r--r--usr/src/test/test-runner/cmd/run2
-rw-r--r--usr/src/uts/common/Makefile.files2
-rw-r--r--usr/src/uts/common/conf/param.c6
-rw-r--r--usr/src/uts/common/os/clock_process.c130
-rw-r--r--usr/src/uts/common/os/clock_thread.c191
56 files changed, 1386 insertions, 1231 deletions
diff --git a/exception_lists/check_rtime b/exception_lists/check_rtime
index dc22d7a930..a512ae6cc4 100644
--- a/exception_lists/check_rtime
+++ b/exception_lists/check_rtime
@@ -233,11 +233,8 @@ FORBIDDEN_DEP usr/lib/netsvc/yp/ypxfrd # C++
# libfakekernel is a test environment, not intended for general use
FORBIDDEN libfakekernel\.so
FORBIDDEN_DEP usr/MACH(lib)/libzpool.so.1
-FORBIDDEN_DEP usr/bin/amd64/ztest
-FORBIDDEN_DEP usr/bin/i86/ztest
+FORBIDDEN_DEP usr/bin/ztest
FORBIDDEN_DEP usr/bin/raidz_test
-FORBIDDEN_DEP usr/bin/sparcv7/ztest
-FORBIDDEN_DEP usr/bin/sparcv9/ztest
FORBIDDEN_DEP usr/lib/MACH(smbfs)/libfknsmb.so.1
FORBIDDEN_DEP usr/lib/MACH(smbfs)/libfksmbfs.so.1
FORBIDDEN_DEP usr/lib/MACH(smbsrv)/libfksmbsrv.so.1
diff --git a/exception_lists/packaging.deps b/exception_lists/packaging.deps
index 244fb4f469..bfac6914b8 100644
--- a/exception_lists/packaging.deps
+++ b/exception_lists/packaging.deps
@@ -25,6 +25,7 @@ pkg:/library/security/openssl
pkg:/library/security/openssl-10
pkg:/library/security/openssl-11
pkg:/library/security/openssl-30
+pkg:/library/security/openssl-3
pkg:/library/security/trousers
pkg:/library/zlib
pkg:/package/pkg
diff --git a/usr/src/cmd/sgs/ar/common/ar.msg b/usr/src/cmd/sgs/ar/common/ar.msg
index 24daa9dce3..a0da94da04 100644
--- a/usr/src/cmd/sgs/ar/common/ar.msg
+++ b/usr/src/cmd/sgs/ar/common/ar.msg
@@ -21,7 +21,6 @@
#
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright 2021 Oxide Computer Company
#
@ _START_
@@ -35,7 +34,6 @@
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"
@@ -43,14 +41,12 @@
@ MSG_TOOBIG4G "ar: archive size exceeds capabilities of 32-bit \
process\n"
-@ MSG_USAGE_01 "ar: one of [drqstpmx] must be specified\n"
+@ MSG_USAGE_01 "ar: one of [drqtpmx] 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"
@@ -122,7 +118,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 4c9c25de6e..4ed18765f6 100644
--- a/usr/src/cmd/sgs/ar/common/cmd.c
+++ b/usr/src/cmd/sgs/ar/common/cmd.c
@@ -20,7 +20,6 @@
*/
/*
* Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2021 Oxide Computer Company
*/
/*
@@ -34,36 +33,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"
@@ -91,7 +90,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;
@@ -479,8 +478,7 @@ tcmd(Cmd_info *cmd_info)
* Refer to "Incompatible Archive Header"
* blocked comment at the beginning of this file.
*/
- if ((cmd_info->opt_flgs & (t_FLAG | v_FLAG)) ==
- (t_FLAG | v_FLAG)) {
+ if (cmd_info->opt_flgs & v_FLAG) {
for (mp = &m[0]; mp < &m[9]; )
ar_select(*mp++, next->ar_mode);
@@ -497,20 +495,17 @@ tcmd(Cmd_info *cmd_info)
(void) fprintf(stdout,
MSG_ORIG(MSG_FMT_SPSTRSP), buf);
}
- 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));
- }
- }
+ 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 8a73d30209..e5667aa196 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,7 +27,6 @@
/*
* Copyright (c) 2018, Joyent, Inc.
- * Copyright 2021 Oxide Computer Company
*/
#include "inc.h"
@@ -132,12 +131,20 @@ 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 | s_FLAG | t_FLAG | x_FLAG)) ||
+ (d_FLAG | m_FLAG | p_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),
@@ -308,44 +315,6 @@ 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/cmd/sgs/libld/common/ldentry.c b/usr/src/cmd/sgs/libld/common/ldentry.c
index 3a9920992d..447dea18b6 100644
--- a/usr/src/cmd/sgs/libld/common/ldentry.c
+++ b/usr/src/cmd/sgs/libld/common/ldentry.c
@@ -149,7 +149,7 @@ ld_map_out(Ofl_desc *ofl)
Aliste idx;
if (((dfiles = sdp->sd_aux->sa_dfiles) == NULL) ||
- (aplist_nitems(dfiles) == 1))
+ (aplist_nitems(dfiles) <= 1))
continue;
/*
diff --git a/usr/src/cmd/sgs/libld/common/outfile.c b/usr/src/cmd/sgs/libld/common/outfile.c
index 447d3a19b7..6d495fb33b 100644
--- a/usr/src/cmd/sgs/libld/common/outfile.c
+++ b/usr/src/cmd/sgs/libld/common/outfile.c
@@ -228,7 +228,7 @@ pad_outfile(Ofl_desc *ofl)
*/
if (oscn && (phdr->p_type == PT_LOAD)) {
Elf_Data * data;
- size_t size;
+ size_t size;
size = (size_t)(S_ROUND(offset, phdr->p_align) -
offset);
@@ -483,7 +483,7 @@ ld_create_outfile(Ofl_desc *ofl)
nseg++;
} else if (sgp->sg_flags & FLG_SG_EMPTY) {
nseg++;
- } else if (sgp->sg_osdescs != NULL) {
+ } else if (aplist_nitems(sgp->sg_osdescs) != 0) {
if ((sgp->sg_flags & FLG_SG_PHREQ) == 0) {
/*
* If this is a segment for which
diff --git a/usr/src/cmd/sgs/libld/common/unwind.c b/usr/src/cmd/sgs/libld/common/unwind.c
index 45cf0b2a9b..f2960f74c6 100644
--- a/usr/src/cmd/sgs/libld/common/unwind.c
+++ b/usr/src/cmd/sgs/libld/common/unwind.c
@@ -177,11 +177,11 @@
* Augmentation Section field 4 is not 0.
*
* z:
- * size uleb128 Length of the remainder of the
- * Augmentation Section
+ * size uleb128 Length of the remainder of the
+ * Augmentation Section
*
* P:
- * personality_enc 1 Encoding specifier - preferred
+ * personality_enc 1 Encoding specifier - preferred
* value is a pc-relative, signed
* 4-byte
*
@@ -191,14 +191,14 @@
* entry for the personality
* routine)
* R:
- * code_enc 1 Non-default encoding for the
+ * code_enc 1 Non-default encoding for the
* code-pointers (FDE members
* "initial_location" and "address_range"
* and the operand for DW_CFA_set_loc)
* - preferred value is pc-relative,
* signed 4-byte.
* L:
- * lsda_enc 1 FDE augmentation bodies may contain
+ * lsda_enc 1 FDE augmentation bodies may contain
* LSDA pointers. If so they are
* encoded as specified here -
* preferred value is pc-relative,
@@ -257,7 +257,7 @@
*
*
* 'z':
- * length uleb128 length of the remainder of the
+ * length uleb128 length of the remainder of the
* FDE augmentation section
*
*
@@ -332,7 +332,7 @@ ld_unwind_make_hdr(Ofl_desc *ofl)
* we only build a unwind header if we have
* some unwind information in the file.
*/
- if (ofl->ofl_unwind == NULL)
+ if (aplist_nitems(ofl->ofl_unwind) == 0)
return (1);
/*
diff --git a/usr/src/cmd/sgs/libld/common/update.c b/usr/src/cmd/sgs/libld/common/update.c
index 2bef6a18a8..0865ae64fa 100644
--- a/usr/src/cmd/sgs/libld/common/update.c
+++ b/usr/src/cmd/sgs/libld/common/update.c
@@ -389,7 +389,7 @@ update_osym(Ofl_desc *ofl)
Aliste idx2;
if (phd->p_type == PT_LOAD) {
- if (sgp->sg_osdescs != NULL) {
+ if (aplist_nitems(sgp->sg_osdescs) != 0) {
Word _flags = phd->p_flags & (PF_W | PF_R);
if (_flags == PF_R)
@@ -580,7 +580,7 @@ update_osym(Ofl_desc *ofl)
* no sections to establish an index for _end, so assign
* it as an absolute.
*/
- if (sgp->sg_osdescs != NULL) {
+ if (aplist_nitems(sgp->sg_osdescs) != 0) {
/*
* Determine the last section for this segment.
*/
@@ -4173,7 +4173,7 @@ ld_update_outfile(Ofl_desc *ofl)
* section descriptors associated with them (ie. some form of
* input section has been matched to this segment).
*/
- if (sgp->sg_osdescs == NULL)
+ if (aplist_nitems(sgp->sg_osdescs) == 0)
continue;
/*
diff --git a/usr/src/cmd/sgs/tools/SUNWonld-README b/usr/src/cmd/sgs/tools/SUNWonld-README
index bb8f0d9b3d..695c545719 100644
--- a/usr/src/cmd/sgs/tools/SUNWonld-README
+++ b/usr/src/cmd/sgs/tools/SUNWonld-README
@@ -1675,3 +1675,4 @@ Bugid Risk Synopsis
13487 want mapfile-based assertions about symbol properties (fix SPARC)
14090 ld(1) could use a normal allocator
14090 backout: turns over big rocks, discovers big bugs
+14152 ld(1) should be more careful about empty alists
diff --git a/usr/src/cmd/zhack/Makefile b/usr/src/cmd/zhack/Makefile
index d4f3018fd7..fa6c3bb99e 100644
--- a/usr/src/cmd/zhack/Makefile
+++ b/usr/src/cmd/zhack/Makefile
@@ -2,9 +2,8 @@
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
+# 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.
@@ -19,39 +18,51 @@
#
# CDDL HEADER END
#
+
#
-# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
-# Copyright (c) 2012 by Delphix. All rights reserved.
+# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
+# Copyright 2017 RackTop Systems.
+# Copyright 2020 Joyent, Inc.
#
PROG= zhack
+OBJS= $(PROG).o
include ../Makefile.cmd
+include ../Makefile.cmd.64
+include ../Makefile.ctf
+
+INCS += -I../../lib/libzpool/common
+INCS += -I../../uts/common/fs/zfs
+INCS += -I../../uts/common/fs/zfs/lua
+INCS += -I../../common/zfs
+INCS += -I../../lib/libzutil/common
+
+LDLIBS += -lzpool -lumem -lnvpair -lzutil
-$(INTEL_BLD)SUBDIRS = $(MACH)
-$(BUILD64)SUBDIRS += $(MACH64)
+CSTD= $(CSTD_GNU99)
-all := TARGET = all
-install := TARGET = install
-clean := TARGET = clean
-clobber := TARGET = clobber
-lint := TARGET = lint
+CFLAGS += $(CCVERBOSE)
+CFLAGS64 += $(CCVERBOSE)
+CPPFLAGS.first = -I$(SRC)/lib/libfakekernel/common -D_FAKE_KERNEL
+CPPFLAGS += -D_LARGEFILE64_SOURCE=1 -D_REENTRANT -DDEBUG $(INCS)
.KEEP_STATE:
-all clean clobber lint: $(SUBDIRS)
+all: $(PROG)
-install: $(SUBDIRS)
- -$(RM) $(ROOTUSRSBINPROG)
- -$(LN) $(ISAEXEC) $(ROOTUSRSBINPROG)
+install: all $(ROOTUSRSBINPROG)
-$(SUBDIRS): FRC
- @cd $@; pwd; $(MAKE) $(TARGET)
+$(PROG): $(OBJS)
+ $(LINK.c) -o $(PROG) $(OBJS) $(LDLIBS)
+ $(POST_PROCESS)
-FRC:
+clean:
+ $(RM) $(OBJS)
include ../Makefile.targ
diff --git a/usr/src/cmd/zhack/Makefile.com b/usr/src/cmd/zhack/Makefile.com
deleted file mode 100644
index d45962c16d..0000000000
--- a/usr/src/cmd/zhack/Makefile.com
+++ /dev/null
@@ -1,76 +0,0 @@
-#
-# CDDL HEADER START
-#
-# 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]
-#
-# CDDL HEADER END
-#
-
-#
-# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
-# Copyright 2017 RackTop Systems.
-# Copyright 2020 Joyent, Inc.
-#
-
-PROG= zhack
-SRCS= ../$(PROG).c
-OBJS= $(PROG).o
-
-include ../../Makefile.cmd
-include ../../Makefile.ctf
-
-INCS += -I../../../lib/libzpool/common
-INCS += -I../../../uts/common/fs/zfs
-INCS += -I../../../uts/common/fs/zfs/lua
-INCS += -I../../../common/zfs
-INCS += -I../../../lib/libzutil/common
-
-LDLIBS += -lzpool -lumem -lnvpair -lzutil
-
-CSTD= $(CSTD_GNU99)
-C99LMODE= -Xc99=%all
-
-CFLAGS += $(CCVERBOSE)
-CFLAGS64 += $(CCVERBOSE)
-CPPFLAGS.first = -I$(SRC)/lib/libfakekernel/common -D_FAKE_KERNEL
-CPPFLAGS += -D_LARGEFILE64_SOURCE=1 -D_REENTRANT -DDEBUG $(INCS)
-
-LINTFLAGS += -erroff=E_STATIC_UNUSED
-LINTFLAGS64 += -erroff=E_STATIC_UNUSED
-
-.KEEP_STATE:
-
-all: $(PROG)
-
-$(PROG): $(OBJS)
- $(LINK.c) -o $(PROG) $(OBJS) $(LDLIBS)
- $(POST_PROCESS)
-
-clean:
- $(RM) $(OBJS)
-
-lint: lint_SRCS
-
-include ../../Makefile.targ
-
-%.o: ../%.c
- $(COMPILE.c) $<
- $(POST_PROCESS_O)
diff --git a/usr/src/cmd/zhack/amd64/Makefile b/usr/src/cmd/zhack/amd64/Makefile
deleted file mode 100644
index 74c7a42a08..0000000000
--- a/usr/src/cmd/zhack/amd64/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (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]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-include ../Makefile.com
-include ../../Makefile.cmd.64
-
-install: all $(ROOTUSRSBINPROG64)
diff --git a/usr/src/cmd/zhack/i386/Makefile b/usr/src/cmd/zhack/i386/Makefile
deleted file mode 100644
index 2ff9c89632..0000000000
--- a/usr/src/cmd/zhack/i386/Makefile
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (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]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-include ../Makefile.com
-
-install: all $(ROOTUSRSBINPROG32)
diff --git a/usr/src/cmd/zhack/sparcv9/Makefile b/usr/src/cmd/zhack/sparcv9/Makefile
deleted file mode 100644
index 74c7a42a08..0000000000
--- a/usr/src/cmd/zhack/sparcv9/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (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]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-include ../Makefile.com
-include ../../Makefile.cmd.64
-
-install: all $(ROOTUSRSBINPROG64)
diff --git a/usr/src/cmd/zinject/Makefile b/usr/src/cmd/zinject/Makefile
index f646689967..b40dbf1150 100644
--- a/usr/src/cmd/zinject/Makefile
+++ b/usr/src/cmd/zinject/Makefile
@@ -22,33 +22,43 @@
# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# ident "%Z%%M% %I% %E% SMI"
+# Copyright (c) 2016 by Delphix. All rights reserved.
+# Copyright 2017 RackTop Systems.
+# Copyright 2020 Joyent, Inc.
#
-PROG:sh= basename `pwd`
+PROG= zinject
+OBJS= $(PROG).o translate.o
include ../Makefile.cmd
+include ../Makefile.cmd.64
+include ../Makefile.ctf
-$(INTEL_BLD)SUBDIRS = $(MACH)
-$(BUILD64)SUBDIRS += $(MACH64)
+INCS += -I../../lib/libzpool/common
+INCS += -I../../uts/common/fs/zfs
+INCS += -I../../uts/common/fs/zfs/lua
-all := TARGET = all
-install := TARGET = install
-clean := TARGET = clean
-clobber := TARGET = clobber
-lint := TARGET = lint
+LDLIBS += -lzfs -lnvpair
+
+CSTD= $(CSTD_GNU99)
+
+CPPFLAGS.first = -I$(SRC)/lib/libfakekernel/common -D_FAKE_KERNEL
+CPPFLAGS += -D_LARGEFILE64_SOURCE=1 -D_REENTRANT $(INCS)
+
+CERRWARN += $(CNOWARN_UNINIT)
+CERRWARN += -_gcc=-Wno-switch
.KEEP_STATE:
-all clean clobber lint: $(SUBDIRS)
+all: $(PROG)
-install: $(SUBDIRS)
- -$(RM) $(ROOTUSRSBINPROG)
- -$(LN) $(ISAEXEC) $(ROOTUSRSBINPROG)
+install: all $(ROOTUSRSBINPROG)
-$(SUBDIRS): FRC
- @cd $@; pwd; $(MAKE) $(TARGET)
+$(PROG): $(OBJS)
+ $(LINK.c) -o $(PROG) $(OBJS) $(LDLIBS)
+ $(POST_PROCESS)
-FRC:
+clean:
+ $(RM) $(OBJS)
include ../Makefile.targ
diff --git a/usr/src/cmd/zinject/Makefile.com b/usr/src/cmd/zinject/Makefile.com
deleted file mode 100644
index 220c877b42..0000000000
--- a/usr/src/cmd/zinject/Makefile.com
+++ /dev/null
@@ -1,71 +0,0 @@
-#
-# CDDL HEADER START
-#
-# 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]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# Copyright (c) 2016 by Delphix. All rights reserved.
-# Copyright 2017 RackTop Systems.
-# Copyright 2020 Joyent, Inc.
-#
-
-PROG:sh= cd ..; basename `pwd`
-OBJS= $(PROG).o translate.o
-SRCS= $(OBJS:%.o=../%.c)
-
-include ../../Makefile.cmd
-
-INCS += -I../../../lib/libzpool/common
-INCS += -I../../../uts/common/fs/zfs
-INCS += -I../../../uts/common/fs/zfs/lua
-
-LDLIBS += -lzfs -lnvpair
-
-CSTD= $(CSTD_GNU99)
-C99LMODE= -Xc99=%all
-
-CPPFLAGS.first = -I$(SRC)/lib/libfakekernel/common -D_FAKE_KERNEL
-CPPFLAGS += -D_LARGEFILE64_SOURCE=1 -D_REENTRANT $(INCS)
-
-CERRWARN += $(CNOWARN_UNINIT)
-CERRWARN += -_gcc=-Wno-switch
-
-LINTFLAGS += -erroff=E_STATIC_UNUSED
-LINTFLAGS64 += -erroff=E_STATIC_UNUSED
-
-.KEEP_STATE:
-
-all: $(PROG)
-
-$(PROG): $(OBJS)
- $(LINK.c) -o $(PROG) $(OBJS) $(LDLIBS)
- $(POST_PROCESS)
-
-clean:
- $(RM) $(OBJS)
-
-lint: lint_SRCS
-
-%.o: ../%.c
- $(COMPILE.c) $<
- $(POST_PROCESS_O)
-
-include ../../Makefile.targ
diff --git a/usr/src/cmd/zinject/amd64/Makefile b/usr/src/cmd/zinject/amd64/Makefile
deleted file mode 100644
index 8740a9f3ac..0000000000
--- a/usr/src/cmd/zinject/amd64/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# CDDL HEADER START
-#
-# 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]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-include ../Makefile.com
-include ../../Makefile.cmd.64
-
-install: all $(ROOTUSRSBINPROG64)
diff --git a/usr/src/cmd/zinject/i386/Makefile b/usr/src/cmd/zinject/i386/Makefile
deleted file mode 100644
index d2cb13dcd1..0000000000
--- a/usr/src/cmd/zinject/i386/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# CDDL HEADER START
-#
-# 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]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-include ../Makefile.com
-
-install: all $(ROOTUSRSBINPROG32)
diff --git a/usr/src/cmd/zinject/sparcv9/Makefile b/usr/src/cmd/zinject/sparcv9/Makefile
deleted file mode 100644
index 8740a9f3ac..0000000000
--- a/usr/src/cmd/zinject/sparcv9/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# CDDL HEADER START
-#
-# 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]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-include ../Makefile.com
-include ../../Makefile.cmd.64
-
-install: all $(ROOTUSRSBINPROG64)
diff --git a/usr/src/cmd/zlook/Makefile b/usr/src/cmd/zlook/Makefile
index fb2ee0ede2..66fc18115b 100644
--- a/usr/src/cmd/zlook/Makefile
+++ b/usr/src/cmd/zlook/Makefile
@@ -23,30 +23,31 @@
# Use is subject to license terms.
#
-PROG:sh= basename `pwd`
+PROG= zlook
+OBJS= $(PROG).o
include ../Makefile.cmd
+include ../Makefile.cmd.64
+include ../Makefile.ctf
-$(INTEL_BLD)SUBDIRS = $(MACH)
-$(BUILD64)SUBDIRS += $(MACH64)
+CSTD= $(CSTD_GNU99)
+CFLAGS += $(CCGDEBUG) $(CCVERBOSE)
+CFLAGS64 += $(CCGDEBUG) $(CCVERBOSE)
+CPPFLAGS += -D_LARGEFILE64_SOURCE=1 -D_REENTRANT $(INCS)
-all := TARGET = all
-install := TARGET = install
-clean := TARGET = clean
-clobber := TARGET = clobber
-lint := TARGET = lint
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
-all clean clobber lint: $(SUBDIRS)
+all: $(PROG)
-install: $(SUBDIRS)
- -$(RM) $(ROOTPROG)
- -$(LN) $(ISAEXEC) $(ROOTPROG)
+install: all $(ROOTPROG)
-$(SUBDIRS): FRC
- @cd $@; pwd; $(MAKE) $(TARGET)
+$(PROG): $(OBJS)
+ $(LINK.c) -o $(PROG) $(OBJS) $(LDLIBS)
+ $(POST_PROCESS)
-FRC:
+clean:
+ $(RM) $(OBJS)
include ../Makefile.targ
diff --git a/usr/src/cmd/zlook/Makefile.com b/usr/src/cmd/zlook/Makefile.com
deleted file mode 100644
index a634a72d2c..0000000000
--- a/usr/src/cmd/zlook/Makefile.com
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# CDDL HEADER START
-#
-# 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]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-PROG= zlook
-SRCS= ../$(PROG).c
-
-include ../../Makefile.cmd
-
-CSTD= $(CSTD_GNU99)
-C99LMODE= -Xc99=%all
-CFLAGS += $(CCGDEBUG) $(CCVERBOSE)
-CFLAGS64 += $(CCGDEBUG) $(CCVERBOSE)
-CPPFLAGS += -D_LARGEFILE64_SOURCE=1 -D_REENTRANT $(INCS)
-
-CERRWARN += $(CNOWARN_UNINIT)
-
-.KEEP_STATE:
-
-all: $(PROG)
-
-$(PROG): $(SRCS)
- $(LINK.c) -o $(PROG) $(SRCS) $(LDLIBS)
- $(POST_PROCESS)
-
-clean:
-
-lint: lint_SRCS
-
-include ../../Makefile.targ
diff --git a/usr/src/cmd/zlook/amd64/Makefile b/usr/src/cmd/zlook/amd64/Makefile
deleted file mode 100644
index 64da121d75..0000000000
--- a/usr/src/cmd/zlook/amd64/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# CDDL HEADER START
-#
-# 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]
-#
-# CDDL HEADER END
-#
-
-#
-# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-include ../Makefile.com
-include ../../Makefile.cmd.64
-
-install: all $(ROOTPROG64)
diff --git a/usr/src/cmd/zlook/i386/Makefile b/usr/src/cmd/zlook/i386/Makefile
deleted file mode 100644
index 1bd7915dff..0000000000
--- a/usr/src/cmd/zlook/i386/Makefile
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# CDDL HEADER START
-#
-# 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]
-#
-# CDDL HEADER END
-#
-
-#
-# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-include ../Makefile.com
-
-install: all $(ROOTPROG32)
diff --git a/usr/src/cmd/zlook/sparcv9/Makefile b/usr/src/cmd/zlook/sparcv9/Makefile
deleted file mode 100644
index 64da121d75..0000000000
--- a/usr/src/cmd/zlook/sparcv9/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# CDDL HEADER START
-#
-# 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]
-#
-# CDDL HEADER END
-#
-
-#
-# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-include ../Makefile.com
-include ../../Makefile.cmd.64
-
-install: all $(ROOTPROG64)
diff --git a/usr/src/cmd/zpool/zpool_main.c b/usr/src/cmd/zpool/zpool_main.c
index d2ae332849..43da32d439 100644
--- a/usr/src/cmd/zpool/zpool_main.c
+++ b/usr/src/cmd/zpool/zpool_main.c
@@ -6417,9 +6417,10 @@ zpool_do_trim(int argc, char **argv)
"combined with the -c or -s options\n"));
usage(B_FALSE);
}
- if (zfs_nicestrtonum(NULL, optarg, &rate) == -1) {
- (void) fprintf(stderr,
- gettext("invalid value for rate\n"));
+ if (zfs_nicestrtonum(g_zfs, optarg, &rate) == -1) {
+ (void) fprintf(stderr, "%s: %s\n",
+ gettext("invalid value for rate"),
+ libzfs_error_description(g_zfs));
usage(B_FALSE);
}
break;
diff --git a/usr/src/cmd/ztest/Makefile b/usr/src/cmd/ztest/Makefile
index 4ae78f4cae..46b79c1383 100644
--- a/usr/src/cmd/ztest/Makefile
+++ b/usr/src/cmd/ztest/Makefile
@@ -19,42 +19,56 @@
# CDDL HEADER END
#
#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# Copyright (c) 2015 by Delphix. All rights reserved.
-#
+# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
+# Copyright 2017 RackTop Systems.
+# Copyright 2020 Joyent, Inc.
-PROG:sh= basename `pwd`
+PROG= ztest
BASHPROG= zloop
ROOTBASHPROG= $(ROOTBIN)/$(BASHPROG)
CLOBBERFILES= $(BASHPROG)
+OBJS= $(PROG).o
+
include ../Makefile.cmd
+include ../Makefile.cmd.64
+include ../Makefile.ctf
-$(INTEL_BLD)SUBDIRS = $(MACH)
-$(BUILD64)SUBDIRS += $(MACH64)
+INCS += -I../../lib/libzpool/common
+INCS += -I../../uts/common/fs/zfs
+INCS += -I../../uts/common/fs/zfs/lua
+INCS += -I../../common/zfs
+INCS += -I../../lib/libzutil/common
-all := TARGET = all
-install := TARGET = install
-clean := TARGET = clean
-clobber := TARGET = clobber
-lint := TARGET = lint
+LDLIBS += -lumem -lzpool -lcmdutils -lm -lnvpair -lfakekernel -lzutil
-.KEEP_STATE:
+CSTD= $(CSTD_GNU99)
+CFLAGS += -g $(CCVERBOSE)
+CFLAGS64 += -g $(CCVERBOSE)
+CPPFLAGS.first = -I$(SRC)/lib/libfakekernel/common -D_FAKE_KERNEL
+CPPFLAGS += -D_LARGEFILE64_SOURCE=1 -D_REENTRANT $(INCS) -DDEBUG
-all lint: $(SUBDIRS) $(BASHPROG)
+CERRWARN += -_gcc=-Wno-switch
+
+# false positive
+SMOFF += signed
+
+# needs work
+SMOFF += all_func_returns
+
+.KEEP_STATE:
-clean clobber: $(SUBDIRS)
+all: $(PROG) $(BASHPROG)
-install: $(SUBDIRS) $(ROOTBASHPROG)
- -$(RM) $(ROOTPROG)
- -$(LN) $(ISAEXEC) $(ROOTPROG)
+install: all $(ROOTPROG) $(ROOTBASHPROG)
-$(SUBDIRS): FRC
- @cd $@; pwd; $(MAKE) $(TARGET)
+$(PROG): $(OBJS)
+ $(LINK.c) -o $(PROG) $(OBJS) $(LDLIBS)
+ $(POST_PROCESS)
-FRC:
+clean:
+ $(RM) $(OBJS)
include ../Makefile.targ
diff --git a/usr/src/cmd/ztest/Makefile.com b/usr/src/cmd/ztest/Makefile.com
deleted file mode 100644
index 0db755a6f7..0000000000
--- a/usr/src/cmd/ztest/Makefile.com
+++ /dev/null
@@ -1,84 +0,0 @@
-#
-# CDDL HEADER START
-#
-# 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]
-#
-# CDDL HEADER END
-#
-#
-# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
-# Copyright 2017 RackTop Systems.
-# Copyright 2020 Joyent, Inc.
-
-PROG= ztest
-OBJS= $(PROG).o
-SRCS= $(OBJS:%.o=../%.c)
-
-include ../../Makefile.cmd
-include ../../Makefile.ctf
-
-INCS += -I../../../lib/libzpool/common
-INCS += -I../../../uts/common/fs/zfs
-INCS += -I../../../uts/common/fs/zfs/lua
-INCS += -I../../../common/zfs
-INCS += -I../../../lib/libzutil/common
-
-LDLIBS += -lumem -lzpool -lcmdutils -lm -lnvpair -lfakekernel -lzutil
-
-CSTD= $(CSTD_GNU99)
-C99LMODE= -Xc99=%all
-CFLAGS += -g $(CCVERBOSE)
-CFLAGS64 += -g $(CCVERBOSE)
-CPPFLAGS.first = -I$(SRC)/lib/libfakekernel/common -D_FAKE_KERNEL
-CPPFLAGS += -D_LARGEFILE64_SOURCE=1 -D_REENTRANT $(INCS) -DDEBUG
-
-# lint complains about unused _umem_* functions
-LINTFLAGS += -xerroff=E_NAME_DEF_NOT_USED2
-LINTFLAGS64 += -xerroff=E_NAME_DEF_NOT_USED2
-
-# lint complains about unused inline functions, even though
-# they are "inline", not "static inline", with "extern inline"
-# implementations and usage in libzpool.
-LINTFLAGS += -erroff=E_STATIC_UNUSED
-LINTFLAGS64 += -erroff=E_STATIC_UNUSED
-
-CERRWARN += -_gcc=-Wno-switch
-
-# false positive
-SMOFF += signed
-
-# needs work
-SMOFF += all_func_returns
-
-.KEEP_STATE:
-
-all: $(PROG)
-
-$(PROG): $(OBJS)
- $(LINK.c) -o $(PROG) $(OBJS) $(LDLIBS)
- $(POST_PROCESS)
-
-clean:
- $(RM) $(OBJS)
-
-lint: lint_SRCS
-
-include ../../Makefile.targ
-
-%.o: ../%.c
- $(COMPILE.c) $<
- $(POST_PROCESS_O)
diff --git a/usr/src/cmd/ztest/amd64/Makefile b/usr/src/cmd/ztest/amd64/Makefile
deleted file mode 100644
index f259815d6e..0000000000
--- a/usr/src/cmd/ztest/amd64/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (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]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-include ../Makefile.com
-include ../../Makefile.cmd.64
-
-install: all $(ROOTPROG64)
diff --git a/usr/src/cmd/ztest/i386/Makefile b/usr/src/cmd/ztest/i386/Makefile
deleted file mode 100644
index 8ca4d0b763..0000000000
--- a/usr/src/cmd/ztest/i386/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (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]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-include ../Makefile.com
-
-install: all $(ROOTPROG32)
diff --git a/usr/src/cmd/ztest/sparcv9/Makefile b/usr/src/cmd/ztest/sparcv9/Makefile
deleted file mode 100644
index f259815d6e..0000000000
--- a/usr/src/cmd/ztest/sparcv9/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (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]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-include ../Makefile.com
-include ../../Makefile.cmd.64
-
-install: all $(ROOTPROG64)
diff --git a/usr/src/cmd/ztest/ztest.c b/usr/src/cmd/ztest/ztest.c
index f4f577e4d3..7870cbe37c 100644
--- a/usr/src/cmd/ztest/ztest.c
+++ b/usr/src/cmd/ztest/ztest.c
@@ -6091,31 +6091,15 @@ ztest_run_zdb(char *pool)
int status;
char zdb[MAXPATHLEN + MAXNAMELEN + 20];
char zbuf[1024];
- char *bin;
- char *ztest;
- char *isa;
- int isalen;
FILE *fp;
- (void) realpath(getexecname(), zdb);
-
- /* zdb lives in /usr/sbin, while ztest lives in /usr/bin */
- bin = strstr(zdb, "/usr/bin/");
- ztest = strstr(bin, "/ztest");
- isa = bin + 8;
- isalen = ztest - isa;
- isa = strdup(isa);
- /* LINTED */
- (void) sprintf(bin,
- "/usr/sbin%.*s/zdb -bcc%s%s -G -d -U %s "
+ (void) snprintf(zdb, sizeof (zdb),
+ "/usr/sbin/zdb -bcc%s%s -G -d -U %s "
"-o zfs_reconstruct_indirect_combinations_max=65536 %s",
- isalen,
- isa,
ztest_opts.zo_verbose >= 3 ? "s" : "",
ztest_opts.zo_verbose >= 4 ? "v" : "",
spa_config_path,
pool);
- free(isa);
if (ztest_opts.zo_verbose >= 5)
(void) printf("Executing %s\n", strstr(zdb, "zdb "));
diff --git a/usr/src/lib/krb5/plugins/kdb/ldap/Makefile.com b/usr/src/lib/krb5/plugins/kdb/ldap/Makefile.com
index dcdaf24b3d..966241305e 100644
--- a/usr/src/lib/krb5/plugins/kdb/ldap/Makefile.com
+++ b/usr/src/lib/krb5/plugins/kdb/ldap/Makefile.com
@@ -67,7 +67,6 @@ CERRWARN += -_gcc=-Wno-unused-function
DYNFLAGS += $(KERBRUNPATH)
# setting -L $(ROOT)/usr/lib/gss because libkdb_ldap needs mech_krb5
LDLIBS += -L $(ROOT)/usr/lib/gss -L $(ROOTLIBDIR) -lkdb_ldap
-$(SPARC_BLD)LDLIBS += -lc
.KEEP_STATE:
diff --git a/usr/src/lib/krb5/plugins/kdb/ldap/sparc/Makefile b/usr/src/lib/krb5/plugins/kdb/ldap/sparc/Makefile
index ab75567679..e7acecf30b 100644
--- a/usr/src/lib/krb5/plugins/kdb/ldap/sparc/Makefile
+++ b/usr/src/lib/krb5/plugins/kdb/ldap/sparc/Makefile
@@ -22,9 +22,13 @@
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# ident "%Z%%M% %I% %E% SMI"
-#
include ../Makefile.com
+#
+# Default -xO3 will trigger inclusion of SSP, which we do not need here.
+# illumos issue #14135
+#
+sparc_COPTFLAG= -O
+
install: all $(ROOTLIBDIR) $(ROOTLIBS) $(ROOTLINKS)
diff --git a/usr/src/lib/libproc/common/libproc.h b/usr/src/lib/libproc/common/libproc.h
index a73f8af647..9c3f1241cf 100644
--- a/usr/src/lib/libproc/common/libproc.h
+++ b/usr/src/lib/libproc/common/libproc.h
@@ -721,6 +721,7 @@ extern int proc_get_secflags(pid_t, prsecflags_t **);
extern prfdinfo_t *proc_get_fdinfo(pid_t, int);
extern const void *proc_fdinfo_misc(const prfdinfo_t *, uint_t, size_t *);
extern void proc_fdinfo_free(prfdinfo_t *);
+extern int proc_get_lwpsinfo(pid_t, uint_t, lwpsinfo_t *);
/*
* Utility functions for debugging tools to convert numeric fault,
diff --git a/usr/src/lib/libproc/common/mapfile-vers b/usr/src/lib/libproc/common/mapfile-vers
index 963ab12d28..d2fb68a991 100644
--- a/usr/src/lib/libproc/common/mapfile-vers
+++ b/usr/src/lib/libproc/common/mapfile-vers
@@ -221,6 +221,7 @@ SYMBOL_VERSION SUNWprivate_1.1 {
proc_get_fdinfo;
proc_get_priv;
proc_get_psinfo;
+ proc_get_lwpsinfo;
proc_get_secflags;
proc_get_status;
proc_initstdio;
diff --git a/usr/src/lib/libproc/common/proc_get_info.c b/usr/src/lib/libproc/common/proc_get_info.c
index 19a84e060e..c030856fdf 100644
--- a/usr/src/lib/libproc/common/proc_get_info.c
+++ b/usr/src/lib/libproc/common/proc_get_info.c
@@ -24,6 +24,7 @@
*/
/*
* Copyright 2015, Joyent, Inc.
+ * Copyright 2021 Oxide Computer Company
*/
#include <stdio.h>
@@ -217,3 +218,21 @@ proc_get_auxv(pid_t pid, auxv_t *pauxv, int naux)
}
return (rv);
}
+
+int
+proc_get_lwpsinfo(pid_t pid, uint_t thr, lwpsinfo_t *lwpip)
+{
+ char fname[PATH_MAX];
+ int fd;
+ int rv = -1;
+
+ (void) snprintf(fname, sizeof (fname), "%s/%d/lwp/%u/lwpsinfo",
+ procfs_path, (int)pid, thr);
+ if ((fd = open(fname, O_RDONLY)) >= 0) {
+ if (read(fd, lwpip, sizeof (*lwpip)) == sizeof (*lwpip))
+ rv = 0;
+ (void) close(fd);
+ }
+ return (rv);
+
+}
diff --git a/usr/src/lib/libzfs/common/libzfs_util.c b/usr/src/lib/libzfs/common/libzfs_util.c
index 5e24635179..5077fe2b73 100644
--- a/usr/src/lib/libzfs/common/libzfs_util.c
+++ b/usr/src/lib/libzfs/common/libzfs_util.c
@@ -1195,8 +1195,9 @@ str2shift(libzfs_handle_t *hdl, const char *buf)
break;
}
if (i == strlen(ends)) {
- zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
- "invalid numeric suffix '%s'"), buf);
+ if (hdl != NULL)
+ zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
+ "invalid numeric suffix '%s'"), buf);
return (-1);
}
@@ -1206,10 +1207,11 @@ str2shift(libzfs_handle_t *hdl, const char *buf)
*/
if (buf[1] == '\0' || (toupper(buf[1]) == 'B' && buf[2] == '\0' &&
toupper(buf[0]) != 'B'))
- return (10*i);
+ return (10 * i);
- zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
- "invalid numeric suffix '%s'"), buf);
+ if (hdl != NULL)
+ zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
+ "invalid numeric suffix '%s'"), buf);
return (-1);
}
diff --git a/usr/src/man/man1/ar.1 b/usr/src/man/man1/ar.1
index 66512b0fb7..5a2ff989f2 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 "September 20, 2021"
+.TH AR 1 "December 28, 2020"
.SH NAME
ar \- maintain portable archive or library
.SH SYNOPSIS
@@ -74,11 +74,6 @@ 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/man/man3c/clock_settime.3c b/usr/src/man/man3c/clock_settime.3c
index 9f6ca16bb9..2c18e48f0c 100644
--- a/usr/src/man/man3c/clock_settime.3c
+++ b/usr/src/man/man3c/clock_settime.3c
@@ -43,147 +43,245 @@
.\" Copyright 1989 AT&T
.\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
.\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
+.\" Copyright 2021 Oxide Computer Company
.\"
-.TH CLOCK_SETTIME 3C "Nov 26, 2017"
-.SH NAME
-clock_settime, clock_gettime, clock_getres \- high-resolution clock operations
-.SH SYNOPSIS
-.LP
-.nf
-#include <time.h>
-
-\fBint\fR \fBclock_settime\fR(\fBclockid_t\fR \fIclock_id\fR, \fBconst struct timespec *\fR\fItp\fR);
-.fi
-
-.LP
-.nf
-\fBint\fR \fBclock_gettime\fR(\fBclockid_t\fR \fIclock_id\fR, \fBstruct timespec *\fR\fItp\fR);
-.fi
-
-.LP
-.nf
-\fBint\fR \fBclock_getres\fR(\fBclockid_t\fR \fIclock_id\fR, \fBstruct timespec *\fR\fIres\fR);
-.fi
-
-.SH DESCRIPTION
-.LP
-The \fBclock_settime()\fR function sets the specified clock, \fIclock_id\fR, to
-the value specified by \fItp\fR. Time values that are between two consecutive
-non-negative integer multiples of the resolution of the specified clock are
-truncated down to the smaller multiple of the resolution.
-.sp
-.LP
-The \fBclock_gettime()\fR function returns the current value \fItp\fR for the
-specified clock, \fIclock_id\fR.
-.sp
-.LP
-The resolution of any clock can be obtained by calling \fBclock_getres()\fR.
-Clock resolutions are system-dependent and cannot be set by a process. If the
-argument \fIres\fR is not \fINULL\fR, the resolution of the specified clock is
-stored in the location pointed to by \fIres\fR. If \fIres\fR is \fINULL\fR, the
-clock resolution is not returned. If the time argument of \fBclock_settime()\fR
-is not a multiple of \fIres\fR, then the value is truncated to a multiple of
-\fIres\fR.
-.sp
-.LP
-A clock may be system wide (that is, visible to all processes) or per-process
-(measuring time that is meaningful only within a process).
-.sp
-.LP
-A \fIclock_id\fR of \fBCLOCK_REALTIME\fR is defined in <\fBtime.h\fR>. This
-clock represents the realtime clock for the system. For this clock, the values
-returned by \fBclock_gettime()\fR and specified by \fBclock_settime()\fR
-represent the amount of time (in seconds and nanoseconds) since the Epoch.
-Additional clocks may also be supported. The interpretation of time values for
-these clocks is unspecified.
-.sp
-.LP
-A \fIclock_id\fR of \fBCLOCK_HIGHRES\fR represents the non-adjustable,
-high-resolution clock for the system. For this clock, the value returned by
-\fBclock_gettime\fR(3C) represents the amount of time (in seconds and
-nanoseconds) since some arbitrary time in the past; it is not correlated in any
-way to the time of day, and thus is not subject to resetting or drifting by way
-of \fBadjtime\fR(2), \fBntp_adjtime\fR(2), \fBsettimeofday\fR(3C), or
-\fBclock_settime()\fR. The time source for this clock is the same as that for
-\fBgethrtime\fR(3C).
-.sp
-.LP
-Additional clocks may also be supported. The interpretation of time values for
-these clocks is unspecified.
-.SH RETURN VALUES
-.LP
-Upon successful completion, \fB0\fR is returned. Otherwise, \fB\(mi1\fR is
-returned and \fBerrno\fR is set to indicate the error.
-.SH ERRORS
-.LP
-The \fBclock_settime()\fR, \fBclock_gettime()\fR and \fBclock_getres()\fR
+.Dd October 3, 2021
+.Dt CLOCK_SETTIME 3C
+.Os
+.Sh NAME
+.Nm clock_settime ,
+.Nm clock_gettime ,
+.Nm clock_getres
+.Nd high-resolution clock operations
+.Sh SYNOPSIS
+.In time.h
+.Ft int
+.Fo clock_settime
+.Fa "clockid_t clock_id"
+.Fa "const struct timespec *tp"
+.Fc
+.Ft int
+.Fo clock_gettime
+.Fa "clockid_t clock_id"
+.Fa "struct timespec *tp"
+.Fc
+.Ft int
+.Fo clock_getres
+.Fa "clockid_t clock_id"
+.Fa "struct timespec *res"
+.Fc
+.Sh DESCRIPTION
+The
+.Fn clock_settime
+function sets the specified clock,
+.Fa clock_id ,
+to the value specified by
+.Fa tp .
+Time values that are between two consecutive non-negative integer multiples of
+the resolution of the specified clock are truncated down to the smaller multiple
+of the resolution.
+.Pp
+The
+.Fn clock_gettime
+function returns the current value
+.Fa tp
+for the specified clock,
+.Fa clock_id .
+.Pp
+The resolution of any clock can be obtained by calling
+.Fn clock_getres
+Clock resolutions are system-dependent and cannot be set by a process.
+If the argument
+.Fa res
+is not
+.Dv NULL ,
+the resolution of the specified clock is stored in the location pointed to by
+.Fa res .
+If
+.Fa res
+is
+.Dv NULL ,
+the clock resolution is not returned.
+If the time argument of
+.Fn clock_settime
+is not a multiple of
+.Fa res ,
+then the value is truncated to a multiple of
+.Fa res .
+.Pp
+A clock may be system wide
+.Pq that is, visible to all processes
+or per-process
+.Pq measuring time that is meaningful only within a process .
+.Pp
+The following clocks are supported in the system and defined by
+including
+.In time.h :
+.Bl -tag -width Ds
+.It Dv CLOCK_REALTIME
+This clock represents the realtime clock for the system.
+For this clock, the values returned by
+.Fn clock_gettime
+and specified by
+.Fn clock_settime
+represent the amount of time
+.Pq in seconds and nanoseconds
+since the Epoch.
+.It Dv CLOCK_HIGHRES
+This clock represents the non-adjustable, high-resolution clock for the system.
+For this clock, the value returned by
+.Fn clock_gettime
+represents the amount of time (in seconds and nanoseconds) since some arbitrary
+time in the past; it is not correlated in any way to the time of day, and thus
+is not subject to resetting or drifting by way of
+.Xr adjtime 2 ,
+.Xr ntp adjtime 2 ,
+.Xr settimeofday 3C ,
+or
+.Fn clock_settime .
+The time source for this clock is the same as that for
+.Xr gethrtime 3C .
+.Pp
+It is not possible to set this clock with
+.Fn clock_settime .
+.Pp
+.Dv CLOCK_MONOTONIC
+is an alias for this clock.
+Other systems define a
+.Dv CLOCK_MONOTONIC_RAW
+for a high-resolution clock which is not subject to adjustments.
+.Dv CLOCK_HIGHRES
+is not subject to time of day adjustments and thus can always be safely
+used here.
+.It Dv CLOCK_VIRTUAL
+This clock represents the amount of CPU-time
+.Pq in seconds and nanoseconds
+that the calling thread has spent executing user code.
+This is the same as the
+.Fa pr_utime
+member of the
+.Vt prusage_t
+and
+.Fa pr_utime
+member of the
+.Vt lwpsinfo_t
+structure discussed in
+.Xr proc 4 .
+.Pp
+This clock cannot be set with
+.Fn clock_settime
+and has the same source as
+.Xr gethrvtime 3C .
+.It Dv CLOCK_THREAD_CPUTIME_ID
+This clock is similar to
+.Dv CLOCK_VIRTUAL ;
+however, it also includes the system time of the calling thread in
+addition to the user time.
+.Pp
+The system time is the same that is seen in the
+.Fa pr_stime
+member of the
+.Vt lwpsinfo_t
+structure discussed in
+.Xr proc 4 .
+System time includes both the system and trap microstates,
+.Fa pr_stime
+and
+.Fa pr_ttime
+of the
+.Vt prusage_t
+structure respectively.
+.Pp
+This clock cannot be set with
+.Fn clock_settime
+and it has an alias of
+.Dv CLOCK_PROF .
+.It Dv ClOCK_PROCESS_CPUTIME_ID
+This clock represents the total CPU-time that the process
+.Pq but not children
+has spent in both user and system time for the calling process.
+This is equivalent to the combination of the
+.Fa pr_utime
+and
+.Fa pr_stime
+members of the
+.Vt psinfo_t
+structure documented in
+.Xr proc 4 .
+.Pp
+This clock is not settable with
+.Fn clock_settime .
+.El
+.Sh RETURN VALUES
+Upon successful completion,
+.Sy 0
+is returned.
+Otherwise,
+.Sy -1
+is returned and
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn clock_settime ,
+.Fn clock_gettime ,
+and
+.Fn clock_getres
functions will fail if:
-.sp
-.ne 2
-.na
-\fB\fBEINVAL\fR\fR
-.ad
-.RS 10n
-The \fIclock_id\fR argument does not specify a known clock.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBENOSYS\fR\fR
-.ad
-.RS 10n
-The functions \fBclock_settime()\fR, \fBclock_gettime()\fR, and
-\fBclock_getres()\fR are not supported by this implementation.
-.RE
-
-.sp
-.LP
-The \fBclock_settime()\fR function will fail if:
-.sp
-.ne 2
-.na
-\fB\fBEINVAL\fR\fR
-.ad
-.RS 10n
-The \fItp\fR argument to \fBclock_settime()\fR is outside the range for the
-given clock ID; or the \fItp\fR argument specified a nanosecond value less than
-zero or greater than or equal to 1000 million.
-.RE
-
-.sp
-.LP
-The \fBclock_settime()\fR function may fail if:
-.sp
-.ne 2
-.na
-\fB\fBEPERM\fR\fR
-.ad
-.RS 9n
+.Bl -tag -width Er
+.It Er EINVAL
+The
+.Fa clock_id
+argument does not specify a known clock.
+.It Er ENOSYS
+The functions
+.Fn \fBclock_settime ,
+.Fn \fBclock_gettime ,
+and
+.Fn clock_getres
+are not supported by this implementation.
+Note, this error should not occur here.
+.El
+.Pp
+The
+.Fn clock_settime
+function will fail if:
+.Bl -tag -width Er
+.It Er EINVAL
+The
+.Fa tp
+argument is outside the range for the given clock ID; or the
+.Fa tp
+argument specified a nanosecond value less than zero or greater than or
+equal to 1000 million.
+.Pp
+The clock specified by
+.Fa clock_id
+does not support being set.
+.El
+.Pp
+The
+.Fn clock_settime
+function may fail if:
+.Bl -tag -width Er
+.It Er EPERM
The requesting process does not have the appropriate privilege to set the
specified clock.
-.RE
-
-.SH ATTRIBUTES
-.LP
-See \fBattributes\fR(5) for descriptions of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-c | c
-l | l .
-ATTRIBUTE TYPE ATTRIBUTE VALUE
-_
-Interface Stability Committed
-_
-MT-Level \fBclock_gettime()\fR is Async-Signal-Safe
-_
-Standard See \fBstandards\fR(5).
-.TE
-
-.SH SEE ALSO
-.LP
-\fBtime\fR(2), \fBctime\fR(3C), \fBgethrtime\fR(3C), \fBtime.h\fR(3HEAD),
-\fBtimer_gettime\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)
+.El
+.Sh INTERFACE STABILITY
+.Sy Committed
+.Sh MT-LEVEL
+.Fn clock_gettime
+is
+.Sy Async-Signal-Safe
+.Sh SEE ALSO
+.Xr adjtime 2 ,
+.Xr ntp_adjtime 2 ,
+.Xr time 2 ,
+.Xr ctime 3C ,
+.Xr gethrtime 3C ,
+.Xr gethrvtime 3C ,
+.Xr settimeofday 3C ,
+.Xr timer_gettime 3C ,
+.Xr time.h 3HEAD ,
+.Xr proc 4
diff --git a/usr/src/man/man3c/timer_create.3c b/usr/src/man/man3c/timer_create.3c
index 63b57e0a41..b02cc7e6ef 100644
--- a/usr/src/man/man3c/timer_create.3c
+++ b/usr/src/man/man3c/timer_create.3c
@@ -44,7 +44,7 @@
.\" Portions Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
.\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
.\"
-.TH TIMER_CREATE 3C "Mar 24, 2016"
+.TH TIMER_CREATE 3C "Oct 04, 2021"
.SH NAME
timer_create \- create a timer
.SH SYNOPSIS
@@ -89,24 +89,6 @@ wall clock
.sp
.ne 2
.na
-\fB\fBCLOCK_VIRTUAL\fR\fR
-.ad
-.RS 18n
-user CPU usage clock
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBCLOCK_PROF\fR\fR
-.ad
-.RS 18n
-user and system CPU usage clock
-.RE
-
-.sp
-.ne 2
-.na
\fB\fBCLOCK_HIGHRES\fR\fR
.ad
.RS 18n
diff --git a/usr/src/man/man3head/time.h.3head b/usr/src/man/man3head/time.h.3head
index 261e30bbc2..dffdeaf5de 100644
--- a/usr/src/man/man3head/time.h.3head
+++ b/usr/src/man/man3head/time.h.3head
@@ -43,23 +43,24 @@
.\" Copyright (c) 2001, The IEEE and The Open Group. All Rights Reserved.
.\" Portions Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
.\" Copyright 2016 Joyent, Inc.
+.\" Copyright 2021 Oxide Computer Company
.\"
-.TH TIME.H 3HEAD "Feb 5, 2008"
-.SH NAME
-time.h, time \- time types
-.SH SYNOPSIS
-.LP
-.nf
-#include <\fBtime.h\fR>
-.fi
-
-.SH DESCRIPTION
-.LP
-The <\fBtime.h\fR> header declares the structure \fBtm\fR, which includes the
-following members:
-.sp
-.in +2
-.nf
+.Dd October 4, 2021
+.Dt TIME.H 3HEAD
+.Os
+.Sh NAME
+.Nm time.h ,
+.Nm time
+.Nd time types
+.Sh SYNOPSIS
+.In time.h
+.Sh DESCRIPTION
+The
+.In time.h
+header declares the structure
+.Vt tm ,
+which includes the following members:
+.Bd -literal -offset indent
int tm_sec /* seconds [0,60] */
int tm_min /* minutes [0,59] */
int tm_hour /* hour [0,23] */
@@ -69,187 +70,157 @@ int tm_year /* years since 1900 */
int tm_wday /* day of week [0,6] (Sunday =0) */
int tm_yday /* day of year [0,365] */
int tm_isdst /* daylight savings flag */
-.fi
-.in -2
-
-.sp
-.LP
-The value of \fBtm_isdst\fR is positive if Daylight Saving Time is in effect, 0
-if Daylight Saving Time is not in effect, and negative if the information is
-not available.
-.sp
-.LP
-The <\fBtime.h\fR> header defines the following symbolic names:
-.sp
-.ne 2
-.na
-\fB\fBNULL\fR\fR
-.ad
-.RS 28n
-Null pointer constant.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBCLOCKS_PER_SEC\fR\fR
-.ad
-.RS 28n
-A number used to convert the value returned by the \fBclock()\fR function into
-seconds. See \fBclock\fR(3C).
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBCLOCK_PROCESS_CPUTIME_ID\fR\fR
-.ad
-.RS 28n
+.Ed
+.Pp
+The value of
+.Fa tm_isdst
+is positive if Daylight Saving Time is in effect, 0 if Daylight Saving
+Time is not in effect, and negative if the information is not available.
+.Pp
+The
+.In time.h
+header defines the following symbolic names:
+.Bl -tag -width Ds
+.It Dv CLOCK_MONOTONIC
+The identifier for the system-wide monotonic clock, which is defined as a clock
+whose value cannot be set with
+.Fn clock_settime
+and that cannot have backward clock jumps.
+The maximum possible clock jump is implementation-defined.
+See
+.Xr clock_settime 3C .
+.It Dv CLOCKS_PER_SEC
+A number used to convert the value returned by the
+.Fn clock
+function into seconds.
+See
+.Xr clock 3C .
+.It Dv CLOCK_PROCESS_CPUTIME_ID
The identifier of the CPU-time clock associated with the process making a
-\fBclock()\fR or \fBtimer*()\fR function call.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBCLOCK_THREAD_CPUTIME_ID\fR\fR
-.ad
-.RS 28n
+.Fn clock
+or
+.Fn timer_*
+function call.
+This clock includes both user and system CPU-time.
+.It Dv CLOCK_REALTIME
+The identifier of the system-wide realtime clock.
+.It Dv CLOCK_THREAD_CPUTIME_ID
The identifier of the CPU-time clock associated with the thread making a
-\fBclock()\fR or \fBtimer*()\fR function call.
-.RE
-
-.sp
-.LP
-The <\fBtime.h\fR> header declares the \fBtimespec\fR structure, which has the
-following members:
-.sp
-.in +2
-.nf
+.Fn clock
+or
+.Fn timer_*
+function call.
+This clock includes both user and system CPU-time.
+.It Dv CLOCK_VIRTUAL
+The identifier of the CPU-time clock associated with the thread making a
+.Fn clock
+or
+.Fn timer_*
+function call.
+This clock only includes user CPU-time.
+.It Dv NULL
+Null pointer constant.
+.It Dv TIMER_ABSTIME
+Flag indicating time is absolute.
+For functions taking timer objects, this refers to the clock associated
+with the timer.
+.It Dv TIME_UTC
+The identifier for the system-wide realtime clock with no time zone
+translation.
+Used in
+.Fn timespec_get .
+.El
+.Pp
+The
+.In time.h
+header declares the
+.Vt timespec
+structure, which has the following members:
+.Bd -literal -offset indent
time_t tv_sec /* seconds */
long tv_nsec /* nanoseconds */
-.fi
-.in -2
-
-.sp
-.LP
-The <\fBtime.h\fR> header declares the \fBitimerspec\fR structure, which has
-the following members:
-.sp
-.in +2
-.nf
+.Ed
+.Pp
+The
+.In time.h
+header declares the
+.Vt itimerspec
+structure, which has the following members:
+.Bd -literal -offset indent
struct timespec it_interval /* timer period */
struct timespec it_value /* timer expiration */
-.fi
-.in -2
-
-.sp
-.LP
-The following manifest constants are defined:
-.sp
-.ne 2
-.na
-\fB\fBCLOCK_REALTIME\fR\fR
-.ad
-.RS 19n
-The identifier of the system-wide realtime clock.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBTIMER_ABSTIME\fR\fR
-.ad
-.RS 19n
-Flag indicating time is absolute. For functions taking timer objects, this
-refers to the clock associated with the timer.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBCLOCK_MONOTONIC\fR\fR
-.ad
-.RS 19n
-The identifier for the system-wide monotonic clock, which is defined as a clock
-whose value cannot be set with \fBclock_settime()\fR and that cannot have
-backward clock jumps. The maximum possible clock jump is
-implementation-defined. See \fBclock_settime\fR(3C).
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBTIME_UTC\fR\fR
-.ad
-.RS 19n
-The identifier for the system-wide realtime clock with no time zone
-translation. Used in \fBtimespec_get\fR().
-.RE
-
-.sp
-.LP
-The \fBclock_t\fR, \fBsize_t\fR, \fBtime_t\fR, \fBclockid_t\fR, and
-\fBtimer_t\fR types are defined as described in <\fBsys/types.h\fR>. See
-\fBtypes.h\fR(3HEAD).
-.sp
-.LP
-Although the value of \fBCLOCKS_PER_SEC\fR is required to be 1 million on all
-standard-conforming systems, it can be variable on other systems, and it should
-not be assumed that \fBCLOCKS_PER_SEC\fR is a compile-time constant.
-.sp
-.LP
-The <\fBtime.h\fR> header provides a declaration for \fBgetdate_err\fR.
-.sp
-.LP
+.Ed
+.Pp
+The
+.Vt clock_t ,
+.Vt size_t ,
+.Vt time_t ,
+.Vt clockid_t ,
+and
+.Vt timer_t
+types are defined as described in
+.In sys/types.h .
+See
+.Xr types.h 3HEAD .
+.Pp
+Although the value of
+.Dv CLOCKS_PER_SEC
+is required to be 1 million on all standard-conforming systems, it can
+be variable on other systems, and it should not be assumed that
+.Dv CLOCKS_PER_SEC
+is a compile-time constant.
+.Pp
+The
+.In time.h
+header provides a declaration for
+.Dv getdate_err .
+.Pp
The following are declared as variables:
-.sp
-.in +2
-.nf
+.Bd -literal -offset indent
extern int daylight;
extern long timezone;
extern char *tzname[];
-.fi
-.in -2
-
-.sp
-.LP
-Inclusion of the <\fBtime.h\fR> header can make visible all symbols from the
-<\fBsignal.h\fR> header.
-.SH USAGE
-.LP
-The range [0,60] for \fBtm_sec\fR allows for the occasional leap second.
-.sp
-.LP
-\fBtm_year\fR is a signed value; therefore, years before 1900 can be
-represented.
-.sp
-.LP
-To obtain the number of clock ticks per second returned by the \fBtimes()\fR
-function, applications should call \fBsysconf(_SC_CLK_TCK)\fR. See
-\fBtimes\fR(2) and \fBsysconf\fR(3C).
-.SH ATTRIBUTES
-.LP
-See \fBattributes\fR(5) for descriptions of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-c | c
-l | l .
-ATTRIBUTE TYPE ATTRIBUTE VALUE
-_
-Interface Stability Committed
-_
-Standard See \fBstandards\fR(5).
-.TE
-
-.SH SEE ALSO
-.LP
-\fBtime\fR(2), \fButime\fR(2), \fBclock\fR(3C), \fBctime\fR(3C),
-\fBdifftime\fR(3C), \fBgetdate\fR(3C), \fBmktime\fR(3C),
-\fBstrftime\fR(3C), \fBstrptime\fR(3C), \fBtypes.h\fR(3HEAD),
-\fBclock_settime\fR(3C), \fBnanosleep\fR(3C), \fBtimer_create\fR(3C),
-\fBtimer_delete\fR(3C), \fBtimer_settime\fR(3C), \fBtimespec_get\fR(3C),
-\fBattributes\fR(5), \fBstandards\fR(5)
+.Ed
+.Pp
+Inclusion of the
+.In time.h
+header can make visible all symbols from the
+.In signal.h
+header.
+.Sh USAGE
+The range [0,60] for
+.Fa tm_sec
+allows for the occasional leap second.
+.Pp
+.Fa tm_year
+is a signed value; therefore, years before 1900 can be represented.
+.Pp
+To obtain the number of clock ticks per second returned by the
+.Fn times
+function, applications should call
+.Fn sysconf "_SC_CLK_TCK" .
+See
+.Xr times 2
+and
+.Xr sysconf 3C .
+.Sh INTERFACE STABILITY
+.Sy Committed
+.Sh SEE ALSO
+.Xr time 2 ,
+.Xr utime 2 ,
+.Xr clock 3C ,
+.Xr clock_settime 3C ,
+.Xr ctime 3C ,
+.Xr difftime 3C ,
+.Xr getdate 3C ,
+.Xr mktime 3C ,
+.Xr nanosleep 3C ,
+.Xr strftime 3C ,
+.Xr strptime 3C ,
+.Xr timer_create 3C ,
+.Xr timer_delete 3C ,
+.Xr timer_settime 3C ,
+.Xr timespec_get 3C ,
+.Xr types.h 3HEAD ,
+.Xr attributes 5 ,
+.Xr standards 5
diff --git a/usr/src/man/man3lib/libproc.3lib b/usr/src/man/man3lib/libproc.3lib
index 72f1a22387..3ae126d1f7 100644
--- a/usr/src/man/man3lib/libproc.3lib
+++ b/usr/src/man/man3lib/libproc.3lib
@@ -313,16 +313,16 @@ library.
.It Sy proc_fltname Ta Sy proc_fltset2str
.It Sy proc_flushstdio Ta Sy proc_get_auxv
.It Sy proc_fdinfo_misc Ta Sy proc_get_cred
-.It Sy proc_get_fdinfo Ta Sy proc_get_priv
-.It Sy proc_get_psinfo Ta Sy proc_get_status
-.It Sy proc_get_initstdio Ta Sy proc_lwp_in_set
-.It Sy proc_lwp_range_valid Ta Sy proc_signame
-.It Sy proc_sigset2str Ta Sy proc_str2content
-.It Sy proc_str2flt Ta Sy proc_str2fltset
-.It Sy proc_str2sig Ta Sy proc_str2sigset
-.It Sy proc_str2sys Ta Sy proc_str2sysset
-.It Sy proc_sysname Ta Sy proc_sysset2str
-.It Sy proc_unctrl_psinfo Ta ""
+.It Sy proc_get_fdinfo Ta Sy proc_get_lwpsinfo
+.It Sy proc_get_priv Ta Sy proc_get_psinfo
+.It Sy proc_get_status Ta Sy proc_get_initstdio
+.It Sy proc_lwp_in_set Ta Sy proc_lwp_range_valid
+.It Sy proc_signame Ta Sy proc_sigset2str
+.It Sy proc_str2content Ta Sy proc_str2flt
+.It Sy proc_str2fltset Ta Sy proc_str2sig
+.It Sy proc_str2sigset Ta Sy proc_str2sys
+.It Sy proc_str2sysset Ta Sy proc_sysname
+.It Sy proc_sysset2str Ta Sy proc_unctrl_psinfo
.El
.Ss x86 Specific Routines
The following routines are specific to the x86, 32-bit and 64-bit,
diff --git a/usr/src/man/man3proc/Makefile b/usr/src/man/man3proc/Makefile
index a0963ce22e..bbfda25aa4 100644
--- a/usr/src/man/man3proc/Makefile
+++ b/usr/src/man/man3proc/Makefile
@@ -131,6 +131,7 @@ MANFILES= \
proc_get_auxv.3proc \
proc_get_cred.3proc \
proc_get_fdinfo.3proc \
+ proc_get_lwpsinfo.3proc \
proc_get_priv.3proc \
proc_get_psinfo.3proc \
proc_get_status.3proc \
diff --git a/usr/src/man/man3proc/proc_get_lwpsinfo.3proc b/usr/src/man/man3proc/proc_get_lwpsinfo.3proc
new file mode 100644
index 0000000000..113ebf97b1
--- /dev/null
+++ b/usr/src/man/man3proc/proc_get_lwpsinfo.3proc
@@ -0,0 +1,65 @@
+.\"
+.\" This file and its contents are supplied under the terms of the
+.\" Common Development and Distribution License ("CDDL"), version 1.0.
+.\" You may only use this file in accordance with the terms of version
+.\" 1.0 of the CDDL.
+.\"
+.\" A full copy of the text of the CDDL should have accompanied this
+.\" source. A copy of the CDDL is also available via the Internet at
+.\" http://www.illumos.org/license/CDDL.
+.\"
+.\"
+.\" Copyright 2021 Oxide Computer Company
+.\"
+.Dd October 3, 2021
+.Dt PROC_GET_LWPSINFO 3PROC
+.Os
+.Sh NAME
+.Nm proc_get_lwpsinfo
+.Nd get thread ps information
+.Sh SYNOPSIS
+.Lb libproc
+.In libproc
+.Ft int
+.Fo proc_get_lwpsinfo
+.Fa "pid_t pid"
+.Fa "uint_t thr"
+.Fa "lwpsinfo_t *lwp"
+.Fc
+.Sh DESCRIPTION
+The
+.Fn proc_get_lwpsinfo
+function is a convenient way to read the /proc lwpsinfo for the specific
+thread,
+.Fa thr ,
+found in the process
+.Fa pid .
+The information from the
+.Pa lwpsinfo
+file will be placed in
+.Fa lwp .
+The definition of the
+.Vt lwpsinfo_t
+structure may be found in
+.Xr proc 4 .
+.Pp
+The thread identifier for a thread is the same between POSIX pthreads,
+C11 threads, and the native threads API.
+It is safe to pass one of those identifiers in as
+.Fa thr
+or to use a specific number.
+.Sh RETURN VALUES
+Upon successful completion, the
+.Fn proc_get_psinfo
+function returns
+.Sy 0 .
+Otherwise,
+.Sy -1
+is returned to indicate an error occurred.
+.Sh INTERFACE STABILITY
+.Sy Uncommitted
+.Sh MT-LEVEL
+.Sy MT-Safe
+.Sh SEE ALSO
+.Xr libproc 3LIB ,
+.Xr proc 4
diff --git a/usr/src/pkg/manifests/system-file-system-zfs-tests.mf b/usr/src/pkg/manifests/system-file-system-zfs-tests.mf
index d39248a2e4..b2d3d84418 100644
--- a/usr/src/pkg/manifests/system-file-system-zfs-tests.mf
+++ b/usr/src/pkg/manifests/system-file-system-zfs-tests.mf
@@ -36,7 +36,6 @@ dir path=kernel/drv group=sys
dir path=kernel/drv/$(ARCH64) group=sys
dir path=usr group=sys
dir path=usr/bin
-$(i386_ONLY)dir path=usr/bin/$(ARCH32)
dir path=usr/bin/$(ARCH64)
dir path=usr/include
dir path=usr/include/sys
@@ -45,27 +44,18 @@ dir path=usr/lib
dir path=usr/lib/devfsadm group=sys
dir path=usr/lib/devfsadm/linkmod group=sys
dir path=usr/sbin
-$(i386_ONLY)dir path=usr/sbin/$(ARCH32)
dir path=usr/sbin/$(ARCH64)
driver name=zut perms="* 0666 root sys"
file path=kernel/drv/$(ARCH64)/zut group=sys
file path=kernel/drv/zut.conf group=sys
-$(i386_ONLY)file path=usr/bin/$(ARCH32)/zlook mode=0555
-$(i386_ONLY)file path=usr/bin/$(ARCH32)/ztest mode=0555
-file path=usr/bin/$(ARCH64)/zlook mode=0555
-file path=usr/bin/$(ARCH64)/ztest mode=0555
file path=usr/bin/raidz_test mode=0555
+file path=usr/bin/zlook mode=0555
file path=usr/bin/zloop mode=0555
+file path=usr/bin/ztest mode=0555
file path=usr/include/sys/fs/zut.h
file path=usr/lib/devfsadm/linkmod/SUNW_zut_link.so group=sys
-$(i386_ONLY)file path=usr/sbin/$(ARCH32)/zhack mode=0555
-$(i386_ONLY)file path=usr/sbin/$(ARCH32)/zinject mode=0555
-file path=usr/sbin/$(ARCH64)/zhack mode=0555
-file path=usr/sbin/$(ARCH64)/zinject mode=0555
-hardlink path=usr/bin/zlook target=../../usr/lib/isaexec
-hardlink path=usr/bin/ztest target=../../usr/lib/isaexec
-hardlink path=usr/sbin/zhack target=../../usr/lib/isaexec
-hardlink path=usr/sbin/zinject target=../../usr/lib/isaexec
+file path=usr/sbin/zhack mode=0555
+file path=usr/sbin/zinject mode=0555
legacy pkg=SUNWonzfs desc="ZFS test commands" name="ZFS unbundled utilities"
legacy pkg=SUNWonzfsr desc="ZFS test driver" name="ZFS unbundled driver"
license cr_Sun license=cr_Sun
diff --git a/usr/src/pkg/manifests/system-library.man3proc.inc b/usr/src/pkg/manifests/system-library.man3proc.inc
index c3388bb920..e10fc8c9ae 100644
--- a/usr/src/pkg/manifests/system-library.man3proc.inc
+++ b/usr/src/pkg/manifests/system-library.man3proc.inc
@@ -151,6 +151,7 @@ file path=usr/share/man/man3proc/proc_fltset2str.3proc
file path=usr/share/man/man3proc/proc_get_auxv.3proc
file path=usr/share/man/man3proc/proc_get_cred.3proc
file path=usr/share/man/man3proc/proc_get_fdinfo.3proc
+file path=usr/share/man/man3proc/proc_get_lwpsinfo.3proc
file path=usr/share/man/man3proc/proc_get_priv.3proc
file path=usr/share/man/man3proc/proc_get_psinfo.3proc
file path=usr/share/man/man3proc/proc_get_status.3proc
diff --git a/usr/src/pkg/manifests/system-test-ostest.mf b/usr/src/pkg/manifests/system-test-ostest.mf
index 60308fc1b1..dae4f33ca2 100644
--- a/usr/src/pkg/manifests/system-test-ostest.mf
+++ b/usr/src/pkg/manifests/system-test-ostest.mf
@@ -50,9 +50,10 @@ file path=kernel/drv/ksensor_test.conf group=sys
file path=opt/os-tests/README mode=0444
file path=opt/os-tests/bin/ostest mode=0555
file path=opt/os-tests/runfiles/default.run mode=0444
-file path=opt/os-tests/tests/imc_test mode=0555
file path=opt/os-tests/tests/OS-6097.32 mode=0555
file path=opt/os-tests/tests/OS-6097.64 mode=0555
+file path=opt/os-tests/tests/clock_gettime.32 mode=0555
+file path=opt/os-tests/tests/clock_gettime.64 mode=0555
file path=opt/os-tests/tests/ddi_ufm/ufm-test mode=0555
file path=opt/os-tests/tests/ddi_ufm/ufm-test-cleanup mode=0555
file path=opt/os-tests/tests/ddi_ufm/ufm-test-setup mode=0555
@@ -62,6 +63,7 @@ file path=opt/os-tests/tests/file-locking/acquire-lock.32 mode=0555
file path=opt/os-tests/tests/file-locking/acquire-lock.64 mode=0555
file path=opt/os-tests/tests/file-locking/runtests.32 mode=0555
file path=opt/os-tests/tests/file-locking/runtests.64 mode=0555
+file path=opt/os-tests/tests/imc_test mode=0555
$(i386_ONLY)file path=opt/os-tests/tests/i386/badseg mode=0555
$(i386_ONLY)file path=opt/os-tests/tests/i386/badseg_exec mode=0555
$(i386_ONLY)file path=opt/os-tests/tests/i386/ldt mode=0555
diff --git a/usr/src/test/os-tests/runfiles/default.run b/usr/src/test/os-tests/runfiles/default.run
index 4a8993e1d5..363ee69942 100644
--- a/usr/src/test/os-tests/runfiles/default.run
+++ b/usr/src/test/os-tests/runfiles/default.run
@@ -34,6 +34,9 @@ tests = ['poll_test', 'epoll_test']
[/opt/os-tests/tests/odirectory.32]
[/opt/os-tests/tests/odirectory.64]
+[/opt/os-tests/tests/clock_gettime.32]
+[/opt/os-tests/tests/clock_gettime.64]
+
[/opt/os-tests/tests/secflags]
user = root
tests = ['secflags_aslr',
diff --git a/usr/src/test/os-tests/tests/Makefile b/usr/src/test/os-tests/tests/Makefile
index 5542b481ba..28d7c8c8e2 100644
--- a/usr/src/test/os-tests/tests/Makefile
+++ b/usr/src/test/os-tests/tests/Makefile
@@ -39,6 +39,7 @@ SUBDIRS = \
$(SUBDIRS_$(MACH))
PROGS = \
+ clock_gettime \
eventfd \
odirectory \
OS-6097 \
@@ -59,6 +60,11 @@ odirectory.64 := LDLIBS64 += -lsocket
OS-6097.32 := LDLIBS += -ldlpi
OS-6097.64 := LDLIBS64 += -ldlpi
+clock_gettime.32 := LDLIBS += -lproc
+clock_gettime.32 := CSTD = $(CSTD_GNU99)
+clock_gettime.64 := LDLIBS64 += -lproc
+clock_gettime.64 := CSTD = $(CSTD_GNU99)
+
writev.32 := CPPFLAGS += -D_FILE_OFFSET_BITS=64
writev.32 := CSTD = $(CSTD_GNU99)
writev.64 := CSTD = $(CSTD_GNU99)
diff --git a/usr/src/test/os-tests/tests/clock_gettime.c b/usr/src/test/os-tests/tests/clock_gettime.c
new file mode 100644
index 0000000000..b6bfdbe7bb
--- /dev/null
+++ b/usr/src/test/os-tests/tests/clock_gettime.c
@@ -0,0 +1,355 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2021 Oxide Comptuer Company
+ */
+
+/*
+ * Test a bunch of basics around clocks.
+ */
+
+#include <time.h>
+#include <err.h>
+#include <stdlib.h>
+#include <libproc.h>
+#include <thread.h>
+#include <sys/sysmacros.h>
+
+typedef hrtime_t (*clock_alttime_f)(void);
+
+typedef struct clock_gettime_test {
+ clockid_t cgt_clock;
+ clock_alttime_f cgt_alt;
+ const char *cgt_name;
+} clock_gettime_test_t;
+
+typedef struct clock_gettime_thr_arg {
+ hrtime_t cgta_usr;
+ hrtime_t cgta_usrsys;
+} clock_gettime_thr_arg_t;
+
+static hrtime_t
+clock_ts2hrt(const timespec_t *tsp)
+{
+ return ((tsp->tv_sec * NANOSEC) + tsp->tv_nsec);
+}
+
+static hrtime_t
+clock_gettime_proc(void)
+{
+ psinfo_t ps;
+
+ if (proc_get_psinfo(getpid(), &ps) != 0) {
+ warn("failed to get psinfo for process");
+ return (0);
+ }
+
+ return (clock_ts2hrt(&ps.pr_time));
+}
+
+static hrtime_t
+clock_gettime_thread(void)
+{
+ lwpsinfo_t lwpsinfo;
+
+ if (proc_get_lwpsinfo(getpid(), thr_self(), &lwpsinfo) != 0) {
+ warn("failed to get lwpsinfo for thread %u", thr_self());
+ return (0);
+ }
+
+ return (clock_ts2hrt(&lwpsinfo.pr_time));
+}
+
+clock_gettime_test_t clock_tests[] = {
+ { CLOCK_HIGHRES, gethrtime, "highres" },
+ { CLOCK_VIRTUAL, gethrvtime, "virtual" },
+ { CLOCK_THREAD_CPUTIME_ID, clock_gettime_thread, "thread_cputime" },
+ { CLOCK_PROCESS_CPUTIME_ID, clock_gettime_proc, "proc_cputime" }
+};
+
+/*
+ * Do a series of reads of the clock from clock_gettime and its secondary
+ * source. Make sure that we always see increasing values.
+ */
+static boolean_t
+clock_test(clock_gettime_test_t *test)
+{
+ hrtime_t hrt0, hrt1, hrt2, convts0, convts1;
+ struct timespec ts0, ts1;
+ boolean_t ret = B_TRUE;
+
+ if (clock_gettime(test->cgt_clock, &ts0) != 0) {
+ warn("failed to get clock %u", test->cgt_clock);
+ return (B_FALSE);
+ }
+
+ hrt0 = test->cgt_alt();
+ hrt1 = test->cgt_alt();
+
+ if (clock_gettime(test->cgt_clock, &ts1) != 0) {
+ warn("failed to get clock %u", test->cgt_clock);
+ return (B_FALSE);
+ }
+
+ hrt2 = test->cgt_alt();
+
+ convts0 = clock_ts2hrt(&ts0);
+ convts1 = clock_ts2hrt(&ts1);
+
+ if (convts0 > hrt0) {
+ warnx("clock %s traveled backwards, clock_gettime ahead of "
+ "later alternate: clock_gettime %lld, alternate: %lld",
+ test->cgt_name, convts0, hrt0);
+ ret = B_FALSE;
+ }
+
+ if (hrt0 > hrt1) {
+ warnx("clock %s traveled backwards, alternate ahead of "
+ "later alternate: first alternate %lld, later "
+ "alternate: %lld", test->cgt_name, hrt0, hrt1);
+ ret = B_FALSE;
+ }
+
+ if (convts1 > hrt2) {
+ warnx("clock %s traveled backwards, clock_gettime ahead of "
+ "later alternate: clock_gettime %lld, alternate: %lld",
+ test->cgt_name, convts1, hrt2);
+ ret = B_FALSE;
+ }
+
+ if (hrt1 > hrt2) {
+ warnx("clock %s traveled backwards, alternate ahead of "
+ "later alternate: first alternate %lld, later "
+ "alternate: %lld", test->cgt_name, hrt1, hrt2);
+ ret = B_FALSE;
+ }
+
+ if (convts0 > convts1) {
+ warnx("clock %s traveled backwards, clock_gettime ahead of "
+ "later clock_gettime: first clock_gettime %lld, later "
+ "clock_gettime: %lld", test->cgt_name, convts0, convts1);
+ ret = B_FALSE;
+ }
+
+ return (ret);
+}
+
+static void *
+clock_test_thr(void *arg)
+{
+ boolean_t ret = B_TRUE;
+
+ for (uint_t i = 0; i < ARRAY_SIZE(clock_tests); i++) {
+ boolean_t rval = clock_test(&clock_tests[i]);
+ if (!rval) {
+ ret = B_FALSE;
+ }
+
+ (void) printf("TEST %s: basic %s usage and interleaving%s\n",
+ rval ? "PASSED" : "FAILED", clock_tests[i].cgt_name,
+ thr_self() == 1 ? "" : " (in thread)");
+ }
+
+ return ((void *)(uintptr_t)ret);
+}
+
+static void *
+clock_test_cputime_thr(void *arg)
+{
+ struct timespec ts;
+ clock_gettime_thr_arg_t *cp = arg;
+
+ if (clock_gettime(CLOCK_VIRTUAL, &ts) != 0) {
+ warn("failed to get clock CLOCK_VIRTUAL");
+ cp->cgta_usr = 0;
+ } else {
+ cp->cgta_usr = clock_ts2hrt(&ts);
+ }
+
+ if (clock_gettime(CLOCK_VIRTUAL, &ts) != 0) {
+ warn("failed to get clock CLOCK_VIRTUAL");
+ cp->cgta_usrsys = 0;
+ } else {
+ cp->cgta_usrsys = clock_ts2hrt(&ts);
+ }
+
+ return (NULL);
+}
+
+/*
+ * Compare the value of CLOCK_THREAD_CPUTIME_ID between a new thread and the
+ * main thread.
+ */
+static boolean_t
+clock_test_thread_clock(void)
+{
+ thread_t thr;
+ clock_gettime_thr_arg_t arg;
+ hrtime_t hrt;
+ struct timespec ts;
+ boolean_t ret = B_TRUE;
+
+ if (thr_create(NULL, 0, clock_test_cputime_thr, &arg, 0, &thr) != 0) {
+ errx(EXIT_FAILURE, "failed to create thread to run basic "
+ "tests!");
+ }
+
+ if (thr_join(thr, NULL, NULL) != 0) {
+ errx(EXIT_FAILURE, "failed to join to thread that ran basic "
+ "tests");
+ }
+
+ if (clock_gettime(CLOCK_VIRTUAL, &ts) != 0) {
+ warn("failed to get clock CLOCK_VIRTUAL");
+ return (B_FALSE);
+ }
+
+ hrt = clock_ts2hrt(&ts);
+ if (arg.cgta_usr > hrt) {
+ warnx("new thread %u somehow had higher CLOCK_VIRTUAL time "
+ "than main thread: new thread: %lld, main thread: %lld",
+ thr, hrt, arg.cgta_usr);
+ ret = B_FALSE;
+ }
+
+ if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts) != 0) {
+ warn("failed to get clock CLOCK_THREAD_CPUTIME_ID");
+ return (B_FALSE);
+ }
+
+ hrt = clock_ts2hrt(&ts);
+ if (arg.cgta_usr > hrt) {
+ warnx("new thread %u somehow had higher "
+ "CLOCK_THREAD_CPUTIME_ID time than main thread: new "
+ "thread: %lld, main thread: %lld", thr, hrt, arg.cgta_usr);
+ ret = B_FALSE;
+ }
+
+ return (ret);
+}
+
+/*
+ * This test is a little circumspect. It's basically going to argue that all the
+ * time we spent doing kernel actions should be larger than the additional bit
+ * of user time to make a subsequent system call. That seems probably
+ * reasonable given everything we've done; however, there's no way to feel like
+ * it's not possibly going to lead to false positives. If so, then just delete
+ * this.
+ */
+static boolean_t
+clock_test_thread_sys(void)
+{
+ struct timespec usr, sys;
+ hrtime_t hrtusr, hrtsys;
+
+ if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &sys) != 0) {
+ warn("failed to get clock CLOCK_THREAD_CPUTIME_ID");
+ return (B_FALSE);
+ }
+
+ if (clock_gettime(CLOCK_VIRTUAL, &usr) != 0) {
+ warn("failed to get clock CLOCK_VIRTUAL");
+ return (B_FALSE);
+ }
+
+ hrtusr = clock_ts2hrt(&usr);
+ hrtsys = clock_ts2hrt(&sys);
+
+ if (hrtusr > hrtsys) {
+ warnx("CLOCK_VIRTUAL was greater than CLOCK_THREAD_CPUTIME_ID: "
+ "usr time: %lld, usr/sys time: %lld (this may be a race)",
+ hrtusr, hrtsys);
+ return (B_FALSE);
+ }
+
+ return (B_TRUE);
+}
+
+/*
+ * This is similar to clock_test_thread_sys(), but using the process clock and
+ * the thread clock. This is circumspect for similar reasons.
+ */
+static boolean_t
+clock_test_thread_proc(void)
+{
+ struct timespec thr, proc;
+ hrtime_t hrtthr, hrtproc;
+
+ if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &proc) != 0) {
+ warn("failed to get clock CLOCK_VIRTUAL");
+ return (B_FALSE);
+ }
+
+ if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &thr) != 0) {
+ warn("failed to get clock CLOCK_THREAD_CPUTIME_ID");
+ return (B_FALSE);
+ }
+
+ hrtthr = clock_ts2hrt(&thr);
+ hrtproc = clock_ts2hrt(&proc);
+
+ if (hrtthr > hrtproc) {
+ warnx("CLOCK_THRAD_CPUTIME_ID was greater than "
+ "CLOCK_PROCESS_CPUTIME_ID: thr time: %lld, proc time: %lld "
+ "(this may be a race)", hrtthr, hrtproc);
+ return (B_FALSE);
+ }
+
+ return (B_TRUE);
+}
+
+int
+main(void)
+{
+ int ret = EXIT_SUCCESS;
+ void *thr_ret;
+ thread_t thr;
+ boolean_t bval;
+
+ thr_ret = clock_test_thr(NULL);
+ if (!(boolean_t)(uintptr_t)thr_ret) {
+ ret = EXIT_FAILURE;
+ }
+
+ if (thr_create(NULL, 0, clock_test_thr, NULL, 0, &thr) != 0) {
+ errx(EXIT_FAILURE, "failed to create thread to run basic "
+ "tests!");
+ }
+
+ if (thr_join(thr, NULL, &thr_ret) != 0) {
+ errx(EXIT_FAILURE, "failed to join to thread that ran basic "
+ "tests");
+ }
+
+ if (!(boolean_t)(uintptr_t)thr_ret) {
+ ret = EXIT_FAILURE;
+ }
+
+ bval = clock_test_thread_clock();
+ (void) printf("TEST %s: comparing CLOCK_THREAD_CPUTIME_ID and "
+ "CLOCK_VIRTUAL between threads\n", bval ? "PASSED" : "FAILED");
+
+ bval = clock_test_thread_sys();
+ (void) printf("TEST %s: comparing CLOCK_THREAD_CPUTIME_ID and "
+ "CLOCK_VIRTUAL\n", bval ? "PASSED" : "FAILED");
+
+
+ bval = clock_test_thread_proc();
+ (void) printf("TEST %s: comparing CLOCK_THREAD_CPUTIME_ID and "
+ "CLOCK_PROCESS_CPUTIME_ID\n", bval ? "PASSED" : "FAILED");
+ /*
+ * XXX CLOCK_THREAD_CPUTIME_ID > CLOCK_VIRTUAL for same thread?
+ * XXX CLOCK_PROCESS_CPUTIME_ID > CLOCK_THREAD_CPUTIME_ID
+ */
+
+ return (ret);
+}
diff --git a/usr/src/test/test-runner/cmd/run b/usr/src/test/test-runner/cmd/run
index db3f33a1a8..bc2dc07e8e 100644
--- a/usr/src/test/test-runner/cmd/run
+++ b/usr/src/test/test-runner/cmd/run
@@ -902,7 +902,7 @@ def find_tests(testrun, options):
def filter_tests(testrun, options):
try:
- fh = open(options.logfile, "r")
+ fh = open(options.logfile, "r", errors='replace')
except Exception as e:
fail('%s' % e)
diff --git a/usr/src/uts/common/Makefile.files b/usr/src/uts/common/Makefile.files
index cdada98c0b..c0d1b69f57 100644
--- a/usr/src/uts/common/Makefile.files
+++ b/usr/src/uts/common/Makefile.files
@@ -130,7 +130,9 @@ GENUNIX_OBJS += \
class.o \
clock.o \
clock_highres.o \
+ clock_process.o \
clock_realtime.o\
+ clock_thread.o \
close.o \
compress.o \
condvar.o \
diff --git a/usr/src/uts/common/conf/param.c b/usr/src/uts/common/conf/param.c
index 68e39909c7..4660a280e8 100644
--- a/usr/src/uts/common/conf/param.c
+++ b/usr/src/uts/common/conf/param.c
@@ -219,6 +219,8 @@ extern void deadman_init(void);
extern void clock_timer_init(void);
extern void clock_realtime_init(void);
extern void clock_highres_init(void);
+extern void clock_thread_init(void);
+extern void clock_process_init(void);
extern void clock_tick_mp_init(void);
extern void cu_init(void);
extern void callout_mp_init(void);
@@ -247,7 +249,9 @@ void (*init_tbl[])(void) = {
clock_timer_init,
clock_realtime_init,
clock_highres_init,
- 0
+ clock_thread_init,
+ clock_process_init,
+ NULL
};
diff --git a/usr/src/uts/common/os/clock_process.c b/usr/src/uts/common/os/clock_process.c
new file mode 100644
index 0000000000..555cfd01d9
--- /dev/null
+++ b/usr/src/uts/common/os/clock_process.c
@@ -0,0 +1,130 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2021 Oxide Computer Company
+ */
+
+/*
+ * This clock backend implements basic support for the CLOCK_PROCESS_CPUTIME_ID
+ * clock. This clock is weakly defined by POSIX as "The identifier of the
+ * CPU-time clock associated with the process making a clock() or timer*()
+ * function call". We interpret that as including LMS_USER, LMS_SYSTEM, and
+ * LMS_TRAP microstates. This is similar to what we do in proc(4) for the
+ * lwpstatus_t and the prstatus_t.
+ *
+ * At this time, we only provide the ability to read the current time (e.g.
+ * through a call to clock_gettime(3C)). There is never a case where being able
+ * to set the time makes sense today and even if so, the privileges required for
+ * that are circumspect. Today, we do not support the ability to create interval
+ * timers based on this backend (e.g. timer_create(3C) and timer_settime(3C)).
+ * However, there is no reason that couldn't be added.
+ *
+ * To implement this, we leverage the existing microstate aggregation time that
+ * is done in /proc.
+ */
+
+#include <sys/timer.h>
+#include <sys/cyclic.h>
+#include <sys/msacct.h>
+
+static clock_backend_t clock_process;
+
+static int
+clock_process_settime(timespec_t *ts)
+{
+ return (EINVAL);
+}
+
+static int
+clock_process_gettime(timespec_t *ts)
+{
+ hrtime_t hrt;
+ proc_t *p = curproc;
+
+ /*
+ * mstate_aggr_state() automatically includes LMS_TRAP when we ask for
+ * LMS_SYSTEM below.
+ */
+ mutex_enter(&p->p_lock);
+ hrt = mstate_aggr_state(p, LMS_USER);
+ hrt += mstate_aggr_state(p, LMS_SYSTEM);
+ mutex_exit(&p->p_lock);
+
+ hrt2ts(hrt, ts);
+
+ return (0);
+}
+
+/*
+ * See the discussion in clock_thread_getres() for the why of using
+ * cyclic_getres() here.
+ */
+static int
+clock_process_getres(timespec_t *ts)
+{
+ hrt2ts(cyclic_getres(), (timestruc_t *)ts);
+
+ return (0);
+}
+
+static int
+clock_process_timer_create(itimer_t *it, void (*fire)(itimer_t *))
+{
+ return (EINVAL);
+}
+
+static int
+clock_process_timer_settime(itimer_t *it, int flags,
+ const struct itimerspec *when)
+{
+ return (EINVAL);
+}
+
+static int
+clock_process_timer_gettime(itimer_t *it, struct itimerspec *when)
+{
+ return (EINVAL);
+}
+
+static int
+clock_process_timer_delete(itimer_t *it)
+{
+ return (EINVAL);
+}
+
+static void
+clock_process_timer_lwpbind(itimer_t *it)
+{
+}
+
+void
+clock_process_init(void)
+{
+ /*
+ * While this clock backend doesn't support notifications right now, we
+ * still fill out the default for what it would be.
+ */
+ clock_process.clk_default.sigev_signo = SIGALRM;
+ clock_process.clk_default.sigev_notify = SIGEV_SIGNAL;
+ clock_process.clk_default.sigev_value.sival_ptr = NULL;
+
+ clock_process.clk_clock_settime = clock_process_settime;
+ clock_process.clk_clock_gettime = clock_process_gettime;
+ clock_process.clk_clock_getres = clock_process_getres;
+ clock_process.clk_timer_create = clock_process_timer_create;
+ clock_process.clk_timer_settime = clock_process_timer_settime;
+ clock_process.clk_timer_gettime = clock_process_timer_gettime;
+ clock_process.clk_timer_delete = clock_process_timer_delete;
+ clock_process.clk_timer_lwpbind = clock_process_timer_lwpbind;
+
+ clock_add_backend(CLOCK_PROCESS_CPUTIME_ID, &clock_process);
+}
diff --git a/usr/src/uts/common/os/clock_thread.c b/usr/src/uts/common/os/clock_thread.c
new file mode 100644
index 0000000000..96dd36fa08
--- /dev/null
+++ b/usr/src/uts/common/os/clock_thread.c
@@ -0,0 +1,191 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2021 Oxide Computer Company
+ */
+
+/*
+ * This clock backend implements basic support for the following two clocks:
+ *
+ * o CLOCK_VIRTUAL This provides the ability to read the amount of
+ * user CPU time that the calling thread has spent
+ * on CPU. This is the LMS_USER cpu microstate.
+ *
+ * o CLOCK_THREAD_CPUTIME_ID This clock is similar to the above; however, it
+ * also includes system time. This is the LMS_USER,
+ * LMS_SYSTEM, and LMS_TRAP microstates combined
+ * together. We include LMS_TRAP here because that
+ * is what you see in a thread's lwpstatus file.
+ *
+ * At this time, we only provide the ability to read the current time (e.g.
+ * through a call to clock_gettime(3C)). There is never a case where being able
+ * to set the time makes sense today and truthfully, lying about a process's
+ * runtime should be left to mdb -kw. Today, we do not support the ability to
+ * create interval timers based on this backend (e.g. timer_create(3C) and
+ * timer_settime(3C)). However, there is no reason that couldn't be added.
+ *
+ * A nice simplification here is that this clock is always about reading from
+ * the current thread. This means that one can always access it. Because the
+ * calling thread exists and is in this code, it means that we know it is here.
+ * Any other privilege information is left to the broader kernel.
+ *
+ * Because the only difference between these is the question of whether or not
+ * we include LMS_SYSTEM time in the value, we generally use the same actual
+ * clock backend functions except for the one that implements
+ * clk_clock_gettime().
+ */
+
+#include <sys/timer.h>
+#include <sys/cyclic.h>
+#include <sys/msacct.h>
+
+static clock_backend_t clock_thread_usr;
+static clock_backend_t clock_thread_usrsys;
+
+static int
+clock_thread_settime(timespec_t *ts)
+{
+ return (EINVAL);
+}
+
+static int
+clock_thread_usr_gettime(timespec_t *ts)
+{
+ hrtime_t hrt;
+ kthread_t *t = curthread;
+ klwp_t *lwp = ttolwp(t);
+
+ hrt = lwp->lwp_mstate.ms_acct[LMS_USER];
+ scalehrtime(&hrt);
+ hrt2ts(hrt, ts);
+
+ return (0);
+}
+
+static int
+clock_thread_usrsys_gettime(timespec_t *ts)
+{
+ hrtime_t hrt;
+ kthread_t *t = curthread;
+
+ /*
+ * mstate_thread_onproc_time() takes care of doing the following:
+ *
+ * o Combining LMS_USER, LMS_SYSTEM, and LMS_TRAP.
+ * o Ensuring that the result is scaled
+ * o Ensuring that the time that's elapsed to the point of our asking
+ * is included. By definition the kernel is executing in LMS_SYSTEM
+ * so this ensures that we add that time which isn't currently in the
+ * microstate to this.
+ */
+ thread_lock(t);
+ hrt = mstate_thread_onproc_time(t);
+ thread_unlock(t);
+
+ hrt2ts(hrt, ts);
+ return (0);
+}
+
+/*
+ * The question of the resolution here is a thorny one. Technically this would
+ * really be based upon the resolution of gethrtime_unscaled(), as we can
+ * actually tell that much due to our use of CPU microstate accounting. However,
+ * from a timer resolution perspective it's actually quite different and would
+ * in theory be based on the system tick rate.
+ *
+ * This basically leaves us with two options:
+ *
+ * 1) Use 'nsec_per_tick' to go down the Hz path.
+ * 2) Use the cyclic resolution, which basically is kind of the resolution of
+ * that timer.
+ *
+ * POSIX is unclear as to the effect of the resolution in the case of timer_*()
+ * functions and only really says it is used to impact the implementation of
+ * clock_settime() which of course isn't actually supported here. As a result,
+ * we opt to prefer the cyclic resolution, which is closer to the actual
+ * resolution of this subsystem. Strictly speaking, this might not be completely
+ * accurate, but should be on current platforms.
+ */
+static int
+clock_thread_getres(timespec_t *ts)
+{
+ hrt2ts(cyclic_getres(), (timestruc_t *)ts);
+
+ return (0);
+}
+
+static int
+clock_thread_timer_create(itimer_t *it, void (*fire)(itimer_t *))
+{
+ return (EINVAL);
+}
+
+static int
+clock_thread_timer_settime(itimer_t *it, int flags,
+ const struct itimerspec *when)
+{
+ return (EINVAL);
+}
+
+static int
+clock_thread_timer_gettime(itimer_t *it, struct itimerspec *when)
+{
+ return (EINVAL);
+}
+
+static int
+clock_thread_timer_delete(itimer_t *it)
+{
+ return (EINVAL);
+}
+
+static void
+clock_thread_timer_lwpbind(itimer_t *it)
+{
+}
+
+void
+clock_thread_init(void)
+{
+ /*
+ * While this clock backends don't support notifications right now, we
+ * still fill out the default for what it would be.
+ */
+ clock_thread_usr.clk_default.sigev_signo = SIGALRM;
+ clock_thread_usr.clk_default.sigev_notify = SIGEV_SIGNAL;
+ clock_thread_usr.clk_default.sigev_value.sival_ptr = NULL;
+
+ clock_thread_usr.clk_clock_settime = clock_thread_settime;
+ clock_thread_usr.clk_clock_gettime = clock_thread_usr_gettime;
+ clock_thread_usr.clk_clock_getres = clock_thread_getres;
+ clock_thread_usr.clk_timer_create = clock_thread_timer_create;
+ clock_thread_usr.clk_timer_settime = clock_thread_timer_settime;
+ clock_thread_usr.clk_timer_gettime = clock_thread_timer_gettime;
+ clock_thread_usr.clk_timer_delete = clock_thread_timer_delete;
+ clock_thread_usr.clk_timer_lwpbind = clock_thread_timer_lwpbind;
+
+ clock_thread_usrsys.clk_default.sigev_signo = SIGALRM;
+ clock_thread_usrsys.clk_default.sigev_notify = SIGEV_SIGNAL;
+ clock_thread_usrsys.clk_default.sigev_value.sival_ptr = NULL;
+
+ clock_thread_usrsys.clk_clock_settime = clock_thread_settime;
+ clock_thread_usrsys.clk_clock_gettime = clock_thread_usrsys_gettime;
+ clock_thread_usrsys.clk_clock_getres = clock_thread_getres;
+ clock_thread_usrsys.clk_timer_create = clock_thread_timer_create;
+ clock_thread_usrsys.clk_timer_settime = clock_thread_timer_settime;
+ clock_thread_usrsys.clk_timer_gettime = clock_thread_timer_gettime;
+ clock_thread_usrsys.clk_timer_delete = clock_thread_timer_delete;
+ clock_thread_usrsys.clk_timer_lwpbind = clock_thread_timer_lwpbind;
+
+ clock_add_backend(CLOCK_VIRTUAL, &clock_thread_usr);
+ clock_add_backend(CLOCK_THREAD_CPUTIME_ID, &clock_thread_usrsys);
+}