xref: /illumos-gate/usr/src/man/man3kstat/kstat_open.3kstat (revision fc910014e8a32a65612105835a10995f2c13d942)
1.\"
2.\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved.
3.\" Copyright 2021 Oxide Computer Company
4.\"
5.\" The contents of this file are subject to the terms of the
6.\" Common Development and Distribution License (the "License").
7.\" You may not use this file except in compliance with the License.
8.\"
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.
13.\"
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]
19.\"
20.Dd November 29, 2021
21.Dt KSTAT_OPEN 3KSTAT
22.Os
23.Sh NAME
24.Nm kstat_open ,
25.Nm kstat_close
26.Nd initialize kernel statistics facility
27.Sh LIBRARY
28.Lb libkstat
29.Sh SYNOPSIS
30.In kstat.h
31.Ft "kstat_ctl_t *"
32.Fo kstat_open
33.Fa "void"
34.Fc
35.Ft int
36.Fo kstat_close
37.Fa "kstat_ctl_t *kc"
38.Fc
39.Sh DESCRIPTION
40The
41.Fn kstat_open
42function initializes a kstat control structure that provides access to the
43kernel statistics library.
44It returns a pointer to this structure, which must be supplied as the
45.Fa kc
46argument in subsequent
47.Sy libkstat
48function calls.
49.Pp
50The
51.Fn kstat_close
52function frees all resources that were associated with
53.Fa kc .
54This is performed automatically on
55.Xr exit 2
56and
57.Xr execve 2 .
58.Sh RETURN VALUES
59Upon successful completion,
60.Fn kstat_open
61returns a pointer to a kstat control structure.
62Otherwise, it returns
63.Dv NULL ,
64no resources are allocated, and
65.Va errno
66is set to indicate the error.
67.Pp
68Upon successful completion,
69.Fn kstat_close
70returns
71.Sy 0 .
72Otherwise,
73.Sy -1
74is returned and
75.Va errno
76is set to indicate the error.
77.Sh FILES
78.Bl -tag -width Pa
79.It Pa /dev/kstat
80kernel statistics driver character device
81.El
82.Sh ERRORS
83The
84.Fn kstat_open
85function will fail if:
86.Bl -tag -width Er
87.It Er ENOMEM
88Insufficient storage space is available.
89.It Er EAGAIN
90The kstat was temporarily unavailable for reading or writing.
91.It Er ENXIO
92The given kstat could not be located for reading.
93.It Er EOVERFLOW
94The data for the given kstat was too large to be stored in the structure.
95.El
96.Pp
97The
98.Fn kstat_open
99function can also return the error values for
100.Xr open 2 .
101.Pp
102The
103.Fn kstat_close
104function can also return the error values for
105.Xr close 2 .
106.Sh INTERFACE STABILITY
107.Sy Committed
108.Sh MT-LEVEL
109.Sy Unsafe
110.Sh SEE ALSO
111.Xr close 2 ,
112.Xr execve 2 ,
113.Xr exit 2 ,
114.Xr open 2 ,
115.Xr kstat 3KSTAT ,
116.Xr kstat_chain_update 3KSTAT ,
117.Xr kstat_lookup 3KSTAT ,
118.Xr kstat_read 3KSTAT ,
119.Xr attributes 7
120