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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
.\"
.\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved.
.\" Copyright 2021 Oxide Computer Company
.\"
.\" 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]
.\"
.Dd November 29, 2021
.Dt KSTAT_OPEN 3KSTAT
.Os
.Sh NAME
.Nm kstat_open ,
.Nm kstat_close
.Nd initialize kernel statistics facility
.Sh LIBRARY
.Lb libkstat
.Sh SYNOPSIS
.In kstat.h
.Ft "kstat_ctl_t *"
.Fo kstat_open
.Fa "void"
.Fc
.Ft int
.Fo kstat_close
.Fa "kstat_ctl_t *kc"
.Fc
.Sh DESCRIPTION
The
.Fn kstat_open
function initializes a kstat control structure that provides access to the
kernel statistics library.
It returns a pointer to this structure, which must be supplied as the
.Fa kc
argument in subsequent
.Sy libkstat
function calls.
.Pp
The
.Fn kstat_close
function frees all resources that were associated with
.Fa kc .
This is performed automatically on
.Xr exit 2
and
.Xr execve 2 .
.Sh RETURN VALUES
Upon successful completion,
.Fn kstat_open
returns a pointer to a kstat control structure.
Otherwise, it returns
.Dv NULL ,
no resources are allocated, and
.Va errno
is set to indicate the error.
.Pp
Upon successful completion,
.Fn kstat_close
returns
.Sy 0 .
Otherwise,
.Sy -1
is returned and
.Va errno
is set to indicate the error.
.Sh FILES
.Bl -tag -width Pa
.It Pa /dev/kstat
kernel statistics driver character device
.El
.Sh ERRORS
The
.Fn kstat_open
function will fail if:
.Bl -tag -width Er
.It Er ENOMEM
Insufficient storage space is available.
.It Er EAGAIN
The kstat was temporarily unavailable for reading or writing.
.It Er ENXIO
The given kstat could not be located for reading.
.It Er EOVERFLOW
The data for the given kstat was too large to be stored in the structure.
.El
.Pp
The
.Fn kstat_open
function can also return the error values for
.Xr open 2 .
.Pp
The
.Fn kstat_close
function can also return the error values for
.Xr close 2 .
.Sh INTERFACE STABILITY
.Sy Committed
.Sh MT-LEVEL
.Sy Unsafe
.Sh SEE ALSO
.Xr close 2 ,
.Xr execve 2 ,
.Xr exit 2 ,
.Xr open 2 ,
.Xr kstat 3KSTAT ,
.Xr kstat_chain_update 3KSTAT ,
.Xr kstat_lookup 3KSTAT ,
.Xr kstat_read 3KSTAT ,
.Xr attributes 5
|