summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Levon <john.levon@joyent.com>2019-08-30 03:00:46 -0700
committerJohn Levon <john.levon@joyent.com>2019-09-12 04:36:23 -0700
commit8eb8717cc9dc99bdd784b74c994bea7ef5e60f92 (patch)
tree0d9edcbb68752a3a5bf2434ec96029e9b33e99c7
parent169b638e2b6e15b2589c3769e4a0d96188adf56d (diff)
downloadillumos-joyent-8eb8717cc9dc99bdd784b74c994bea7ef5e60f92.tar.gz
11626 introduce /etc/versions/build
11627 clean up UUID code for ::status Reviewed by: Peter Tribble <peter.tribble@gmail.com> Reviewed by: Andy Fiddaman <andy@omniosce.org> Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r--usr/src/cmd/boot/filelist/i386/filelist.ramdisk1
-rw-r--r--usr/src/cmd/mdb/common/kmdb/kmdb_kvm.c21
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_ks.h6
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_kvm.c22
-rw-r--r--usr/src/cmd/mdb/common/modules/mdb_ks/mdb_ks.c24
-rw-r--r--usr/src/cmd/nsadmin/Makefile17
-rw-r--r--usr/src/pkg/manifests/SUNWcs.mf3
-rw-r--r--usr/src/tools/env/illumos.sh3
-rw-r--r--usr/src/uts/common/os/modsysfile.c20
9 files changed, 95 insertions, 22 deletions
diff --git a/usr/src/cmd/boot/filelist/i386/filelist.ramdisk b/usr/src/cmd/boot/filelist/i386/filelist.ramdisk
index 70059bb5f3..387411504e 100644
--- a/usr/src/cmd/boot/filelist/i386/filelist.ramdisk
+++ b/usr/src/cmd/boot/filelist/i386/filelist.ramdisk
@@ -18,6 +18,7 @@ etc/rtc_config
etc/system
etc/system.d
etc/hostid
+etc/versions
kernel
platform/i86hvm/kernel
platform/i86pc/kernel
diff --git a/usr/src/cmd/mdb/common/kmdb/kmdb_kvm.c b/usr/src/cmd/mdb/common/kmdb/kmdb_kvm.c
index 1b75f21911..eb814f09f4 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 2018 Joyent, Inc.
+ * Copyright 2019 Joyent, Inc.
*/
#include <kmdb/kmdb_kvm.h>
@@ -49,6 +49,7 @@
#include <sys/kobj.h>
#include <sys/kobj_impl.h>
#include <sys/bitmap.h>
+#include <sys/uuid.h>
#include <vm/as.h>
static const char KMT_RTLD_NAME[] = "krtld";
@@ -552,7 +553,7 @@ static int
kmt_status_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
struct utsname uts;
- char uuid[37];
+ char uuid[UUID_PRINTABLE_STRING_LENGTH];
kreg_t tt;
if (mdb_tgt_readsym(mdb.m_target, MDB_TGT_AS_VIRT, &uts, sizeof (uts),
@@ -568,16 +569,14 @@ 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);
- if (mdb_tgt_readsym(mdb.m_target, MDB_TGT_AS_VIRT, uuid, sizeof (uuid),
- "genunix", "dump_osimage_uuid") != sizeof (uuid)) {
- warn("failed to read 'dump_osimage_uuid' string from kernel\n");
- (void) strcpy(uuid, "(error)");
- } else if (*uuid == '\0') {
- (void) strcpy(uuid, "(not set)");
- } else if (uuid[36] != '\0') {
- (void) strcpy(uuid, "(invalid)");
+ mdb_print_buildversion();
+
+ if (mdb_readsym(uuid, sizeof (uuid),
+ "dump_osimage_uuid") == sizeof (uuid) &&
+ uuid[sizeof (uuid) - 1] == '\0') {
+ mdb_printf("image uuid: %s\n", uuid[0] != '\0' ?
+ uuid : "(not set)");
}
- mdb_printf("image uuid: %s\n", uuid);
mdb_printf("DTrace state: %s\n", (kmdb_kdi_dtrace_get_state() ==
KDI_DTSTATE_DTRACE_ACTIVE ? "active (debugger breakpoints cannot "
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_ks.h b/usr/src/cmd/mdb/common/mdb/mdb_ks.h
index 1fe64fbc55..0ac58d26f5 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb_ks.h
+++ b/usr/src/cmd/mdb/common/mdb/mdb_ks.h
@@ -23,6 +23,10 @@
* Use is subject to license terms.
*/
+/*
+ * Copyright 2019 Joyent, Inc.
+ */
+
#ifndef _MDB_KS_H
#define _MDB_KS_H
@@ -140,6 +144,8 @@ 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_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 0c2b6efbed..b12a9c63ed 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) 2013, Joyent, Inc. All rights reserved.
+ * Copyright 2019 Joyent, Inc.
*/
/*
@@ -51,6 +51,7 @@
#include <sys/panic.h>
#include <sys/dumphdr.h>
#include <sys/dumpadm.h>
+#include <sys/uuid.h>
#include <dlfcn.h>
#include <libctf.h>
@@ -68,6 +69,7 @@
#include <mdb/mdb_kvm.h>
#include <mdb/mdb_module.h>
#include <mdb/mdb_kb.h>
+#include <mdb/mdb_ks.h>
#include <mdb/mdb.h>
#define KT_RELOC_BUF(buf, obase, nbase) \
@@ -94,6 +96,8 @@ typedef struct kt_maparg {
static const char KT_MODULE[] = "mdb_ks";
static const char KT_CTFPARENT[] = "genunix";
+static void (*print_buildversion)(void);
+
static void
kt_load_module(kt_data_t *kt, mdb_tgt_t *t, kt_module_t *km)
{
@@ -485,6 +489,9 @@ 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_buildversion != NULL)
+ print_buildversion();
+
if (kt->k_dumphdr) {
dumphdr_t *dh = kt->k_dumphdr;
@@ -494,11 +501,13 @@ kt_status_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
kt->k_dump_print_content(dh, kt->k_dumpcontent);
} else {
- char uuid[37];
+ char uuid[UUID_PRINTABLE_STRING_LENGTH];
- if (mdb_readsym(uuid, 37, "dump_osimage_uuid") == 37 &&
- uuid[36] == '\0') {
- mdb_printf("image uuid: %s\n", uuid);
+ if (mdb_readsym(uuid, sizeof (uuid),
+ "dump_osimage_uuid") == sizeof (uuid) &&
+ uuid[sizeof (uuid) - 1] == '\0') {
+ mdb_printf("image uuid: %s\n", uuid[0] != '\0' ?
+ uuid : "(not set)");
}
}
@@ -582,6 +591,9 @@ kt_activate(mdb_tgt_t *t)
"some modules may not load\n");
}
+ 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");
if (sym != NULL)
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 d4b817295d..85f3839c96 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 2017 Joyent, Inc.
+ * Copyright 2019 Joyent, Inc.
*/
/*
@@ -1012,9 +1012,9 @@ find_mbind(const char *name, uintptr_t *hashtab)
int
mdb_name_to_major(const char *name, major_t *major)
{
- uintptr_t mbind;
- uintptr_t mb_hashtab[MOD_BIND_HASHSIZE];
- struct bind mbind_local;
+ uintptr_t mbind;
+ uintptr_t mb_hashtab[MOD_BIND_HASHSIZE];
+ struct bind mbind_local;
if (mdb_readsym(mb_hashtab, sizeof (mb_hashtab), "mb_hashtab") == -1) {
@@ -1810,3 +1810,19 @@ mdb_get_lbolt(void)
return ((ts/nsec) - lbi.lbi_debug_time);
}
+
+void
+mdb_print_buildversion(void)
+{
+ GElf_Sym sym;
+
+ if (mdb_lookup_by_name("buildversion", &sym) != 0)
+ return;
+
+ char *str = mdb_zalloc(4096, UM_SLEEP | UM_GC);
+
+ if (mdb_readstr(str, 4096, sym.st_value) < 1)
+ return;
+
+ mdb_printf("build version: %s\n", str);
+}
diff --git a/usr/src/cmd/nsadmin/Makefile b/usr/src/cmd/nsadmin/Makefile
index c87810e767..533351bd86 100644
--- a/usr/src/cmd/nsadmin/Makefile
+++ b/usr/src/cmd/nsadmin/Makefile
@@ -22,6 +22,8 @@
# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
+# Copyright 2019 Joyent, Inc.
+#
PROG= profile .login ksh.kshrc system
PROGSKEL= .profile .kshrc
@@ -32,6 +34,8 @@ include ../Makefile.cmd
ROOTROOT= $(ROOT)/root
ROOTETCSKEL= $(ROOTETC)/skel
ROOTETCSKELPROG= $(PROGSKEL:%=$(ROOTETCSKEL)/%)
+ROOTETCVERSIONS= $(ROOTETC)/versions
+ROOTETCVERSIONSPROG= $(ROOTETCVERSIONS)/build
ROOTROOTPROG= $(PROGROOT:%=$(ROOTROOT)/%)
FILEMODE= 0644
@@ -66,14 +70,23 @@ $(ROOTETCSKEL)/%: %
$(INS.file)
$(ROOTROOT) \
+$(ROOTETCVERSIONS) \
$(ROOTETCSKEL):
$(INS.dir)
-install: all $(ROOTETCSKEL) $(ROOTETCPROG) $(ROOTETCSKELPROG) $(ROOTROOTPROG)
+$(ROOTETCVERSIONSPROG): $(ROOTETCVERSIONS) FRC
+ if [[ -n "$$BUILDVERSION_EXEC" ]]; then \
+ $$BUILDVERSION_EXEC >$(ROOTETCVERSIONSPROG) ; \
+ else \
+ touch $(ROOTETCVERSIONSPROG) ; \
+ fi
+
+install: all $(ROOTETCSKEL) $(ROOTETCPROG) \
+ $(ROOTETCSKELPROG) $(ROOTROOTPROG) $(ROOTETCVERSIONSPROG)
clean:
clobber:
$(RM) $(CLOBBERFILES)
-lint:
+FRC:
diff --git a/usr/src/pkg/manifests/SUNWcs.mf b/usr/src/pkg/manifests/SUNWcs.mf
index a0204cdae6..f1e20d919f 100644
--- a/usr/src/pkg/manifests/SUNWcs.mf
+++ b/usr/src/pkg/manifests/SUNWcs.mf
@@ -26,6 +26,7 @@
# Copyright 2017 Nexenta Systems, Inc.
# Copyright 2017 Toomas Soome <tsoome@me.com>
# Copyright 2019 Peter Tribble.
+# Copyright 2019 Joyent, Inc.
# Copyright (c) 2011, 2015 by Delphix. All rights reserved.
#
@@ -94,6 +95,7 @@ dir path=etc/sysevent/config group=sys
dir path=etc/system.d group=sys
dir path=etc/tm group=sys
dir path=etc/user_attr.d group=sys
+dir path=etc/versions group=sys
dir path=export group=sys
dir path=home group=root mode=0555
dir path=lib
@@ -470,6 +472,7 @@ file path=etc/ttydefs group=sys preserve=true
file path=etc/ttysrch group=sys preserve=true
file path=etc/user_attr group=sys preserve=true timestamp=19700101T000000Z
file path=etc/user_attr.d/SUNWcs group=sys
+file path=etc/versions/build group=sys
file path=etc/vfstab group=sys preserve=true
file path=lib/inet/in.mpathd mode=0555
file path=lib/inet/ipmgmtd mode=0555
diff --git a/usr/src/tools/env/illumos.sh b/usr/src/tools/env/illumos.sh
index ca28e3f617..3753a0be3e 100644
--- a/usr/src/tools/env/illumos.sh
+++ b/usr/src/tools/env/illumos.sh
@@ -135,6 +135,9 @@ export ENABLE_SMB_PRINTING=
# nightly(1) for interactions between environment variables and this command.
#POST_NIGHTLY=
+# Populates /etc/versions/build on each nightly run
+export BUILDVERSION_EXEC="git describe --all --long --dirty"
+
# -----------------------------------------------------------------------------
# You are less likely to need to modify parameters below.
# -----------------------------------------------------------------------------
diff --git a/usr/src/uts/common/os/modsysfile.c b/usr/src/uts/common/os/modsysfile.c
index 3605104ae7..de5c106782 100644
--- a/usr/src/uts/common/os/modsysfile.c
+++ b/usr/src/uts/common/os/modsysfile.c
@@ -23,6 +23,7 @@
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright 2017 Nexenta Systems, Inc.
+ * Copyright 2019 Joyent, Inc.
*/
#include <sys/types.h>
@@ -67,6 +68,11 @@ static char dacffile[] = DACFFILE;
char *self_assembly = "/etc/system.d/.self-assembly";
char *systemfile = "/etc/system"; /* name of ascii system file */
+#define BUILDVERSION_LEN (4096)
+
+char *versionfile = "/etc/versions/build";
+char buildversion[BUILDVERSION_LEN];
+
static struct sysparam *sysparam_hd; /* head of parameters list */
static struct sysparam *sysparam_tl; /* tail of parameters list */
static vmem_t *mod_sysfile_arena; /* parser memory */
@@ -811,6 +817,8 @@ read_system_file(char *name)
void
mod_read_system_file(int ask)
{
+ struct _buf *file;
+
mod_sysfile_arena = vmem_create("mod_sysfile", NULL, 0, 8,
segkmem_alloc, segkmem_free, heap_arena, 0, VM_SLEEP);
@@ -838,6 +846,18 @@ mod_read_system_file(int ask)
if (ask == 0)
setparams();
+
+ /*
+ * A convenient place to read in our build version string.
+ */
+
+ if ((file = kobj_open_file(versionfile)) != (struct _buf *)-1) {
+ if (kobj_read_file(file, buildversion,
+ sizeof (buildversion) - 1, 0) == -1) {
+ cmn_err(CE_WARN, "failed to read %s\n", versionfile);
+ }
+ kobj_close_file(file);
+ }
}
/*