xref: /freebsd/sys/contrib/openzfs/lib/libspl/include/sys/tunables.h (revision 4303bde4297a3d19cabdb08ce1550f682578d2ba)
1 // SPDX-License-Identifier: CDDL-1.0
2 /*
3  * CDDL HEADER START
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 https://opensource.org/licenses/CDDL-1.0.
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  * CDDL HEADER END
21  */
22 
23 /*
24  * Copyright (c) 2025, Rob Norris <robn@despairlabs.com>
25  */
26 
27 #ifndef _SYS_TUNABLES_H
28 //#define	_SYS_TUNABLES_H extern __attribute__((visibility("hidden")))
29 #define _SYS_TUNABLES_H extern
30 
31 typedef enum {
32 	ZFS_TUNABLE_TYPE_INT,
33 	ZFS_TUNABLE_TYPE_UINT,
34 	ZFS_TUNABLE_TYPE_ULONG,
35 	ZFS_TUNABLE_TYPE_U64,
36 	ZFS_TUNABLE_TYPE_STRING,
37 } zfs_tunable_type_t;
38 
39 typedef enum {
40 	ZFS_TUNABLE_PERM_ZMOD_RW,
41 	ZFS_TUNABLE_PERM_ZMOD_RD,
42 } zfs_tunable_perm_t;
43 
44 typedef struct zfs_tunable {
45 	const char		*zt_name;
46 	void			*zt_varp;
47 	size_t			zt_varsz;
48 	zfs_tunable_type_t	zt_type;
49 	zfs_tunable_perm_t	zt_perm;
50 	const char		*zt_desc;
51 } zfs_tunable_t;
52 
53 _SYS_TUNABLES_H int zfs_tunable_set(const zfs_tunable_t *tunable,
54     const char *val);
55 _SYS_TUNABLES_H int zfs_tunable_get(const zfs_tunable_t *tunable, char *val,
56     size_t valsz);
57 
58 _SYS_TUNABLES_H const zfs_tunable_t *zfs_tunable_lookup(const char *name);
59 
60 typedef int (*zfs_tunable_iter_t)(const zfs_tunable_t *tunable, void *arg);
61 _SYS_TUNABLES_H void zfs_tunable_iter(zfs_tunable_iter_t cb, void *arg);
62 
63 #endif
64