1eda14cbcSMatt Macy /* 2eda14cbcSMatt Macy * CDDL HEADER START 3eda14cbcSMatt Macy * 4eda14cbcSMatt Macy * The contents of this file are subject to the terms of the 5eda14cbcSMatt Macy * Common Development and Distribution License (the "License"). 6eda14cbcSMatt Macy * You may not use this file except in compliance with the License. 7eda14cbcSMatt Macy * 8eda14cbcSMatt Macy * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9eda14cbcSMatt Macy * or http://www.opensolaris.org/os/licensing. 10eda14cbcSMatt Macy * See the License for the specific language governing permissions 11eda14cbcSMatt Macy * and limitations under the License. 12eda14cbcSMatt Macy * 13eda14cbcSMatt Macy * When distributing Covered Code, include this CDDL HEADER in each 14eda14cbcSMatt Macy * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15eda14cbcSMatt Macy * If applicable, add the following below this CDDL HEADER, with the 16eda14cbcSMatt Macy * fields enclosed by brackets "[]" replaced with your own identifying 17eda14cbcSMatt Macy * information: Portions Copyright [yyyy] [name of copyright owner] 18eda14cbcSMatt Macy * 19eda14cbcSMatt Macy * CDDL HEADER END 20eda14cbcSMatt Macy */ 21eda14cbcSMatt Macy /* 22eda14cbcSMatt Macy * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 23eda14cbcSMatt Macy * Use is subject to license terms. 24eda14cbcSMatt Macy */ 25eda14cbcSMatt Macy 26eda14cbcSMatt Macy #ifndef _ZFS_PROP_H 2716038816SMartin Matuska #define _ZFS_PROP_H extern __attribute__((visibility("default"))) 28eda14cbcSMatt Macy 29eda14cbcSMatt Macy #include <sys/fs/zfs.h> 30eda14cbcSMatt Macy #include <sys/types.h> 31*e92ffd9bSMartin Matuska #include <sys/zfs_sysfs.h> 32eda14cbcSMatt Macy 33eda14cbcSMatt Macy #ifdef __cplusplus 34eda14cbcSMatt Macy extern "C" { 35eda14cbcSMatt Macy #endif 36eda14cbcSMatt Macy 37eda14cbcSMatt Macy /* 38eda14cbcSMatt Macy * For index types (e.g. compression and checksum), we want the numeric value 39eda14cbcSMatt Macy * in the kernel, but the string value in userland. 40eda14cbcSMatt Macy */ 41eda14cbcSMatt Macy typedef enum { 42eda14cbcSMatt Macy PROP_TYPE_NUMBER, /* numeric value */ 43eda14cbcSMatt Macy PROP_TYPE_STRING, /* string value */ 44eda14cbcSMatt Macy PROP_TYPE_INDEX /* numeric value indexed by string */ 45eda14cbcSMatt Macy } zprop_type_t; 46eda14cbcSMatt Macy 47eda14cbcSMatt Macy typedef enum { 48eda14cbcSMatt Macy PROP_DEFAULT, 49eda14cbcSMatt Macy PROP_READONLY, 50eda14cbcSMatt Macy PROP_INHERIT, 51eda14cbcSMatt Macy /* 52eda14cbcSMatt Macy * ONETIME properties are a sort of conglomeration of READONLY 53eda14cbcSMatt Macy * and INHERIT. They can be set only during object creation, 54eda14cbcSMatt Macy * after that they are READONLY. If not explicitly set during 55eda14cbcSMatt Macy * creation, they can be inherited. ONETIME_DEFAULT properties 56eda14cbcSMatt Macy * work the same way, but they will default instead of 57eda14cbcSMatt Macy * inheriting a value. 58eda14cbcSMatt Macy */ 59eda14cbcSMatt Macy PROP_ONETIME, 60eda14cbcSMatt Macy PROP_ONETIME_DEFAULT 61eda14cbcSMatt Macy } zprop_attr_t; 62eda14cbcSMatt Macy 63eda14cbcSMatt Macy typedef struct zfs_index { 64eda14cbcSMatt Macy const char *pi_name; 65eda14cbcSMatt Macy uint64_t pi_value; 66eda14cbcSMatt Macy } zprop_index_t; 67eda14cbcSMatt Macy 68eda14cbcSMatt Macy typedef struct { 69eda14cbcSMatt Macy const char *pd_name; /* human-readable property name */ 70eda14cbcSMatt Macy int pd_propnum; /* property number */ 71eda14cbcSMatt Macy zprop_type_t pd_proptype; /* string, boolean, index, number */ 72eda14cbcSMatt Macy const char *pd_strdefault; /* default for strings */ 73eda14cbcSMatt Macy uint64_t pd_numdefault; /* for boolean / index / number */ 74eda14cbcSMatt Macy zprop_attr_t pd_attr; /* default, readonly, inherit */ 75eda14cbcSMatt Macy int pd_types; /* bitfield of valid dataset types */ 76eda14cbcSMatt Macy /* fs | vol | snap; or pool */ 77eda14cbcSMatt Macy const char *pd_values; /* string telling acceptable values */ 78eda14cbcSMatt Macy const char *pd_colname; /* column header for "zfs list" */ 79eda14cbcSMatt Macy boolean_t pd_rightalign; /* column alignment for "zfs list" */ 80eda14cbcSMatt Macy boolean_t pd_visible; /* do we list this property with the */ 81eda14cbcSMatt Macy /* "zfs get" help message */ 82eda14cbcSMatt Macy boolean_t pd_zfs_mod_supported; /* supported by running zfs module */ 83eda14cbcSMatt Macy const zprop_index_t *pd_table; /* for index properties, a table */ 84eda14cbcSMatt Macy /* defining the possible values */ 85eda14cbcSMatt Macy size_t pd_table_size; /* number of entries in pd_table[] */ 86eda14cbcSMatt Macy } zprop_desc_t; 87eda14cbcSMatt Macy 88eda14cbcSMatt Macy /* 89eda14cbcSMatt Macy * zfs dataset property functions 90eda14cbcSMatt Macy */ 9116038816SMartin Matuska _ZFS_PROP_H void zfs_prop_init(void); 9216038816SMartin Matuska _ZFS_PROP_H zprop_type_t zfs_prop_get_type(zfs_prop_t); 9316038816SMartin Matuska _ZFS_PROP_H boolean_t zfs_prop_delegatable(zfs_prop_t prop); 9416038816SMartin Matuska _ZFS_PROP_H zprop_desc_t *zfs_prop_get_table(void); 95eda14cbcSMatt Macy 96eda14cbcSMatt Macy /* 97eda14cbcSMatt Macy * zpool property functions 98eda14cbcSMatt Macy */ 9916038816SMartin Matuska _ZFS_PROP_H void zpool_prop_init(void); 10016038816SMartin Matuska _ZFS_PROP_H zprop_type_t zpool_prop_get_type(zpool_prop_t); 10116038816SMartin Matuska _ZFS_PROP_H zprop_desc_t *zpool_prop_get_table(void); 102eda14cbcSMatt Macy 103eda14cbcSMatt Macy /* 104681ce946SMartin Matuska * vdev property functions 105681ce946SMartin Matuska */ 106681ce946SMartin Matuska _ZFS_PROP_H void vdev_prop_init(void); 107681ce946SMartin Matuska _ZFS_PROP_H zprop_type_t vdev_prop_get_type(vdev_prop_t prop); 108681ce946SMartin Matuska _ZFS_PROP_H zprop_desc_t *vdev_prop_get_table(void); 109681ce946SMartin Matuska 110681ce946SMartin Matuska /* 111eda14cbcSMatt Macy * Common routines to initialize property tables 112eda14cbcSMatt Macy */ 11316038816SMartin Matuska _ZFS_PROP_H void zprop_register_impl(int, const char *, zprop_type_t, uint64_t, 114eda14cbcSMatt Macy const char *, zprop_attr_t, int, const char *, const char *, 115*e92ffd9bSMartin Matuska boolean_t, boolean_t, const zprop_index_t *, 116*e92ffd9bSMartin Matuska const struct zfs_mod_supported_features *); 11716038816SMartin Matuska _ZFS_PROP_H void zprop_register_string(int, const char *, const char *, 118*e92ffd9bSMartin Matuska zprop_attr_t attr, int, const char *, const char *, 119*e92ffd9bSMartin Matuska const struct zfs_mod_supported_features *); 12016038816SMartin Matuska _ZFS_PROP_H void zprop_register_number(int, const char *, uint64_t, 121*e92ffd9bSMartin Matuska zprop_attr_t, int, const char *, const char *, 122*e92ffd9bSMartin Matuska const struct zfs_mod_supported_features *); 12316038816SMartin Matuska _ZFS_PROP_H void zprop_register_index(int, const char *, uint64_t, zprop_attr_t, 124*e92ffd9bSMartin Matuska int, const char *, const char *, const zprop_index_t *, 125*e92ffd9bSMartin Matuska const struct zfs_mod_supported_features *); 12616038816SMartin Matuska _ZFS_PROP_H void zprop_register_hidden(int, const char *, zprop_type_t, 127*e92ffd9bSMartin Matuska zprop_attr_t, int, const char *, const struct zfs_mod_supported_features *); 128eda14cbcSMatt Macy 129eda14cbcSMatt Macy /* 130eda14cbcSMatt Macy * Common routines for zfs and zpool property management 131eda14cbcSMatt Macy */ 13216038816SMartin Matuska _ZFS_PROP_H int zprop_iter_common(zprop_func, void *, boolean_t, boolean_t, 13316038816SMartin Matuska zfs_type_t); 13416038816SMartin Matuska _ZFS_PROP_H int zprop_name_to_prop(const char *, zfs_type_t); 13516038816SMartin Matuska _ZFS_PROP_H int zprop_string_to_index(int, const char *, uint64_t *, 13616038816SMartin Matuska zfs_type_t); 137681ce946SMartin Matuska _ZFS_PROP_H int zprop_index_to_string(int, uint64_t, const char **, 138681ce946SMartin Matuska zfs_type_t); 13916038816SMartin Matuska _ZFS_PROP_H uint64_t zprop_random_value(int, uint64_t, zfs_type_t); 14016038816SMartin Matuska _ZFS_PROP_H const char *zprop_values(int, zfs_type_t); 14116038816SMartin Matuska _ZFS_PROP_H size_t zprop_width(int, boolean_t *, zfs_type_t); 14216038816SMartin Matuska _ZFS_PROP_H boolean_t zprop_valid_for_type(int, zfs_type_t, boolean_t); 143681ce946SMartin Matuska _ZFS_PROP_H int zprop_valid_char(char c); 144eda14cbcSMatt Macy 145eda14cbcSMatt Macy #ifdef __cplusplus 146eda14cbcSMatt Macy } 147eda14cbcSMatt Macy #endif 148eda14cbcSMatt Macy 149eda14cbcSMatt Macy #endif /* _ZFS_PROP_H */ 150