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
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]
23 * Copyright (c) 1994, by Sun Microsytems, Inc.
26 #pragma ident "%Z%%M% %I% %E% SMI"
29 * Error code manipulation routines
36 #include "tnfctl_int.h"
39 #if !defined(TEXT_DOMAIN)
40 #define TEXT_DOMAIN "SYS_TEST"
45 * tnfctl_strerror() - this routine returns a pointer to a static string
46 * describing the error argument.
49 tnfctl_strerror(tnfctl_errcode_t prexstat
)
53 return (dgettext(TEXT_DOMAIN
, "Success"));
54 case TNFCTL_ERR_ACCES
:
55 return (dgettext(TEXT_DOMAIN
, "Permission denied"));
56 case TNFCTL_ERR_NOTARGET
:
57 return (dgettext(TEXT_DOMAIN
, "Target process finished"));
58 case TNFCTL_ERR_ALLOCFAIL
:
59 return (dgettext(TEXT_DOMAIN
, "Memory allocation failed"));
60 case TNFCTL_ERR_INTERNAL
:
61 return (dgettext(TEXT_DOMAIN
, "Internal error"));
62 case TNFCTL_ERR_SIZETOOSMALL
:
63 return (dgettext(TEXT_DOMAIN
, "Requested size too small"));
64 case TNFCTL_ERR_SIZETOOBIG
:
65 return (dgettext(TEXT_DOMAIN
, "Requested size too big"));
66 case TNFCTL_ERR_BADARG
:
67 return (dgettext(TEXT_DOMAIN
, "Bad input argument"));
68 case TNFCTL_ERR_NOTDYNAMIC
:
69 return (dgettext(TEXT_DOMAIN
, "Not a dynamic executable"));
70 case TNFCTL_ERR_NOLIBTNFPROBE
:
71 return (dgettext(TEXT_DOMAIN
,
72 "No libtnfprobe linked in target"));
73 case TNFCTL_ERR_BUFEXISTS
:
74 return (dgettext(TEXT_DOMAIN
, "Buffer already exists"));
75 case TNFCTL_ERR_NOBUF
:
76 return (dgettext(TEXT_DOMAIN
, "No buffer exists"));
77 case TNFCTL_ERR_BADDEALLOC
:
78 return (dgettext(TEXT_DOMAIN
, "Can't deallocate buffer when "
79 "tracing is active"));
80 case TNFCTL_ERR_NOPROCESS
:
81 return (dgettext(TEXT_DOMAIN
, "Process not found"));
82 case TNFCTL_ERR_FILENOTFOUND
:
83 return (dgettext(TEXT_DOMAIN
, "No such file"));
85 return (dgettext(TEXT_DOMAIN
,
86 "Device busy - kernel or process already tracing"));
87 case TNFCTL_ERR_INVALIDPROBE
:
88 return (dgettext(TEXT_DOMAIN
, "Invalid probe specified"));
90 return (dgettext(TEXT_DOMAIN
, "User error 1"));
92 return (dgettext(TEXT_DOMAIN
, "User error 2"));
94 return (dgettext(TEXT_DOMAIN
, "User error 3"));
96 return (dgettext(TEXT_DOMAIN
, "User error 4"));
98 return (dgettext(TEXT_DOMAIN
, "User error 5"));
100 return (dgettext(TEXT_DOMAIN
,
101 "Unknown libtnfctl.so error code"));
106 * prb_map_to_errocde() - this routine returns maps an internal error code
107 * to a tnfctl_errcode_t
110 _tnfctl_map_to_errcode(prb_status_t prbstat
)
112 tnfctl_errcode_t err
= TNFCTL_ERR_INTERNAL
;
114 if (prbstat
>= PRB_STATUS_MINERRNO
&&
115 prbstat
<= PRB_STATUS_MAXERRNO
) {
116 if (prbstat
== ENOENT
)
117 err
= TNFCTL_ERR_FILENOTFOUND
;
118 else if (prbstat
== ESRCH
)
119 err
= TNFCTL_ERR_NOPROCESS
;
120 else if (prbstat
== EACCES
)
121 err
= TNFCTL_ERR_ACCES
;
122 else if (prbstat
== EBUSY
)
123 err
= TNFCTL_ERR_BUSY
;
125 if (prbstat
== PRB_STATUS_OK
)
126 err
= TNFCTL_ERR_NONE
;
127 else if (prbstat
== PRB_STATUS_ALLOCFAIL
)
128 err
= TNFCTL_ERR_ALLOCFAIL
;
135 * tnfctl_status_map() - this routine converts an errno value into a
139 tnfctl_status_map(int val
)
141 tnfctl_errcode_t err
= TNFCTL_ERR_INTERNAL
;
144 err
= TNFCTL_ERR_FILENOTFOUND
;
145 else if (val
== ESRCH
)
146 err
= TNFCTL_ERR_NOPROCESS
;
147 else if (val
== EACCES
)
148 err
= TNFCTL_ERR_ACCES
;
149 else if (val
== EBUSY
)
150 err
= TNFCTL_ERR_BUSY
;