1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
'\" te
.\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved.
.\" 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 KSTAT_LOOKUP 3KSTAT "March 24, 2020"
.SH NAME
kstat_lookup, kstat_data_lookup \- find a kstat by name
.SH SYNOPSIS
.nf
\fBcc\fR [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-lkstat\fR [ \fIlibrary\fR\&.\|.\|.]
#include <kstat.h>
\fBkstat_t *\fR\fBkstat_lookup\fR(\fBkstat_ctl_t *\fR\fIkc\fR, \fBchar *\fR\fIks_module\fR, \fBint\fR \fIks_instance\fR,
\fBchar *\fR\fIks_name\fR);
.fi
.LP
.nf
\fBvoid *\fR\fBkstat_data_lookup\fR(\fBkstat_t *\fR\fIksp\fR, \fBchar *\fR\fIname\fR);
.fi
.SH DESCRIPTION
The \fBkstat_lookup()\fR function traverses the kstat chain,
\fIkc\fR->\fBkc_chain\fR, searching for a kstat with the same \fIks_module\fR,
\fIks_instance\fR, and \fIks_name\fR fields; this triplet uniquely identifies a
kstat. If \fIks_module\fR is \fINULL\fR, \fIks_instance\fR is -1, or
\fIks_name\fR is \fINULL\fR, those fields will be ignored in the search. For
example, \fBkstat_lookup(kc, NULL, -1, "foo")\fR will find the first kstat
with name "foo".
.sp
.LP
The \fBkstat_data_lookup()\fR function searches the kstat's data section for
the record with the specified \fIname\fR. This operation is valid only for
those kstat types that have named data records: \fBKSTAT_TYPE_NAMED\fR and
\fBKSTAT_TYPE_TIMER\fR.
.SS Lifetime
The \fBkstat_t\fR structures and any associated data are owned by the library
and the corresponding handle, \fIkc\fR. That is, two callers with same library
handle will generally have the same memory returned to them, though this is not
a guaranteed part of the interface. Callers should not modify or attempt to free
the data associated with either. Calling the \fBkstat_chain_update\fR(3KSTAT) or
\fBkstat_close\fR(3KSTAT) functions on the handle \fIkc\fR will cause the
pointers returned from these functions with the same handle to be invalid.
.SH RETURN VALUES
The \fBkstat_lookup()\fR function returns a pointer to the requested kstat if
it is found. Otherwise it returns \fINULL\fR and sets \fBerrno\fR to indicate
the error.
.sp
.LP
The \fBkstat_data_lookup()\fR function returns a pointer to the requested data
record if it is found. Otherwise it returns \fINULL\fR and sets \fBerrno\fR to
indicate the error .
.SH ERRORS
The \fBkstat_lookup()\fR and \fBkstat_data_lookup()\fR functions will fail if:
.sp
.ne 2
.na
\fB\fBEINVAL\fR\fR
.ad
.RS 10n
An attempt was made to look up data for a kstat that was not of type
\fBKSTAT_TYPE_NAMED\fR or \fBKSTAT_TYPE_TIMER\fR.
.RE
.sp
.ne 2
.na
\fB\fBENOENT\fR\fR
.ad
.RS 10n
The requested kstat could not be found.
.RE
.SH FILES
.ne 2
.na
\fB\fB/dev/kstat\fR\fR
.ad
.RS 14n
kernel statistics driver
.RE
.SH ATTRIBUTES
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
Interface Stability Stable
_
MT-Level Unsafe
.TE
.SH SEE ALSO
\fBkstat\fR(3KSTAT), \fBkstat_chain_update\fR(3KSTAT),
\fBkstat_open\fR(3KSTAT), \fBkstat_read\fR(3KSTAT), \fBattributes\fR(5)
|