History log of /freebsd-head/sys/kern/subr_prf.c
Revision Date Author Comments
165ba25434b2bb8b19301b4b2a10e65eaf2de2fa 12-Jan-2020 mjg <mjg@FreeBSD.org> Add KERNEL_PANICKED macro for use in place of direct panicstr tests
38fa0aaa51eff2a1630b8d8d8c762831a846b206 07-May-2019 cem <cem@FreeBSD.org> device_printf: Use sbuf for more coherent prints on SMP

device_printf does multiple calls to printf allowing other console messages to
be inserted between the device name, and the rest of the message. This change
uses sbuf to compose to two into a single buffer, and prints it all at once.

It exposes an sbuf drain function (drain-to-printf) for common use.

Update documentation to match; some unit tests included.

Submitted by: jmg
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D16690
515c6c397b0a13cecced72ebb4fc13ef696dc0c5 20-Oct-2018 cem <cem@FreeBSD.org> Replace ttyprintf with sbuf_printf and tty drain routine

Add string variants of cnputc and tty_putchar, and use them from the tty
sbuf drain routine.

Suggested by: ed@
Sponsored by: Dell EMC Isilon
ae3e1ed6d13ad2dbee6e9d35e68cd0de37d26681 17-Oct-2018 jamie <jamie@FreeBSD.org> Add a new jail permission, allow.read_msgbuf. When true, jailed processes
can see the dmesg buffer (this is the current behavior). When false (the
new default), dmesg will be unavailable to jailed users, whether root or
not.

The security.bsd.unprivileged_read_msgbuf sysctl still works as before,
controlling system-wide whether non-root users can see the buffer.

PR: 211580
Submitted by: bz
Approved by: re@ (kib@)
MFC after: 3 days
645507f98f49426e21192b220f427a0d29a2298a 17-Aug-2018 kevans <kevans@FreeBSD.org> subr_prf: Don't write kern.boot_tag if it's empty

This change allows one to set kern.boot_tag="" and not get a blank line
preceding other boot messages. While this isn't super critical- blank lines
are easy to filter out both mentally and in processing dmesg later- it
allows for a mode of operation that matches previous behavior.

I intend to MFC this whole series to stable/11 by the end of the month with
boot_tag empty by default to make this effectively a nop in the stable
branch.
d0635b16ccbfa48e80cd13ec1e2f674186c6ea26 10-Aug-2018 kevans <kevans@FreeBSD.org> subr_prf: remove think-o that had returned to local patch

Reported by: cognet
46cff726c193a4a9993340c0ab67497963c3c114 10-Aug-2018 kevans <kevans@FreeBSD.org> boot tagging: minor fixes

msgbufinit may be called multiple times as we initialize the msgbuf into a
progressively larger buffer. This doesn't happen as of now on head, but it
may happen in the future and we generally support this. As such, only print
the boot tag if we've just initialized the buffer for the first time.

The boot tag also now has a newline appended to it for better visibility,
and has been switched to a normal printf, by requesto f bde, after we've
denoted that the msgbuf is mapped.
135e1f225da6ad62e7994d78f2c16f9a7a6571dd 09-Aug-2018 kevans <kevans@FreeBSD.org> subr_prf: style(9) the sizeof

Reported by: jkim, ian
a4d7516115c460bf58d492e990ebccbb51477028 09-Aug-2018 kevans <kevans@FreeBSD.org> subr_prf: Use "sizeof current_boot_tag" instead
d2718a67f32aa06250e155b398482280db899b74 09-Aug-2018 kevans <kevans@FreeBSD.org> 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
3aecd7a21e673f8fbe588aaa50f90a2ce1d08656 09-Aug-2018 kevans <kevans@FreeBSD.org> msgbuf: Light detailing (const'ify and bool'itize)
47b7c5f8ae967e41a3d9667d03057174bccb4f34 09-Aug-2018 kevans <kevans@FreeBSD.org> kern: Add a BOOT_TAG marker at the beginning of boot dmesg

From the "newly licensed to drive" PR department, add a BOOT_TAG marker (by
default, --<<BOOT>>--, to the beginning of each boot's dmesg. This makes it
easier to do textproc magic to locate the start of each boot and, of
particular interest to some, the dmesg of the current boot.

The PR has a dmesg(8) component as well that I've opted not to include for
the moment- it was the more contentious part of this PR.

bde@ also made the statement that this boot tag should be written with an
ordinary printf, which I've- for the moment- declined to change about this
patch to keep it more transparent to observer of the boot process.

PR: 43434
Submitted by: dak <aurelien.nephtali@wanadoo.fr> (basically rewritten)
MFC after: maybe never
ee61c6704cceae8f7fb41cef1598a93171d5aff9 17-Jul-2018 markj <markj@FreeBSD.org> Add a FALLTHROUGH comment to kvprintf().

Submitted by: Sebastian Huber <sebastian.huber@embedded-brains.de>
MFC after: 3 days
350f65779559e2302ce71c05596154fb9fe44de7 19-May-2018 mmacy <mmacy@FreeBSD.org> fix uninitialized variable warning
55fe5887ffe7d5b8b88667d83aebb6e1e100058f 31-Dec-2017 cperciva <cperciva@FreeBSD.org> Use the TSLOG framework to record entry/exit timestamps for DELAY and
_vprintf; these functions are called in many places and can contribute
meaningfully to the total time spent booting.
d81660feebdf285121d1946decba91a190e590e0 07-Dec-2017 bde <bde@FreeBSD.org> Move instantiation of msgbufp from 9 MD files to subr_prf.c.

This variable should be pure MI except possibly for reading it in MD
dump routines. Its initialization was pure MD in 4.4BSD, but FreeBSD
changed this in r36441 in 1998. There were many imperfections in
r36441. This commit fixes only a small one, to simplify fixing the
others 1 arch at a time. (r47678 added support for
special/early/multiple message buffer initialization which I want in
a more general form, but this was too fragile to use because hacking
on the msgbufp global corrupted it, and was only used for 5 hours in
-current...)
4736ccfd9c3411d50371d7f21f9450a47c19047e 20-Nov-2017 pfg <pfg@FreeBSD.org> sys: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
fda9c1d9c438a9c32a879f101c87cc1f03c13d0e 12-Jul-2017 rlibby <rlibby@FreeBSD.org> kvprintf %b enhancements

Make the %b formatter accept number formatting flags. It will now accept
alternate form, precision, and length modifiers. It also now partially
supports field width (but forces left justification).

Reviewed by: markj
Approved by: markj (mentor)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D11284
3fa198df85a337eb8b27dc1b05de750eaaad3d79 13-Jun-2017 kib <kib@FreeBSD.org> Remove stray return.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week
dd0e3acdac73023cb72c7ba9e36cbb164a5899c2 28-Feb-2017 scottl <scottl@FreeBSD.org> Provide a comment on why stdio.h needs to be included.
0bc43962f11a18ea4aefd11b0ef406b566aa1807 28-Feb-2017 jkim <jkim@FreeBSD.org> Include stdio.h to fix libsbuf build.

Reviewed by: scottl
0a682607847b7b7a320c7e81a620b68634a692f7 28-Feb-2017 scottl <scottl@FreeBSD.org> Implement sbuf_prf(), which takes an sbuf and outputs it
to stdout in the non-kernel case and to the console+log
in the kernel case. For the kernel case it hooks the
putbuf() machinery underneath printf(9) so that the buffer
is written completely atomically and without a copy into
another temporary buffer. This is useful for fixing
compound console/log messages that become broken and
interleaved when multiple threads are competing for the
console.

Reviewed by: ken, imp
Sponsored by: Netflix
f7a7b1ef507b4df0097e151ce7ea6a2447b4828f 24-Oct-2016 marcel <marcel@FreeBSD.org> Include <stdarg.h> instead of <machine/stdarg.h> when compiled as
part of libsbuf. The former is the standard header, and allows us
to compile libsbuf on macOS/linux.
00b67b15b9ffa1019fe84745accba07152c64e44 15-Sep-2016 emaste <emaste@FreeBSD.org> Renumber license clauses in sys/kern to avoid skipping #3
b09e5777ab34d6c70f421ad7a7f27bc70175f4c1 28-Jul-2016 kib <kib@FreeBSD.org> MFC r303151:
Provide counter_warning(9) KPI.

MFC r303155:
Hide counted_warning(9) under #ifdef _KERNEL braces.
35a1ffc1d85f92bd8e671ca9c507d82ececba002 21-Jul-2016 kib <kib@FreeBSD.org> Hide counted_warning(9) under #ifdef _KERNEL braces, to allow building
subr_prf.c in userspace for libsbuf.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week
48a468731d645cee6fe1dd15232469d5d431673c 21-Jul-2016 kib <kib@FreeBSD.org> Provide counter_warning(9) KPI which allows to issue limited number of
warnings for some kernel events, mostly intended for the use of
obsoleted or otherwise undersired interfaces.

This is an abstracted and race-expelled code from compat pty driver.

Requested and reviewed by: jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D7270
5ebc37ce13cc781ebe2b412f696455def98d857b 09-Jun-2016 cem <cem@FreeBSD.org> kvprintf: Pad %*c to width, like %*s

Sponsored by: EMC / Isilon Storage Division
00d578928eca75be320b36d37543a7e2a4f9fbdb 27-May-2016 grehan <grehan@FreeBSD.org> Create branch for bhyve graphics import.
afc7726a4655204bd2beef48dfac832b21f3e466 19-Nov-2015 markj <markj@FreeBSD.org> Add vlog(9).

Reviewed by: cem, jhb
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D4183
65381bf93d359744f5273394ccc73cf9fe5b55d8 02-Oct-2015 vangyzen <vangyzen@FreeBSD.org> MFC r281785

Always send log(9) messages to the message buffer.

It is truer to the semantics of logging for messages to *always*
go to the message buffer, where they can eventually be collected
and, in fact, be put into a log file.

This restores the behavior prior to r70239, which seems to have
changed it inadvertently.

Submitted by: Eric Badger <eric@badgerio.us>
Obtained from: Dell Inc.
1d2632e58b4f9b2c6256c2da8cefdd3574d81cde 16-Jun-2015 ken <ken@FreeBSD.org> MFC, r284192:

------------------------------------------------------------------------
r284192 | ken | 2015-06-09 15:39:38 -0600 (Tue, 09 Jun 2015) | 102 lines

Add support for reading MAM attributes to camcontrol(8) and libcam(3).

MAM is Medium Auxiliary Memory and is most commonly found as flash
chips on tapes.

This includes support for reading attributes and decoding most
known attributes, but does not yet include support for writing
attributes or reporting attributes in XML format.

libsbuf/Makefile:
Add subr_prf.c for the new sbuf_hexdump() function. This
function is essentially the same function.

libsbuf/Symbol.map:
Add a new shared library minor version, and include the
sbuf_hexdump() function.

libsbuf/Version.def:
Add version 1.4 of the libsbuf library.

libutil/hexdump.3:
Document sbuf_hexdump() alongside hexdump(3), since it is
essentially the same function.

camcontrol/Makefile:
Add attrib.c.

camcontrol/attrib.c:
Implementation of READ ATTRIBUTE support for camcontrol(8).

camcontrol/camcontrol.8:
Document the new 'camcontrol attrib' subcommand.

camcontrol/camcontrol.c:
Add the new 'camcontrol attrib' subcommand.

camcontrol/camcontrol.h:
Add a function prototype for scsiattrib().

share/man/man9/sbuf.9:
Document the existence of sbuf_hexdump() and point users to
the hexdump(3) man page for more details.

sys/cam/scsi/scsi_all.c:
Add a table of known attributes, text descriptions and
handler functions.

Add a new scsi_attrib_sbuf() function along with a number
of other related functions that help decode attributes.

scsi_attrib_ascii_sbuf() decodes ASCII format attributes.

scsi_attrib_int_sbuf() decodes binary format attributes, and
will pass them off to scsi_attrib_hexdump_sbuf() if they're
bigger than 8 bytes.

scsi_attrib_vendser_sbuf() decodes the vendor and drive
serial number attribute.

scsi_attrib_volcoh_sbuf() decodes the Volume Coherency
Information attribute that LTFS writes out.

sys/cam/scsi/scsi_all.h:
Add a number of attribute-related structure definitions and
other defines.

Add function prototypes for all of the functions added in
scsi_all.c.

sys/kern/subr_prf.c:
Add a new function, sbuf_hexdump(). This is the same as
the existing hexdump(9) function, except that it puts the
result in an sbuf.

This also changes subr_prf.c so that it can be compiled in
userland for includsion in libsbuf.

We should work to change this so that the kernel hexdump
implementation is a wrapper around sbuf_hexdump() with a
statically allocated sbuf with a drain. That will require
a drain function that goes to the kernel printf() buffer
that can take a non-NUL terminated string as input.
That is because an sbuf isn't NUL-terminated until it is
finished, and we don't want to finish it while we're still
using it.

We should also work to consolidate the userland hexdump and
kernel hexdump implemenatations, which are currently
separate. This would also mean making applications that
currently link in libutil link in libsbuf.

sys/sys/sbuf.h:
Add the prototype for sbuf_hexdump(), and add another copy
of the hexdump flag values if they aren't already defined.

Ideally the flags should be defined in one place but the
implemenation makes it difficult to do properly. (See
above.)

Sponsored by: Spectra Logic Corporation

------------------------------------------------------------------------
aec88085886918edaec858c439ed4b18826ae87e 09-Jun-2015 ken <ken@FreeBSD.org> Add support for reading MAM attributes to camcontrol(8) and libcam(3).

MAM is Medium Auxiliary Memory and is most commonly found as flash
chips on tapes.

This includes support for reading attributes and decoding most
known attributes, but does not yet include support for writing
attributes or reporting attributes in XML format.

libsbuf/Makefile:
Add subr_prf.c for the new sbuf_hexdump() function. This
function is essentially the same function.

libsbuf/Symbol.map:
Add a new shared library minor version, and include the
sbuf_hexdump() function.

libsbuf/Version.def:
Add version 1.4 of the libsbuf library.

libutil/hexdump.3:
Document sbuf_hexdump() alongside hexdump(3), since it is
essentially the same function.

camcontrol/Makefile:
Add attrib.c.

camcontrol/attrib.c:
Implementation of READ ATTRIBUTE support for camcontrol(8).

camcontrol/camcontrol.8:
Document the new 'camcontrol attrib' subcommand.

camcontrol/camcontrol.c:
Add the new 'camcontrol attrib' subcommand.

camcontrol/camcontrol.h:
Add a function prototype for scsiattrib().

share/man/man9/sbuf.9:
Document the existence of sbuf_hexdump() and point users to
the hexdump(3) man page for more details.

sys/cam/scsi/scsi_all.c:
Add a table of known attributes, text descriptions and
handler functions.

Add a new scsi_attrib_sbuf() function along with a number
of other related functions that help decode attributes.

scsi_attrib_ascii_sbuf() decodes ASCII format attributes.

scsi_attrib_int_sbuf() decodes binary format attributes, and
will pass them off to scsi_attrib_hexdump_sbuf() if they're
bigger than 8 bytes.

scsi_attrib_vendser_sbuf() decodes the vendor and drive
serial number attribute.

scsi_attrib_volcoh_sbuf() decodes the Volume Coherency
Information attribute that LTFS writes out.

sys/cam/scsi/scsi_all.h:
Add a number of attribute-related structure definitions and
other defines.

Add function prototypes for all of the functions added in
scsi_all.c.

sys/kern/subr_prf.c:
Add a new function, sbuf_hexdump(). This is the same as
the existing hexdump(9) function, except that it puts the
result in an sbuf.

This also changes subr_prf.c so that it can be compiled in
userland for includsion in libsbuf.

We should work to change this so that the kernel hexdump
implementation is a wrapper around sbuf_hexdump() with a
statically allocated sbuf with a drain. That will require
a drain function that goes to the kernel printf() buffer
that can take a non-NUL terminated string as input.
That is because an sbuf isn't NUL-terminated until it is
finished, and we don't want to finish it while we're still
using it.

We should also work to consolidate the userland hexdump and
kernel hexdump implemenatations, which are currently
separate. This would also mean making applications that
currently link in libutil link in libsbuf.

sys/sys/sbuf.h:
Add the prototype for sbuf_hexdump(), and add another copy
of the hexdump flag values if they aren't already defined.

Ideally the flags should be defined in one place but the
implemenation makes it difficult to do properly. (See
above.)

Sponsored by: Spectra Logic Corporation
MFC after: 1 week
807ec5634253b1ad323addaa8913ac4a805c185e 20-Apr-2015 vangyzen <vangyzen@FreeBSD.org> Always send log(9) messages to the message buffer.

It is truer to the semantics of logging for messages to *always*
go to the message buffer, where they can eventually be collected
and, in fact, be put into a log file.

This restores the behavior prior to r70239, which seems to have
changed it inadvertently.

Submitted by: Eric Badger <eric@badgerio.us>
Reviewed by: jhb
Approved by: kib (mentor)
Obtained from: Dell Inc.
MFC after: 1 week
ce129cdb73b192f26ecd70960780dc0002899da5 15-Mar-2015 dim <dim@FreeBSD.org> Merge ^/head r279995 through r280029.
e497716fbdc70d18195c3f432c3b428b0c1dbcea 15-Mar-2015 ian <ian@FreeBSD.org> Add a nulterm byte to the returned sysctl string.

PR: 195668
d20a416d73ddf444f93a59ee260047f046a1884a 23-Jan-2015 danfe <danfe@FreeBSD.org> Fix usage example in kvprintf(9) and its copy in libstand(3): trailing '\n'
in bitfield argument is wrong, as it will be treated as bit 10, causing any
code printing >=10 bits with bit 10 on as having a trailing comma.

Newline (intended one) should be part of the format string (already present
in the examples).

Also fix grammar and kill EOL whitespace in comment while here.

PR: 195005
Approved by: bdrewery
35b126e324b8032aebea9ab6b4daf7c0bf8daed0 28-Jun-2014 hselasky <hselasky@FreeBSD.org> Pull in r267961 and r267973 again. Fix for issues reported will follow.
fc21f40567ac7485e9e987cf5a539bd0d11c7155 27-Jun-2014 gjb <gjb@FreeBSD.org> Revert r267961, r267973:

These changes prevent sysctl(8) from returning proper output,
such as:

1) no output from sysctl(8)
2) erroneously returning ENOMEM with tools like truss(1)
or uname(1)
truss: can not get etype: Cannot allocate memory
bd1ed65f0faa90d56aad3c8fc1b55d874d1548d9 27-Jun-2014 hselasky <hselasky@FreeBSD.org> Extend the meaning of the CTLFLAG_TUN flag to automatically check if
there is an environment variable which shall initialize the SYSCTL
during early boot. This works for all SYSCTL types both statically and
dynamically created ones, except for the SYSCTL NODE type and SYSCTLs
which belong to VNETs. A new flag, CTLFLAG_NOFETCH, has been added to
be used in the case a tunable sysctl has a custom initialisation
function allowing the sysctl to still be marked as a tunable. The
kernel SYSCTL API is mostly the same, with a few exceptions for some
special operations like iterating childrens of a static/extern SYSCTL
node. This operation should probably be made into a factored out
common macro, hence some device drivers use this. The reason for
changing the SYSCTL API was the need for a SYSCTL parent OID pointer
and not only the SYSCTL parent OID list pointer in order to quickly
generate the sysctl path. The motivation behind this patch is to avoid
parameter loading cludges inside the OFED driver subsystem. Instead of
adding special code to the OFED driver subsystem to post-load tunables
into dynamically created sysctls, we generalize this in the kernel.

Other changes:
- Corrected a possibly incorrect sysctl name from "hw.cbb.intr_mask"
to "hw.pcic.intr_mask".
- Removed redundant TUNABLE statements throughout the kernel.
- Some minor code rewrites in connection to removing not needed
TUNABLE statements.
- Added a missing SYSCTL_DECL().
- Wrapped two very long lines.
- Avoid malloc()/free() inside sysctl string handling, in case it is
called to initialize a sysctl from a tunable, hence malloc()/free() is
not ready when sysctls from the sysctl dataset are registered.
- Bumped FreeBSD version to indicate SYSCTL API change.

MFC after: 2 weeks
Sponsored by: Mellanox Technologies
4742b38bad2021d36f17b02ec7f94799806ac558 15-May-2014 ian <ian@FreeBSD.org> MFC r261786, r261789

Rework the EARLY_PRINTF mechanism. Instead of defining a special eprintf()
routine, now a platform can provide a pointer to an early_putc() routine
which is used instead of cn_putc(). Control can be handed off from early
printf support to standard console support by NULLing out the pointer
during standard console init.

Convert two while(1); statements into proper panics.
393ed120ae54ade20f39ff2e4182685fc0324b23 14-May-2014 ian <ian@FreeBSD.org> MFC r261038, r261039, r261040, r261041

Implement generic support for early printf.
c8a6d26c3cb398551768cd23ce6b3bea7011f3a2 14-May-2014 bdrewery <bdrewery@FreeBSD.org> MFC r264795:

Fix grammar error and trailing newline.
9c2b40ff1378081489e24d46dd19e674a2bb6de7 23-Apr-2014 bdrewery <bdrewery@FreeBSD.org> Fix grammar error and trailing newline.

Submitted by: danfe
MFC after: 3 days
e696b793ca74d2408093f408357dbd274417dffa 30-Mar-2014 bdrewery <bdrewery@FreeBSD.org> MFC r263129:

Combine similar code from vprintf(9) and log(9).
fd2362b1d8bff5560938631a27c38d5192d54450 14-Mar-2014 bdrewery <bdrewery@FreeBSD.org> Combine similar code from vprintf(9) and log(9).

MFC after: 2 weeks
eb1a5f8de9f7ea602c373a710f531abbf81141c4 21-Feb-2014 gjb <gjb@FreeBSD.org> Move ^/user/gjb/hacking/release-embedded up one directory, and remove
^/user/gjb/hacking since this is likely to be merged to head/ soon.

Sponsored by: The FreeBSD Foundation
4ca4e5e36919a8b45fe0de86bf7f016d9b250caa 12-Feb-2014 ian <ian@FreeBSD.org> Rework the EARLY_PRINTF mechanism. Instead of defining a special eprintf()
routine, now a platform can provide a pointer to an early_putc() routine
which is used instead of cn_putc(). Control can be handed off from early
printf support to standard console support by NULLing out the pointer
during standard console init.

This leverages all the existing error reporting that uses printf calls,
such as panic() which can now be usefully employed even in early
platform init code (useful at least to those who maintain that code and
build kernels with EARLY_PRINTF defined).

Reviewed by: imp, eadler
deb3c28dd0ba605218af648dde284e96f089d48f 22-Jan-2014 imp <imp@FreeBSD.org> Implement generic support for early printf. Thought I can't find the
paper trail now, this patch is similar to one posted for one of the
preliminary versions of a new armv6 port. I took them and made them
more generic. Option not enabled by default since each board/port has
to provide its own eputc, and possibly do other things as well...
6b01bbf146ab195243a8e7d43bb11f8835c76af8 27-Dec-2013 gjb <gjb@FreeBSD.org> Copy head@r259933 -> user/gjb/hacking/release-embedded for initial
inclusion of (at least) arm builds with the release.

Sponsored by: The FreeBSD Foundation
b3080da236407f37102bde7b1e2cd292b78aa8ab 13-Sep-2013 kib <kib@FreeBSD.org> Reduce the scope of the proctree_lock. If several processes cause
continuous calls to the uprintf(9), the proctree_lock could be
shared-locked for indefinite amount of time, starving exclusive
requests. Since proctree_lock is needed for fork() and exit(), this
effectively stops the machine.

While there, do the similar reduction for tprintf(9).

Reported and tested by: pho
Reviewed by: ed
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Approved by: re (glebius)
24e0bcea209256960f8d7476c2e6fb93569913c4 07-Sep-2013 np <np@FreeBSD.org> Add a vtprintf. It is to tprintf what vprintf is to printf.

Reviewed by: kib
494f14b9330151d98df404a05bd9f313ee56af30 16-Oct-2011 marcel <marcel@FreeBSD.org> Fix double vision syndrome (read: double output) when in the
debugger without a panic.
048adb69c7c57c1cc5c423e5118cbc3e1176c3e7 07-Jun-2011 ken <ken@FreeBSD.org> Set pca.p_bufr to NULL when we haven't allocated a buffer.

Otherwise, p_bufr is set to garbage on the stack, and if that garbage
happens to be non-NULL, and the TOLOG or TOCONS flag is set, putbuf()
will get called and attempt to fill the non-existent buffer.

This is really only relevant for tprintf() (and only when the priority is
not -1), but set it in uprintf() and ttyprintf() for completeness.

The next step, to avoid log buffer scrambling, would be to add the
PRINTF_BUFR_SIZE code to tprintf(), but this should prevent panics.

Submitted by: rmacklem
Found by: pho
bc4d32e80bd81ea96c4c2544ab36f7e8caa777b7 31-May-2011 attilio <attilio@FreeBSD.org> MFC
0febb6df5eb6907033b87d0f65654df70b739241 31-May-2011 ken <ken@FreeBSD.org> Fix apparent garbage in the message buffer.

While we have had a fix in place (options PRINTF_BUFR_SIZE=128) to fix
scrambled console output, the message buffer and syslog were still getting
log messages one character at a time. While all of the characters still
made it into the log (courtesy of atomic operations), they were often
interleaved when there were multiple threads writing to the buffer at the
same time.

This fixes message buffer accesses to use buffering logic as well, so that
strings that are less than PRINTF_BUFR_SIZE will be put into the message
buffer atomically. So now dmesg output should look the same as console
output.

subr_msgbuf.c: Convert most message buffer calls to use a new spin
lock instead of atomic variables in some places.

Add a new routine, msgbuf_addstr(), that adds a
NUL-terminated string to a message buffer. This
takes a priority argument, which allows us to
eliminate some races (at least in the the string
at a time case) that are present in the
implementation of msglogchar(). (dangling and
lastpri are static variables, and are subject to
races when multiple callers are present.)

msgbuf_addstr() also allows the caller to request
that carriage returns be stripped out of the
string. This matches the behavior of msglogchar(),
but in testing so far it doesn't appear that any
newlines are being stripped out. So the carriage
return removal functionality may be a candidate
for removal later on if further analysis shows
that it isn't necessary.

subr_prf.c: Add a new msglogstr() routine that calls
msgbuf_logstr().

Rename putcons() to putbuf(). This now handles
buffered output to the message log as well as
the console. Also, remove the logic in putcons()
(now putbuf()) that added a carriage return before
a newline. The console path was the only path that
needed it, and cnputc() (called by cnputs())
already adds a carriage return. So this
duplication resulted in kernel-generated console
output lines ending in '\r''\r''\n'.

Refactor putchar() to handle the new buffering
scheme.

Add buffering to log().

Change log_console() to use msglogstr() instead of
msglogchar(). Don't add extra newlines by default
in log_console(). Hide that behavior behind a
tunable/sysctl (kern.log_console_add_linefeed) for
those who would like the old behavior. The old
behavior led to the insertion of extra newlines
for log output for programs that print out a
string, and then a trailing newline on a separate
write. (This is visible with dmesg -a.)

msgbuf.h: Add a prototype for msgbuf_addstr().

Add three new fields to struct msgbuf, msg_needsnl,
msg_lastpri and msg_lock. The first two are needed
for log message functionality previously handled
by msglogchar(). (Which is still active if
buffering isn't enabled.)

Include sys/lock.h and sys/mutex.h for the new
mutex.

Reviewed by: gibbs
09f9c897d33c41618ada06fbbcf1a9b3812dee53 19-Oct-2010 jamie <jamie@FreeBSD.org> A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.
06b6c2769b308fbbd16afe28e00b4d8462fcfa7e 12-Jul-2010 jkim <jkim@FreeBSD.org> Use type-specific inline function imax() instead of deprecated macro MAX().

Prodded by: bde
93b88a93dabf70976640d9a81668eacdfa35891c 08-Jul-2010 jkim <jkim@FreeBSD.org> Implement optional 'precision' for numbers. Previously, it was parsed but
ignored. Some third-party modules (e.g., APCICA) prefer this format over
zero padding flag '0'.
f1216d1f0ade038907195fc114b7e630623b402c 19-Mar-2010 delphij <delphij@FreeBSD.org> Create a custom branch where I will be able to do the merge.
da18b1b80b0a91169134a3de012b7a7057a31ea2 03-Nov-2009 ed <ed@FreeBSD.org> Make /dev/klog and kern.msgbuf* MPSAFE.

Normally msgbufp is locked using Giant. Switch it to use the
msgbuf_lock. Instead of changing the tsleep() calls to msleep(), just
convert it to condvar(9).

In my opinion the locking around msgbuf_peekbytes() still remains
questionable. It looks like locks are dropped while performing copies of
multiple blocks to userspace, which may cause the msgbuf to be reset in
the mean time. At least getting it underneath from Giant should make it
a little easier for us to figure out how to solve that.

Reminded by: rdivacky
f02ef8e872244e98e3caa4724a632319c7f5132a 27-Feb-2009 ed <ed@FreeBSD.org> Remove redundant code in printf() and vprintf().

printf() and vprintf() are exactly the same, except the way arguments
are passed. Just like we see in other pieces of code (i.e. libc's
printf()), implement printf() using vprintf().

Submitted by: Christoph Mallon <christoph mallon gmx de>
2078a09b34868de14884530615367f198f95ab7e 27-Feb-2009 ed <ed@FreeBSD.org> Revert previous commit to subr_prf.c and make it more tidy.

As mentioned by bz and bde, the change I made wasn't the proper way to
fix. Inspired by bde's patch, perform some small cleanups to uprintf().

Reviewed by: bz
280ef3dd2367a2ffb0c778dfaad55377a0f712f4 26-Feb-2009 ed <ed@FreeBSD.org> Remove redundant assignment of `p'.

`p' is already initialized with `td->td_proc'. Because td is always
curthread, it is safe to initialize it without any locks.

Found by: LLVM's scan-build
82f181ca79c23c7cc0b108cb75e74eb54798e1d6 03-Feb-2009 imp <imp@FreeBSD.org> Use NULL in preference to 0 for pointers.
c48b61a389020acf4ab85f00bc3a05fac8d07ecf 21-Dec-2008 ed <ed@FreeBSD.org> Revert r185891.

In r185891 I removed the newlines from messages written to /dev/console,
because it made startup messages from rc-scripts harder to read. This,
unfortunately, causes the kernel message that is printed after a
non-terminated log message to be concatenated.

This could be fixed, but on short term it's better to just revert the
change.

Reported by: Jaakko Heinonen <jh saunalahti fi>
4400e3e1347538c7fbe0db7c802baf4b84a6d3e0 10-Dec-2008 ed <ed@FreeBSD.org> Remove added newlines from logged messages written to /dev/console.

The /dev/console device node logs all strings that are written to it.
When the string does not contain a trailing newline, it appends one. I
can imagine this was useful a long time ago, but with our current
rc-scripts, it generates a whole bunch of messages that look like:

| Configuring syscons:
| blanktime
| .

By not appending the newlines, the output of `dmesg -a' is now (almost?)
exactly the same as what the user will see on the console device
(syscons, uart).
19b6af98ec71398e77874582eb84ec5310c7156f 22-Nov-2008 dfr <dfr@FreeBSD.org> Clone Kip's Xen on stable/6 tree so that I can work on improving FreeBSD/amd64
performance in Xen's HVM mode.
39ade9204da1551bd876825b040820bfdef173a1 17-Nov-2008 delphij <delphij@FreeBSD.org> Obey signedness flag in %z case.

MFC after: 2 months
cf5320822f93810742e3d4a1ac8202db8482e633 19-Oct-2008 lulf <lulf@FreeBSD.org> - Import the HEAD csup code which is the basis for the cvsmode work.
cc3116a9380fe32a751b584f3d8083698ccfba15 20-Aug-2008 ed <ed@FreeBSD.org> Integrate the new MPSAFE TTY layer to the FreeBSD operating system.

The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:

- Improved driver model:

The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.

If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.

- Improved hotplugging:

With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).

The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.

- Improved performance:

One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.

Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.

Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
80d6cde009b5766eaf8fb0ee64deb32113487939 08-Mar-2007 julian <julian@FreeBSD.org> Instead of doing comparisons using the pcpu area to see if
a thread is an idle thread, just see if it has the IDLETD
flag set. That flag will probably move to the pflags word
as it's permenent and never chenges for the life of the
system so it doesn't need locking.
01bbbf558ed34f28834e42af63b3db5cabf02279 30-Nov-2006 jb <jb@FreeBSD.org> Flushing the buffer is conditional on actually using the buffer. Oops.
da35e3e55f3d5d5ed5bc5018536e8b0a54ddc767 30-Nov-2006 jb <jb@FreeBSD.org> Turn console printf buffering into a kernel option and only on
by default for sun4v where it is absolutely required.

This change moves the buffer from struct pcpu to the stack to avoid
using the critical section which created a LOR in a couple of cases
due to interaction with the tty code and kqueue. The LOR can't be
fixed with the critical section and the pcpu buffer can't be used
without the critical section.

Putting the buffer on the stack was my initial solution, but it was
pointed out that the stress on the stack might cause problems
depending on the call path. We don't have a way of creating tests
for those possible cases, so it's best to leave this as an option
for the time being. In time we may get enough data to enable this
option more generally.
10d0d9cf473dc5f0ce1bf263ead445ffe7819154 06-Nov-2006 rwatson <rwatson@FreeBSD.org> Sweep kernel replacing suser(9) calls with priv(9) calls, assigning
specific privilege names to a broad range of privileges. These may
require some future tweaking.

Sponsored by: nCircle Network Security, Inc.
Obtained from: TrustedBSD Project
Discussed on: arch@
Reviewed (at least in part) by: mlaier, jmg, pjd, bde, ceri,
Alex Lyashkov <umka at sevcity dot net>,
Skip Ford <skip dot ford at verizon dot net>,
Antoine Brodin <antoine dot brodin at laposte dot net>
d2bd8073567b9878a0f047164ede93eea2930207 01-Nov-2006 jb <jb@FreeBSD.org> Add a cnputs() function to write a string to the console with
a lock to prevent interspersed strings written from different CPUs
at the same time.

To avoid putting a buffer on the stack or having to malloc one,
space is incorporated in the per-cpu structure. The buffer
size if 128 bytes; chosen because it's the next power of 2 size
up from 80 characters.

String writes to the console are buffered up the end of the line
or until the buffer fills. Then the buffer is flushed to all
console devices.

Existing low level console output via cnputc() is unaffected by
this change. ithread calls to log() are also unaffected to avoid
blocking those threads.

A minor change to the behaviour in a panic situation is that
console output will still be buffered, but won't be written to
a tty as before. This should prevent interspersed panic output
as a number of CPUs panic before we end up single threaded
running ddb.

Reviewed by: scottl, jhb
MFC after: 2 weeks
8b3f7ca1ce8cf2bc4798641c8aea9d3b1bc0eb0a 17-Sep-2006 rwatson <rwatson@FreeBSD.org> Declare security and security.bsd sysctl hierarchies in sysctl.h along
with other commonly used sysctl name spaces, rather than declaring them
all over the place.

MFC after: 1 month
Sponsored by: nCircle Network Security, Inc.
a72b0bcd7fd4baed9952beefc6398b3d79c789d9 12-Jul-2006 jhb <jhb@FreeBSD.org> Simplify the pager support in DDB. Allowing different db commands to
install custom pager functions didn't actually happen in practice (they
all just used the simple pager and passed in a local quit pointer). So,
just hardcode the simple pager as the only pager and make it set a global
db_pager_quit flag that db commands can check when the user hits 'q' (or a
suitable variant) at the pager prompt. Also, now that it's easy to do so,
enable paging by default for all ddb commands. Any command that wishes to
honor the quit flag can do so by checking db_pager_quit. Note that the
pager can also be effectively disabled by setting $lines to 0.

Other fixes:
- 'show idt' on i386 and pc98 now actually checks the quit flag and
terminates early.
- 'show intr' now actually checks the quit flag and terminates early.
fa42b82744504ede151f2766ec47e74eeae0544c 22-May-2006 jkim <jkim@FreeBSD.org> MFC: src/lib/libstand/printf.c 1.9
src/sys/kern/subr_prf.c 1.123

Implement printf 'X' conversion for both libstand and kernel.
7e4fc3b8f97d1bb977eef30e3d8d163162d0f9f7 09-Mar-2006 jkim <jkim@FreeBSD.org> Implement printf 'X' conversion for both libstand and kernel.
2144501c63c03694506b1a5e4a20fd3f69e97931 25-Feb-2006 scottl <scottl@FreeBSD.org> Always print a newline char at the end of the line.
01b0d42812b9bceb886bced56be12fa5e2ac8664 07-Oct-2005 phk <phk@FreeBSD.org> MFC:
make the kernels printf more paranoid about unknown %-formats

Approved by: re@ (scottl)
5db6e492eeaac9ae9ef11ad06299c9d987fcbfda 29-Sep-2005 rwatson <rwatson@FreeBSD.org> Merge subr_prof.c:1.119, 1.120, 1.121, nfs_socket.c:1.130,
rpcclnt.c:1.14 from HEAD to RELENG_6:

Acquire Giant in uprintf() and tprintf() due to the non-MPSAFEty of
the tty code invoked from these functions. In two cases, during
timeout handling in NFS-related RPC client code, acquire Giant in
the caller before other mutexes the caller might hold, in order to
avoid lock order reversals with Giant (a recursive acquire is not
a reversal as it won't ever wait).

Correct age-old comments about uprintf()/tprintf() sleeping: they
will never sleep.

Much useful feedback from: bde
Approved by: re (scottl)
0106e151c3c4cbbe01b965a029f455618053512b 26-Sep-2005 rwatson <rwatson@FreeBSD.org> Acquire Giant in uprintf() and tprintf() rather than asserting it. In
the vast majority of cases, these functions are called without mutexes
held, meaning that in all but two cases, there will be no ordering
issues with doing this, and it will eliminate the need for changes in
the caller. In two cases, mutexes are held, so Giant must be acquired
before those mutexes such that uprintf() and tprintf() recurse Giant
rather than generating a lock order reversal.

Suggested by: bde
8448d393fa29035f10fb826d685e9b2cc5d6171d 20-Sep-2005 rwatson <rwatson@FreeBSD.org> Correct an incorrect comment from the dawn of time: neither tprintf()
nor uprintf() is believed to perform tsleep() or msleep() as written,
as ttycheckoutq() is called with '0' as its sleep argument.

Remove recently added WITNESS warnings for sleep as the comment was
incorrect. This should silence a warning from the nfs_timer() code.

Discussed with: bde
c479a90eb8129ad770ff6daba981e9f20af69e6f 19-Sep-2005 rwatson <rwatson@FreeBSD.org> Add GIANT_REQUIRED and WITNESS sleep warnings to uprintf() and tprintf(),
as they both interact with the tty code (!MPSAFE) and may sleep if the
tty buffer is full (per comment).

Modify all consumers of uprintf() and tprintf() to hold Giant around
calls into these functions. In most cases, this means adding an
acquisition of Giant immediately around the function. In some cases
(nfs_timer()), it means acquiring Giant higher up in the callout.

With these changes, UFS no longer panics on SMP when either blocks are
exhausted or inodes are exhausted under load due to races in the tty
code when running without Giant.

NB: Some reduction in calls to uprintf() in the svr4 code is probably
desirable.

NB: In the case of nfs_timer(), calling uprintf() while holding a mutex,
or even in a callout at all, is a bad idea, and will generate warnings
and potential upset. This needs to be fixed, but was a problem before
this change.

NB: uprintf()/tprintf() sleeping is generally a bad ideas, as is having
non-MPSAFE tty code.

MFC after: 1 week
4f84dc1091a7f182e77e54d804ecf0ebff3f32ef 14-Sep-2005 delphij <delphij@FreeBSD.org> MFC 1.118:

When padding with zero, do pad after prefixes rather than padding
before prefixes.

Use cases:
printf("%05d", -42); --> "00-42" (should be "-0042")
printf("%#05x", 12); --> "000xc" (should be "0x00c")

Submitted by: Oliver Fromme
PR: kern/85520
Approved by: re (kensmith)
5f683ee68de8850994da2bd671f19eda8998dd91 04-Sep-2005 delphij <delphij@FreeBSD.org> When padding with zero, do pad after prefixes rather than padding
before prefixes.

Use cases:
printf("%05d", -42); --> "00-42" (should be "-0042")
printf("%#05x", 12); --> "000xc" (should be "0x00c")

Submitted by: Oliver Fromme
PR: kern/85520
MFC After: 1 week
40bead9126c4546fb34ceaa13c0245e51662c1c8 03-Sep-2005 phk <phk@FreeBSD.org> If we ignore an unknown % sequence, we must stop interpreting the
remaining % arguments because the varargs are now out of sync and
there is a risk that we might for instance dereference an integer
in a %s argument.

Sponsored by: Napatech.com
1d894721d3bdaa106a0e4dfbe69187b44c508154 06-Jun-2005 dwhite <dwhite@FreeBSD.org> Make "show msgbuf" use the pager instead of blasting the whole thing out.

MFC after: 3 days
46c303a78b5662f22124d5ffd7c84efadd776284 06-Apr-2005 phk <phk@FreeBSD.org> Constify hexdump() harder.
d6c8765efc947151e1249f9407fd0efd6bdee75f 17-Mar-2005 phk <phk@FreeBSD.org> In stange circumstances we may end up being the last reference to a
session in tprintf(). SESSRELE() needs to properly dispose of the
sessions mutex.

Add sessrele() which does the proper cleanup and have SESSRELE() call it.

Use SESSRELE also in pgdelete().

Found by: Coverity (ID:526)
54e2d39fa084cad1ce98614653948c6a8251887d 10-Jul-2004 marcel <marcel@FreeBSD.org> Update for the KDB framework:
o Check kdb_active instead of db_active and do so unconditionally.
b9f13e4266e1a358f8e0f5ee3542e657eabb8a19 10-Jul-2004 phk <phk@FreeBSD.org> Clean up and wash struct iovec and struct uio handling.

Add copyiniov() which copies a struct iovec array in from userland into
a malloc'ed struct iovec. Caller frees.

Change uiofromiov() to malloc the uio (caller frees) and name it
copyinuio() which is more appropriate.

Add cloneuio() which returns a malloc'ed copy. Caller frees.

Use them throughout.
e57eac4be2487a6e3b24c40052e828e9a5081d12 18-Jun-2004 green <green@FreeBSD.org> Add a sysctl/tunable, "kern.always_console_output", that lets you set
output to permanently (not ephemerally) go to the console. It is also
sent to any other console specified by TIOCCONS as normal.

While I'm here, document the kern.log_console_output sysctl.
74cf37bd00b1e09a0b991b7b1edd335d8e0c2355 05-Apr-2004 imp <imp@FreeBSD.org> Remove advertising clause from University of California Regent's license,
per letter dated July 22, 1999.

Approved by: core
a3ce894968d0ca71e7f6c77fdec6454239b4d39d 19-Feb-2004 njl <njl@FreeBSD.org> Add support for 'h' and 'hh' modifiers for printf(9).

Submitted by: Bruno Ducrot <ducrot AT poupinou.org>
Reviewed by: bde
2b68e67c6dd54583034d8bfd6d2b87e8de25e973 07-Dec-2003 scottl <scottl@FreeBSD.org> Re-arrange and consolidate some random debugging stuff
eb30c92e4910efd8f5aa99168e8b74d8414f3eb1 22-Jul-2003 phk <phk@FreeBSD.org> Revert stuff which accidentally ended up in the previous commit.
c4a9334fa698660a5dd1a0c4fddb61ed0893fc58 22-Jul-2003 phk <phk@FreeBSD.org> Don't attempt to inline large functions mb_alloc() and mb_free(),
it more than doubles the text size of this file.

GCC has wisely ignored us on this previously
768b08c167a71febe6dfe07d6208897dff50feb7 22-Jun-2003 iedowse <iedowse@FreeBSD.org> When DDB is active, always send printf() output directly to the
console, even if there is a TIOCCONS console tty. We were already
doing this after a panic, but it's also useful when entering DDB
for some other reason too.
65000a220ab41d3a7e96a605fef81d386eeca712 22-Jun-2003 iedowse <iedowse@FreeBSD.org> Use a new message buffer `consmsgbuf' to forward messages to a
TIOCCONS console (e.g. xconsole) via a timeout routine instead of
calling into the tty code directly from printf(). This fixes a
number of cases where calling printf() at the wrong time (such as
with locks held) would cause a panic if xconsole is running.

The TIOCCONS message buffer is 8k in size by default, but this can
be changed with the kern.consmsgbuf_size sysctl. By default, messages
are checked for 5 times per second. The timer runs and the buffer
memory remains allocated only at times when a TIOCCONS console is
active.

Discussed on: freebsd-arch
6bb0e5cb462431a2a86e4263d027ba8ad04eddc4 22-Jun-2003 iedowse <iedowse@FreeBSD.org> Replace the code for reading and writing the kernel message buffer
with a new implementation that has a mostly reentrant "addchar"
routine, supports multiple message buffers in the kernel, and hides
the implementation details from callers.

The new code uses a kind of sequence number to represend the current
read and write positions in the buffer. This approach (suggested
mainly by bde) permits the read and write pointers to be maintained
separately, which reduces the number of atomic operations that are
required. The "mostly reentrant" above refers to the way that while
it is now always safe to have any number of concurrent writers,
readers could see the message buffer after a writer has advanced
the pointers but before it has witten the new character.

Discussed on: freebsd-arch
3b8fff9e4cedc4d9df3fb1ff39f5b668abdb9676 11-Jun-2003 obrien <obrien@FreeBSD.org> Use __FBSDID().
145891d899607e6317e5fe1df2e01818b81c3737 31-May-2003 phk <phk@FreeBSD.org> Remove unused variable(s).
Remove break after goto

Found by: FlexeLint
872336ea36fb488a069baa7c5b33f3221e51bd01 17-Apr-2003 jhb <jhb@FreeBSD.org> Don't assume that p_session hasn't changed out from under us after unlocking
the process and session. Instead, cache a true reference to the session
when we do the hold and release our reference on that session. This avoids
the need for the proc lock when dropping the reference.
b399d5ecbd4716ab7d85123d538e0eac2cfecdec 28-Mar-2003 iedowse <iedowse@FreeBSD.org> Add a checksum to the kernel message buffer, and update it every
time a character is written. Use this at boot time to reject the
existing buffer contents if they are corrupt. This fixes a problem
seen on some hardware (especially laptops) where the message buffer
gets partially corrupted during a short power cycle or reset, but
the msgbuf structure is left intact so it gets reused, resulting
in random junk and control characters appearing in dmesg and
/var/log/messages.

PR: kern/28497
e059b79437b2e02b4b4fdc0788b40a5da22e1f9b 18-Mar-2003 phk <phk@FreeBSD.org> Including <sys/stdint.h> is (almost?) universally only to be able to use
%j in printfs, so put a newsted include in <sys/systm.h> where the printf
prototype lives and save everybody else the trouble.
cf874b345d0f766fb64cf4737e1c85ccc78d2bee 19-Feb-2003 imp <imp@FreeBSD.org> Back out M_* changes, per decision of the TRB.

Approved by: trb
1abb95308bcc72d0a245f8d4c0f779f3cbe67d90 04-Feb-2003 phk <phk@FreeBSD.org> Add vsnrprintf() which is just like vsnprintf() but takes a "radix"
argument for the kernel-special %r format.
bf8e8a6e8f0bd9165109f0a258730dd242299815 21-Jan-2003 alfred <alfred@FreeBSD.org> Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.
Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
09a741fae61bb411204d6d533ec4670c5f416c37 07-Jan-2003 jhb <jhb@FreeBSD.org> Cast the integer read as the first argument for %b to an unsigned integer
so it's value is not sign extended when assigned to the uintmax_t variable
used internally by printf. For example, if bit 31 is set in the cpuid
feature word, then %b would print out the initial value as a 16 character
hexadecimal value. Now it only prints out an 8 character value.

Reviewed by: bde
bc8317a9ccc24ec3221daec3d347cdbda528939c 04-Jan-2003 phk <phk@FreeBSD.org> Move #include of ddb/ddb.h up with the rest.
6bce41dbe0c44950686bd7b136c004e7130f9dd6 14-Nov-2002 tmm <tmm@FreeBSD.org> Make the msg_size, msg_bufx and msg_bufr memebers of struct msgbuf
signed, since they describe a ring buffer and signed arithmetic is
performed on them. This avoids some evilish casts.

Since this changes all but two members of this structure, style(9)
those remaining ones, too.

Requested by: bde
Reviewed by: bde (earlier version)
06657e3da637adc5c3bf0ec833d3a117f55cf08b 13-Nov-2002 mux <mux@FreeBSD.org> Add support for the C99 %t format modifier.
bdcd4ebb5d13250d4ca2e13312032e45fee4c725 25-Oct-2002 mux <mux@FreeBSD.org> - Rename the DDB specific %z printf format to %y.
- Make DDB use %y instead of %z.
- Teach GCC about %y.
- Implement support for the C99 %z format modifier.

Approved by: re@
Reviewed by: peter
Tested on: i386, sparc64
27f6c5f7cc6e18133a1a85cff1e27894a02115da 11-Oct-2002 jhb <jhb@FreeBSD.org> Fix %z to always print values as signed like it is supposed to.

Reviewed by: bde
Tested on: i386 in ddb
a4c01edbf36322e79eaa50b950895f88016834de 28-Sep-2002 phk <phk@FreeBSD.org> Change a return to a break so the local buffers get properly freeed.

Spotte by: FlexeLint

Reviewed by: rwatson
017aab1fde0d8fd18f78554ecf21630acd240177 11-Aug-2002 dwmalone <dwmalone@FreeBSD.org> Make kern.log_console_output a tuneable aswell as a sysctl.

MFC after: 1 week
9568924023a1e322c446870c4a4dd514800517c3 05-Jul-2002 imp <imp@FreeBSD.org> dd %i as an alias for %d for greater compatibility with our *BSD bretheren

Obtained from: NetBSD
Reviewed by: jake, rwatson, bosko
8cd894ca7009ef10fdf67d1a9583636aaf3b2c6f 29-Jun-2002 alfred <alfred@FreeBSD.org> More caddr_t removal.
Change struct knote's kn_hook from caddr_t to void *.
7464466a40e9c91cea4262275d62eb1fbd2a8031 02-Jun-2002 des <des@FreeBSD.org> ANSIfy the one remaining K&R function.
f58932ded5ade8e19674fd359b1b21f77ac2c5b0 02-Jun-2002 des <des@FreeBSD.org> Whitespace nits.
a79d7499e250582669e824b1d69b74ff6bf3912c 02-Jun-2002 des <des@FreeBSD.org> Add support for 'j' flag. Simplify the size modifier code and reduce code
duplication. Also add support for 'n' specifier.

Reviewed by: bde
2eb82b93ad637b0d0525d53112535fe89053281c 29-Apr-2002 dwmalone <dwmalone@FreeBSD.org> Add a sysctl which disables the logging of console output.

Approved by: phk
MFC after: 2 weeks
dc2e474f79c1287592679cd5e0c4c2307feccd60 01-Apr-2002 jhb <jhb@FreeBSD.org> Change the suser() API to take advantage of td_ucred as well as do a
general cleanup of the API. The entire API now consists of two functions
similar to the pre-KSE API. The suser() function takes a thread pointer
as its only argument. The td_ucred member of this thread must be valid
so the only valid thread pointers are curthread and a few kernel threads
such as thread0. The suser_cred() function takes a pointer to a struct
ucred as its first argument and an integer flag as its second argument.
The flag is currently only used for the PRISON_ROOT flag.

Discussed on: smp@
357e37e023059920b1f80494e489797e2f69a3dd 19-Mar-2002 alfred <alfred@FreeBSD.org> Remove __P.
22c75bf1c95925ca749760aa92580541ac2e6196 11-Mar-2002 tanimura <tanimura@FreeBSD.org> Stop abusing the pgrpsess_lock.
a09da298590e8c11ebafa37f79e0046814665237 23-Feb-2002 tanimura <tanimura@FreeBSD.org> Lock struct pgrp, session and sigio.

New locks are:

- pgrpsess_lock which locks the whole pgrps and sessions,
- pg_mtx which protects the pgrp members, and
- s_mtx which protects the session members.

Please refer to sys/proc.h for the coverage of these locks.

Changes on the pgrp/session interface:

- pgfind() needs the pgrpsess_lock held.

- The caller of enterpgrp() is responsible to allocate a new pgrp and
session.

- Call enterthispgrp() in order to enter an existing pgrp.

- pgsignal() requires a pgrp lock held.

Reviewed by: jhb, alfred
Tested on: cvsup.jp.FreeBSD.org
(which is a quad-CPU machine running -current)
95c1f2fa1ec419cafad04edf3e4afe2b83b04747 10-Feb-2002 phk <phk@FreeBSD.org> Style(9) nits.

Obtained from: ~bde/sys.dif.gz
1ae1e4e3f2015a0dd28a67d111327bf8b681ba37 16-Jan-2002 arr <arr@FreeBSD.org> - Attempt to help declutter kern. sysctl by moving security out from
beneath it.

Reviewed by: rwatson
aa8360c1cd7a7e842c08ab62bfc84fa95a2826c3 30-Nov-2001 rwatson <rwatson@FreeBSD.org> o Introduce kern.security.bsd.unprivileged_read_msgbuf, which allows
the administrator to restrict access to the kernel message buffer.
It defaults to '1', which permits access, but if set to '0', requires
that the process making the sysctl() have appropriate privilege.
o Note that for this to be effective, access to this data via system
logs derived from /dev/klog must also be limited.

Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs
8122c9fcb409b8b399474666a0fe1fc5d8c8d8a2 09-Nov-2001 iedowse <iedowse@FreeBSD.org> Properly sanity-check the old msgbuf structure before we accept it
as being valid. Previously only the magic number and the virtual
address were checked, but it makes little sense to require that
the virtual address is the same (the message buffer is located at
the end of physical memory), and checks on the msg_bufx and msg_bufr
indices were missing.

Submitted by: Bodo Rueskamp <br@clabsms.de>
Tripped over during a kernel debugging tutorial given by: grog
Reviewed by: grog, dwmalone
MFC after: 1 week
5596676e6c6c1e81e899cd0531f9b1c28a292669 12-Sep-2001 julian <julian@FreeBSD.org> KSE Milestone 2
Note ALL MODULES MUST BE RECOMPILED
make the kernel aware that there are smaller units of scheduling than the
process. (but only allow one thread per process at this time).
This is functionally equivalent to teh previousl -current except
that there is a thread associated with each process.

Sorry john! (your next MFC will be a doosie!)

Reviewed by: peter@freebsd.org, dillon@freebsd.org

X-MFC after: ha ha ha ha
6dd375961b07fa6608ebb267904bfd314b0e4c55 03-Jul-2001 tmm <tmm@FreeBSD.org> Make the code to read the kernel message buffer via sysctl machine-
independent and rename the corresponding sysctls from machdep.msgbuf and
machdep.msgbuf_clear (i386 only) to kern.msgbuf and kern.msgbuf_clear.
4f5d8ed82579a945555b585b43ab2d09eae30c77 10-Jan-2001 jake <jake@FreeBSD.org> Use PCPU_GET, PCPU_PTR and PCPU_SET to access all per-cpu variables
other then curproc.
0861a5c19cae621d1d7bb2cb8367e14902f7ae63 23-Dec-2000 mjacob <mjacob@FreeBSD.org> Make sure we have a non-null proc pointer before referring to fields
off of it.
bfa5821075613f91d269e9064694fa03e0b1eb05 20-Dec-2000 phk <phk@FreeBSD.org> A last minute brucification resulted in syntax errors in the previous commit.
04b71d6b6d5b879ea0b817c773f4ce96507247f6 20-Dec-2000 phk <phk@FreeBSD.org> Replace logwakeup() with "int msgbuftrigger". There is little
point in calling a function just to set a flag.

Keep better track of the syslog FAC/PRI code and try to DTRT if
they mingle.

Log all writes to /dev/console to syslog with <console.info>
priority. The formatting is not preserved, there is no robust,
way of doing it. (Ideas with patches welcome).
7101ba5caa38060b2d927dc5bd81c320b7055e6b 26-Nov-2000 phk <phk@FreeBSD.org> Simplify the tprintf() API.

Loose the special <sys/tprintf.h> #include file.
7c4763bbdd4cb046f92027fbbfb033f3e9987580 26-Nov-2000 phk <phk@FreeBSD.org> Make log(-1, ...) do what addlog(...) did.

Replace all uses of addlog(...) with log(-1, ...)

Remove bogus "register" keywords in subr_prf.c

Make log() return void.
2c511bc3643abe9802cbd0bac1d7248598cde736 02-Oct-2000 msmith <msmith@FreeBSD.org> Treat %X the same as %x (not entirely correct, but close enough).
769e0f974d8929599ba599ac496510fffc90ff34 07-Sep-2000 jasone <jasone@FreeBSD.org> Major update to the way synchronization is done in the kernel. Highlights
include:

* Mutual exclusion is used instead of spl*(). See mutex(9). (Note: The
alpha port is still in transition and currently uses both.)

* Per-CPU idle processes.

* Interrupts are run in their own separate kernel threads and can be
preempted (i386 only).

Partially contributed by: BSDi (BSD/OS)
Submissions by (at least): cp, dfr, dillon, grog, jake, jhb, sheldonh
a63f67a2b62190c2dbf87506a1ca5ba5ff395f98 29-Apr-2000 peter <peter@FreeBSD.org> Do not fault if curproc is null.
b42951578188c5aab5c9f8cbcde4a743f8092cdc 02-Apr-2000 cvs2svn <cvs2svn@FreeBSD.org> This commit was manufactured by cvs2svn to create branch 'ALSA'.
3b842d34e82312a8004a7ecd65ccdb837ef72ac1 28-Aug-1999 peter <peter@FreeBSD.org> $Id$ -> $FreeBSD$
ee871b6440719fbe58a0cb8e994ad543265f4e1a 09-Aug-1999 phk <phk@FreeBSD.org> Merge the cons.c and cons.h to the best of my ability. alpha may or
may not compile, I can't test it.
794dc7dbf91fe8aa89ae5e4d55f91c7fc115348f 07-Aug-1999 green <green@FreeBSD.org> Make long longs ("%ll" format) work.

Reviewed by: msmith
49f6f0f9f07f737a67db278436cbb3c3cf738c26 24-Jul-1999 dfr <dfr@FreeBSD.org> This makes the in kernel printf routines conform to the documented
behavior of their userland counterparts with respect to return values.

Submitted by: Matthew N. Dodd <winter@jurai.net>
e179e11229b4e38e618443691a7d1a1fdacd7216 14-Jul-1999 peter <peter@FreeBSD.org> Oops, missed out one chunk of the last patch. (*blush*)

Submitted by: Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
Submitted by: "Matthew N. Dodd" <winter@jurai.net>
49a30aa645e3f361acf747fdefab3e56b508deec 10-Jul-1999 peter <peter@FreeBSD.org> Fixes for a couple of problems in last commit:
1. Printing large quads in small bases overflowed the buffer if
sizeof(u_quad_t) > sizeof(u_long).
2. The sharpflag checks had operator precedence bugs due to excessive
parentheses in all the wrong places.
3. The explicit 0L was bogus in the quad_t comparison and useless in
the long comparision.
4. There was some more bitrot in the comment about ksprintn(). Our
ksprintn() handles bases up to 36 as well as down to 2.

Bruce has other complaints about using %q in kernel and would rather
we went towards using the C9X style %ll and/or %j. (I agree for that
matter, as long as gcc/egcs know how to deal with that.)

Submitted by: bde
cffb9f52763efc27ca3c087911953cfe48c4fe12 09-Jul-1999 peter <peter@FreeBSD.org> Implement the %q prefix for the integer types. Note that egcs on the
Alpha believes that %q is for long long, whereas our quad_t and int64_t
is only just a plain long. long long on the alpha is the same size (64
bit) as a long. It was requested, but I have not implemented yet, support
for C9X style %lld - it should be pretty easy though.
dcb08e10ae76c01a5ada8606d738723a94a91fc3 07-Jun-1999 archie <archie@FreeBSD.org> ksprintn() may be called with base=2, so redefine MAXNBUF accordingly.
Other brucification tweaks.

Obtained from: bde@freebsd.org
f40f015be9fdde8af432707fbebe0acf7610c6f1 06-Jun-1999 archie <archie@FreeBSD.org> The function ksprintn(), which is used to convert numbers to ASCII, is not
reentrant because it returns a static buffer. This results in a race condition
when/if an interrupt handler calls log(), printf() etc. Fix this.
b5d4171ff60677d883a8f4fdf912b23d5de9a433 01-Jun-1999 jlemon <jlemon@FreeBSD.org> Unifdef VM86.

Reviewed by: silence on on -current
8ccd28a438a394a3aaf0e4c54acfa634195f6bc1 03-Dec-1998 archie <archie@FreeBSD.org> Add snprintf(3) and vsnprintf(3) capability to the kernel.
Reviewed by: bde
b9386dfd70628078e594d978a5f89ffc314add64 06-Sep-1998 ache <ache@FreeBSD.org> Store formatted panic string in static buffer to make it available later
for savecore.
Previous code give only panic format to savecore
5f83b9b480944421611a7688dc43b090b48d6951 10-Aug-1998 bde <bde@FreeBSD.org> Fixed the formatting of some tables (mainly the one produced by ps
in ddb) which I broke by changing %8[l]x to %8p. Hacked the central
printf routine to not add an "0x" prefix for %p formats if the field
width is nonzero. The tables are still horribly misformatted on
64-bit machines.

Use %p instead of %8p to print pointers when the field width isn't
important.
863d5c8b6850a65e8b4e00a7b23bbd29bd466602 15-Jul-1998 bde <bde@FreeBSD.org> Cast pointers to uintptr_t/intptr_t instead of to u_long/long,
respectively. Most of the longs should probably have been
u_longs, but this changes is just to prevent warnings about
casts between pointers and integers of different sizes, not
to fix poorly chosen types.
b5d9d2e7066642affdab55e8415242ac5619218d 08-Jul-1998 bde <bde@FreeBSD.org> Fixed (un)sign extension bugs in %+n format. -4 became
(long)(u_long)(u_int)-4 = 0x00000000fffffffc on machines with 32-bit
ints and 64-bit longs.

Restored %z format for printing signed hex. %+x shouldn't have been
used since it is an error in userland.

Prepared to nuke %n format by cloning it to %r. %n shouldn't have
been used because it means something completely different in
userland. Now %+r is equivalent to ddb's original %r, and %r is
equivalent to ddb's original %n.

Ignore '+' flag in combination with unsigned formats %{o,p,u,x}.
d3d65c6b2e376ac074f3ca386b6f5b70ea37636f 28-May-1998 phk <phk@FreeBSD.org> Some cleanups related to timecounters and weird ifdefs in <sys/time.h>.

Clean up (or if antipodic: down) some of the msgbuf stuff.

Use an inline function rather than a macro for timecounter delta.

Maintain process "on-cpu" time as 64 bits of microseconds to avoid
needless second rollover overhead.

Avoid calling microuptime the second time in mi_switch() if we do
not pass through _idle in cpu_switch()

This should reduce our context-switch overhead a bit, in particular
on pre-P5 and SMP systems.

WARNING: Programs which muck about with struct proc in userland
will have to be fixed.

Reviewed, but found imperfect by: bde
00b3b49e1bf2cd947f5d9fc0b4a645f000094534 19-May-1998 phk <phk@FreeBSD.org> Make the size of the msgbuf (dmesg) a "normal" option.
0506343883d62f6649f7bbaf1a436133cef6261d 11-Jan-1998 cvs2svn <cvs2svn@FreeBSD.org> This commit was manufactured by cvs2svn to create branch 'jb'.
7c6e96080c4fb49bf912942804477d202a53396c 10-Jan-1998 cvs2svn <cvs2svn@FreeBSD.org> This commit was manufactured by cvs2svn to create branch 'JB'.
e24f5de85f72ddce45fa50297bcc1a1d25a9b943 28-Dec-1997 bde <bde@FreeBSD.org> Handle "%...p" as "%#...x" instead of "0x%...x". This is a quick fix
for field widths being 2 larger than specified for "%<number>p". Only
printing of null pointers is "wrong" now (it is actually "right", but
inconsistent with printf(3)).
36e7a51ea1dedf0fc860ff3106aee1db1ab3b1f5 12-Oct-1997 phk <phk@FreeBSD.org> Last major round (Unless Bruce thinks of somthing :-) of malloc changes.

Distribute all but the most fundamental malloc types. This time I also
remembered the trick to making things static: Put "static" in front of
them.

A couple of finer points by: bde
6ffb8bf9af1d6800f2c8b2595b03e7696ec1a850 02-Sep-1997 bde <bde@FreeBSD.org> Removed unused #includes.
94b6d727947e1242356988da003ea702d41a97de 22-Feb-1997 peter <peter@FreeBSD.org> Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are not
ready for it yet.
808a36ef658c1810327b5d329469bcf5dad24b28 14-Jan-1997 jkh <jkh@FreeBSD.org> Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.
070eb30ca675029e79f93333b60287527efc0906 31-Aug-1996 bde <bde@FreeBSD.org> Fixed the easy cases of const poisoning in the kernel. Cosmetic.
65b6e7181bc8bde1918c94186c38543764663453 19-Aug-1996 julian <julian@FreeBSD.org> Collect all the functioons concerned with rebooting into one place
also add the at_shutdown callout list, and change the one user of
the present (broken) method (the vn driver) to use the new scheme.
86058739b95ae00ed08a591f6e8001326915086f 09-May-1996 gpalmer <gpalmer@FreeBSD.org> Correct a comment. There is no fn `kprintf'
c79cc630ede15ddb8641deef1f5256d6296ae31b 08-May-1996 gpalmer <gpalmer@FreeBSD.org> Clean up various compiler warnings. Most (if not all) were benign

Reviewed by: bde
7bfc0101cb7b18e50bfb65137a0be725c51d26cb 02-May-1996 phk <phk@FreeBSD.org> KGDB is dead. It may come back one day if somebody does it.
2f862644fc587fdd7916d765092abe6590870b27 25-Mar-1996 jkh <jkh@FreeBSD.org> Bill Fenner <fenner@parc.xerox.com> comes up with a better fix to the
debugger_on_panic stuff.
4d62e1dae8eabe2df600d0e7f46b88be1b8f6c0e 23-Mar-1996 jkh <jkh@FreeBSD.org> Ok, now this is correct (even simple fixes sometimes ain't so simple :)
78a7a152d0202d6f1151e96d289ea70df5bdaf6f 23-Mar-1996 jkh <jkh@FreeBSD.org> Fix bogus last commit - debugger_on_panic was referenced even when
not defined. Another change clearly committed without testing! :-(
d821d192551b56cfa172ffd1e388bd00e26c6c41 23-Mar-1996 phk <phk@FreeBSD.org> Remove all traces of KADB
add sysctl
debug.debugger_on_panic: 1
if DDB or KGDB is defined.

Requested by: davidg
072464b1987f27964703650957bbf91f8350ace1 11-Mar-1996 peter <peter@FreeBSD.org> Import 4.4BSD-Lite2 onto the vendor branch, note that in the kernel, all
files are off the vendor branch, so this should not change anything.

A "U" marker generally means that the file was not changed in between
the 4.4Lite and Lite-2 releases, and does not need a merge. "C" generally
means that there was a change.
[note new unused (in this form) syscalls.conf, to be 'cvs rm'ed]
1dec7bc8c62c5a84a1a6aa5fa2cd0d0e41af3bd0 28-Feb-1996 gpalmer <gpalmer@FreeBSD.org> Add a new option: DDB_UNATTENDED. Stops machine dropping into DDB
when it panics, but leaving activation of DDB from the console
unaffected.
6757073e1cbbf8550ab7b9a86c80a651de07d833 29-Jan-1996 gibbs <gibbs@FreeBSD.org> Kernel printf now returns int.
bdbbbadb36681bbcef9b5a0d92802ffdd161ddf4 25-Jan-1996 bde <bde@FreeBSD.org> Restored newline at the end of panic messages.
defff6cc5b2169d11d666f9ccd9d32a5719a8f28 24-Jan-1996 phk <phk@FreeBSD.org> Remove %r hack, we have vprintf() now.
Add %D for "dumping" data. Good for ethernet/MAC addresses and such.
Handle 1 < radix < 37.
285a427184f99b06c5b365e09b169f2c41abcc19 22-Jan-1996 phk <phk@FreeBSD.org> bounds check the radix, just in case.
fd032b69a65de38d570f0e4652c6202b4473ee6e 19-Jan-1996 phk <phk@FreeBSD.org> Imake %.*s really work. :-(
02594239cba00cc8c226917dfc520887295bff10 19-Jan-1996 phk <phk@FreeBSD.org> Make result of sprintf zero terminated. Fix %r for sprintf case.
1525c6d7bd751cf04506b7b926c44f1d24c0c212 18-Jan-1996 phk <phk@FreeBSD.org> Make %.*s work.
80fe9dce3306f953b4ea2a8704db23b570c99cf0 16-Jan-1996 phk <phk@FreeBSD.org> Add support for %.{int|*}s
c3e6222aa59d814018c016139a893ede0ef0d03d 15-Jan-1996 phk <phk@FreeBSD.org> Get rid of two and a half printf in the kernel.
Add more features to the one remaining to handle the job:
+ signed quantity.
# alternate format
- left padding
* read width as next arg.
n numeric in (argument specified) default radix.

Fix the DDB debugger to use these.
Use vprintf in debug routine in pcvt.

The warnings from gcc may become more wrong and intolerable because
of this.

Warning: I have not checked the entire source for unsupported or
changed constructs, but generally belive that there are only a few.

Suggested by: bde
39d3a9a3d35d380cd5627d8f1fa68782a1d614c0 04-Jan-1996 wollman <wollman@FreeBSD.org> Convert DDB to new-style option.
63ec2c0ae9b44c5394bae5d6ee7fea5be9659585 14-Dec-1995 phk <phk@FreeBSD.org> A Major staticize sweep. Generates a couple of warnings that I'll deal
with later.
A number of unused vars removed.
A number of unused procs removed or #ifdefed.
86f1bc4514fdcfd255f37f3218fe234bdc3664fc 05-Nov-1995 cvs2svn <cvs2svn@FreeBSD.org> This commit was manufactured by cvs2svn to create branch 'LINUX'.
b4c4ba59320a2fb509913cbf2f600ee945283bfd 24-Aug-1995 dg <dg@FreeBSD.org> Killed some gratuitous #include's.
3ed1e41c8e5a7ab085abf335f526b2b0a0a56772 07-Aug-1995 dg <dg@FreeBSD.org> Woops, I committed the wrong version of the diff in the last rev.
fad46e4f97a35f12dc96b526b7d14f3ed00e7e26 07-Aug-1995 dg <dg@FreeBSD.org> Made msgbuf range checking more robust and clean.
f0b49bdd9e4c38d2f87ac4bff85ea99d0377c3e1 06-Aug-1995 dg <dg@FreeBSD.org> Restore check for msg_bufx being negative. Changed if() expression to be
in Lite2 style.
909b527c19133d6ced3b877bb3277396b00696ae 14-Jun-1995 bde <bde@FreeBSD.org> Convert %p to 0x%x instead of to 0x%8x. The latter gives blank padding
in the wrong place. Blank padding in the right place or zero padding
would be inconsistent with user mode.

Put case 'p' in alphabetical order.

Implement %p in sprintf() too. I'd like only a single, more complete
printf() core, perhaps one based on vsnprintf().
2feff74c285a9678d5c38db2c45437df72a5bfdb 08-Apr-1995 joerg <joerg@FreeBSD.org> Implement a simple hook (or hack?) to allow graphics device console
drivers to protect DDB from being invoked while the console is in
process-controlled (i.e., graphics) mode.

Implement the logic to use this hook from within pcvt. (I'm sure
Søren will do the syscons part RSN).

I've still got one occasion where the system stalled, but my attempts
to trigger the situation artificially resulted int the expected
behaviour. It's hard to track bugs without the console and DDB
available. :-/
1c0c97a80b66beb80a344489aaf9902decdb341f 01-Apr-1995 joerg <joerg@FreeBSD.org> subr_prf.c used to provide an exported function kprintf(), but only had
a private declaration for it. Declare the function publically instead.
289f11acb49b6dbb3081e09bf94a86f008f55814 16-Mar-1995 bde <bde@FreeBSD.org> Add and move declarations to fix all of the warnings from `gcc -Wimplicit'
(except in netccitt, netiso and netns) and most of the warnings from
`gcc -Wnested-externs'. Fix all the bugs found. There were no serious
ones.
2e14d9ebc3d3592c67bdf625af9ebe0dfc386653 14-Mar-1995 cvs2svn <cvs2svn@FreeBSD.org> This commit was manufactured by cvs2svn to create branch 'MATT_THOMAS'.
fd0281dbd4e56ade5234234bb83c1bbda1c554cc 19-Feb-1995 bde <bde@FreeBSD.org> Don't flush the message buffer when it fills up.
927dfdafa7eef2e20014517a7cebde101c00737d 30-Dec-1994 bde <bde@FreeBSD.org> Print "(null)" instead of "<null>" for NULL string args for consistency
with the libc and ddb printf's.

Print "(fmt null)\n" for NULL formats.
d2d47d9034b1b237f7c5071ae8e6448ec71a79b2 28-Dec-1994 dg <dg@FreeBSD.org> Make printf() a bit more robust and allow NULL strings (print them as
"<null>"). It bad to have diagnostic printfs cause panics when they are
trying to tell you about another problem.
c3e49455410fee43dec92514e04dfed13eb8c587 02-Oct-1994 phk <phk@FreeBSD.org> All of this is cosmetic. prototypes, #includes, printfs and so on. Makes
GCC a lot more silent.
ee374e924368a8ad1784b8e35054a5b3b807ba2f 28-Sep-1994 phk <phk@FreeBSD.org> Added a %p to printf & friends, same thing as 0x%08x but more with the
potiential to make a warning from gcc more useful.
34cd81d75f398ee455e61969b118639dacbfd7a6 23-Sep-1994 cvs2svn <cvs2svn@FreeBSD.org> This commit was manufactured by cvs2svn to create branch 'MACKERRAS'.
4d4250da00e8f202ebcf4523fa25568d04b116ad 27-Aug-1994 dg <dg@FreeBSD.org> 1) Changed ddb into a option rather than a pseudo-device (use options DDB
in your kernel config now).
2) Added ps ddb function from 1.1.5. Cleaned it up a bit and moved into its
own file.
3) Added \r handing in db_printf.
4) Added missing memory usage stats to statclock().
5) Added dummy function to pseudo_set so it will be emitted if there
are no other pseudo declarations.
9daaac06d011638b2c9c77c569a63927ae68ed7b 13-Aug-1994 dg <dg@FreeBSD.org> Made the kernel compile cleanly with gcc 2.6.0. Thanks go to Bruce
Evans for suggesting a method to detect various versions of gcc.
e16baf7a5fe7ac1453381d0017ed1dcdeefbc995 07-Aug-1994 cvs2svn <cvs2svn@FreeBSD.org> This commit was manufactured by cvs2svn to create branch 'SUNRPC'.
8d205697aac53476badf354623abd4e1c7bc5aff 02-Aug-1994 dg <dg@FreeBSD.org> Added $Id$
2469c867a164210ce96143517059f21db7f1fd17 25-May-1994 rgrimes <rgrimes@FreeBSD.org> The big 4.4BSD Lite to FreeBSD 2.0.0 (Development) patch.

Reviewed by: Rodney W. Grimes
Submitted by: John Dyson and David Greenman
8fb65ce818b3e3c6f165b583b910af24000768a5 24-May-1994 rgrimes <rgrimes@FreeBSD.org> BSD 4.4 Lite Kernel Sources