49 |
49 |
50 #include <libzfs.h> |
50 #include <libzfs.h> |
51 |
51 |
52 #include "zpool_util.h" |
52 #include "zpool_util.h" |
53 #include "zfs_comutil.h" |
53 #include "zfs_comutil.h" |
|
54 #include "zfeature_common.h" |
54 |
55 |
55 #include "statcommon.h" |
56 #include "statcommon.h" |
56 |
57 |
57 static int zpool_do_create(int, char **); |
58 static int zpool_do_create(int, char **); |
58 static int zpool_do_destroy(int, char **); |
59 static int zpool_do_destroy(int, char **); |
198 return (gettext("\tattach [-f] <pool> <device> " |
199 return (gettext("\tattach [-f] <pool> <device> " |
199 "<new-device>\n")); |
200 "<new-device>\n")); |
200 case HELP_CLEAR: |
201 case HELP_CLEAR: |
201 return (gettext("\tclear [-nF] <pool> [device]\n")); |
202 return (gettext("\tclear [-nF] <pool> [device]\n")); |
202 case HELP_CREATE: |
203 case HELP_CREATE: |
203 return (gettext("\tcreate [-fn] [-o property=value] ... \n" |
204 return (gettext("\tcreate [-fnd] [-o property=value] ... \n" |
204 "\t [-O file-system-property=value] ... \n" |
205 "\t [-O file-system-property=value] ... \n" |
205 "\t [-m mountpoint] [-R root] <pool> <vdev> ...\n")); |
206 "\t [-m mountpoint] [-R root] <pool> <vdev> ...\n")); |
206 case HELP_DESTROY: |
207 case HELP_DESTROY: |
207 return (gettext("\tdestroy [-f] <pool>\n")); |
208 return (gettext("\tdestroy [-f] <pool>\n")); |
208 case HELP_DETACH: |
209 case HELP_DETACH: |
329 "PROPERTY", "EDIT", "VALUES"); |
330 "PROPERTY", "EDIT", "VALUES"); |
330 |
331 |
331 /* Iterate over all properties */ |
332 /* Iterate over all properties */ |
332 (void) zprop_iter(print_prop_cb, fp, B_FALSE, B_TRUE, |
333 (void) zprop_iter(print_prop_cb, fp, B_FALSE, B_TRUE, |
333 ZFS_TYPE_POOL); |
334 ZFS_TYPE_POOL); |
|
335 |
|
336 (void) fprintf(fp, "\t%-15s ", "feature@..."); |
|
337 (void) fprintf(fp, "YES disabled | enabled | active\n"); |
|
338 |
|
339 (void) fprintf(fp, gettext("\nThe feature@ properties must be " |
|
340 "appended with a feature name.\nSee zpool-features(5).\n")); |
334 } |
341 } |
335 |
342 |
336 /* |
343 /* |
337 * See comments at end of main(). |
344 * See comments at end of main(). |
338 */ |
345 */ |
395 } |
402 } |
396 |
403 |
397 proplist = *props; |
404 proplist = *props; |
398 |
405 |
399 if (poolprop) { |
406 if (poolprop) { |
400 if ((prop = zpool_name_to_prop(propname)) == ZPROP_INVAL) { |
407 if ((prop = zpool_name_to_prop(propname)) == ZPROP_INVAL && |
|
408 !zpool_prop_feature(propname)) { |
401 (void) fprintf(stderr, gettext("property '%s' is " |
409 (void) fprintf(stderr, gettext("property '%s' is " |
402 "not a valid pool property\n"), propname); |
410 "not a valid pool property\n"), propname); |
403 return (2); |
411 return (2); |
404 } |
412 } |
405 normnm = zpool_prop_to_name(prop); |
413 if (zpool_prop_feature(propname)) |
|
414 normnm = propname; |
|
415 else |
|
416 normnm = zpool_prop_to_name(prop); |
406 } else { |
417 } else { |
407 if ((fprop = zfs_name_to_prop(propname)) != ZPROP_INVAL) { |
418 if ((fprop = zfs_name_to_prop(propname)) != ZPROP_INVAL) { |
408 normnm = zfs_prop_to_name(fprop); |
419 normnm = zfs_prop_to_name(fprop); |
409 } else { |
420 } else { |
410 normnm = propname; |
421 normnm = propname; |
572 |
583 |
573 return (ret); |
584 return (ret); |
574 } |
585 } |
575 |
586 |
576 /* |
587 /* |
577 * zpool create [-fn] [-o property=value] ... |
588 * zpool create [-fnd] [-o property=value] ... |
578 * [-O file-system-property=value] ... |
589 * [-O file-system-property=value] ... |
579 * [-R root] [-m mountpoint] <pool> <dev> ... |
590 * [-R root] [-m mountpoint] <pool> <dev> ... |
580 * |
591 * |
581 * -f Force creation, even if devices appear in use |
592 * -f Force creation, even if devices appear in use |
582 * -n Do not create the pool, but display the resulting layout if it |
593 * -n Do not create the pool, but display the resulting layout if it |
583 * were to be created. |
594 * were to be created. |
584 * -R Create a pool under an alternate root |
595 * -R Create a pool under an alternate root |
585 * -m Set default mountpoint for the root dataset. By default it's |
596 * -m Set default mountpoint for the root dataset. By default it's |
586 * '/<pool>' |
597 * '/<pool>' |
587 * -o Set property=value. |
598 * -o Set property=value. |
|
599 * -d Don't automatically enable all supported pool features |
|
600 * (individual features can be enabled with -o). |
588 * -O Set fsproperty=value in the pool's root file system |
601 * -O Set fsproperty=value in the pool's root file system |
589 * |
602 * |
590 * Creates the named pool according to the given vdev specification. The |
603 * Creates the named pool according to the given vdev specification. The |
591 * bulk of the vdev processing is done in get_vdev_spec() in zpool_vdev.c. Once |
604 * bulk of the vdev processing is done in get_vdev_spec() in zpool_vdev.c. Once |
592 * we get the nvlist back from get_vdev_spec(), we either print out the contents |
605 * we get the nvlist back from get_vdev_spec(), we either print out the contents |
595 int |
608 int |
596 zpool_do_create(int argc, char **argv) |
609 zpool_do_create(int argc, char **argv) |
597 { |
610 { |
598 boolean_t force = B_FALSE; |
611 boolean_t force = B_FALSE; |
599 boolean_t dryrun = B_FALSE; |
612 boolean_t dryrun = B_FALSE; |
|
613 boolean_t enable_all_pool_feat = B_TRUE; |
600 int c; |
614 int c; |
601 nvlist_t *nvroot = NULL; |
615 nvlist_t *nvroot = NULL; |
602 char *poolname; |
616 char *poolname; |
603 int ret = 1; |
617 int ret = 1; |
604 char *altroot = NULL; |
618 char *altroot = NULL; |
606 nvlist_t *fsprops = NULL; |
620 nvlist_t *fsprops = NULL; |
607 nvlist_t *props = NULL; |
621 nvlist_t *props = NULL; |
608 char *propval; |
622 char *propval; |
609 |
623 |
610 /* check options */ |
624 /* check options */ |
611 while ((c = getopt(argc, argv, ":fnR:m:o:O:")) != -1) { |
625 while ((c = getopt(argc, argv, ":fndR:m:o:O:")) != -1) { |
612 switch (c) { |
626 switch (c) { |
613 case 'f': |
627 case 'f': |
614 force = B_TRUE; |
628 force = B_TRUE; |
615 break; |
629 break; |
616 case 'n': |
630 case 'n': |
617 dryrun = B_TRUE; |
631 dryrun = B_TRUE; |
|
632 break; |
|
633 case 'd': |
|
634 enable_all_pool_feat = B_FALSE; |
618 break; |
635 break; |
619 case 'R': |
636 case 'R': |
620 altroot = optarg; |
637 altroot = optarg; |
621 if (add_prop_list(zpool_prop_to_name( |
638 if (add_prop_list(zpool_prop_to_name( |
622 ZPOOL_PROP_ALTROOT), optarg, &props, B_TRUE)) |
639 ZPOOL_PROP_ALTROOT), optarg, &props, B_TRUE)) |
641 *propval = '\0'; |
658 *propval = '\0'; |
642 propval++; |
659 propval++; |
643 |
660 |
644 if (add_prop_list(optarg, propval, &props, B_TRUE)) |
661 if (add_prop_list(optarg, propval, &props, B_TRUE)) |
645 goto errout; |
662 goto errout; |
|
663 |
|
664 /* |
|
665 * If the user is creating a pool that doesn't support |
|
666 * feature flags, don't enable any features. |
|
667 */ |
|
668 if (zpool_name_to_prop(optarg) == ZPOOL_PROP_VERSION) { |
|
669 char *end; |
|
670 u_longlong_t ver; |
|
671 |
|
672 ver = strtoull(propval, &end, 10); |
|
673 if (*end == '\0' && |
|
674 ver < SPA_VERSION_FEATURES) { |
|
675 enable_all_pool_feat = B_FALSE; |
|
676 } |
|
677 } |
646 break; |
678 break; |
647 case 'O': |
679 case 'O': |
648 if ((propval = strchr(optarg, '=')) == NULL) { |
680 if ((propval = strchr(optarg, '=')) == NULL) { |
649 (void) fprintf(stderr, gettext("missing " |
681 (void) fprintf(stderr, gettext("missing " |
650 "'=' for -O option\n")); |
682 "'=' for -O option\n")); |
705 (void) fprintf(stderr, gettext("invalid vdev " |
737 (void) fprintf(stderr, gettext("invalid vdev " |
706 "specification: at least one toplevel vdev must be " |
738 "specification: at least one toplevel vdev must be " |
707 "specified\n")); |
739 "specified\n")); |
708 goto errout; |
740 goto errout; |
709 } |
741 } |
710 |
|
711 |
742 |
712 if (altroot != NULL && altroot[0] != '/') { |
743 if (altroot != NULL && altroot[0] != '/') { |
713 (void) fprintf(stderr, gettext("invalid alternate root '%s': " |
744 (void) fprintf(stderr, gettext("invalid alternate root '%s': " |
714 "must be an absolute path\n"), altroot); |
745 "must be an absolute path\n"), altroot); |
715 goto errout; |
746 goto errout; |
788 ret = 0; |
819 ret = 0; |
789 } else { |
820 } else { |
790 /* |
821 /* |
791 * Hand off to libzfs. |
822 * Hand off to libzfs. |
792 */ |
823 */ |
|
824 if (enable_all_pool_feat) { |
|
825 int i; |
|
826 for (i = 0; i < SPA_FEATURES; i++) { |
|
827 char propname[MAXPATHLEN]; |
|
828 zfeature_info_t *feat = &spa_feature_table[i]; |
|
829 |
|
830 (void) snprintf(propname, sizeof (propname), |
|
831 "feature@%s", feat->fi_uname); |
|
832 |
|
833 /* |
|
834 * Skip feature if user specified it manually |
|
835 * on the command line. |
|
836 */ |
|
837 if (nvlist_exists(props, propname)) |
|
838 continue; |
|
839 |
|
840 if (add_prop_list(propname, ZFS_FEATURE_ENABLED, |
|
841 &props, B_TRUE) != 0) |
|
842 goto errout; |
|
843 } |
|
844 } |
793 if (zpool_create(g_zfs, poolname, |
845 if (zpool_create(g_zfs, poolname, |
794 nvroot, props, fsprops) == 0) { |
846 nvroot, props, fsprops) == 0) { |
795 zfs_handle_t *pool = zfs_open(g_zfs, poolname, |
847 zfs_handle_t *pool = zfs_open(g_zfs, poolname, |
796 ZFS_TYPE_FILESYSTEM); |
848 ZFS_TYPE_FILESYSTEM); |
797 if (pool != NULL) { |
849 if (pool != NULL) { |
1119 |
1171 |
1120 case VDEV_AUX_VERSION_NEWER: |
1172 case VDEV_AUX_VERSION_NEWER: |
1121 (void) printf(gettext("newer version")); |
1173 (void) printf(gettext("newer version")); |
1122 break; |
1174 break; |
1123 |
1175 |
|
1176 case VDEV_AUX_UNSUP_FEAT: |
|
1177 (void) printf(gettext("unsupported feature(s)")); |
|
1178 break; |
|
1179 |
1124 case VDEV_AUX_SPARED: |
1180 case VDEV_AUX_SPARED: |
1125 verify(nvlist_lookup_uint64(nv, ZPOOL_CONFIG_GUID, |
1181 verify(nvlist_lookup_uint64(nv, ZPOOL_CONFIG_GUID, |
1126 &cb.cb_guid) == 0); |
1182 &cb.cb_guid) == 0); |
1127 if (zpool_iter(g_zfs, find_spare, &cb) == 1) { |
1183 if (zpool_iter(g_zfs, find_spare, &cb) == 1) { |
1128 if (strcmp(zpool_get_name(cb.cb_zhp), |
1184 if (strcmp(zpool_get_name(cb.cb_zhp), |
1400 break; |
1460 break; |
1401 |
1461 |
1402 case ZPOOL_STATUS_VERSION_NEWER: |
1462 case ZPOOL_STATUS_VERSION_NEWER: |
1403 (void) printf(gettext(" status: The pool is formatted using an " |
1463 (void) printf(gettext(" status: The pool is formatted using an " |
1404 "incompatible version.\n")); |
1464 "incompatible version.\n")); |
|
1465 break; |
|
1466 |
|
1467 case ZPOOL_STATUS_UNSUP_FEAT_READ: |
|
1468 (void) printf(gettext("status: The pool uses the following " |
|
1469 "feature(s) not supported on this sytem:\n")); |
|
1470 zpool_print_unsup_feat(config); |
|
1471 break; |
|
1472 |
|
1473 case ZPOOL_STATUS_UNSUP_FEAT_WRITE: |
|
1474 (void) printf(gettext("status: The pool can only be accessed " |
|
1475 "in read-only mode on this system. It\n\tcannot be " |
|
1476 "accessed in read-write mode because it uses the " |
|
1477 "following\n\tfeature(s) not supported on this system:\n")); |
|
1478 zpool_print_unsup_feat(config); |
1405 break; |
1479 break; |
1406 |
1480 |
1407 case ZPOOL_STATUS_HOSTID_MISMATCH: |
1481 case ZPOOL_STATUS_HOSTID_MISMATCH: |
1408 (void) printf(gettext(" status: The pool was last accessed by " |
1482 (void) printf(gettext(" status: The pool was last accessed by " |
1409 "another system.\n")); |
1483 "another system.\n")); |
1459 (void) printf(gettext(" action: The pool cannot be " |
1533 (void) printf(gettext(" action: The pool cannot be " |
1460 "imported. Access the pool on a system running " |
1534 "imported. Access the pool on a system running " |
1461 "newer\n\tsoftware, or recreate the pool from " |
1535 "newer\n\tsoftware, or recreate the pool from " |
1462 "backup.\n")); |
1536 "backup.\n")); |
1463 break; |
1537 break; |
|
1538 case ZPOOL_STATUS_UNSUP_FEAT_READ: |
|
1539 (void) printf(gettext("action: The pool cannot be " |
|
1540 "imported. Access the pool on a system that " |
|
1541 "supports\n\tthe required feature(s), or recreate " |
|
1542 "the pool from backup.\n")); |
|
1543 break; |
|
1544 case ZPOOL_STATUS_UNSUP_FEAT_WRITE: |
|
1545 (void) printf(gettext("action: The pool cannot be " |
|
1546 "imported in read-write mode. Import the pool " |
|
1547 "with\n" |
|
1548 "\t\"-o readonly=on\", access the pool on a system " |
|
1549 "that supports the\n\trequired feature(s), or " |
|
1550 "recreate the pool from backup.\n")); |
|
1551 break; |
1464 case ZPOOL_STATUS_MISSING_DEV_R: |
1552 case ZPOOL_STATUS_MISSING_DEV_R: |
1465 case ZPOOL_STATUS_MISSING_DEV_NR: |
1553 case ZPOOL_STATUS_MISSING_DEV_NR: |
1466 case ZPOOL_STATUS_BAD_GUID_SUM: |
1554 case ZPOOL_STATUS_BAD_GUID_SUM: |
1467 (void) printf(gettext(" action: The pool cannot be " |
1555 (void) printf(gettext(" action: The pool cannot be " |
1468 "imported. Attach the missing\n\tdevices and try " |
1556 "imported. Attach the missing\n\tdevices and try " |
1534 |
1622 |
1535 verify(nvlist_lookup_uint64(config, |
1623 verify(nvlist_lookup_uint64(config, |
1536 ZPOOL_CONFIG_POOL_STATE, &state) == 0); |
1624 ZPOOL_CONFIG_POOL_STATE, &state) == 0); |
1537 verify(nvlist_lookup_uint64(config, |
1625 verify(nvlist_lookup_uint64(config, |
1538 ZPOOL_CONFIG_VERSION, &version) == 0); |
1626 ZPOOL_CONFIG_VERSION, &version) == 0); |
1539 if (version > SPA_VERSION) { |
1627 if (!SPA_VERSION_IS_SUPPORTED(version)) { |
1540 (void) fprintf(stderr, gettext("cannot import '%s': pool " |
1628 (void) fprintf(stderr, gettext("cannot import '%s': pool " |
1541 "is formatted using a newer ZFS version\n"), name); |
1629 "is formatted using an unsupported ZFS version\n"), name); |
1542 return (1); |
1630 return (1); |
1543 } else if (state != POOL_STATE_EXPORTED && |
1631 } else if (state != POOL_STATE_EXPORTED && |
1544 !(flags & ZFS_IMPORT_ANY_HOST)) { |
1632 !(flags & ZFS_IMPORT_ANY_HOST)) { |
1545 uint64_t hostid; |
1633 uint64_t hostid; |
1546 |
1634 |
2471 */ |
2559 */ |
2472 static void |
2560 static void |
2473 print_header(list_cbdata_t *cb) |
2561 print_header(list_cbdata_t *cb) |
2474 { |
2562 { |
2475 zprop_list_t *pl = cb->cb_proplist; |
2563 zprop_list_t *pl = cb->cb_proplist; |
|
2564 char headerbuf[ZPOOL_MAXPROPLEN]; |
2476 const char *header; |
2565 const char *header; |
2477 boolean_t first = B_TRUE; |
2566 boolean_t first = B_TRUE; |
2478 boolean_t right_justify; |
2567 boolean_t right_justify; |
2479 size_t width = 0; |
2568 size_t width = 0; |
2480 |
2569 |
2481 for (; pl != NULL; pl = pl->pl_next) { |
2570 for (; pl != NULL; pl = pl->pl_next) { |
2482 if (pl->pl_prop == ZPROP_INVAL) |
|
2483 continue; |
|
2484 |
|
2485 width = pl->pl_width; |
2571 width = pl->pl_width; |
2486 if (first && cb->cb_verbose) { |
2572 if (first && cb->cb_verbose) { |
2487 /* |
2573 /* |
2488 * Reset the width to accommodate the verbose listing |
2574 * Reset the width to accommodate the verbose listing |
2489 * of devices. |
2575 * of devices. |
2494 if (!first) |
2580 if (!first) |
2495 (void) printf(" "); |
2581 (void) printf(" "); |
2496 else |
2582 else |
2497 first = B_FALSE; |
2583 first = B_FALSE; |
2498 |
2584 |
2499 header = zpool_prop_column_name(pl->pl_prop); |
2585 right_justify = B_FALSE; |
2500 right_justify = zpool_prop_align_right(pl->pl_prop); |
2586 if (pl->pl_prop != ZPROP_INVAL) { |
|
2587 header = zpool_prop_column_name(pl->pl_prop); |
|
2588 right_justify = zpool_prop_align_right(pl->pl_prop); |
|
2589 } else { |
|
2590 int i; |
|
2591 |
|
2592 for (i = 0; pl->pl_user_prop[i] != '\0'; i++) |
|
2593 headerbuf[i] = toupper(pl->pl_user_prop[i]); |
|
2594 headerbuf[i] = '\0'; |
|
2595 header = headerbuf; |
|
2596 } |
2501 |
2597 |
2502 if (pl->pl_next == NULL && !right_justify) |
2598 if (pl->pl_next == NULL && !right_justify) |
2503 (void) printf("%s", header); |
2599 (void) printf("%s", header); |
2504 else if (right_justify) |
2600 else if (right_justify) |
2505 (void) printf("%*s", width, header); |
2601 (void) printf("%*s", width, header); |
3894 (void) printf(gettext("action: Access the pool from a system " |
3995 (void) printf(gettext("action: Access the pool from a system " |
3895 "running more recent software, or\n\trestore the pool from " |
3996 "running more recent software, or\n\trestore the pool from " |
3896 "backup.\n")); |
3997 "backup.\n")); |
3897 break; |
3998 break; |
3898 |
3999 |
|
4000 case ZPOOL_STATUS_UNSUP_FEAT_READ: |
|
4001 (void) printf(gettext("status: The pool cannot be accessed on " |
|
4002 "this system because it uses the\n\tfollowing feature(s) " |
|
4003 "not supported on this system:\n")); |
|
4004 zpool_print_unsup_feat(config); |
|
4005 (void) printf("\n"); |
|
4006 (void) printf(gettext("action: Access the pool from a system " |
|
4007 "that supports the required feature(s),\n\tor restore the " |
|
4008 "pool from backup.\n")); |
|
4009 break; |
|
4010 |
|
4011 case ZPOOL_STATUS_UNSUP_FEAT_WRITE: |
|
4012 (void) printf(gettext("status: The pool can only be accessed " |
|
4013 "in read-only mode on this system. It\n\tcannot be " |
|
4014 "accessed in read-write mode because it uses the " |
|
4015 "following\n\tfeature(s) not supported on this system:\n")); |
|
4016 zpool_print_unsup_feat(config); |
|
4017 (void) printf("\n"); |
|
4018 (void) printf(gettext("action: The pool cannot be accessed in " |
|
4019 "read-write mode. Import the pool with\n" |
|
4020 "\t\"-o readonly=on\", access the pool from a system that " |
|
4021 "supports the\n\trequired feature(s), or restore the " |
|
4022 "pool from backup.\n")); |
|
4023 break; |
|
4024 |
3899 case ZPOOL_STATUS_FAULTED_DEV_R: |
4025 case ZPOOL_STATUS_FAULTED_DEV_R: |
3900 (void) printf(gettext("status: One or more devices are " |
4026 (void) printf(gettext("status: One or more devices are " |
3901 "faulted in response to persistent errors.\n\tSufficient " |
4027 "faulted in response to persistent errors.\n\tSufficient " |
3902 "replicas exist for the pool to continue functioning " |
4028 "replicas exist for the pool to continue functioning " |
3903 "in a\n\tdegraded state.\n")); |
4029 "in a\n\tdegraded state.\n")); |
4118 |
4244 |
4119 config = zpool_get_config(zhp, NULL); |
4245 config = zpool_get_config(zhp, NULL); |
4120 verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION, |
4246 verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION, |
4121 &version) == 0); |
4247 &version) == 0); |
4122 |
4248 |
4123 if (!cbp->cb_newer && version < SPA_VERSION) { |
4249 if (!cbp->cb_newer && SPA_VERSION_IS_SUPPORTED(version) && |
|
4250 version != SPA_VERSION) { |
4124 if (!cbp->cb_all) { |
4251 if (!cbp->cb_all) { |
4125 if (cbp->cb_first) { |
4252 if (cbp->cb_first) { |
4126 (void) printf(gettext("The following pools are " |
4253 (void) printf(gettext("The following pools are " |
4127 "out of date, and can be upgraded. After " |
4254 "out of date, and can be upgraded. After " |
4128 "being\nupgraded, these pools will no " |
4255 "being\nupgraded, these pools will no " |
4141 if (!ret) { |
4268 if (!ret) { |
4142 (void) printf(gettext("Successfully upgraded " |
4269 (void) printf(gettext("Successfully upgraded " |
4143 "'%s'\n\n"), zpool_get_name(zhp)); |
4270 "'%s'\n\n"), zpool_get_name(zhp)); |
4144 } |
4271 } |
4145 } |
4272 } |
4146 } else if (cbp->cb_newer && version > SPA_VERSION) { |
4273 } else if (cbp->cb_newer && !SPA_VERSION_IS_SUPPORTED(version)) { |
4147 assert(!cbp->cb_all); |
4274 assert(!cbp->cb_all); |
4148 |
4275 |
4149 if (cbp->cb_first) { |
4276 if (cbp->cb_first) { |
4150 (void) printf(gettext("The following pools are " |
4277 (void) printf(gettext("The following pools are " |
4151 "formatted using a newer software version and\n" |
4278 "formatted using an unsupported software version " |
4152 "cannot be accessed on the current system.\n\n")); |
4279 "and\ncannot be accessed on the current " |
|
4280 "system.\n\n")); |
4153 (void) printf(gettext("VER POOL\n")); |
4281 (void) printf(gettext("VER POOL\n")); |
4154 (void) printf(gettext("--- ------------\n")); |
4282 (void) printf(gettext("--- ------------\n")); |
4155 cbp->cb_first = B_FALSE; |
4283 cbp->cb_first = B_FALSE; |
4156 } |
4284 } |
4157 |
4285 |
4231 case 'v': |
4359 case 'v': |
4232 showversions = B_TRUE; |
4360 showversions = B_TRUE; |
4233 break; |
4361 break; |
4234 case 'V': |
4362 case 'V': |
4235 cb.cb_version = strtoll(optarg, &end, 10); |
4363 cb.cb_version = strtoll(optarg, &end, 10); |
4236 if (*end != '\0' || cb.cb_version > SPA_VERSION || |
4364 if (*end != '\0' || |
4237 cb.cb_version < SPA_VERSION_1) { |
4365 !SPA_VERSION_IS_SUPPORTED(cb.cb_version)) { |
4238 (void) fprintf(stderr, |
4366 (void) fprintf(stderr, |
4239 gettext("invalid version '%s'\n"), optarg); |
4367 gettext("invalid version '%s'\n"), optarg); |
4240 usage(B_FALSE); |
4368 usage(B_FALSE); |
4241 } |
4369 } |
4242 break; |
4370 break; |
4277 "be used along with a pool name\n")); |
4405 "be used along with a pool name\n")); |
4278 usage(B_FALSE); |
4406 usage(B_FALSE); |
4279 } |
4407 } |
4280 } |
4408 } |
4281 |
4409 |
4282 (void) printf(gettext("This system is currently running " |
4410 (void) printf(gettext("This system supports ZFS pool feature " |
4283 "ZFS pool version %llu.\n\n"), SPA_VERSION); |
4411 "flags.\n\n")); |
4284 cb.cb_first = B_TRUE; |
4412 cb.cb_first = B_TRUE; |
4285 if (showversions) { |
4413 if (showversions) { |
4286 (void) printf(gettext("The following versions are " |
4414 (void) printf(gettext("The following versions are " |
4287 "supported:\n\n")); |
4415 "supported:\n\n")); |
4288 (void) printf(gettext("VER DESCRIPTION\n")); |
4416 (void) printf(gettext("VER DESCRIPTION\n")); |
4529 */ |
4657 */ |
4530 if (pl->pl_prop == ZPOOL_PROP_NAME && |
4658 if (pl->pl_prop == ZPOOL_PROP_NAME && |
4531 pl == cbp->cb_proplist) |
4659 pl == cbp->cb_proplist) |
4532 continue; |
4660 continue; |
4533 |
4661 |
4534 if (zpool_get_prop(zhp, pl->pl_prop, |
4662 if (pl->pl_prop == ZPROP_INVAL && |
4535 value, sizeof (value), &srctype) != 0) |
4663 (zpool_prop_feature(pl->pl_user_prop) || |
4536 continue; |
4664 zpool_prop_unsupported(pl->pl_user_prop))) { |
4537 |
4665 srctype = ZPROP_SRC_LOCAL; |
4538 zprop_print_one_property(zpool_get_name(zhp), cbp, |
4666 |
4539 zpool_prop_to_name(pl->pl_prop), value, srctype, NULL, |
4667 if (zpool_prop_get_feature(zhp, pl->pl_user_prop, |
4540 NULL); |
4668 value, sizeof (value)) == 0) { |
|
4669 zprop_print_one_property(zpool_get_name(zhp), |
|
4670 cbp, pl->pl_user_prop, value, srctype, |
|
4671 NULL, NULL); |
|
4672 } |
|
4673 } else { |
|
4674 if (zpool_get_prop(zhp, pl->pl_prop, value, |
|
4675 sizeof (value), &srctype) != 0) |
|
4676 continue; |
|
4677 |
|
4678 zprop_print_one_property(zpool_get_name(zhp), cbp, |
|
4679 zpool_prop_to_name(pl->pl_prop), value, srctype, |
|
4680 NULL, NULL); |
|
4681 } |
4541 } |
4682 } |
4542 return (0); |
4683 return (0); |
4543 } |
4684 } |
4544 |
4685 |
4545 int |
4686 int |
4547 { |
4688 { |
4548 zprop_get_cbdata_t cb = { 0 }; |
4689 zprop_get_cbdata_t cb = { 0 }; |
4549 zprop_list_t fake_name = { 0 }; |
4690 zprop_list_t fake_name = { 0 }; |
4550 int ret; |
4691 int ret; |
4551 |
4692 |
4552 if (argc < 3) |
4693 if (argc < 2) { |
|
4694 (void) fprintf(stderr, gettext("missing property " |
|
4695 "argument\n")); |
4553 usage(B_FALSE); |
4696 usage(B_FALSE); |
|
4697 } |
4554 |
4698 |
4555 cb.cb_first = B_TRUE; |
4699 cb.cb_first = B_TRUE; |
4556 cb.cb_sources = ZPROP_SRC_ALL; |
4700 cb.cb_sources = ZPROP_SRC_ALL; |
4557 cb.cb_columns[0] = GET_COL_NAME; |
4701 cb.cb_columns[0] = GET_COL_NAME; |
4558 cb.cb_columns[1] = GET_COL_PROPERTY; |
4702 cb.cb_columns[1] = GET_COL_PROPERTY; |
4559 cb.cb_columns[2] = GET_COL_VALUE; |
4703 cb.cb_columns[2] = GET_COL_VALUE; |
4560 cb.cb_columns[3] = GET_COL_SOURCE; |
4704 cb.cb_columns[3] = GET_COL_SOURCE; |
4561 cb.cb_type = ZFS_TYPE_POOL; |
4705 cb.cb_type = ZFS_TYPE_POOL; |
4562 |
4706 |
4563 if (zprop_get_list(g_zfs, argv[1], &cb.cb_proplist, |
4707 if (zprop_get_list(g_zfs, argv[1], &cb.cb_proplist, |
4564 ZFS_TYPE_POOL) != 0) |
4708 ZFS_TYPE_POOL) != 0) |
4565 usage(B_FALSE); |
4709 usage(B_FALSE); |
4566 |
4710 |
4567 if (cb.cb_proplist != NULL) { |
4711 if (cb.cb_proplist != NULL) { |
4568 fake_name.pl_prop = ZPOOL_PROP_NAME; |
4712 fake_name.pl_prop = ZPOOL_PROP_NAME; |