CMN_ERR(K) UNIX System V CMN_ERR(K)
Name
cmn_err - displays message or panics the system
Syntax
#include "sys/cmn_err.h"
int
cmn_err(severity, format, arguments)
char *format;
int severity, arguments;
Description
cmn_err displays a message on the console and can
additionally, panic the system. This routine is an
improvement over printf in that cmn_err automatically
handles a variety of terminals such as bit-mapped graphics
terminals (which printf cannot handle), and cmn_err permits
grading messages into four categories by level of severity.
The levels are for continued messages, notice messges,
warning messages, and panic messages. If a panic message is
called immediately after another panic request, a ``double
panic'' results.
cmn_err is also used to store messages in putbuf, a circular
array in memory that can be accessed from crash(ADM). All
messages are also stored in /usr/adm/messages (an error
background program conveys the messages to this file).
Warning
An incorrect severity argument value causes a system panic.
Also, this routine is not interrupt-driven and therefore
suspends all other system activities while executing.
Parameters
severity One of four different levels for indicating
the severity of the message. Use CE_NOTE
to display a message preceded with NOTICE:.
Use CE_WARN to display a message preceded
with WARNING:. Use CE_PANIC to panic the
system and to display a message preceded
with PANIC:. If two or more panic requests
are called at the same time, DOUBLE PANIC:
is displayed. Use CE_CONT to continue a
previous message or to display a message
without a severity indicator preceding the
message. The severity argument must be
specified; if omitted, a panic results.
format A message to be displayed. The destination
of the message is specified with the first
character of format. If the first
character is an exclamation point (!), then
the message is stored in putbuf and not
displayed on the console. If the first
character is a carat (^), then the message
is displayed on the console and not stored
in putbuf. Any other character at the
start of format sends the message to both
putbuf and the console. The message is
appended with a \n for all severity levels
except for CE_CONT. format accepts data
type specifications the same as printf(K)
for displaying the arguments passed to the
message string. 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)
Specifications 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,
\t, \033, and so on are C language features
that are supported by the C compiler and
are thus supported in this kernel routine.
arguments optional variables to be displayed using
the format argument.
Example
You can use cmn_err to display messages on the console as
follows:
cmn_err(CE_NOTE," xxioctl routine called - device number = %x",
device);
cmn_err(CE_CONT," this is not a problem.\n");
(printed 7/6/89)