1fa9e4066Sahrens /* 2fa9e4066Sahrens * CDDL HEADER START 3fa9e4066Sahrens * 4fa9e4066Sahrens * The contents of this file are subject to the terms of the 5e9dbad6fSeschrock * Common Development and Distribution License (the "License"). 6e9dbad6fSeschrock * You may not use this file except in compliance with the License. 7fa9e4066Sahrens * 8fa9e4066Sahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9fa9e4066Sahrens * or http://www.opensolaris.org/os/licensing. 10fa9e4066Sahrens * See the License for the specific language governing permissions 11fa9e4066Sahrens * and limitations under the License. 12fa9e4066Sahrens * 13fa9e4066Sahrens * When distributing Covered Code, include this CDDL HEADER in each 14fa9e4066Sahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15fa9e4066Sahrens * If applicable, add the following below this CDDL HEADER, with the 16fa9e4066Sahrens * fields enclosed by brackets "[]" replaced with your own identifying 17fa9e4066Sahrens * information: Portions Copyright [yyyy] [name of copyright owner] 18fa9e4066Sahrens * 19fa9e4066Sahrens * CDDL HEADER END 20fa9e4066Sahrens */ 21fa9e4066Sahrens /* 22*4853e976Sgw25295 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23fa9e4066Sahrens * Use is subject to license terms. 24fa9e4066Sahrens */ 25fa9e4066Sahrens 26fa9e4066Sahrens #ifndef _ZFS_PROP_H 27fa9e4066Sahrens #define _ZFS_PROP_H 28fa9e4066Sahrens 29fa9e4066Sahrens #pragma ident "%Z%%M% %I% %E% SMI" 30fa9e4066Sahrens 31fa9e4066Sahrens #include <sys/fs/zfs.h> 32fa9e4066Sahrens #include <sys/types.h> 33fa9e4066Sahrens 34fa9e4066Sahrens #ifdef __cplusplus 35fa9e4066Sahrens extern "C" { 36fa9e4066Sahrens #endif 37fa9e4066Sahrens 38101f5531Slling /* 39101f5531Slling * For index types (e.g. compression and checksum), we want the numeric value 40101f5531Slling * in the kernel, but the string value in userland. 41101f5531Slling */ 42fa9e4066Sahrens typedef enum { 4391ebeef5Sahrens PROP_TYPE_NUMBER, /* numeric value */ 4491ebeef5Sahrens PROP_TYPE_STRING, /* string value */ 4591ebeef5Sahrens PROP_TYPE_INDEX /* numeric value indexed by string */ 46990b4856Slling } zprop_type_t; 47fa9e4066Sahrens 48990b4856Slling typedef enum { 49990b4856Slling PROP_DEFAULT, 50990b4856Slling PROP_READONLY, 51da6c28aaSamw PROP_INHERIT, 52da6c28aaSamw /* 53da6c28aaSamw * ONETIME properties are a sort of conglomeration of READONLY 54da6c28aaSamw * and INHERIT. They can be set only during object creation, 55da6c28aaSamw * after that they are READONLY. If not explicitly set during 56da6c28aaSamw * creation, they can be inherited. 57da6c28aaSamw */ 58da6c28aaSamw PROP_ONETIME 59990b4856Slling } zprop_attr_t; 60990b4856Slling 61990b4856Slling typedef struct zfs_index { 62990b4856Slling const char *pi_name; 63990b4856Slling uint64_t pi_value; 64990b4856Slling } zprop_index_t; 65990b4856Slling 66990b4856Slling typedef struct { 67990b4856Slling const char *pd_name; /* human-readable property name */ 68990b4856Slling int pd_propnum; /* property number */ 69990b4856Slling zprop_type_t pd_proptype; /* string, boolean, index, number */ 70990b4856Slling const char *pd_strdefault; /* default for strings */ 71990b4856Slling uint64_t pd_numdefault; /* for boolean / index / number */ 72990b4856Slling zprop_attr_t pd_attr; /* default, readonly, inherit */ 73990b4856Slling int pd_types; /* bitfield of valid dataset types */ 74990b4856Slling /* fs | vol | snap; or pool */ 75990b4856Slling const char *pd_values; /* string telling acceptable values */ 76990b4856Slling const char *pd_colname; /* column header for "zfs list" */ 77990b4856Slling boolean_t pd_rightalign; /* column alignment for "zfs list" */ 78990b4856Slling boolean_t pd_visible; /* do we list this property with the */ 79990b4856Slling /* "zfs get" help message */ 80990b4856Slling const zprop_index_t *pd_table; /* for index properties, a table */ 81990b4856Slling /* defining the possible values */ 82990b4856Slling } zprop_desc_t; 83990b4856Slling 84990b4856Slling /* 85990b4856Slling * zfs dataset property functions 86990b4856Slling */ 8791ebeef5Sahrens void zfs_prop_init(void); 88990b4856Slling zprop_type_t zfs_prop_get_type(zfs_prop_t); 89990b4856Slling boolean_t zfs_prop_delegatable(zfs_prop_t prop); 90990b4856Slling zprop_desc_t *zfs_prop_get_table(void); 91990b4856Slling 92990b4856Slling /* 93990b4856Slling * zpool property functions 94990b4856Slling */ 95990b4856Slling void zpool_prop_init(void); 96990b4856Slling zprop_type_t zpool_prop_get_type(zpool_prop_t); 97990b4856Slling zprop_desc_t *zpool_prop_get_table(void); 98990b4856Slling 99990b4856Slling /* 100990b4856Slling * Common routines to initialize property tables 101990b4856Slling */ 102990b4856Slling void register_impl(int, const char *, zprop_type_t, uint64_t, 103990b4856Slling const char *, zprop_attr_t, int, const char *, const char *, 104990b4856Slling boolean_t, boolean_t, const zprop_index_t *); 105990b4856Slling void register_string(int, const char *, const char *, zprop_attr_t attr, 106990b4856Slling int, const char *, const char *); 107990b4856Slling void register_number(int, const char *, uint64_t, zprop_attr_t, int, 108990b4856Slling const char *, const char *); 109990b4856Slling void register_index(int, const char *, uint64_t, zprop_attr_t, int, 110990b4856Slling const char *, const char *, const zprop_index_t *); 111990b4856Slling void register_hidden(int, const char *, zprop_type_t, zprop_attr_t, 112990b4856Slling int, const char *); 113990b4856Slling 114990b4856Slling /* 115990b4856Slling * Common routines for zfs and zpool property management 116990b4856Slling */ 117990b4856Slling int zprop_iter_common(zprop_func, void *, boolean_t, boolean_t, zfs_type_t); 118990b4856Slling int zprop_name_to_prop(const char *, zfs_type_t); 119990b4856Slling int zprop_string_to_index(int, const char *, uint64_t *, zfs_type_t); 120990b4856Slling int zprop_index_to_string(int, uint64_t, const char **, zfs_type_t); 121990b4856Slling const char *zprop_values(int, zfs_type_t); 122990b4856Slling size_t zprop_width(int, boolean_t *, zfs_type_t); 123*4853e976Sgw25295 boolean_t zprop_valid_for_type(int, zfs_type_t); 124fa9e4066Sahrens 125fa9e4066Sahrens #ifdef __cplusplus 126fa9e4066Sahrens } 127fa9e4066Sahrens #endif 128fa9e4066Sahrens 129fa9e4066Sahrens #endif /* _ZFS_PROP_H */ 130