PRINTF(K) UNIX System V PRINTF(K)
Name
printf - print a message on the console
Syntax
int
printf(format, arg1, arg2, ...)
char *format;
void arg1, arg2;
Description
The kernel printf routine prints error messages and
debugging information on the system console. In addition,
all messages are stored in /usr/adm/messages by a background
program error handler. printf is a simplified version of
the standard C library printf(S) routine.
Parameters
The parameters are:
format A string to be displayed similar to the
format argument to printf(S). format
also accepts specifications for
displaying the arg variables. The
supported specifications are:
Type Description
%b two-digit hexadecimal byte
%c character
%d signed decimal
%o unsigned octal
%s string (character pointer)
%x hexadecimal (prints leading zeros)
Specification values can be indicated in
either upper or lower case. Field
length specifications cannot be used for
arguments. For example, %9d is not
permitted. Escaped characters such as
\n (new line), \t (tab), \r (return),
and so on are C language features
supported by the C compiler and thus are
supported in this kernel routine.
arg1, arg2 Optional variables to be displayed using
the format.
Notes
This routine is not interrupt-driven and therefore suspends
all other system activities while executing.
This routine is similar to standard C library function
printf(S), except that only the formats specified here are
valid, and precision is not supported.
This routine does not function properly on consoles running
layers(C). As it is impossible for a driver to know if a
console is running layers, use of printf(K) for other than
debug purposes is not recommended. Use cmn_err(K) instead.
Example
It is often useful to use printf for driver debug
statements. For example in your xxioctl routine you might
do this:
xxioctl(dev, cmd, arg, mode)
dev_t dev;
int cmd, arg, mode;
{
printf("dev= %x, cmd= %d, addr of arg= %x, mode= %x\n",
dev, cmd, arg, mode);
}
See Also
cmn_err(K), printf(S)
Page 2 (printed 7/6/89)