2 .\" Copyright (c) 2001 Andrew R. Reiter
3 .\" Copyright (c) 2004 Joerg Wunsch
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20 .\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
22 .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 .\" $FreeBSD: src/share/man/man9/printf.9,v 1.8 2006/09/08 14:05:03 ru Exp $
43 .Nd formatted output conversion
48 .Fn kprintf "const char *format" ...
50 .Fn ksprintf "char *str" "const char *format" ...
52 .Fn ksnprintf "char *str" "size_t size" "const char *format" ...
54 .Fn kvprintf "const char *format" "__va_list ap"
56 .Fn kvsprintf "char *str" "const char *format" "__va_list ap"
58 .Fn kvsnprintf "char *str" "size_t size" "const char *format" "__va_list ap"
60 .Fn krateprintf "struct krate *rate" "const char *format" ...
62 .Fn uprintf "const char *format" ...
65 .Fn tprintf "struct proc *p" "int pri" "const char *format" ...
68 .Fn log "int pri" "const char *format" ...
72 family of functions are similar to the
75 The different functions each use a different output stream.
78 function outputs to the current process' controlling tty, while
86 write to the console as well as to the logging facility.
89 function outputs to the tty associated with the process
91 and the logging facility if
96 function sends the message to the kernel logging facility, using
97 the log level as indicated by
100 Each of these related functions use the
106 parameters in the same manner as
110 functions add another conversion specifier to
115 identifier expects two arguments: an
119 These are used as a register value and a print mask for decoding bitmasks.
120 The print mask is made up of two parts: the base and the
122 The base value is the output base expressed as an integer value;
123 for example, \e10 gives octal and \e20 gives hexadecimal.
124 The arguments are made up of a sequence of bit identifiers.
125 Each bit identifier begins with an integer value which is the number of the
126 bit (starting from 1) this identifier describes.
127 The rest of the identifier is a string of characters containing the name of
129 The string is terminated by either the bit number at the start of the next
132 for the last bit identifier.
144 parameter (mistakenly called
149 of \-1 is given, the message will be appended to the last log message
150 started by a previous call to
152 As these messages are generated by the kernel itself, the facility will
158 function is a rate controlled version of
166 must be initialized with the desired reporting frequency.
169 of 0 will result in no output.
172 to a negative value allows an initial burst.
185 functions return the number of characters displayed.
189 function returns 1 or 0, depending on whether anything was printed or not,
190 allowing code to issue additional
194 Tunables can be set at the
196 prompt before booting the kernel or stored in
198 .Bl -tag -width "xxxxxx"
199 .It Va kern.kprintf_logging
200 A bit mask that specifies the targets of
202 Supported targets are the console (0x1) and the dmesg buffer (0x4).
203 The default value is 5 (print to both).
204 .It Va kern.log_console_output
205 Specifies whether console output is duplicated to the syslog.
206 The default value is 1.
207 .It Va security.ptr_restrict
208 Specifying 1 masks out the upper bits of pointers printed with %p, and
209 specifying 2 masks out pointer values altogether.
210 The default value is 0.
211 .It Va security.unprivileged_read_msgbuf
212 Specifies if unprivileged processes may read the kernel buffer.
213 The default value is 1.
216 The loader tunables described in
218 are also available as sysctl(8) variables of the same names.
220 This example demonstrates the use of the
222 conversion specifier.
224 .Bd -literal -offset indent
228 kprintf("reg=%pb%i\en", "\e10\e2BITTWO\e1BITONE\en", 3);
232 will produce the following output:
233 .Bd -literal -offset indent
238 .Bd -literal -offset indent
239 log(LOG_DEBUG, "%s%d: been there.\en", sc->sc_name, sc->sc_unit);
242 will add the appropriate debug message at priority