aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2018-08-09 17:47:47 +0000
committerKyle Evans <kevans@FreeBSD.org>2018-08-09 17:47:47 +0000
commit2a4650cc117cdbda17c26257d5084c3083635308 (patch)
tree5ee3c4c3d7f14b097ef6c1142b2d97dedabb4df6 /sys
parent21aa6e834558d085efe22f754f7086a01d7ca1b9 (diff)
downloadsrc-2a4650cc117cdbda17c26257d5084c3083635308.tar.gz
src-2a4650cc117cdbda17c26257d5084c3083635308.zip
Notes
Diffstat (limited to 'sys')
-rw-r--r--sys/conf/NOTES10
-rw-r--r--sys/conf/options2
-rw-r--r--sys/kern/subr_prf.c18
-rw-r--r--sys/sys/msgbuf.h3
4 files changed, 29 insertions, 4 deletions
diff --git a/sys/conf/NOTES b/sys/conf/NOTES
index 4fc6ee1f2446..70d37eccd232 100644
--- a/sys/conf/NOTES
+++ b/sys/conf/NOTES
@@ -145,6 +145,16 @@ options INCLUDE_CONFIG_FILE # Include this file in kernel
options BOOTVERBOSE=1
options BOOTHOWTO=RB_MULTIPLE
+#
+# Compile-time defaults for dmesg boot tagging
+#
+# Default boot tag; may use 'kern.boot_tag' loader tunable to override. The
+# current boot's tag is also exposed via the 'kern.boot_tag' sysctl.
+options BOOT_TAG=\"---<<BOOT>>---\"
+# Maximum boot tag size the kernel's static buffer should accomodate. Maximum
+# size for both BOOT_TAG and the assocated tunable.
+options BOOT_TAG_SZ=32
+
options GEOM_BDE # Disk encryption.
options GEOM_BSD # BSD disklabels (obsolete, gone in 12)
options GEOM_CACHE # Disk cache.
diff --git a/sys/conf/options b/sys/conf/options
index f1b132cc7a43..c8177ccf8fba 100644
--- a/sys/conf/options
+++ b/sys/conf/options
@@ -811,6 +811,8 @@ TERMINAL_NORM_ATTR opt_teken.h
# options for printf
PRINTF_BUFR_SIZE opt_printf.h
+BOOT_TAG opt_printf.h
+BOOT_TAG_SZ opt_printf.h
# kbd options
KBD_DISABLE_KEYMAP_LOAD opt_kbd.h
diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c
index 666677c4453c..041d9dc332ff 100644
--- a/sys/kern/subr_prf.c
+++ b/sys/kern/subr_prf.c
@@ -124,6 +124,18 @@ static bool msgbufmapped; /* Set when safe to use msgbuf */
int msgbuftrigger;
struct msgbuf *msgbufp;
+#ifndef BOOT_TAG_SZ
+#define BOOT_TAG_SZ 32
+#endif
+#ifndef BOOT_TAG
+/* Tag used to mark the start of a boot in dmesg */
+#define BOOT_TAG "---<<BOOT>>---"
+#endif
+
+static char current_boot_tag[BOOT_TAG_SZ + 1] = BOOT_TAG;
+SYSCTL_STRING(_kern, OID_AUTO, boot_tag, CTLFLAG_RDTUN | CTLFLAG_NOFETCH,
+ current_boot_tag, 0, "Tag added to dmesg at start of boot");
+
static int log_console_output = 1;
SYSCTL_INT(_kern, OID_AUTO, log_console_output, CTLFLAG_RWTUN,
&log_console_output, 0, "Duplicate console output to the syslog");
@@ -1025,9 +1037,13 @@ msgbufinit(void *ptr, int size)
size -= sizeof(*msgbufp);
cp = (char *)ptr;
+ /* Attempt to fetch kern.boot_tag tunable on first mapping */
+ if (!msgbufmapped)
+ TUNABLE_STR_FETCH("kern.boot_tag", current_boot_tag,
+ BOOT_TAG_SZ + 1);
msgbufp = (struct msgbuf *)(cp + size);
msgbuf_reinit(msgbufp, cp, size);
- msgbuf_addstr(msgbufp, -1, BOOT_TAG, 0);
+ msgbuf_addstr(msgbufp, -1, current_boot_tag, 0);
if (msgbufmapped && oldp != msgbufp)
msgbuf_copy(oldp, msgbufp);
msgbufmapped = true;
diff --git a/sys/sys/msgbuf.h b/sys/sys/msgbuf.h
index 9585dabda149..df61f130e46f 100644
--- a/sys/sys/msgbuf.h
+++ b/sys/sys/msgbuf.h
@@ -60,9 +60,6 @@ struct msgbuf {
/* Subtract sequence numbers. Note that only positive values result. */
#define MSGBUF_SEQSUB(mbp, seq1, seq2) (MSGBUF_SEQNORM((mbp), (seq1) - (seq2)))
-/* Tag used to mark the start of a boot in dmesg */
-#define BOOT_TAG "---<<BOOT>>---"
-
#ifdef _KERNEL
extern int msgbufsize;
extern int msgbuftrigger;