Print this page
11626 introduce /etc/versions/build
11627 clean up UUID code for ::status
@@ -21,10 +21,11 @@
/*
* 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>
#include <sys/inttypes.h>
#include <sys/param.h>
@@ -65,10 +66,15 @@
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 */
char obp_bootpath[BO_MAXOBJNAME]; /* bootpath from obp */
@@ -809,10 +815,12 @@
}
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);
if (ask)
mod_askparams();
@@ -836,10 +844,22 @@
(void) mod_sysctl(SYS_SET_KVAR, NULL);
param_check();
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);
+ }
}
/*
* Search for a specific module variable assignment in /etc/system. If
* successful, 1 is returned and the value is stored in '*value'.