2 .\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved.
3 .\" 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.
4 .\" 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.
5 .\" 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]
6 .TH KSTAT_READ 3KSTAT "Aug 3, 2004"
8 kstat_read, kstat_write \- read or write kstat data
12 \fBcc\fR [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-lkstat\fR [ \fIlibrary\fR\&.\|.\|. ]
15 \fBkid_t\fR \fBkstat_read\fR(\fBkstat_ctl_t *\fR\fIkc\fR, \fBkstat_t *\fR\fIksp\fR, \fBvoid *\fR\fIbuf\fR);
20 \fBkid_t\fR \fBkstat_write\fR(\fBkstat_ctl_t *\fR\fIkc\fR, \fBkstat_t *\fR\fIksp\fR, \fBvoid *\fR\fIbuf\fR);
26 The \fBkstat_read()\fR function gets data from the kernel for the kstat pointed
27 to by \fIksp\fR. The \fIksp\fR->\fBks_data\fR field is automatically allocated
28 (or reallocated) to be large enough to hold all of the data. The
29 \fIksp\fR->\fBks_ndata\fR field is set to the number of data fields,
30 \fIksp\fR->\fBks_data_size\fR is set to the total size of the data, and
31 \fIksp\fR->\fBks_snaptime\fR is set to the high-resolution time at which the
32 data snapshot was taken. If \fIbuf\fR is non-null, the data is copied from
33 \fIksp\fR->\fBks_data\fR to \fIbuf\fR.
36 The \fBkstat_write()\fR function writes data from \fIbuf\fR, or from
37 \fIksp\fR->\fBks_data\fR if \fIbuf\fR is \fINULL\fR, to the corresponding kstat
38 in the kernel. Only the superuser can use \fBkstat_write()\fR.
42 Upon successful completion, \fBkstat_read()\fR and \fBkstat_write()\fR return
43 the current kstat chain ID (KCID). Otherwise, they return \(mi1 and set
44 \fBerrno\fR to indicate the error.
48 The \fBkstat_read()\fR and \fBkstat_write()\fR functions will fail if:
55 An attempt was made to write to a non-writable kstat.
64 The kstat was temporarily unavailable for reading or writing.
73 An attempt was made to write data to a kstat, but the number of elements or the
74 data size does not match.
83 Insufficient storage space is available.
92 The given kstat could not be located for reading or writing.
101 The data for the given kstat was too large to be stored in the structure.
110 An attempt was made to write to a kstat, but {\fBPRIV_SYS_CONFIG\fR} was not
111 asserted in the effective privilege set.
118 \fB\fB/dev/kstat\fR\fR
121 kernel statistics driver
127 See \fBattributes\fR(5) for descriptions of the following attributes:
135 ATTRIBUTE TYPE ATTRIBUTE VALUE
137 Interface Stability Stable
145 \fBkstat\fR(3KSTAT), \fBkstat_chain_update\fR(3KSTAT),
146 \fBkstat_lookup\fR(3KSTAT), \fBkstat_open\fR(3KSTAT), \fBattributes\fR(5),