1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * 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.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21/*
| 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * 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.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21/*
|
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
| 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
|
23 * Use is subject to license terms. 24 */ 25 26#include <sys/zio.h> 27#include <sys/spa.h> 28#include <sys/u8_textprep.h> 29#include <sys/zfs_acl.h> 30#include <sys/zfs_ioctl.h> 31#include <sys/zfs_znode.h> 32 33#include "zfs_prop.h" 34#include "zfs_deleg.h" 35 36#if defined(_KERNEL) 37#include <sys/systm.h> 38#else 39#include <stdlib.h> 40#include <string.h> 41#include <ctype.h> 42#endif 43 44static zprop_desc_t zfs_prop_table[ZFS_NUM_PROPS]; 45
| 23 * Use is subject to license terms. 24 */ 25 26#include <sys/zio.h> 27#include <sys/spa.h> 28#include <sys/u8_textprep.h> 29#include <sys/zfs_acl.h> 30#include <sys/zfs_ioctl.h> 31#include <sys/zfs_znode.h> 32 33#include "zfs_prop.h" 34#include "zfs_deleg.h" 35 36#if defined(_KERNEL) 37#include <sys/systm.h> 38#else 39#include <stdlib.h> 40#include <string.h> 41#include <ctype.h> 42#endif 43 44static zprop_desc_t zfs_prop_table[ZFS_NUM_PROPS]; 45
|
| 46/* Note this is indexed by zfs_userquota_prop_t, keep the order the same */ 47const char *zfs_userquota_prop_prefixes[] = { 48 "userused@", 49 "userquota@", 50 "groupused@", 51 "groupquota@" 52}; 53
|
46zprop_desc_t * 47zfs_prop_get_table(void) 48{ 49 return (zfs_prop_table); 50} 51 52void 53zfs_prop_init(void) 54{ 55 static zprop_index_t checksum_table[] = { 56 { "on", ZIO_CHECKSUM_ON }, 57 { "off", ZIO_CHECKSUM_OFF }, 58 { "fletcher2", ZIO_CHECKSUM_FLETCHER_2 }, 59 { "fletcher4", ZIO_CHECKSUM_FLETCHER_4 }, 60 { "sha256", ZIO_CHECKSUM_SHA256 }, 61 { NULL } 62 }; 63 64 static zprop_index_t compress_table[] = { 65 { "on", ZIO_COMPRESS_ON }, 66 { "off", ZIO_COMPRESS_OFF }, 67 { "lzjb", ZIO_COMPRESS_LZJB }, 68 { "gzip", ZIO_COMPRESS_GZIP_6 }, /* gzip default */ 69 { "gzip-1", ZIO_COMPRESS_GZIP_1 }, 70 { "gzip-2", ZIO_COMPRESS_GZIP_2 }, 71 { "gzip-3", ZIO_COMPRESS_GZIP_3 }, 72 { "gzip-4", ZIO_COMPRESS_GZIP_4 }, 73 { "gzip-5", ZIO_COMPRESS_GZIP_5 }, 74 { "gzip-6", ZIO_COMPRESS_GZIP_6 }, 75 { "gzip-7", ZIO_COMPRESS_GZIP_7 }, 76 { "gzip-8", ZIO_COMPRESS_GZIP_8 }, 77 { "gzip-9", ZIO_COMPRESS_GZIP_9 }, 78 { NULL } 79 }; 80 81 static zprop_index_t snapdir_table[] = { 82 { "hidden", ZFS_SNAPDIR_HIDDEN }, 83 { "visible", ZFS_SNAPDIR_VISIBLE }, 84 { NULL } 85 }; 86 87 static zprop_index_t acl_mode_table[] = { 88 { "discard", ZFS_ACL_DISCARD }, 89 { "groupmask", ZFS_ACL_GROUPMASK }, 90 { "passthrough", ZFS_ACL_PASSTHROUGH }, 91 { NULL } 92 }; 93 94 static zprop_index_t acl_inherit_table[] = { 95 { "discard", ZFS_ACL_DISCARD }, 96 { "noallow", ZFS_ACL_NOALLOW }, 97 { "restricted", ZFS_ACL_RESTRICTED }, 98 { "passthrough", ZFS_ACL_PASSTHROUGH }, 99 { "secure", ZFS_ACL_RESTRICTED }, /* bkwrd compatability */ 100 { "passthrough-x", ZFS_ACL_PASSTHROUGH_X }, 101 { NULL } 102 }; 103 104 static zprop_index_t case_table[] = { 105 { "sensitive", ZFS_CASE_SENSITIVE }, 106 { "insensitive", ZFS_CASE_INSENSITIVE }, 107 { "mixed", ZFS_CASE_MIXED }, 108 { NULL } 109 }; 110 111 static zprop_index_t copies_table[] = { 112 { "1", 1 }, 113 { "2", 2 }, 114 { "3", 3 }, 115 { NULL } 116 }; 117 118 /* 119 * Use the unique flags we have to send to u8_strcmp() and/or 120 * u8_textprep() to represent the various normalization property 121 * values. 122 */ 123 static zprop_index_t normalize_table[] = { 124 { "none", 0 }, 125 { "formD", U8_TEXTPREP_NFD }, 126 { "formKC", U8_TEXTPREP_NFKC }, 127 { "formC", U8_TEXTPREP_NFC }, 128 { "formKD", U8_TEXTPREP_NFKD }, 129 { NULL } 130 }; 131 132 static zprop_index_t version_table[] = { 133 { "1", 1 }, 134 { "2", 2 }, 135 { "3", 3 },
| 54zprop_desc_t * 55zfs_prop_get_table(void) 56{ 57 return (zfs_prop_table); 58} 59 60void 61zfs_prop_init(void) 62{ 63 static zprop_index_t checksum_table[] = { 64 { "on", ZIO_CHECKSUM_ON }, 65 { "off", ZIO_CHECKSUM_OFF }, 66 { "fletcher2", ZIO_CHECKSUM_FLETCHER_2 }, 67 { "fletcher4", ZIO_CHECKSUM_FLETCHER_4 }, 68 { "sha256", ZIO_CHECKSUM_SHA256 }, 69 { NULL } 70 }; 71 72 static zprop_index_t compress_table[] = { 73 { "on", ZIO_COMPRESS_ON }, 74 { "off", ZIO_COMPRESS_OFF }, 75 { "lzjb", ZIO_COMPRESS_LZJB }, 76 { "gzip", ZIO_COMPRESS_GZIP_6 }, /* gzip default */ 77 { "gzip-1", ZIO_COMPRESS_GZIP_1 }, 78 { "gzip-2", ZIO_COMPRESS_GZIP_2 }, 79 { "gzip-3", ZIO_COMPRESS_GZIP_3 }, 80 { "gzip-4", ZIO_COMPRESS_GZIP_4 }, 81 { "gzip-5", ZIO_COMPRESS_GZIP_5 }, 82 { "gzip-6", ZIO_COMPRESS_GZIP_6 }, 83 { "gzip-7", ZIO_COMPRESS_GZIP_7 }, 84 { "gzip-8", ZIO_COMPRESS_GZIP_8 }, 85 { "gzip-9", ZIO_COMPRESS_GZIP_9 }, 86 { NULL } 87 }; 88 89 static zprop_index_t snapdir_table[] = { 90 { "hidden", ZFS_SNAPDIR_HIDDEN }, 91 { "visible", ZFS_SNAPDIR_VISIBLE }, 92 { NULL } 93 }; 94 95 static zprop_index_t acl_mode_table[] = { 96 { "discard", ZFS_ACL_DISCARD }, 97 { "groupmask", ZFS_ACL_GROUPMASK }, 98 { "passthrough", ZFS_ACL_PASSTHROUGH }, 99 { NULL } 100 }; 101 102 static zprop_index_t acl_inherit_table[] = { 103 { "discard", ZFS_ACL_DISCARD }, 104 { "noallow", ZFS_ACL_NOALLOW }, 105 { "restricted", ZFS_ACL_RESTRICTED }, 106 { "passthrough", ZFS_ACL_PASSTHROUGH }, 107 { "secure", ZFS_ACL_RESTRICTED }, /* bkwrd compatability */ 108 { "passthrough-x", ZFS_ACL_PASSTHROUGH_X }, 109 { NULL } 110 }; 111 112 static zprop_index_t case_table[] = { 113 { "sensitive", ZFS_CASE_SENSITIVE }, 114 { "insensitive", ZFS_CASE_INSENSITIVE }, 115 { "mixed", ZFS_CASE_MIXED }, 116 { NULL } 117 }; 118 119 static zprop_index_t copies_table[] = { 120 { "1", 1 }, 121 { "2", 2 }, 122 { "3", 3 }, 123 { NULL } 124 }; 125 126 /* 127 * Use the unique flags we have to send to u8_strcmp() and/or 128 * u8_textprep() to represent the various normalization property 129 * values. 130 */ 131 static zprop_index_t normalize_table[] = { 132 { "none", 0 }, 133 { "formD", U8_TEXTPREP_NFD }, 134 { "formKC", U8_TEXTPREP_NFKC }, 135 { "formC", U8_TEXTPREP_NFC }, 136 { "formKD", U8_TEXTPREP_NFKD }, 137 { NULL } 138 }; 139 140 static zprop_index_t version_table[] = { 141 { "1", 1 }, 142 { "2", 2 }, 143 { "3", 3 },
|
| 144 { "4", 4 },
|
136 { "current", ZPL_VERSION }, 137 { NULL } 138 }; 139 140 static zprop_index_t boolean_table[] = { 141 { "off", 0 }, 142 { "on", 1 }, 143 { NULL } 144 }; 145 146 static zprop_index_t canmount_table[] = { 147 { "off", ZFS_CANMOUNT_OFF }, 148 { "on", ZFS_CANMOUNT_ON }, 149 { "noauto", ZFS_CANMOUNT_NOAUTO }, 150 { NULL } 151 }; 152 153 static zprop_index_t cache_table[] = { 154 { "none", ZFS_CACHE_NONE }, 155 { "metadata", ZFS_CACHE_METADATA }, 156 { "all", ZFS_CACHE_ALL }, 157 { NULL } 158 }; 159 160 /* inherit index properties */ 161 register_index(ZFS_PROP_CHECKSUM, "checksum", ZIO_CHECKSUM_DEFAULT, 162 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 163 "on | off | fletcher2 | fletcher4 | sha256", "CHECKSUM", 164 checksum_table); 165 register_index(ZFS_PROP_COMPRESSION, "compression", 166 ZIO_COMPRESS_DEFAULT, PROP_INHERIT, 167 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 168 "on | off | lzjb | gzip | gzip-[1-9]", "COMPRESS", compress_table); 169 register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN, 170 PROP_INHERIT, ZFS_TYPE_FILESYSTEM, 171 "hidden | visible", "SNAPDIR", snapdir_table); 172 register_index(ZFS_PROP_ACLMODE, "aclmode", ZFS_ACL_GROUPMASK, 173 PROP_INHERIT, ZFS_TYPE_FILESYSTEM, 174 "discard | groupmask | passthrough", "ACLMODE", acl_mode_table); 175 register_index(ZFS_PROP_ACLINHERIT, "aclinherit", ZFS_ACL_RESTRICTED, 176 PROP_INHERIT, ZFS_TYPE_FILESYSTEM, 177 "discard | noallow | restricted | passthrough | passthrough-x", 178 "ACLINHERIT", acl_inherit_table); 179 register_index(ZFS_PROP_COPIES, "copies", 1, 180 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 181 "1 | 2 | 3", "COPIES", copies_table); 182 register_index(ZFS_PROP_PRIMARYCACHE, "primarycache", 183 ZFS_CACHE_ALL, PROP_INHERIT, 184 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, 185 "all | none | metadata", "PRIMARYCACHE", cache_table); 186 register_index(ZFS_PROP_SECONDARYCACHE, "secondarycache", 187 ZFS_CACHE_ALL, PROP_INHERIT, 188 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, 189 "all | none | metadata", "SECONDARYCACHE", cache_table); 190 191 /* inherit index (boolean) properties */ 192 register_index(ZFS_PROP_ATIME, "atime", 1, PROP_INHERIT, 193 ZFS_TYPE_FILESYSTEM, "on | off", "ATIME", boolean_table); 194 register_index(ZFS_PROP_DEVICES, "devices", 1, PROP_INHERIT, 195 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "DEVICES", 196 boolean_table); 197 register_index(ZFS_PROP_EXEC, "exec", 1, PROP_INHERIT, 198 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "EXEC", 199 boolean_table); 200 register_index(ZFS_PROP_SETUID, "setuid", 1, PROP_INHERIT, 201 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "SETUID", 202 boolean_table); 203 register_index(ZFS_PROP_READONLY, "readonly", 0, PROP_INHERIT, 204 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off", "RDONLY", 205 boolean_table); 206 register_index(ZFS_PROP_ZONED, "jailed", 0, PROP_INHERIT, 207 ZFS_TYPE_FILESYSTEM, "on | off", "JAILED", boolean_table); 208 register_index(ZFS_PROP_XATTR, "xattr", 1, PROP_INHERIT, 209 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "XATTR", 210 boolean_table); 211 register_index(ZFS_PROP_VSCAN, "vscan", 0, PROP_INHERIT, 212 ZFS_TYPE_FILESYSTEM, "on | off", "VSCAN", 213 boolean_table); 214 register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT, 215 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "NBMAND", 216 boolean_table); 217 218 /* default index properties */ 219 register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT, 220 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
| 145 { "current", ZPL_VERSION }, 146 { NULL } 147 }; 148 149 static zprop_index_t boolean_table[] = { 150 { "off", 0 }, 151 { "on", 1 }, 152 { NULL } 153 }; 154 155 static zprop_index_t canmount_table[] = { 156 { "off", ZFS_CANMOUNT_OFF }, 157 { "on", ZFS_CANMOUNT_ON }, 158 { "noauto", ZFS_CANMOUNT_NOAUTO }, 159 { NULL } 160 }; 161 162 static zprop_index_t cache_table[] = { 163 { "none", ZFS_CACHE_NONE }, 164 { "metadata", ZFS_CACHE_METADATA }, 165 { "all", ZFS_CACHE_ALL }, 166 { NULL } 167 }; 168 169 /* inherit index properties */ 170 register_index(ZFS_PROP_CHECKSUM, "checksum", ZIO_CHECKSUM_DEFAULT, 171 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 172 "on | off | fletcher2 | fletcher4 | sha256", "CHECKSUM", 173 checksum_table); 174 register_index(ZFS_PROP_COMPRESSION, "compression", 175 ZIO_COMPRESS_DEFAULT, PROP_INHERIT, 176 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 177 "on | off | lzjb | gzip | gzip-[1-9]", "COMPRESS", compress_table); 178 register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN, 179 PROP_INHERIT, ZFS_TYPE_FILESYSTEM, 180 "hidden | visible", "SNAPDIR", snapdir_table); 181 register_index(ZFS_PROP_ACLMODE, "aclmode", ZFS_ACL_GROUPMASK, 182 PROP_INHERIT, ZFS_TYPE_FILESYSTEM, 183 "discard | groupmask | passthrough", "ACLMODE", acl_mode_table); 184 register_index(ZFS_PROP_ACLINHERIT, "aclinherit", ZFS_ACL_RESTRICTED, 185 PROP_INHERIT, ZFS_TYPE_FILESYSTEM, 186 "discard | noallow | restricted | passthrough | passthrough-x", 187 "ACLINHERIT", acl_inherit_table); 188 register_index(ZFS_PROP_COPIES, "copies", 1, 189 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 190 "1 | 2 | 3", "COPIES", copies_table); 191 register_index(ZFS_PROP_PRIMARYCACHE, "primarycache", 192 ZFS_CACHE_ALL, PROP_INHERIT, 193 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, 194 "all | none | metadata", "PRIMARYCACHE", cache_table); 195 register_index(ZFS_PROP_SECONDARYCACHE, "secondarycache", 196 ZFS_CACHE_ALL, PROP_INHERIT, 197 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, 198 "all | none | metadata", "SECONDARYCACHE", cache_table); 199 200 /* inherit index (boolean) properties */ 201 register_index(ZFS_PROP_ATIME, "atime", 1, PROP_INHERIT, 202 ZFS_TYPE_FILESYSTEM, "on | off", "ATIME", boolean_table); 203 register_index(ZFS_PROP_DEVICES, "devices", 1, PROP_INHERIT, 204 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "DEVICES", 205 boolean_table); 206 register_index(ZFS_PROP_EXEC, "exec", 1, PROP_INHERIT, 207 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "EXEC", 208 boolean_table); 209 register_index(ZFS_PROP_SETUID, "setuid", 1, PROP_INHERIT, 210 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "SETUID", 211 boolean_table); 212 register_index(ZFS_PROP_READONLY, "readonly", 0, PROP_INHERIT, 213 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off", "RDONLY", 214 boolean_table); 215 register_index(ZFS_PROP_ZONED, "jailed", 0, PROP_INHERIT, 216 ZFS_TYPE_FILESYSTEM, "on | off", "JAILED", boolean_table); 217 register_index(ZFS_PROP_XATTR, "xattr", 1, PROP_INHERIT, 218 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "XATTR", 219 boolean_table); 220 register_index(ZFS_PROP_VSCAN, "vscan", 0, PROP_INHERIT, 221 ZFS_TYPE_FILESYSTEM, "on | off", "VSCAN", 222 boolean_table); 223 register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT, 224 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "NBMAND", 225 boolean_table); 226 227 /* default index properties */ 228 register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT, 229 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
|
221 "1 | 2 | 3 | current", "VERSION", version_table);
| 230 "1 | 2 | 3 | 4 | current", "VERSION", version_table);
|
222 register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON, 223 PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto", 224 "CANMOUNT", canmount_table); 225 226 /* readonly index (boolean) properties */ 227 register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY, 228 ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table); 229 230 /* set once index properties */ 231 register_index(ZFS_PROP_NORMALIZE, "normalization", 0, 232 PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, 233 "none | formC | formD | formKC | formKD", "NORMALIZATION", 234 normalize_table); 235 register_index(ZFS_PROP_CASE, "casesensitivity", ZFS_CASE_SENSITIVE, 236 PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, 237 "sensitive | insensitive | mixed", "CASE", case_table); 238 239 /* set once index (boolean) properties */ 240 register_index(ZFS_PROP_UTF8ONLY, "utf8only", 0, PROP_ONETIME, 241 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, 242 "on | off", "UTF8ONLY", boolean_table); 243 244 /* string properties */ 245 register_string(ZFS_PROP_ORIGIN, "origin", NULL, PROP_READONLY, 246 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<snapshot>", "ORIGIN"); 247 register_string(ZFS_PROP_MOUNTPOINT, "mountpoint", "/", PROP_INHERIT, 248 ZFS_TYPE_FILESYSTEM, "<path> | legacy | none", "MOUNTPOINT"); 249 register_string(ZFS_PROP_SHARENFS, "sharenfs", "off", PROP_INHERIT, 250 ZFS_TYPE_FILESYSTEM, "on | off | share(1M) options", "SHARENFS"); 251 register_string(ZFS_PROP_SHAREISCSI, "shareiscsi", "off", PROP_INHERIT, 252 ZFS_TYPE_DATASET, "on | off | type=<type>", "SHAREISCSI"); 253 register_string(ZFS_PROP_TYPE, "type", NULL, PROP_READONLY, 254 ZFS_TYPE_DATASET, "filesystem | volume | snapshot", "TYPE"); 255 register_string(ZFS_PROP_SHARESMB, "sharesmb", "off", PROP_INHERIT, 256 ZFS_TYPE_FILESYSTEM, "on | off | sharemgr(1M) options", "SHARESMB"); 257 258 /* readonly number properties */ 259 register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY, 260 ZFS_TYPE_DATASET, "<size>", "USED"); 261 register_number(ZFS_PROP_AVAILABLE, "available", 0, PROP_READONLY, 262 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "AVAIL"); 263 register_number(ZFS_PROP_REFERENCED, "referenced", 0, PROP_READONLY, 264 ZFS_TYPE_DATASET, "<size>", "REFER"); 265 register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0, 266 PROP_READONLY, ZFS_TYPE_DATASET, 267 "<1.00x or higher if compressed>", "RATIO"); 268 register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize", 8192, 269 PROP_ONETIME, 270 ZFS_TYPE_VOLUME, "512 to 128k, power of 2", "VOLBLOCK"); 271 register_number(ZFS_PROP_USEDSNAP, "usedbysnapshots", 0, PROP_READONLY, 272 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDSNAP"); 273 register_number(ZFS_PROP_USEDDS, "usedbydataset", 0, PROP_READONLY, 274 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDDS"); 275 register_number(ZFS_PROP_USEDCHILD, "usedbychildren", 0, PROP_READONLY, 276 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDCHILD"); 277 register_number(ZFS_PROP_USEDREFRESERV, "usedbyrefreservation", 0, 278 PROP_READONLY, 279 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDREFRESERV"); 280 281 /* default number properties */ 282 register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT, 283 ZFS_TYPE_FILESYSTEM, "<size> | none", "QUOTA"); 284 register_number(ZFS_PROP_RESERVATION, "reservation", 0, PROP_DEFAULT, 285 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size> | none", "RESERV"); 286 register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT, 287 ZFS_TYPE_VOLUME, "<size>", "VOLSIZE"); 288 register_number(ZFS_PROP_REFQUOTA, "refquota", 0, PROP_DEFAULT, 289 ZFS_TYPE_FILESYSTEM, "<size> | none", "REFQUOTA"); 290 register_number(ZFS_PROP_REFRESERVATION, "refreservation", 0, 291 PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 292 "<size> | none", "REFRESERV"); 293 294 /* inherit number properties */ 295 register_number(ZFS_PROP_RECORDSIZE, "recordsize", SPA_MAXBLOCKSIZE, 296 PROP_INHERIT, 297 ZFS_TYPE_FILESYSTEM, "512 to 128k, power of 2", "RECSIZE"); 298 299 /* hidden properties */ 300 register_hidden(ZFS_PROP_CREATETXG, "createtxg", PROP_TYPE_NUMBER, 301 PROP_READONLY, ZFS_TYPE_DATASET, "CREATETXG"); 302 register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER, 303 PROP_READONLY, ZFS_TYPE_SNAPSHOT, NULL); 304 register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING, 305 PROP_READONLY, ZFS_TYPE_DATASET, "NAME"); 306 register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions", PROP_TYPE_STRING, 307 PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS"); 308 register_hidden(ZFS_PROP_GUID, "guid", PROP_TYPE_NUMBER, PROP_READONLY, 309 ZFS_TYPE_DATASET, "GUID");
| 231 register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON, 232 PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto", 233 "CANMOUNT", canmount_table); 234 235 /* readonly index (boolean) properties */ 236 register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY, 237 ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table); 238 239 /* set once index properties */ 240 register_index(ZFS_PROP_NORMALIZE, "normalization", 0, 241 PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, 242 "none | formC | formD | formKC | formKD", "NORMALIZATION", 243 normalize_table); 244 register_index(ZFS_PROP_CASE, "casesensitivity", ZFS_CASE_SENSITIVE, 245 PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, 246 "sensitive | insensitive | mixed", "CASE", case_table); 247 248 /* set once index (boolean) properties */ 249 register_index(ZFS_PROP_UTF8ONLY, "utf8only", 0, PROP_ONETIME, 250 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, 251 "on | off", "UTF8ONLY", boolean_table); 252 253 /* string properties */ 254 register_string(ZFS_PROP_ORIGIN, "origin", NULL, PROP_READONLY, 255 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<snapshot>", "ORIGIN"); 256 register_string(ZFS_PROP_MOUNTPOINT, "mountpoint", "/", PROP_INHERIT, 257 ZFS_TYPE_FILESYSTEM, "<path> | legacy | none", "MOUNTPOINT"); 258 register_string(ZFS_PROP_SHARENFS, "sharenfs", "off", PROP_INHERIT, 259 ZFS_TYPE_FILESYSTEM, "on | off | share(1M) options", "SHARENFS"); 260 register_string(ZFS_PROP_SHAREISCSI, "shareiscsi", "off", PROP_INHERIT, 261 ZFS_TYPE_DATASET, "on | off | type=<type>", "SHAREISCSI"); 262 register_string(ZFS_PROP_TYPE, "type", NULL, PROP_READONLY, 263 ZFS_TYPE_DATASET, "filesystem | volume | snapshot", "TYPE"); 264 register_string(ZFS_PROP_SHARESMB, "sharesmb", "off", PROP_INHERIT, 265 ZFS_TYPE_FILESYSTEM, "on | off | sharemgr(1M) options", "SHARESMB"); 266 267 /* readonly number properties */ 268 register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY, 269 ZFS_TYPE_DATASET, "<size>", "USED"); 270 register_number(ZFS_PROP_AVAILABLE, "available", 0, PROP_READONLY, 271 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "AVAIL"); 272 register_number(ZFS_PROP_REFERENCED, "referenced", 0, PROP_READONLY, 273 ZFS_TYPE_DATASET, "<size>", "REFER"); 274 register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0, 275 PROP_READONLY, ZFS_TYPE_DATASET, 276 "<1.00x or higher if compressed>", "RATIO"); 277 register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize", 8192, 278 PROP_ONETIME, 279 ZFS_TYPE_VOLUME, "512 to 128k, power of 2", "VOLBLOCK"); 280 register_number(ZFS_PROP_USEDSNAP, "usedbysnapshots", 0, PROP_READONLY, 281 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDSNAP"); 282 register_number(ZFS_PROP_USEDDS, "usedbydataset", 0, PROP_READONLY, 283 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDDS"); 284 register_number(ZFS_PROP_USEDCHILD, "usedbychildren", 0, PROP_READONLY, 285 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDCHILD"); 286 register_number(ZFS_PROP_USEDREFRESERV, "usedbyrefreservation", 0, 287 PROP_READONLY, 288 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDREFRESERV"); 289 290 /* default number properties */ 291 register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT, 292 ZFS_TYPE_FILESYSTEM, "<size> | none", "QUOTA"); 293 register_number(ZFS_PROP_RESERVATION, "reservation", 0, PROP_DEFAULT, 294 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size> | none", "RESERV"); 295 register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT, 296 ZFS_TYPE_VOLUME, "<size>", "VOLSIZE"); 297 register_number(ZFS_PROP_REFQUOTA, "refquota", 0, PROP_DEFAULT, 298 ZFS_TYPE_FILESYSTEM, "<size> | none", "REFQUOTA"); 299 register_number(ZFS_PROP_REFRESERVATION, "refreservation", 0, 300 PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, 301 "<size> | none", "REFRESERV"); 302 303 /* inherit number properties */ 304 register_number(ZFS_PROP_RECORDSIZE, "recordsize", SPA_MAXBLOCKSIZE, 305 PROP_INHERIT, 306 ZFS_TYPE_FILESYSTEM, "512 to 128k, power of 2", "RECSIZE"); 307 308 /* hidden properties */ 309 register_hidden(ZFS_PROP_CREATETXG, "createtxg", PROP_TYPE_NUMBER, 310 PROP_READONLY, ZFS_TYPE_DATASET, "CREATETXG"); 311 register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER, 312 PROP_READONLY, ZFS_TYPE_SNAPSHOT, NULL); 313 register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING, 314 PROP_READONLY, ZFS_TYPE_DATASET, "NAME"); 315 register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions", PROP_TYPE_STRING, 316 PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS"); 317 register_hidden(ZFS_PROP_GUID, "guid", PROP_TYPE_NUMBER, PROP_READONLY, 318 ZFS_TYPE_DATASET, "GUID");
|
| 319 register_hidden(ZFS_PROP_USERACCOUNTING, "useraccounting", 320 PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, NULL);
|
310 311 /* oddball properties */ 312 register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0, NULL, 313 PROP_READONLY, ZFS_TYPE_DATASET, 314 "<date>", "CREATION", B_FALSE, B_TRUE, NULL); 315} 316 317boolean_t 318zfs_prop_delegatable(zfs_prop_t prop) 319{ 320 zprop_desc_t *pd = &zfs_prop_table[prop]; 321 return (pd->pd_attr != PROP_READONLY); 322} 323 324/* 325 * Given a zfs dataset property name, returns the corresponding property ID. 326 */ 327zfs_prop_t 328zfs_name_to_prop(const char *propname) 329{ 330 return (zprop_name_to_prop(propname, ZFS_TYPE_DATASET)); 331} 332
| 321 322 /* oddball properties */ 323 register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0, NULL, 324 PROP_READONLY, ZFS_TYPE_DATASET, 325 "<date>", "CREATION", B_FALSE, B_TRUE, NULL); 326} 327 328boolean_t 329zfs_prop_delegatable(zfs_prop_t prop) 330{ 331 zprop_desc_t *pd = &zfs_prop_table[prop]; 332 return (pd->pd_attr != PROP_READONLY); 333} 334 335/* 336 * Given a zfs dataset property name, returns the corresponding property ID. 337 */ 338zfs_prop_t 339zfs_name_to_prop(const char *propname) 340{ 341 return (zprop_name_to_prop(propname, ZFS_TYPE_DATASET)); 342} 343
|
333
| |
334/* 335 * For user property names, we allow all lowercase alphanumeric characters, plus 336 * a few useful punctuation characters. 337 */ 338static int 339valid_char(char c) 340{ 341 return ((c >= 'a' && c <= 'z') || 342 (c >= '0' && c <= '9') || 343 c == '-' || c == '_' || c == '.' || c == ':'); 344} 345 346/* 347 * Returns true if this is a valid user-defined property (one with a ':'). 348 */ 349boolean_t 350zfs_prop_user(const char *name) 351{ 352 int i; 353 char c; 354 boolean_t foundsep = B_FALSE; 355 356 for (i = 0; i < strlen(name); i++) { 357 c = name[i]; 358 if (!valid_char(c)) 359 return (B_FALSE); 360 if (c == ':') 361 foundsep = B_TRUE; 362 } 363 364 if (!foundsep) 365 return (B_FALSE); 366 367 return (B_TRUE); 368} 369 370/*
| 344/* 345 * For user property names, we allow all lowercase alphanumeric characters, plus 346 * a few useful punctuation characters. 347 */ 348static int 349valid_char(char c) 350{ 351 return ((c >= 'a' && c <= 'z') || 352 (c >= '0' && c <= '9') || 353 c == '-' || c == '_' || c == '.' || c == ':'); 354} 355 356/* 357 * Returns true if this is a valid user-defined property (one with a ':'). 358 */ 359boolean_t 360zfs_prop_user(const char *name) 361{ 362 int i; 363 char c; 364 boolean_t foundsep = B_FALSE; 365 366 for (i = 0; i < strlen(name); i++) { 367 c = name[i]; 368 if (!valid_char(c)) 369 return (B_FALSE); 370 if (c == ':') 371 foundsep = B_TRUE; 372 } 373 374 if (!foundsep) 375 return (B_FALSE); 376 377 return (B_TRUE); 378} 379 380/*
|
| 381 * Returns true if this is a valid userspace-type property (one with a '@'). 382 * Note that after the @, any character is valid (eg, another @, for SID 383 * user@domain). 384 */ 385boolean_t 386zfs_prop_userquota(const char *name) 387{ 388 zfs_userquota_prop_t prop; 389 390 for (prop = 0; prop < ZFS_NUM_USERQUOTA_PROPS; prop++) { 391 if (strncmp(name, zfs_userquota_prop_prefixes[prop], 392 strlen(zfs_userquota_prop_prefixes[prop])) == 0) { 393 return (B_TRUE); 394 } 395 } 396 397 return (B_FALSE); 398} 399 400/*
|
371 * Tables of index types, plus functions to convert between the user view 372 * (strings) and internal representation (uint64_t). 373 */ 374int 375zfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *index) 376{ 377 return (zprop_string_to_index(prop, string, index, ZFS_TYPE_DATASET)); 378} 379 380int 381zfs_prop_index_to_string(zfs_prop_t prop, uint64_t index, const char **string) 382{ 383 return (zprop_index_to_string(prop, index, string, ZFS_TYPE_DATASET)); 384} 385 386/* 387 * Returns TRUE if the property applies to any of the given dataset types. 388 */ 389boolean_t 390zfs_prop_valid_for_type(int prop, zfs_type_t types) 391{ 392 return (zprop_valid_for_type(prop, types)); 393} 394 395zprop_type_t 396zfs_prop_get_type(zfs_prop_t prop) 397{ 398 return (zfs_prop_table[prop].pd_proptype); 399} 400 401/* 402 * Returns TRUE if the property is readonly. 403 */ 404boolean_t 405zfs_prop_readonly(zfs_prop_t prop) 406{ 407 return (zfs_prop_table[prop].pd_attr == PROP_READONLY || 408 zfs_prop_table[prop].pd_attr == PROP_ONETIME); 409} 410 411/* 412 * Returns TRUE if the property is only allowed to be set once. 413 */ 414boolean_t 415zfs_prop_setonce(zfs_prop_t prop) 416{ 417 return (zfs_prop_table[prop].pd_attr == PROP_ONETIME); 418} 419 420const char * 421zfs_prop_default_string(zfs_prop_t prop) 422{ 423 return (zfs_prop_table[prop].pd_strdefault); 424} 425 426uint64_t 427zfs_prop_default_numeric(zfs_prop_t prop) 428{ 429 return (zfs_prop_table[prop].pd_numdefault); 430} 431 432/* 433 * Given a dataset property ID, returns the corresponding name. 434 * Assuming the zfs dataset property ID is valid. 435 */ 436const char * 437zfs_prop_to_name(zfs_prop_t prop) 438{ 439 return (zfs_prop_table[prop].pd_name); 440} 441 442/* 443 * Returns TRUE if the property is inheritable. 444 */ 445boolean_t 446zfs_prop_inheritable(zfs_prop_t prop) 447{ 448 return (zfs_prop_table[prop].pd_attr == PROP_INHERIT || 449 zfs_prop_table[prop].pd_attr == PROP_ONETIME); 450} 451 452#ifndef _KERNEL 453 454/* 455 * Returns a string describing the set of acceptable values for the given 456 * zfs property, or NULL if it cannot be set. 457 */ 458const char * 459zfs_prop_values(zfs_prop_t prop) 460{ 461 return (zfs_prop_table[prop].pd_values); 462} 463 464/* 465 * Returns TRUE if this property is a string type. Note that index types 466 * (compression, checksum) are treated as strings in userland, even though they 467 * are stored numerically on disk. 468 */ 469int 470zfs_prop_is_string(zfs_prop_t prop) 471{ 472 return (zfs_prop_table[prop].pd_proptype == PROP_TYPE_STRING || 473 zfs_prop_table[prop].pd_proptype == PROP_TYPE_INDEX); 474} 475 476/* 477 * Returns the column header for the given property. Used only in 478 * 'zfs list -o', but centralized here with the other property information. 479 */ 480const char * 481zfs_prop_column_name(zfs_prop_t prop) 482{ 483 return (zfs_prop_table[prop].pd_colname); 484} 485 486/* 487 * Returns whether the given property should be displayed right-justified for 488 * 'zfs list'. 489 */ 490boolean_t 491zfs_prop_align_right(zfs_prop_t prop) 492{ 493 return (zfs_prop_table[prop].pd_rightalign); 494} 495 496#endif
| 401 * Tables of index types, plus functions to convert between the user view 402 * (strings) and internal representation (uint64_t). 403 */ 404int 405zfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *index) 406{ 407 return (zprop_string_to_index(prop, string, index, ZFS_TYPE_DATASET)); 408} 409 410int 411zfs_prop_index_to_string(zfs_prop_t prop, uint64_t index, const char **string) 412{ 413 return (zprop_index_to_string(prop, index, string, ZFS_TYPE_DATASET)); 414} 415 416/* 417 * Returns TRUE if the property applies to any of the given dataset types. 418 */ 419boolean_t 420zfs_prop_valid_for_type(int prop, zfs_type_t types) 421{ 422 return (zprop_valid_for_type(prop, types)); 423} 424 425zprop_type_t 426zfs_prop_get_type(zfs_prop_t prop) 427{ 428 return (zfs_prop_table[prop].pd_proptype); 429} 430 431/* 432 * Returns TRUE if the property is readonly. 433 */ 434boolean_t 435zfs_prop_readonly(zfs_prop_t prop) 436{ 437 return (zfs_prop_table[prop].pd_attr == PROP_READONLY || 438 zfs_prop_table[prop].pd_attr == PROP_ONETIME); 439} 440 441/* 442 * Returns TRUE if the property is only allowed to be set once. 443 */ 444boolean_t 445zfs_prop_setonce(zfs_prop_t prop) 446{ 447 return (zfs_prop_table[prop].pd_attr == PROP_ONETIME); 448} 449 450const char * 451zfs_prop_default_string(zfs_prop_t prop) 452{ 453 return (zfs_prop_table[prop].pd_strdefault); 454} 455 456uint64_t 457zfs_prop_default_numeric(zfs_prop_t prop) 458{ 459 return (zfs_prop_table[prop].pd_numdefault); 460} 461 462/* 463 * Given a dataset property ID, returns the corresponding name. 464 * Assuming the zfs dataset property ID is valid. 465 */ 466const char * 467zfs_prop_to_name(zfs_prop_t prop) 468{ 469 return (zfs_prop_table[prop].pd_name); 470} 471 472/* 473 * Returns TRUE if the property is inheritable. 474 */ 475boolean_t 476zfs_prop_inheritable(zfs_prop_t prop) 477{ 478 return (zfs_prop_table[prop].pd_attr == PROP_INHERIT || 479 zfs_prop_table[prop].pd_attr == PROP_ONETIME); 480} 481 482#ifndef _KERNEL 483 484/* 485 * Returns a string describing the set of acceptable values for the given 486 * zfs property, or NULL if it cannot be set. 487 */ 488const char * 489zfs_prop_values(zfs_prop_t prop) 490{ 491 return (zfs_prop_table[prop].pd_values); 492} 493 494/* 495 * Returns TRUE if this property is a string type. Note that index types 496 * (compression, checksum) are treated as strings in userland, even though they 497 * are stored numerically on disk. 498 */ 499int 500zfs_prop_is_string(zfs_prop_t prop) 501{ 502 return (zfs_prop_table[prop].pd_proptype == PROP_TYPE_STRING || 503 zfs_prop_table[prop].pd_proptype == PROP_TYPE_INDEX); 504} 505 506/* 507 * Returns the column header for the given property. Used only in 508 * 'zfs list -o', but centralized here with the other property information. 509 */ 510const char * 511zfs_prop_column_name(zfs_prop_t prop) 512{ 513 return (zfs_prop_table[prop].pd_colname); 514} 515 516/* 517 * Returns whether the given property should be displayed right-justified for 518 * 'zfs list'. 519 */ 520boolean_t 521zfs_prop_align_right(zfs_prop_t prop) 522{ 523 return (zfs_prop_table[prop].pd_rightalign); 524} 525 526#endif
|