Print this page
11626 introduce /etc/versions/build
11627 clean up UUID code for ::status

@@ -21,11 +21,11 @@
 /*
  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
- * Copyright (c) 2013, Joyent, Inc.  All rights reserved.
+ * Copyright 2019 Joyent, Inc.
  */
 
 /*
  * Libkvm Kernel Target
  *

@@ -49,10 +49,11 @@
 #include <sys/kobj_impl.h>
 #include <sys/utsname.h>
 #include <sys/panic.h>
 #include <sys/dumphdr.h>
 #include <sys/dumpadm.h>
+#include <sys/uuid.h>
 
 #include <dlfcn.h>
 #include <libctf.h>
 #include <string.h>
 #include <fcntl.h>

@@ -66,10 +67,11 @@
 #include <mdb/mdb_io_impl.h>
 #include <mdb/mdb_ctf.h>
 #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) \
         ((uintptr_t)(buf) - (uintptr_t)(obase) + (uintptr_t)(nbase))
 

@@ -92,10 +94,12 @@
 } kt_maparg_t;
 
 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)
 {
         km->km_data = mdb_alloc(km->km_datasz, UM_SLEEP);
 

@@ -483,24 +487,29 @@
         }
 
         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;
 
                 mdb_printf("image uuid: %s\n", dh->dump_uuid[0] != '\0' ?
                     dh->dump_uuid : "(not set)");
                 mdb_printf("panic message: %s\n", dh->dump_panicstring);
 
                 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)");
                 }
         }
 
         return (DCMD_OK);
 }

@@ -580,10 +589,13 @@
                 if (mdb_module_load(KT_MODULE, MDB_MOD_GLOBAL) < 0) {
                         warn("failed to load kernel support module -- "
                             "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)
                                 kt->k_dump_print_content = (void (*)())sym;