mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-28 08:02:54 +00:00
BOOT_TAG: Make a config(5) option, expose as sysctl and loader tunable
BOOT_TAG lived shortly in sys/msgbuf.h, but this wasn't necessarily great for changing it or removing it. Move it into subr_prf.c and add options for it to opt_printf.h. One can specify both the BOOT_TAG and BOOT_TAG_SZ (really, size of the buffer that holds the BOOT_TAG). We expose it as kern.boot_tag and also add a loader tunable by the same name that we'll fetch upon initialization of the msgbuf. This allows for flexibility and also ensures that there's a consistent way to figure out the boot tag of the running kernel, rather than relying on headers to be in-sync. Prodded super-super-lightly by: imp
This commit is contained in:
parent
21aa6e8345
commit
2a4650cc11
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=337545
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user