ohmu
·
2026-10-15
1#pragma once
2
3#include "fastfetch.h"
4
5// From https://github.com/openzfs/zfs/blob/master/include/libzfs.h
6
7/*
8 * CDDL HEADER START
9 *
10 * The contents of this file are subject to the terms of the
11 * Common Development and Distribution License (the "License").
12 * You may not use this file except in compliance with the License.
13 *
14 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
15 * or https://opensource.org/licenses/CDDL-1.0.
16 * See the License for the specific language governing permissions
17 * and limitations under the License.
18 *
19 * When distributing Covered Code, include this CDDL HEADER in each
20 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
21 * If applicable, add the following below this CDDL HEADER, with the
22 * fields enclosed by brackets "[]" replaced with your own identifying
23 * information: Portions Copyright [yyyy] [name of copyright owner]
24 *
25 * CDDL HEADER END
26 */
27
28// zpool_prop_t and zprop_source_t were previously enums in upstream OpenZFS.
29// However, the enum values for these types vary greatly between different platforms,
30// making it unsafe to use the enum values directly. To ensure portability,
31// we define them as simple int typedefs and use zpool_name_to_prop to look up
32// the correct value for a property at runtime.
33typedef int zpool_prop_t;
34typedef int zprop_source_t;
35typedef int boolean_t;
36
37typedef struct libzfs_handle libzfs_handle_t;
38typedef struct zpool_handle zpool_handle_t;
39typedef int (*zpool_iter_f)(zpool_handle_t*, void*);
40
41extern libzfs_handle_t* libzfs_init(void);
42extern void libzfs_fini(libzfs_handle_t*);
43extern int zpool_iter(libzfs_handle_t*, zpool_iter_f, void*);
44extern zpool_prop_t zpool_name_to_prop(const char*);
45// https://github.com/openzfs/zfs/blob/06c73cffabc30b61a695988ec8e290f43cb3768d/lib/libzfs/libzfs_pool.c#L300
46extern uint64_t zpool_get_prop_int(zpool_handle_t* zhp, zpool_prop_t prop, zprop_source_t* srctype);
47extern int zpool_get_prop(zpool_handle_t* zhp, zpool_prop_t prop, char* buf, size_t len, zprop_source_t* srctype, boolean_t literal);
48extern void zpool_close(zpool_handle_t*);