summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorHans Rosenfeld <hans.rosenfeld@nexenta.com>2014-10-22 17:32:17 +0200
committerRobert Mustacchi <rm@joyent.com>2014-11-03 09:35:49 -0800
commitca9a201c205f81e7d3779aa2571a820f07423b9f (patch)
treeb29d03de8d9977712dc5147f4a885d4a5f9cd675 /usr/src
parent0b4538017e5f84a04187012fe88bb3e46f1c5f51 (diff)
downloadillumos-gate-ca9a201c205f81e7d3779aa2571a820f07423b9f.tar.gz
2922 dev_err() needs manpage
5272 dev_err(9F) ignores special first character of message Reviewed by: Dan McDonald <danmcd@omniti.com> Reviewed by: Marcel Telka <marcel@telka.sk> Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com> Reviewed by: Garrett D'Amore <garrett@damore.org> Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com> Approved by: Robert Mustacchi <rm@joyent.com>
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/man/man9f/Makefile4
-rw-r--r--usr/src/man/man9f/cmn_err.9f78
-rw-r--r--usr/src/pkg/manifests/system-kernel.man9f.inc2
-rw-r--r--usr/src/uts/common/os/printf.c63
4 files changed, 94 insertions, 53 deletions
diff --git a/usr/src/man/man9f/Makefile b/usr/src/man/man9f/Makefile
index 265c50f628..00714a8145 100644
--- a/usr/src/man/man9f/Makefile
+++ b/usr/src/man/man9f/Makefile
@@ -857,6 +857,7 @@ MANLINKS= SIZEOF_PTR.9f \
ddi_umem_unlock.9f \
ddi_unmap_regs.9f \
desballoc.9f \
+ dev_err.9f \
devmap_load.9f \
devmap_umem_setup.9f \
dlerrorack.9f \
@@ -1158,6 +1159,7 @@ MANLINKS= SIZEOF_PTR.9f \
va_end.9f \
va_start.9f \
vcmn_err.9f \
+ vzcmn_err.9f \
wr.9f \
zcmn_err.9f
@@ -1299,7 +1301,9 @@ atomic_swap_uint.9f := LINKSRC = atomic_swap.9f
atomic_swap_ulong.9f := LINKSRC = atomic_swap.9f
atomic_swap_ushort.9f := LINKSRC = atomic_swap.9f
+dev_err.9f := LINKSRC = cmn_err.9f
vcmn_err.9f := LINKSRC = cmn_err.9f
+vzcmn_err.9f := LINKSRC = cmn_err.9f
zcmn_err.9f := LINKSRC = cmn_err.9f
cv_broadcast.9f := LINKSRC = condvar.9f
diff --git a/usr/src/man/man9f/cmn_err.9f b/usr/src/man/man9f/cmn_err.9f
index b58a537ebe..f328df6341 100644
--- a/usr/src/man/man9f/cmn_err.9f
+++ b/usr/src/man/man9f/cmn_err.9f
@@ -1,12 +1,14 @@
'\" te
+.\" Copyright (c) 2014, Nexenta Systems, Inc. All Rights Reserved.
.\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
.\" Copyright 1989 AT&T
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH CMN_ERR 9F "Jan 16, 2006"
+.TH CMN_ERR 9F "Oct 28, 2014"
.SH NAME
-cmn_err, vcmn_err, zcmn_err \- display an error message or panic the system
+cmn_err, dev_err, vcmn_err, zcmn_err, vzcmn_err \-
+display an error message or panic the system
.SH SYNOPSIS
.LP
.nf
@@ -16,7 +18,12 @@ cmn_err, vcmn_err, zcmn_err \- display an error message or panic the system
-\fBvoid\fR \fBcmn_err\fR(\fBint\fR \fIlevel\fR, \fBchar *\fR\fIformat\fR...
+\fBvoid\fR \fBcmn_err\fR(\fBint\fR \fIlevel\fR, \fBchar *\fR\fIformat\fR, ...);
+.fi
+
+.LP
+.nf
+\fBvoid\fR \fBdev_err\fR(\fBdev_info_t\fR \fI*dip\fR, \fBint\fR \fIlevel\fR, \fBchar *\fR\fIformat\fR, ...);
.fi
.LP
@@ -34,16 +41,19 @@ cmn_err, vcmn_err, zcmn_err \- display an error message or panic the system
-\fBvoid\fR \fBzcmn_err\fR(\fBzoneid_t\fR \fIzoneid\fR, \fBint\fR \fIlevel\fR, \fBchar *\fR\fIformat\fR...);
+\fBvoid\fR \fBzcmn_err\fR(\fBzoneid_t\fR \fIzoneid\fR, \fBint\fR \fIlevel\fR, \fBchar *\fR\fIformat\fR, ...);
+.fi
+
+.LP
+.nf
+\fBvoid\fR \fBvzcmn_err\fR(\fBzoneid_t\fR \fIzoneid\fR, \fBint\fR \fIlevel\fR, \fBchar *\fR\fIformat\fR, \fBva_list\fR \fIap\fR);
.fi
.SH INTERFACE LEVEL
-.sp
.LP
Architecture independent level 1 (DDI/DKI).
.SH PARAMETERS
.SS "cmn_err(\|)"
-.sp
.ne 2
.na
\fB\fIlevel\fR\fR
@@ -61,8 +71,20 @@ A constant indicating the severity of the error condition.
Message to be displayed.
.RE
-.SS "vcmn_err(\|)"
+.SS "dev_err(\|)"
+.LP
+The \fBdev_err()\fR function works exactly like \fBcmn_err()\fR, but includes
+an additional argument:
.sp
+.ne 2
+.na
+\fB\fIdip\fR\fR
+.ad
+.RS 10n
+A pointer to the device's \fBdev_info\fR structure.
+.RE
+
+.SS "vcmn_err(\|)"
.LP
The \fBvcmn_err()\fR function takes \fIlevel\fR and \fIformat\fR as described
for \fBcmn_err()\fR, but its third argument is different:
@@ -76,7 +98,6 @@ Variable argument list passed to the function.
.RE
.SS "zcmn_err(\|)"
-.sp
.LP
The \fBzcmn_err()\fR function works exactly like \fBcmn_err()\fR, but includes
an additional argument:
@@ -89,9 +110,21 @@ an additional argument:
Zone to which log messages should be directed. See \fBzones\fR(5).
.RE
+.SS "vzcmn_err(\|)"
+.LP
+The \fBvzcmn_err()\fR function works exactly like \fBvcmn_err()\fR, but includes
+an additional argument:
+.sp
+.ne 2
+.na
+\fB\fIzoneid\fR\fR
+.ad
+.RS 10n
+Zone to which log messages should be directed. See \fBzones\fR(5).
+.RE
+
.SH DESCRIPTION
.SS "cmn_err(\|)"
-.sp
.LP
The \fBcmn_err()\fR function displays a specified message on the console.
\fBcmn_err()\fR can also panic the system. When the system panics, it attempts
@@ -280,7 +313,6 @@ log, but is only written to the console when the system has been booted in
verbose mode. See \fBkernel\fR(1M). If neither condition is met, the '?\|'
character has no effect and is simply ignored.
.RE
-
.sp
.LP
Refer to \fBsyslogd\fR(1M) to determine where the system log is written.
@@ -289,8 +321,14 @@ Refer to \fBsyslogd\fR(1M) to determine where the system log is written.
The \fBcmn_err()\fR function sends log messages to the log of the global zone.
\fBcmn_err()\fR appends a \fB\en\fR to each \fIformat\fR, except when
\fIlevel\fR is \fBCE_CONT\fR.
+.SS "dev_err(\|)"
+.LP
+With the exception of its first argument (\fBdip\fR), \fBdev_err()\fR is
+identical to \fBcmn_err()\fR. \fBdip\fR is a pointer to a device's
+\fBdev_info\fR structure, which is used to prepend the driver name and
+instance number to the message. The driver name and instance number are
+retrieved using \fBddi_driver_name\fR(9F) and \fBddi_get_instance\fR(9F).
.SS "vcmn_err(\|)"
-.sp
.LP
The \fBvcmn_err()\fR function is identical to \fBcmn_err()\fR except that its
last argument, \fIap\fR, is a pointer to a variable list of arguments. \fIap\fR
@@ -300,7 +338,6 @@ contains the list of arguments used by the conversion specifications in
the list. Multiple traversals of the argument list, each bracketed by
\fBva_start\fR(9F) and \fBva_end\fR(9F), are possible.
.SS "zcmn_err(\|)"
-.sp
.LP
With the exception of its first argument (\fBzoneid\fR), \fBzcmn_err()\fR is
identical to \fBcmn_err()\fR. \fBzoneid\fR is the numeric ID of the zone to
@@ -311,8 +348,12 @@ than the log in the global zone. This is accomplished by the message being
received and processed by the \fBsyslogd\fR(1M) process running in the
specified zone instead of the one running in the global zone. You can retrieve
a process zone ID from its credential structure using \fBcrgetzoneid\fR(9F).
+.SS "vzcmn_err(\|)"
+.LP
+With the exception of its first argument (\fBzoneid\fR), \fBvzcmn_err()\fR is
+identical to \fBvcmn_err()\fR. See the description of \fBzcmn_err()\fR
+above for an explanation on how the \fBzoneid\fR argument is handled.
.SH RETURN VALUES
-.sp
.LP
None. However, if an unknown \fIlevel\fR is passed to \fBcmn_err()\fR, the
following panic error message is displayed:
@@ -325,7 +366,6 @@ panic: unknown level in cmn_err (level=\fIlevel\fR, msg=format)
.sp
.SH CONTEXT
-.sp
.LP
The \fBcmn_err()\fR function can be called from user, kernel, interrupt, or
high-level interrupt context.
@@ -458,27 +498,25 @@ messages should instead be sent to the global zone using \fBcmn_err()\fR.
.sp
.in +2
.nf
-zcmn_err(crgetzoneid(ddi_get_cred()), CE_NOTE, "out of processes0);
+zcmn_err(crgetzoneid(ddi_get_cred()), CE_NOTE, "out of processes");
.fi
.in -2
.SH SEE ALSO
-.sp
.LP
\fBdmesg\fR(1M), \fBkernel\fR(1M), \fBprintf\fR(3C), \fBzones\fR(5),
-\fBddi_binding_name\fR(9F), \fBddi_cred\fR(9F), \fBsprintf\fR(9F),
-\fBva_arg\fR(9F), \fBva_end\fR(9F), \fBva_start\fR(9F), \fBvsprintf\fR(9F)
+\fBddi_binding_name\fR(9F), \fBddi_cred\fR(9F), \fBddi_driver_name\fR(9F),
+\fBddi_get_instance\fR(9F), \fBsprintf\fR(9F), \fBva_arg\fR(9F),
+\fBva_end\fR(9F), \fBva_start\fR(9F), \fBvsprintf\fR(9F)
.sp
.LP
\fIWriting Device Drivers\fR
.SH WARNINGS
-.sp
.LP
The \fBcmn_err()\fR function with the \fBCE_CONT\fR argument can be used by
driver developers as a driver code debugging tool. However, using
\fBcmn_err()\fR in this capacity can change system timing characteristics.
.SH NOTES
-.sp
.LP
Messages of arbitrary length can be generated using \fBcmn_err()\fR, but if the
call to \fBcmn_err()\fR is made from high-level interrupt context and
diff --git a/usr/src/pkg/manifests/system-kernel.man9f.inc b/usr/src/pkg/manifests/system-kernel.man9f.inc
index db3f08a3e2..934c066d22 100644
--- a/usr/src/pkg/manifests/system-kernel.man9f.inc
+++ b/usr/src/pkg/manifests/system-kernel.man9f.inc
@@ -866,6 +866,7 @@ link path=usr/share/man/man9f/ddi_umem_free.9f target=ddi_umem_alloc.9f
link path=usr/share/man/man9f/ddi_umem_unlock.9f target=ddi_umem_lock.9f
link path=usr/share/man/man9f/ddi_unmap_regs.9f target=ddi_map_regs.9f
link path=usr/share/man/man9f/desballoc.9f target=esballoc.9f
+link path=usr/share/man/man9f/dev_err.9f target=cmn_err.9f
link path=usr/share/man/man9f/devmap_load.9f target=devmap_unload.9f
link path=usr/share/man/man9f/devmap_umem_setup.9f \
target=devmap_devmem_setup.9f
@@ -1233,5 +1234,6 @@ link path=usr/share/man/man9f/va_copy.9f target=va_arg.9f
link path=usr/share/man/man9f/va_end.9f target=va_arg.9f
link path=usr/share/man/man9f/va_start.9f target=va_arg.9f
link path=usr/share/man/man9f/vcmn_err.9f target=cmn_err.9f
+link path=usr/share/man/man9f/vzcmn_err.9f target=cmn_err.9f
link path=usr/share/man/man9f/wr.9f target=WR.9f
link path=usr/share/man/man9f/zcmn_err.9f target=cmn_err.9f
diff --git a/usr/src/uts/common/os/printf.c b/usr/src/uts/common/os/printf.c
index d47443334f..3ef207d77b 100644
--- a/usr/src/uts/common/os/printf.c
+++ b/usr/src/uts/common/os/printf.c
@@ -22,7 +22,7 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
- * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
#include <sys/param.h>
@@ -70,8 +70,8 @@ static char ce_suffix[CE_IGNORE][2] = { "", "\n", "\n", "" };
static void
cprintf(const char *fmt, va_list adx, int sl, const char *prefix,
- const char *suffix, void *site, int mid, int sid, int level,
- zoneid_t zoneid)
+ const char *suffix, void *site, int mid, int sid, int level,
+ zoneid_t zoneid, dev_info_t *dip)
{
uint32_t msgid;
size_t bufsize = LOG_MSGSIZE;
@@ -112,6 +112,9 @@ retry:
"%s: [ID %u FACILITY_AND_PRIORITY] ",
mod_containing_pc(site), msgid);
msgp += snprintf(msgp, bufend - msgp, prefix);
+ if (dip)
+ msgp += snprintf(msgp, bufend - msgp, "%s%d: ",
+ ddi_driver_name(dip), ddi_get_instance(dip));
msgp += vsnprintf(msgp, bufend - msgp, fmt, adx);
msgp += snprintf(msgp, bufend - msgp, suffix);
len = strlen(body);
@@ -178,7 +181,7 @@ void
vzprintf(zoneid_t zoneid, const char *fmt, va_list adx)
{
cprintf(fmt, adx, SL_CONSOLE | SL_NOTE, "", "", caller(), 0, 0, 0,
- zoneid);
+ zoneid, NULL);
}
void
@@ -195,7 +198,7 @@ printf(const char *fmt, ...)
va_start(adx, fmt);
cprintf(fmt, adx, SL_CONSOLE | SL_NOTE, "", "", caller(), 0, 0, 0,
- GLOBAL_ZONEID);
+ GLOBAL_ZONEID, NULL);
va_end(adx);
}
@@ -207,7 +210,7 @@ zprintf(zoneid_t zoneid, const char *fmt, ...)
va_start(adx, fmt);
cprintf(fmt, adx, SL_CONSOLE | SL_NOTE, "", "", caller(), 0, 0, 0,
- zoneid);
+ zoneid, NULL);
va_end(adx);
}
@@ -219,12 +222,12 @@ vuprintf(const char *fmt, va_list adx)
/* Message the user tty, if any, and the global zone syslog */
cprintf(fmt, adx, SL_CONSOLE | SL_LOGONLY | SL_USER | SL_NOTE,
- "", "", caller(), 0, 0, 0, GLOBAL_ZONEID);
+ "", "", caller(), 0, 0, 0, GLOBAL_ZONEID, NULL);
/* Now message the local zone syslog */
if (!INGLOBALZONE(curproc))
cprintf(fmt, adxcp, SL_CONSOLE | SL_LOGONLY | SL_NOTE,
- "", "", caller(), 0, 0, 0, getzoneid());
+ "", "", caller(), 0, 0, 0, getzoneid(), NULL);
va_end(adxcp);
}
@@ -242,21 +245,28 @@ uprintf(const char *fmt, ...)
va_end(adx);
}
-void
-vzcmn_err(zoneid_t zoneid, int ce, const char *fmt, va_list adx)
+static void
+vzdcmn_err(zoneid_t zoneid, int ce, const char *fmt, va_list adx,
+ dev_info_t *dip)
{
if (ce == CE_PANIC)
vpanic(fmt, adx);
if ((uint_t)ce < CE_IGNORE)
cprintf(fmt, adx, ce_to_sl[ce] | SL_CONSOLE,
ce_prefix[ce], ce_suffix[ce], caller(), 0, 0, 0,
- zoneid);
+ zoneid, dip);
+}
+
+void
+vzcmn_err(zoneid_t zoneid, int ce, const char *fmt, va_list adx)
+{
+ vzdcmn_err(zoneid, ce, fmt, adx, NULL);
}
void
vcmn_err(int ce, const char *fmt, va_list adx)
{
- vzcmn_err(GLOBAL_ZONEID, ce, fmt, adx);
+ vzdcmn_err(GLOBAL_ZONEID, ce, fmt, adx, NULL);
}
/*PRINTFLIKE2*/
@@ -266,12 +276,7 @@ cmn_err(int ce, const char *fmt, ...)
va_list adx;
va_start(adx, fmt);
- if (ce == CE_PANIC)
- vpanic(fmt, adx);
- if ((uint_t)ce < CE_IGNORE)
- cprintf(fmt, adx, ce_to_sl[ce] | SL_CONSOLE,
- ce_prefix[ce], ce_suffix[ce], caller(), 0, 0, 0,
- GLOBAL_ZONEID);
+ vzdcmn_err(GLOBAL_ZONEID, ce, fmt, adx, NULL);
va_end(adx);
}
@@ -282,11 +287,7 @@ zcmn_err(zoneid_t zoneid, int ce, const char *fmt, ...)
va_list adx;
va_start(adx, fmt);
- if (ce == CE_PANIC)
- vpanic(fmt, adx);
- if ((uint_t)ce < CE_IGNORE)
- cprintf(fmt, adx, ce_to_sl[ce] | SL_CONSOLE, ce_prefix[ce],
- ce_suffix[ce], caller(), 0, 0, 0, zoneid);
+ vzdcmn_err(zoneid, ce, fmt, adx, NULL);
va_end(adx);
}
@@ -294,15 +295,11 @@ zcmn_err(zoneid_t zoneid, int ce, const char *fmt, ...)
void
dev_err(dev_info_t *dip, int ce, char *fmt, ...)
{
- va_list ap;
- char buf[LOG_MSGSIZE];
-
- (void) snprintf(buf, sizeof (buf), "%s%d: %s",
- ddi_driver_name(dip), ddi_get_instance(dip), fmt);
+ va_list adx;
- va_start(ap, fmt);
- vcmn_err(ce, buf, ap);
- va_end(ap);
+ va_start(adx, fmt);
+ vzdcmn_err(GLOBAL_ZONEID, ce, fmt, adx, dip);
+ va_end(adx);
}
int
@@ -343,7 +340,7 @@ strlog(short mid, short sid, char level, ushort_t sl, char *fmt, ...)
va_list adx;
va_start(adx, fmt);
cprintf(fmt, adx, sl, "", "", caller(), mid, sid, level,
- GLOBAL_ZONEID);
+ GLOBAL_ZONEID, NULL);
va_end(adx);
}
return (1);
@@ -354,6 +351,6 @@ vstrlog(short mid, short sid, char level, ushort_t sl, char *fmt, va_list adx)
{
if (sl & log_global.lz_active)
cprintf(fmt, adx, sl, "", "", caller(), mid, sid, level,
- GLOBAL_ZONEID);
+ GLOBAL_ZONEID, NULL);
return (1);
}