summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Levon <john.levon@joyent.com>2019-08-20 20:44:44 +0000
committerJohn Levon <john.levon@joyent.com>2019-08-21 07:35:56 +0000
commitf0a2865453f053f6ff0041c6326877f1149d89ec (patch)
tree6ceb3fff46dd567be415a839ae9b74ee2c27b5f3
parent0678e39e27ea5dfce7fc85dcc38c837f3c8f6f6d (diff)
downloadillumos-joyent-f0a2865453f053f6ff0041c6326877f1149d89ec.tar.gz
OS-7922 buildstamp module should live in illumos-joyent
Reviewed by: Robert Mustacchi <rm@joyent.com> Approved by: Robert Mustacchi <rm@joyent.com>
-rw-r--r--manifest1
-rw-r--r--usr/src/Makefile1
-rw-r--r--usr/src/cmd/mdb/common/kmdb/kmdb_kvm.c4
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_ks.h4
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_kvm.c12
-rw-r--r--usr/src/cmd/mdb/common/modules/mdb_ks/mdb_ks.c13
-rw-r--r--usr/src/cmd/nsadmin/system6
-rw-r--r--usr/src/tools/scripts/nightly.sh13
-rw-r--r--usr/src/uts/common/os/buildversion.c112
-rw-r--r--usr/src/uts/intel/Makefile.intel2
-rw-r--r--usr/src/uts/intel/buildversion/Makefile50
-rw-r--r--usr/src/uts/intel/os/name_to_major2
-rw-r--r--usr/src/uts/sparc/Makefile.sparc2
-rw-r--r--usr/src/uts/sparc/buildversion/Makefile50
14 files changed, 252 insertions, 20 deletions
diff --git a/manifest b/manifest
index a7c085ff8e..7e8474a2f1 100644
--- a/manifest
+++ b/manifest
@@ -1064,6 +1064,7 @@ f kernel/misc/amd64/ac97 0755 root sys
f kernel/misc/amd64/acpica 0755 root sys
f kernel/misc/amd64/bignum 0755 root sys
f kernel/misc/amd64/bootdev 0755 root sys
+f kernel/misc/amd64/buildversion 0755 root sys
f kernel/misc/amd64/busra 0755 root sys
f kernel/misc/amd64/cc 0755 root sys
f kernel/misc/amd64/cmlb 0755 root sys
diff --git a/usr/src/Makefile b/usr/src/Makefile
index 566050738b..60aea931d8 100644
--- a/usr/src/Makefile
+++ b/usr/src/Makefile
@@ -140,6 +140,7 @@ clobber_local:
@cd tools; pwd; $(MAKE) clobber
@cd common/mapfiles; pwd; $(MAKE) clobber
@cd msg; pwd; $(MAKE) clobber
+ $(RM) buildversion
# If the tarballs are included inside ON_CLOSED_BINS, use those to extract and
# preserve the permissions (in case a distro ships them).
diff --git a/usr/src/cmd/mdb/common/kmdb/kmdb_kvm.c b/usr/src/cmd/mdb/common/kmdb/kmdb_kvm.c
index 787dc7cfd8..d14ce2fbed 100644
--- a/usr/src/cmd/mdb/common/kmdb/kmdb_kvm.c
+++ b/usr/src/cmd/mdb/common/kmdb/kmdb_kvm.c
@@ -22,7 +22,7 @@
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013 by Delphix. All rights reserved.
*
- * Copyright (c) 2019, Joyent, Inc.
+ * Copyright 2019 Joyent, Inc.
*/
#include <kmdb/kmdb_kvm.h>
@@ -571,7 +571,7 @@ kmt_status_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
mdb_printf("operating system: %s %s (%s)\n",
uts.release, uts.version, uts.machine);
- mdb_print_gitstatus();
+ mdb_print_buildversion();
if (mdb_readsym(uuid, sizeof (uuid),
"dump_osimage_uuid") == sizeof (uuid) &&
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_ks.h b/usr/src/cmd/mdb/common/mdb/mdb_ks.h
index 0717e2acce..0ac58d26f5 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb_ks.h
+++ b/usr/src/cmd/mdb/common/mdb/mdb_ks.h
@@ -24,7 +24,7 @@
*/
/*
- * Copyright (c) 2019, Joyent, Inc.
+ * Copyright 2019 Joyent, Inc.
*/
#ifndef _MDB_KS_H
@@ -144,7 +144,7 @@ extern const char *mdb_dlpi_prim(int);
/* Generic function for working with MAC (network layer 2) addresses. */
extern void mdb_mac_addr(const uint8_t *, size_t, char *, size_t);
-extern void mdb_print_gitstatus(void);
+extern void mdb_print_buildversion(void);
/*
* Target-specific interfaces
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_kvm.c b/usr/src/cmd/mdb/common/mdb/mdb_kvm.c
index 2646e49d6c..2a446d6fc9 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb_kvm.c
+++ b/usr/src/cmd/mdb/common/mdb/mdb_kvm.c
@@ -23,7 +23,7 @@
*/
/*
- * Copyright (c) 2019, Joyent, Inc.
+ * Copyright 2019 Joyent, Inc.
*/
/*
@@ -96,7 +96,7 @@ typedef struct kt_maparg {
static const char KT_MODULE[] = "mdb_ks";
static const char KT_CTFPARENT[] = "genunix";
-static void (*print_gitstatus)(void);
+static void (*print_buildversion)(void);
static void
kt_load_module(kt_data_t *kt, mdb_tgt_t *t, kt_module_t *km)
@@ -489,8 +489,8 @@ kt_status_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
mdb_printf("operating system: %s %s (%s)\n",
uts.release, uts.version, uts.machine);
- if (print_gitstatus != NULL)
- print_gitstatus();
+ if (print_buildversion != NULL)
+ print_buildversion();
if (kt->k_dumphdr) {
dumphdr_t *dh = kt->k_dumphdr;
@@ -591,8 +591,8 @@ kt_activate(mdb_tgt_t *t)
"some modules may not load\n");
}
- print_gitstatus = (void (*)(void))dlsym(RTLD_NEXT,
- "mdb_print_gitstatus");
+ print_buildversion = (void (*)(void))dlsym(RTLD_NEXT,
+ "mdb_print_buildversion");
if (mdb_prop_postmortem && kt->k_dumphdr != NULL) {
sym = dlsym(RTLD_NEXT, "mdb_dump_print_content");
diff --git a/usr/src/cmd/mdb/common/modules/mdb_ks/mdb_ks.c b/usr/src/cmd/mdb/common/modules/mdb_ks/mdb_ks.c
index cdbfd3d755..944d9b13b2 100644
--- a/usr/src/cmd/mdb/common/modules/mdb_ks/mdb_ks.c
+++ b/usr/src/cmd/mdb/common/modules/mdb_ks/mdb_ks.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2019, Joyent, Inc.
+ * Copyright 2019 Joyent, Inc.
*/
/*
@@ -1823,16 +1823,19 @@ mdb_get_lbolt(void)
* Dig out the branch and revision of the illumos-joyent repo, if we were
* provided with it. This is a rather fragile JSON parser, in that it requires
* JSON formatted exactly as per the boot_archive.gitstatus file that
- * "gitstatus_start" is built from.
+ * "buildversion_start" is built from.
*/
void
-mdb_print_gitstatus(void)
+mdb_print_buildversion(void)
{
boolean_t in_joyent = B_FALSE;
GElf_Sym sym;
- if (mdb_lookup_by_name("gitstatus_start", &sym) != 0)
- return;
+ if (mdb_lookup_by_name("buildversion_start", &sym) != 0) {
+ /* Older kernels used this name. */
+ if (mdb_lookup_by_name("gitstatus_start", &sym) != 0)
+ return;
+ }
char *str = mdb_zalloc(4096, UM_SLEEP | UM_GC);
diff --git a/usr/src/cmd/nsadmin/system b/usr/src/cmd/nsadmin/system
index 905594de8a..1143a7b7ec 100644
--- a/usr/src/cmd/nsadmin/system
+++ b/usr/src/cmd/nsadmin/system
@@ -171,8 +171,6 @@ set sd:sd_io_time=10
set hires_tick=1
*
-* The "buildstamp" module contains information about the git sources used to
-* build the operating system image. Once loaded, the driver will refuse to
-* detach. We load it early to ensure it is in a crash dump wherever possible.
+* See usr/src/uts/common/os/buildversion.c
*
-forceload: drv/buildstamp
+forceload: misc/buildversion
diff --git a/usr/src/tools/scripts/nightly.sh b/usr/src/tools/scripts/nightly.sh
index 8641236b6c..56fdab5d77 100644
--- a/usr/src/tools/scripts/nightly.sh
+++ b/usr/src/tools/scripts/nightly.sh
@@ -1543,6 +1543,19 @@ fi
[[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory."
[[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
+TMPFILE=/tmp/tmp.nightly.$$
+if [[ -n "${BUILDVERSION_EXEC}" ]]; then
+ ${BUILDVERSION_EXEC} >$TMPFILE || \
+ fatal_error "${BUILDVERSION_EXEC} failed"
+else
+ echo "version unset" >$TMPFILE
+fi
+
+if ! cmp $TMPFILE $SRC/buildversion >/dev/null 2>&1; then
+ mv $TMPFILE $SRC/buildversion
+fi
+rm -f $TMPFILE
+
if [[ "$t_FLAG" = "y" ]]; then
set_non_debug_build_flags
bootstrap_tools || fatal_error "Error: could not bootstrap tools"
diff --git a/usr/src/uts/common/os/buildversion.c b/usr/src/uts/common/os/buildversion.c
new file mode 100644
index 0000000000..d67cc87fc1
--- /dev/null
+++ b/usr/src/uts/common/os/buildversion.c
@@ -0,0 +1,112 @@
+/*
+ * 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 2019 Joyent, Inc.
+ */
+
+/*
+ * This kernel module carries the contents of the file $SRC/buildversion
+ * in such a way that it will be included in kernel crash dumps. It will be
+ * forceloaded at boot, will refuse to detach, and has no other moving parts.
+ *
+ * The git information can be read back with "mdb", either on the live system
+ * or from a crash dump; e.g.,
+ *
+ * # mdb -ke buildversion_start/s
+ *
+ * or with
+ *
+ * # mdb -ke ::status
+ */
+
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+#include <sys/modctl.h>
+
+int buildversion_no_detach = 1;
+
+static int
+buildversion_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
+{
+ switch (cmd) {
+ case DDI_ATTACH:
+ case DDI_RESUME:
+ return (DDI_SUCCESS);
+
+ default:
+ return (DDI_FAILURE);
+ }
+}
+
+static int
+buildversion_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
+{
+
+ switch (cmd) {
+ case DDI_DETACH:
+ if (buildversion_no_detach) {
+ return (DDI_FAILURE);
+ }
+ /* FALLTHRU */
+ case DDI_SUSPEND:
+ return (DDI_SUCCESS);
+
+ default:
+ return (DDI_FAILURE);
+ }
+}
+
+static struct dev_ops buildversion_dev_ops = {
+ .devo_rev = DEVO_REV,
+ .devo_refcnt = 0,
+ .devo_getinfo = nodev,
+ .devo_identify = nulldev,
+ .devo_probe = nulldev,
+
+ .devo_attach = buildversion_attach,
+ .devo_detach = buildversion_detach,
+
+ .devo_reset = nodev,
+ .devo_cb_ops = NULL,
+ .devo_bus_ops = NULL,
+ .devo_power = nodev,
+ .devo_quiesce = ddi_quiesce_not_needed,
+};
+
+static struct modldrv buildversion_md = {
+ .drv_modops = &mod_driverops,
+ .drv_linkinfo = "illumos buildversion",
+ .drv_dev_ops = &buildversion_dev_ops,
+};
+
+static struct modlinkage buildversion_ml = {
+ .ml_rev = MODREV_1,
+ .ml_linkage = { &buildversion_md, NULL }
+};
+
+int
+_init(void)
+{
+ return (mod_install(&buildversion_ml));
+}
+
+int
+_info(struct modinfo *mi)
+{
+ return (mod_info(&buildversion_ml, mi));
+}
+
+int
+_fini(void)
+{
+ return (mod_remove(&buildversion_ml));
+}
diff --git a/usr/src/uts/intel/Makefile.intel b/usr/src/uts/intel/Makefile.intel
index 32f5ff1bad..4d43a7d77a 100644
--- a/usr/src/uts/intel/Makefile.intel
+++ b/usr/src/uts/intel/Makefile.intel
@@ -697,6 +697,8 @@ MISC_KMODS += uathfw
MISC_KMODS += klmmod klmops
+MISC_KMODS += buildversion
+
#
# Software Cryptographic Providers (/kernel/crypto):
#
diff --git a/usr/src/uts/intel/buildversion/Makefile b/usr/src/uts/intel/buildversion/Makefile
new file mode 100644
index 0000000000..c4cf46c1a2
--- /dev/null
+++ b/usr/src/uts/intel/buildversion/Makefile
@@ -0,0 +1,50 @@
+#
+# 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 2019 Joyent, Inc.
+#
+
+UTSBASE = ../..
+
+MODULE = buildversion
+OBJECTS = $(OBJS_DIR)/$(MODULE).o $(OBJS_DIR)/bvstr.o
+BVSTR = $(OBJS_DIR)/buildversion
+ROOTMODULE = $(ROOT_MISC_DIR)/$(MODULE)
+
+include $(UTSBASE)/intel/Makefile.intel
+
+ALL_TARGET = $(BINARY)
+INSTALL_TARGET = $(ALL_TARGET) $(ROOTMODULE)
+
+CLEANFILES += $(BVSTR)
+
+.KEEP_STATE:
+
+def: $(DEF_DEPS)
+
+all: $(ALL_DEPS)
+
+clean: $(CLEAN_DEPS)
+
+clobber: $(CLOBBER_DEPS)
+
+install: $(INSTALL_DEPS)
+
+#
+# If nightly didn't generate this at all, we do so here
+$(SRC)/buildversion:
+ echo "version unset" >$(SRC)/buildversion
+
+$(OBJS_DIR)/bvstr.o: $(SRC)/buildversion
+ cp $(SRC)/buildversion $(BVSTR)
+ printf '\0' >>$(BVSTR)
+ elfwrap -64 -z target=x86 -o $@ $(BVSTR)
+
+include $(UTSBASE)/intel/Makefile.targ
diff --git a/usr/src/uts/intel/os/name_to_major b/usr/src/uts/intel/os/name_to_major
index e7fe60a8ab..6041728774 100644
--- a/usr/src/uts/intel/os/name_to_major
+++ b/usr/src/uts/intel/os/name_to_major
@@ -298,7 +298,7 @@ smrt 300
iwn 301
xhci 302
qede 303
-buildstamp 304
+buildversion 304
vmm 305
viona 306
ppt 307
diff --git a/usr/src/uts/sparc/Makefile.sparc b/usr/src/uts/sparc/Makefile.sparc
index e592b8a8ff..26494d418e 100644
--- a/usr/src/uts/sparc/Makefile.sparc
+++ b/usr/src/uts/sparc/Makefile.sparc
@@ -432,6 +432,8 @@ MISC_KMODS += mii
MISC_KMODS += klmmod klmops
+MISC_KMODS += buildversion
+
#
# Software Cryptographic Providers (/kernel/crypto):
#
diff --git a/usr/src/uts/sparc/buildversion/Makefile b/usr/src/uts/sparc/buildversion/Makefile
new file mode 100644
index 0000000000..794cf866b8
--- /dev/null
+++ b/usr/src/uts/sparc/buildversion/Makefile
@@ -0,0 +1,50 @@
+#
+# 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 2019 Joyent, Inc.
+#
+
+UTSBASE = ../..
+
+MODULE = buildversion
+OBJECTS = $(OBJS_DIR)/$(MODULE).o $(OBJS_DIR)/bvstr.o
+BVSTR = $(OBJS_DIR)/buildversion
+ROOTMODULE = $(ROOT_MISC_DIR)/$(MODULE)
+
+include $(UTSBASE)/sparc/Makefile.sparc
+
+ALL_TARGET = $(BINARY)
+INSTALL_TARGET = $(ALL_TARGET) $(ROOTMODULE)
+
+CLEANFILES += $(BVSTR)
+
+.KEEP_STATE:
+
+def: $(DEF_DEPS)
+
+all: $(ALL_DEPS)
+
+clean: $(CLEAN_DEPS)
+
+clobber: $(CLOBBER_DEPS)
+
+install: $(INSTALL_DEPS)
+
+#
+# If nightly didn't generate this at all, we do so here
+$(SRC)/buildversion:
+ echo "version unset" >$(SRC)/buildversion
+
+$(OBJS_DIR)/bvstr.o: $(SRC)/buildversion
+ cp $(SRC)/buildversion $(BVSTR)
+ printf '\0' >>$(BVSTR)
+ elfwrap -64 -z target=sparc -o $@ $(BVSTR)
+
+include $(UTSBASE)/sparc/Makefile.targ