Path: blob/main/sys/contrib/openzfs/include/zfs_prop.h
48254 views
// SPDX-License-Identifier: CDDL-1.01/*2* CDDL HEADER START3*4* The contents of this file are subject to the terms of the5* Common Development and Distribution License (the "License").6* You may not use this file except in compliance with the License.7*8* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE9* or https://opensource.org/licenses/CDDL-1.0.10* See the License for the specific language governing permissions11* and limitations under the License.12*13* When distributing Covered Code, include this CDDL HEADER in each14* file and include the License file at usr/src/OPENSOLARIS.LICENSE.15* If applicable, add the following below this CDDL HEADER, with the16* fields enclosed by brackets "[]" replaced with your own identifying17* information: Portions Copyright [yyyy] [name of copyright owner]18*19* CDDL HEADER END20*/21/*22* Copyright 2010 Sun Microsystems, Inc. All rights reserved.23* Use is subject to license terms.24*/2526#ifndef _ZFS_PROP_H27#define _ZFS_PROP_H extern __attribute__((visibility("default")))2829#include <sys/fs/zfs.h>30#include <sys/types.h>31#include <sys/zfs_sysfs.h>3233#ifdef __cplusplus34extern "C" {35#endif3637/*38* For index types (e.g. compression and checksum), we want the numeric value39* in the kernel, but the string value in userland.40*/41typedef enum {42PROP_TYPE_NUMBER, /* numeric value */43PROP_TYPE_STRING, /* string value */44PROP_TYPE_INDEX /* numeric value indexed by string */45} zprop_type_t;4647typedef enum {48PROP_DEFAULT,49PROP_READONLY,50PROP_INHERIT,51/*52* ONETIME properties are a sort of conglomeration of READONLY53* and INHERIT. They can be set only during object creation,54* after that they are READONLY. If not explicitly set during55* creation, they can be inherited. ONETIME_DEFAULT properties56* work the same way, but they will default instead of57* inheriting a value.58*/59PROP_ONETIME,60PROP_ONETIME_DEFAULT61} zprop_attr_t;6263typedef struct zfs_index {64const char *pi_name;65uint64_t pi_value;66} zprop_index_t;6768typedef struct {69const char *pd_name; /* human-readable property name */70int pd_propnum; /* property number */71zprop_type_t pd_proptype; /* string, boolean, index, number */72const char *pd_strdefault; /* default for strings */73uint64_t pd_numdefault; /* for boolean / index / number */74zprop_attr_t pd_attr; /* default, readonly, inherit */75int pd_types; /* bitfield of valid dataset types */76/* fs | vol | snap; or pool */77const char *pd_values; /* string telling acceptable values */78const char *pd_colname; /* column header for "zfs list" */79boolean_t pd_rightalign: 1; /* column alignment for "zfs list" */80boolean_t pd_visible: 1; /* do we list this property with the */81/* "zfs get" help message */82boolean_t pd_zfs_mod_supported: 1; /* supported by running zfs module */83boolean_t pd_always_flex: 1; /* never fixed-width */84const zprop_index_t *pd_table; /* for index properties, a table */85/* defining the possible values */86size_t pd_table_size; /* number of entries in pd_table[] */87} zprop_desc_t;8889/*90* zfs dataset property functions91*/92_ZFS_PROP_H void zfs_prop_init(void);93_ZFS_PROP_H zprop_type_t zfs_prop_get_type(zfs_prop_t);94_ZFS_PROP_H boolean_t zfs_prop_delegatable(zfs_prop_t prop);95_ZFS_PROP_H zprop_desc_t *zfs_prop_get_table(void);9697/*98* zpool property functions99*/100_ZFS_PROP_H void zpool_prop_init(void);101_ZFS_PROP_H zprop_type_t zpool_prop_get_type(zpool_prop_t);102_ZFS_PROP_H zprop_desc_t *zpool_prop_get_table(void);103104/*105* vdev property functions106*/107_ZFS_PROP_H void vdev_prop_init(void);108_ZFS_PROP_H zprop_type_t vdev_prop_get_type(vdev_prop_t prop);109_ZFS_PROP_H zprop_desc_t *vdev_prop_get_table(void);110111/*112* Common routines to initialize property tables113*/114_ZFS_PROP_H void zprop_register_impl(int, const char *, zprop_type_t, uint64_t,115const char *, zprop_attr_t, int, const char *, const char *,116boolean_t, boolean_t, boolean_t, const zprop_index_t *,117const struct zfs_mod_supported_features *);118_ZFS_PROP_H void zprop_register_string(int, const char *, const char *,119zprop_attr_t attr, int, const char *, const char *,120const struct zfs_mod_supported_features *);121_ZFS_PROP_H void zprop_register_number(int, const char *, uint64_t,122zprop_attr_t, int, const char *, const char *, boolean_t,123const struct zfs_mod_supported_features *);124_ZFS_PROP_H void zprop_register_index(int, const char *, uint64_t, zprop_attr_t,125int, const char *, const char *, const zprop_index_t *,126const struct zfs_mod_supported_features *);127_ZFS_PROP_H void zprop_register_hidden(int, const char *, zprop_type_t,128zprop_attr_t, int, const char *, boolean_t,129const struct zfs_mod_supported_features *);130131/*132* Common routines for zfs and zpool property management133*/134_ZFS_PROP_H int zprop_iter_common(zprop_func, void *, boolean_t, boolean_t,135zfs_type_t);136_ZFS_PROP_H int zprop_name_to_prop(const char *, zfs_type_t);137_ZFS_PROP_H int zprop_string_to_index(int, const char *, uint64_t *,138zfs_type_t);139_ZFS_PROP_H int zprop_index_to_string(int, uint64_t, const char **,140zfs_type_t);141_ZFS_PROP_H uint64_t zprop_random_value(int, uint64_t, zfs_type_t);142_ZFS_PROP_H const char *zprop_values(int, zfs_type_t);143_ZFS_PROP_H size_t zprop_width(int, boolean_t *, zfs_type_t);144_ZFS_PROP_H boolean_t zprop_valid_for_type(int, zfs_type_t, boolean_t);145_ZFS_PROP_H int zprop_valid_char(char c);146147#ifdef __cplusplus148}149#endif150151#endif /* _ZFS_PROP_H */152153154