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 (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved. 24 * Copyright (c) 2012, 2018 by Delphix. All rights reserved. 25 * Copyright (c) 2021, Colm Buckley <colm@tuatha.org> 26 * Copyright (c) 2021, Klara Inc. 27 */ 28 29 #include <sys/zio.h> 30 #include <sys/spa.h> 31 #include <sys/zfs_acl.h> 32 #include <sys/zfs_ioctl.h> 33 #include <sys/fs/zfs.h> 34 35 #include "zfs_prop.h" 36 37 #if !defined(_KERNEL) 38 #include <stdlib.h> 39 #include <string.h> 40 #include <ctype.h> 41 #endif 42 43 static zprop_desc_t zpool_prop_table[ZPOOL_NUM_PROPS]; 44 static zprop_desc_t vdev_prop_table[VDEV_NUM_PROPS]; 45 46 zprop_desc_t * 47 zpool_prop_get_table(void) 48 { 49 return (zpool_prop_table); 50 } 51 52 void 53 zpool_prop_init(void) 54 { 55 static const zprop_index_t boolean_table[] = { 56 { "off", 0}, 57 { "on", 1}, 58 { NULL } 59 }; 60 61 static const zprop_index_t failuremode_table[] = { 62 { "wait", ZIO_FAILURE_MODE_WAIT }, 63 { "continue", ZIO_FAILURE_MODE_CONTINUE }, 64 { "panic", ZIO_FAILURE_MODE_PANIC }, 65 { NULL } 66 }; 67 68 struct zfs_mod_supported_features *sfeatures = 69 zfs_mod_list_supported(ZFS_SYSFS_POOL_PROPERTIES); 70 71 /* string properties */ 72 zprop_register_string(ZPOOL_PROP_ALTROOT, "altroot", NULL, PROP_DEFAULT, 73 ZFS_TYPE_POOL, "<path>", "ALTROOT", sfeatures); 74 zprop_register_string(ZPOOL_PROP_BOOTFS, "bootfs", NULL, PROP_DEFAULT, 75 ZFS_TYPE_POOL, "<filesystem>", "BOOTFS", sfeatures); 76 zprop_register_string(ZPOOL_PROP_CACHEFILE, "cachefile", NULL, 77 PROP_DEFAULT, ZFS_TYPE_POOL, "<file> | none", "CACHEFILE", 78 sfeatures); 79 zprop_register_string(ZPOOL_PROP_COMMENT, "comment", NULL, 80 PROP_DEFAULT, ZFS_TYPE_POOL, "<comment-string>", "COMMENT", 81 sfeatures); 82 zprop_register_string(ZPOOL_PROP_COMPATIBILITY, "compatibility", 83 "off", PROP_DEFAULT, ZFS_TYPE_POOL, 84 "<file[,file...]> | off | legacy", "COMPATIBILITY", sfeatures); 85 86 /* readonly number properties */ 87 zprop_register_number(ZPOOL_PROP_SIZE, "size", 0, PROP_READONLY, 88 ZFS_TYPE_POOL, "<size>", "SIZE", sfeatures); 89 zprop_register_number(ZPOOL_PROP_FREE, "free", 0, PROP_READONLY, 90 ZFS_TYPE_POOL, "<size>", "FREE", sfeatures); 91 zprop_register_number(ZPOOL_PROP_FREEING, "freeing", 0, PROP_READONLY, 92 ZFS_TYPE_POOL, "<size>", "FREEING", sfeatures); 93 zprop_register_number(ZPOOL_PROP_CHECKPOINT, "checkpoint", 0, 94 PROP_READONLY, ZFS_TYPE_POOL, "<size>", "CKPOINT", sfeatures); 95 zprop_register_number(ZPOOL_PROP_LEAKED, "leaked", 0, PROP_READONLY, 96 ZFS_TYPE_POOL, "<size>", "LEAKED", sfeatures); 97 zprop_register_number(ZPOOL_PROP_ALLOCATED, "allocated", 0, 98 PROP_READONLY, ZFS_TYPE_POOL, "<size>", "ALLOC", sfeatures); 99 zprop_register_number(ZPOOL_PROP_EXPANDSZ, "expandsize", 0, 100 PROP_READONLY, ZFS_TYPE_POOL, "<size>", "EXPANDSZ", sfeatures); 101 zprop_register_number(ZPOOL_PROP_FRAGMENTATION, "fragmentation", 0, 102 PROP_READONLY, ZFS_TYPE_POOL, "<percent>", "FRAG", sfeatures); 103 zprop_register_number(ZPOOL_PROP_CAPACITY, "capacity", 0, PROP_READONLY, 104 ZFS_TYPE_POOL, "<size>", "CAP", sfeatures); 105 zprop_register_number(ZPOOL_PROP_GUID, "guid", 0, PROP_READONLY, 106 ZFS_TYPE_POOL, "<guid>", "GUID", sfeatures); 107 zprop_register_number(ZPOOL_PROP_LOAD_GUID, "load_guid", 0, 108 PROP_READONLY, ZFS_TYPE_POOL, "<load_guid>", "LOAD_GUID", 109 sfeatures); 110 zprop_register_number(ZPOOL_PROP_HEALTH, "health", 0, PROP_READONLY, 111 ZFS_TYPE_POOL, "<state>", "HEALTH", sfeatures); 112 zprop_register_number(ZPOOL_PROP_DEDUPRATIO, "dedupratio", 0, 113 PROP_READONLY, ZFS_TYPE_POOL, "<1.00x or higher if deduped>", 114 "DEDUP", sfeatures); 115 116 /* default number properties */ 117 zprop_register_number(ZPOOL_PROP_VERSION, "version", SPA_VERSION, 118 PROP_DEFAULT, ZFS_TYPE_POOL, "<version>", "VERSION", sfeatures); 119 zprop_register_number(ZPOOL_PROP_ASHIFT, "ashift", 0, PROP_DEFAULT, 120 ZFS_TYPE_POOL, "<ashift, 9-16, or 0=default>", "ASHIFT", sfeatures); 121 122 /* default index (boolean) properties */ 123 zprop_register_index(ZPOOL_PROP_DELEGATION, "delegation", 1, 124 PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "DELEGATION", 125 boolean_table, sfeatures); 126 zprop_register_index(ZPOOL_PROP_AUTOREPLACE, "autoreplace", 0, 127 PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "REPLACE", boolean_table, 128 sfeatures); 129 zprop_register_index(ZPOOL_PROP_LISTSNAPS, "listsnapshots", 0, 130 PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "LISTSNAPS", 131 boolean_table, sfeatures); 132 zprop_register_index(ZPOOL_PROP_AUTOEXPAND, "autoexpand", 0, 133 PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "EXPAND", boolean_table, 134 sfeatures); 135 zprop_register_index(ZPOOL_PROP_READONLY, "readonly", 0, 136 PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "RDONLY", boolean_table, 137 sfeatures); 138 zprop_register_index(ZPOOL_PROP_MULTIHOST, "multihost", 0, 139 PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "MULTIHOST", 140 boolean_table, sfeatures); 141 142 /* default index properties */ 143 zprop_register_index(ZPOOL_PROP_FAILUREMODE, "failmode", 144 ZIO_FAILURE_MODE_WAIT, PROP_DEFAULT, ZFS_TYPE_POOL, 145 "wait | continue | panic", "FAILMODE", failuremode_table, 146 sfeatures); 147 zprop_register_index(ZPOOL_PROP_AUTOTRIM, "autotrim", 148 SPA_AUTOTRIM_DEFAULT, PROP_DEFAULT, ZFS_TYPE_POOL, 149 "on | off", "AUTOTRIM", boolean_table, sfeatures); 150 151 /* hidden properties */ 152 zprop_register_hidden(ZPOOL_PROP_NAME, "name", PROP_TYPE_STRING, 153 PROP_READONLY, ZFS_TYPE_POOL, "NAME", sfeatures); 154 zprop_register_hidden(ZPOOL_PROP_MAXBLOCKSIZE, "maxblocksize", 155 PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_POOL, "MAXBLOCKSIZE", 156 sfeatures); 157 zprop_register_hidden(ZPOOL_PROP_TNAME, "tname", PROP_TYPE_STRING, 158 PROP_ONETIME, ZFS_TYPE_POOL, "TNAME", sfeatures); 159 zprop_register_hidden(ZPOOL_PROP_MAXDNODESIZE, "maxdnodesize", 160 PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_POOL, "MAXDNODESIZE", 161 sfeatures); 162 zprop_register_hidden(ZPOOL_PROP_DEDUPDITTO, "dedupditto", 163 PROP_TYPE_NUMBER, PROP_DEFAULT, ZFS_TYPE_POOL, "DEDUPDITTO", 164 sfeatures); 165 166 zfs_mod_list_supported_free(sfeatures); 167 } 168 169 /* 170 * Given a property name and its type, returns the corresponding property ID. 171 */ 172 zpool_prop_t 173 zpool_name_to_prop(const char *propname) 174 { 175 return (zprop_name_to_prop(propname, ZFS_TYPE_POOL)); 176 } 177 178 /* 179 * Given a pool property ID, returns the corresponding name. 180 * Assuming the pool property ID is valid. 181 */ 182 const char * 183 zpool_prop_to_name(zpool_prop_t prop) 184 { 185 return (zpool_prop_table[prop].pd_name); 186 } 187 188 zprop_type_t 189 zpool_prop_get_type(zpool_prop_t prop) 190 { 191 return (zpool_prop_table[prop].pd_proptype); 192 } 193 194 boolean_t 195 zpool_prop_readonly(zpool_prop_t prop) 196 { 197 return (zpool_prop_table[prop].pd_attr == PROP_READONLY); 198 } 199 200 boolean_t 201 zpool_prop_setonce(zpool_prop_t prop) 202 { 203 return (zpool_prop_table[prop].pd_attr == PROP_ONETIME); 204 } 205 206 const char * 207 zpool_prop_default_string(zpool_prop_t prop) 208 { 209 return (zpool_prop_table[prop].pd_strdefault); 210 } 211 212 uint64_t 213 zpool_prop_default_numeric(zpool_prop_t prop) 214 { 215 return (zpool_prop_table[prop].pd_numdefault); 216 } 217 218 /* 219 * Returns true if this is a valid feature@ property. 220 */ 221 boolean_t 222 zpool_prop_feature(const char *name) 223 { 224 static const char *prefix = "feature@"; 225 return (strncmp(name, prefix, strlen(prefix)) == 0); 226 } 227 228 /* 229 * Returns true if this is a valid unsupported@ property. 230 */ 231 boolean_t 232 zpool_prop_unsupported(const char *name) 233 { 234 static const char *prefix = "unsupported@"; 235 return (strncmp(name, prefix, strlen(prefix)) == 0); 236 } 237 238 int 239 zpool_prop_string_to_index(zpool_prop_t prop, const char *string, 240 uint64_t *index) 241 { 242 return (zprop_string_to_index(prop, string, index, ZFS_TYPE_POOL)); 243 } 244 245 int 246 zpool_prop_index_to_string(zpool_prop_t prop, uint64_t index, 247 const char **string) 248 { 249 return (zprop_index_to_string(prop, index, string, ZFS_TYPE_POOL)); 250 } 251 252 uint64_t 253 zpool_prop_random_value(zpool_prop_t prop, uint64_t seed) 254 { 255 return (zprop_random_value(prop, seed, ZFS_TYPE_POOL)); 256 } 257 258 #ifndef _KERNEL 259 #include <libzfs.h> 260 261 const char * 262 zpool_prop_values(zpool_prop_t prop) 263 { 264 return (zpool_prop_table[prop].pd_values); 265 } 266 267 const char * 268 zpool_prop_column_name(zpool_prop_t prop) 269 { 270 return (zpool_prop_table[prop].pd_colname); 271 } 272 273 boolean_t 274 zpool_prop_align_right(zpool_prop_t prop) 275 { 276 return (zpool_prop_table[prop].pd_rightalign); 277 } 278 #endif 279 280 zprop_desc_t * 281 vdev_prop_get_table(void) 282 { 283 return (vdev_prop_table); 284 } 285 286 void 287 vdev_prop_init(void) 288 { 289 static const zprop_index_t boolean_table[] = { 290 { "off", 0}, 291 { "on", 1}, 292 { NULL } 293 }; 294 static const zprop_index_t boolean_na_table[] = { 295 { "off", 0}, 296 { "on", 1}, 297 { "-", 2}, /* ZPROP_BOOLEAN_NA */ 298 { NULL } 299 }; 300 301 struct zfs_mod_supported_features *sfeatures = 302 zfs_mod_list_supported(ZFS_SYSFS_VDEV_PROPERTIES); 303 304 /* string properties */ 305 zprop_register_string(VDEV_PROP_COMMENT, "comment", NULL, 306 PROP_DEFAULT, ZFS_TYPE_VDEV, "<comment-string>", "COMMENT", 307 sfeatures); 308 zprop_register_string(VDEV_PROP_PATH, "path", NULL, 309 PROP_DEFAULT, ZFS_TYPE_VDEV, "<device-path>", "PATH", sfeatures); 310 zprop_register_string(VDEV_PROP_DEVID, "devid", NULL, 311 PROP_READONLY, ZFS_TYPE_VDEV, "<devid>", "DEVID", sfeatures); 312 zprop_register_string(VDEV_PROP_PHYS_PATH, "physpath", NULL, 313 PROP_READONLY, ZFS_TYPE_VDEV, "<physpath>", "PHYSPATH", sfeatures); 314 zprop_register_string(VDEV_PROP_ENC_PATH, "encpath", NULL, 315 PROP_READONLY, ZFS_TYPE_VDEV, "<encpath>", "ENCPATH", sfeatures); 316 zprop_register_string(VDEV_PROP_FRU, "fru", NULL, 317 PROP_READONLY, ZFS_TYPE_VDEV, "<fru>", "FRU", sfeatures); 318 zprop_register_string(VDEV_PROP_PARENT, "parent", NULL, 319 PROP_READONLY, ZFS_TYPE_VDEV, "<parent>", "PARENT", sfeatures); 320 zprop_register_string(VDEV_PROP_CHILDREN, "children", NULL, 321 PROP_READONLY, ZFS_TYPE_VDEV, "<child[,...]>", "CHILDREN", 322 sfeatures); 323 324 /* readonly number properties */ 325 zprop_register_number(VDEV_PROP_SIZE, "size", 0, PROP_READONLY, 326 ZFS_TYPE_VDEV, "<size>", "SIZE", sfeatures); 327 zprop_register_number(VDEV_PROP_FREE, "free", 0, PROP_READONLY, 328 ZFS_TYPE_VDEV, "<size>", "FREE", sfeatures); 329 zprop_register_number(VDEV_PROP_ALLOCATED, "allocated", 0, 330 PROP_READONLY, ZFS_TYPE_VDEV, "<size>", "ALLOC", sfeatures); 331 zprop_register_number(VDEV_PROP_EXPANDSZ, "expandsize", 0, 332 PROP_READONLY, ZFS_TYPE_VDEV, "<size>", "EXPANDSZ", sfeatures); 333 zprop_register_number(VDEV_PROP_FRAGMENTATION, "fragmentation", 0, 334 PROP_READONLY, ZFS_TYPE_VDEV, "<percent>", "FRAG", sfeatures); 335 zprop_register_number(VDEV_PROP_CAPACITY, "capacity", 0, PROP_READONLY, 336 ZFS_TYPE_VDEV, "<size>", "CAP", sfeatures); 337 zprop_register_number(VDEV_PROP_GUID, "guid", 0, PROP_READONLY, 338 ZFS_TYPE_VDEV, "<guid>", "GUID", sfeatures); 339 zprop_register_number(VDEV_PROP_STATE, "state", 0, PROP_READONLY, 340 ZFS_TYPE_VDEV, "<state>", "STATE", sfeatures); 341 zprop_register_number(VDEV_PROP_BOOTSIZE, "bootsize", 0, PROP_READONLY, 342 ZFS_TYPE_VDEV, "<size>", "BOOTSIZE", sfeatures); 343 zprop_register_number(VDEV_PROP_ASIZE, "asize", 0, PROP_READONLY, 344 ZFS_TYPE_VDEV, "<asize>", "ASIZE", sfeatures); 345 zprop_register_number(VDEV_PROP_PSIZE, "psize", 0, PROP_READONLY, 346 ZFS_TYPE_VDEV, "<psize>", "PSIZE", sfeatures); 347 zprop_register_number(VDEV_PROP_ASHIFT, "ashift", 0, PROP_READONLY, 348 ZFS_TYPE_VDEV, "<ashift>", "ASHIFT", sfeatures); 349 zprop_register_number(VDEV_PROP_PARITY, "parity", 0, PROP_READONLY, 350 ZFS_TYPE_VDEV, "<parity>", "PARITY", sfeatures); 351 zprop_register_number(VDEV_PROP_NUMCHILDREN, "numchildren", 0, 352 PROP_READONLY, ZFS_TYPE_VDEV, "<number-of-children>", "NUMCHILD", 353 sfeatures); 354 zprop_register_number(VDEV_PROP_READ_ERRORS, "read_errors", 0, 355 PROP_READONLY, ZFS_TYPE_VDEV, "<errors>", "RDERR", sfeatures); 356 zprop_register_number(VDEV_PROP_WRITE_ERRORS, "write_errors", 0, 357 PROP_READONLY, ZFS_TYPE_VDEV, "<errors>", "WRERR", sfeatures); 358 zprop_register_number(VDEV_PROP_CHECKSUM_ERRORS, "checksum_errors", 0, 359 PROP_READONLY, ZFS_TYPE_VDEV, "<errors>", "CKERR", sfeatures); 360 zprop_register_number(VDEV_PROP_INITIALIZE_ERRORS, 361 "initialize_errors", 0, PROP_READONLY, ZFS_TYPE_VDEV, "<errors>", 362 "INITERR", sfeatures); 363 zprop_register_number(VDEV_PROP_OPS_NULL, "null_ops", 0, 364 PROP_READONLY, ZFS_TYPE_VDEV, "<operations>", "NULLOP", sfeatures); 365 zprop_register_number(VDEV_PROP_OPS_READ, "read_ops", 0, 366 PROP_READONLY, ZFS_TYPE_VDEV, "<operations>", "READOP", sfeatures); 367 zprop_register_number(VDEV_PROP_OPS_WRITE, "write_ops", 0, 368 PROP_READONLY, ZFS_TYPE_VDEV, "<operations>", "WRITEOP", sfeatures); 369 zprop_register_number(VDEV_PROP_OPS_FREE, "free_ops", 0, 370 PROP_READONLY, ZFS_TYPE_VDEV, "<operations>", "FREEOP", sfeatures); 371 zprop_register_number(VDEV_PROP_OPS_CLAIM, "claim_ops", 0, 372 PROP_READONLY, ZFS_TYPE_VDEV, "<operations>", "CLAIMOP", sfeatures); 373 zprop_register_number(VDEV_PROP_OPS_TRIM, "trim_ops", 0, 374 PROP_READONLY, ZFS_TYPE_VDEV, "<operations>", "TRIMOP", sfeatures); 375 zprop_register_number(VDEV_PROP_BYTES_NULL, "null_bytes", 0, 376 PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "NULLBYTE", sfeatures); 377 zprop_register_number(VDEV_PROP_BYTES_READ, "read_bytes", 0, 378 PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "READBYTE", sfeatures); 379 zprop_register_number(VDEV_PROP_BYTES_WRITE, "write_bytes", 0, 380 PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "WRITEBYTE", sfeatures); 381 zprop_register_number(VDEV_PROP_BYTES_FREE, "free_bytes", 0, 382 PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "FREEBYTE", sfeatures); 383 zprop_register_number(VDEV_PROP_BYTES_CLAIM, "claim_bytes", 0, 384 PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "CLAIMBYTE", sfeatures); 385 zprop_register_number(VDEV_PROP_BYTES_TRIM, "trim_bytes", 0, 386 PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "TRIMBYTE", sfeatures); 387 388 /* default numeric properties */ 389 390 /* default index (boolean) properties */ 391 zprop_register_index(VDEV_PROP_REMOVING, "removing", 0, 392 PROP_READONLY, ZFS_TYPE_VDEV, "on | off", "REMOVING", 393 boolean_table, sfeatures); 394 zprop_register_index(VDEV_PROP_ALLOCATING, "allocating", 1, 395 PROP_DEFAULT, ZFS_TYPE_VDEV, "on | off", "ALLOCATING", 396 boolean_na_table, sfeatures); 397 398 /* default index properties */ 399 400 /* hidden properties */ 401 zprop_register_hidden(VDEV_PROP_NAME, "name", PROP_TYPE_STRING, 402 PROP_READONLY, ZFS_TYPE_VDEV, "NAME", sfeatures); 403 404 zfs_mod_list_supported_free(sfeatures); 405 } 406 407 /* 408 * Given a property name and its type, returns the corresponding property ID. 409 */ 410 vdev_prop_t 411 vdev_name_to_prop(const char *propname) 412 { 413 return (zprop_name_to_prop(propname, ZFS_TYPE_VDEV)); 414 } 415 416 /* 417 * Returns true if this is a valid user-defined property (one with a ':'). 418 */ 419 boolean_t 420 vdev_prop_user(const char *name) 421 { 422 int i; 423 char c; 424 boolean_t foundsep = B_FALSE; 425 426 for (i = 0; i < strlen(name); i++) { 427 c = name[i]; 428 if (!zprop_valid_char(c)) 429 return (B_FALSE); 430 if (c == ':') 431 foundsep = B_TRUE; 432 } 433 434 return (foundsep); 435 } 436 437 /* 438 * Given a pool property ID, returns the corresponding name. 439 * Assuming the pool property ID is valid. 440 */ 441 const char * 442 vdev_prop_to_name(vdev_prop_t prop) 443 { 444 return (vdev_prop_table[prop].pd_name); 445 } 446 447 zprop_type_t 448 vdev_prop_get_type(vdev_prop_t prop) 449 { 450 return (vdev_prop_table[prop].pd_proptype); 451 } 452 453 boolean_t 454 vdev_prop_readonly(vdev_prop_t prop) 455 { 456 return (vdev_prop_table[prop].pd_attr == PROP_READONLY); 457 } 458 459 const char * 460 vdev_prop_default_string(vdev_prop_t prop) 461 { 462 return (vdev_prop_table[prop].pd_strdefault); 463 } 464 465 uint64_t 466 vdev_prop_default_numeric(vdev_prop_t prop) 467 { 468 return (vdev_prop_table[prop].pd_numdefault); 469 } 470 471 int 472 vdev_prop_string_to_index(vdev_prop_t prop, const char *string, 473 uint64_t *index) 474 { 475 return (zprop_string_to_index(prop, string, index, ZFS_TYPE_VDEV)); 476 } 477 478 int 479 vdev_prop_index_to_string(vdev_prop_t prop, uint64_t index, 480 const char **string) 481 { 482 return (zprop_index_to_string(prop, index, string, ZFS_TYPE_VDEV)); 483 } 484 485 /* 486 * Returns true if this is a valid vdev property. 487 */ 488 boolean_t 489 zpool_prop_vdev(const char *name) 490 { 491 return (vdev_name_to_prop(name) != VDEV_PROP_INVAL); 492 } 493 494 uint64_t 495 vdev_prop_random_value(vdev_prop_t prop, uint64_t seed) 496 { 497 return (zprop_random_value(prop, seed, ZFS_TYPE_VDEV)); 498 } 499 500 #ifndef _KERNEL 501 const char * 502 vdev_prop_values(vdev_prop_t prop) 503 { 504 return (vdev_prop_table[prop].pd_values); 505 } 506 507 const char * 508 vdev_prop_column_name(vdev_prop_t prop) 509 { 510 return (vdev_prop_table[prop].pd_colname); 511 } 512 513 boolean_t 514 vdev_prop_align_right(vdev_prop_t prop) 515 { 516 return (vdev_prop_table[prop].pd_rightalign); 517 } 518 #endif 519 520 #if defined(_KERNEL) 521 /* zpool property functions */ 522 EXPORT_SYMBOL(zpool_prop_init); 523 EXPORT_SYMBOL(zpool_prop_get_type); 524 EXPORT_SYMBOL(zpool_prop_get_table); 525 526 /* vdev property functions */ 527 EXPORT_SYMBOL(vdev_prop_init); 528 EXPORT_SYMBOL(vdev_prop_get_type); 529 EXPORT_SYMBOL(vdev_prop_get_table); 530 531 /* Pool property functions shared between libzfs and kernel. */ 532 EXPORT_SYMBOL(zpool_name_to_prop); 533 EXPORT_SYMBOL(zpool_prop_to_name); 534 EXPORT_SYMBOL(zpool_prop_default_string); 535 EXPORT_SYMBOL(zpool_prop_default_numeric); 536 EXPORT_SYMBOL(zpool_prop_readonly); 537 EXPORT_SYMBOL(zpool_prop_feature); 538 EXPORT_SYMBOL(zpool_prop_unsupported); 539 EXPORT_SYMBOL(zpool_prop_index_to_string); 540 EXPORT_SYMBOL(zpool_prop_string_to_index); 541 EXPORT_SYMBOL(zpool_prop_vdev); 542 543 /* vdev property functions shared between libzfs and kernel. */ 544 EXPORT_SYMBOL(vdev_name_to_prop); 545 EXPORT_SYMBOL(vdev_prop_user); 546 EXPORT_SYMBOL(vdev_prop_to_name); 547 EXPORT_SYMBOL(vdev_prop_default_string); 548 EXPORT_SYMBOL(vdev_prop_default_numeric); 549 EXPORT_SYMBOL(vdev_prop_readonly); 550 EXPORT_SYMBOL(vdev_prop_index_to_string); 551 EXPORT_SYMBOL(vdev_prop_string_to_index); 552 #endif 553