9075 Improve ZFS pool import/load process and corrupted pool recovery
[unleashed.git] / usr / src / common / smbios / smb_error.c
blob7c0ad4ddbfd9b886cd6f1d2a2e9ec76f9130314a
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
24 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
28 #pragma ident "%Z%%M% %I% %E% SMI"
30 #include <sys/smbios_impl.h>
32 static const char *const _smb_errlist[] = {
33 "System does not export an SMBIOS table", /* ESMB_NOTFOUND */
34 "Failed to map SMBIOS table", /* ESMB_MAPDEV */
35 "Failed to locate specified structure", /* ESMB_NOENT */
36 "Failed to allocate memory", /* ESMB_NOMEM */
37 "Failed to read SMBIOS entry point", /* ESMB_NOHDR */
38 "Failed to read SMBIOS structure table", /* ESMB_NOSTAB */
39 "Generic info not available for structure", /* ESMB_NOINFO */
40 "Structure table is shorter than expected", /* ESMB_SHORT */
41 "SMBIOS data structure is corrupted", /* ESMB_CORRUPT */
42 "Requested library version is not supported", /* ESMB_VERSION */
43 "Structure type is not supported by this BIOS", /* ESMB_NOTSUP */
44 "Header is not a valid SMBIOS entry point", /* ESMB_HEADER */
45 "SMBIOS format is too old for processing", /* ESMB_OLD */
46 "SMBIOS format is new and not yet supported", /* ESMB_NEW */
47 "SMBIOS header checksum mismatch", /* ESMB_CKSUM */
48 "Invalid argument specified in library call", /* ESMB_INVAL */
49 "Structure is not of the expected type", /* ESMB_TYPE */
50 "Unknown SMBIOS error" /* ESMB_UNKNOWN */
53 static const int _smb_nerr = sizeof (_smb_errlist) / sizeof (_smb_errlist[0]);
55 const char *
56 smbios_errmsg(int error)
58 const char *str;
60 if (error >= ESMB_BASE && (error - ESMB_BASE) < _smb_nerr)
61 str = _smb_errlist[error - ESMB_BASE];
62 else
63 str = smb_strerror(error);
65 return (str ? str : "Unknown error");
68 int
69 smbios_errno(smbios_hdl_t *shp)
71 return (shp->sh_err);
74 int
75 smb_set_errno(smbios_hdl_t *shp, int error)
77 shp->sh_err = error;
78 return (SMB_ERR);