Deleted Added
full compact
zpool_main.c (236146) zpool_main.c (236155)
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

--- 8 unchanged lines hidden (view full) ---

17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
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

--- 8 unchanged lines hidden (view full) ---

17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
25 * Copyright (c) 2011 by Delphix. All rights reserved.
25 * Copyright (c) 2012 by Delphix. All rights reserved.
26 * Copyright (c) 2012 by Frederik Wessels. All rights reserved.
26 * Copyright (c) 2012 by Frederik Wessels. All rights reserved.
27 * Copyright (c) 2011 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
27 * Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
28 */
29
30#include <solaris.h>
31#include <assert.h>
32#include <ctype.h>
33#include <dirent.h>
34#include <errno.h>
35#include <fcntl.h>

--- 5 unchanged lines hidden (view full) ---

41#include <stdlib.h>
42#include <string.h>
43#include <strings.h>
44#include <unistd.h>
45#include <priv.h>
46#include <pwd.h>
47#include <zone.h>
48#include <sys/time.h>
28 */
29
30#include <solaris.h>
31#include <assert.h>
32#include <ctype.h>
33#include <dirent.h>
34#include <errno.h>
35#include <fcntl.h>

--- 5 unchanged lines hidden (view full) ---

41#include <stdlib.h>
42#include <string.h>
43#include <strings.h>
44#include <unistd.h>
45#include <priv.h>
46#include <pwd.h>
47#include <zone.h>
48#include <sys/time.h>
49#include <zfs_prop.h>
49#include <sys/fs/zfs.h>
50#include <sys/stat.h>
51
52#include <libzfs.h>
53
54#include "zpool_util.h"
55#include "zfs_comutil.h"
56

--- 8 unchanged lines hidden (view full) ---

65
66static int zpool_do_list(int, char **);
67static int zpool_do_iostat(int, char **);
68static int zpool_do_status(int, char **);
69
70static int zpool_do_online(int, char **);
71static int zpool_do_offline(int, char **);
72static int zpool_do_clear(int, char **);
50#include <sys/fs/zfs.h>
51#include <sys/stat.h>
52
53#include <libzfs.h>
54
55#include "zpool_util.h"
56#include "zfs_comutil.h"
57

--- 8 unchanged lines hidden (view full) ---

66
67static int zpool_do_list(int, char **);
68static int zpool_do_iostat(int, char **);
69static int zpool_do_status(int, char **);
70
71static int zpool_do_online(int, char **);
72static int zpool_do_offline(int, char **);
73static int zpool_do_clear(int, char **);
74static int zpool_do_reopen(int, char **);
73
74static int zpool_do_reguid(int, char **);
75
76static int zpool_do_attach(int, char **);
77static int zpool_do_detach(int, char **);
78static int zpool_do_replace(int, char **);
79static int zpool_do_split(int, char **);
80

--- 46 unchanged lines hidden (view full) ---

127 HELP_REPLACE,
128 HELP_REMOVE,
129 HELP_SCRUB,
130 HELP_STATUS,
131 HELP_UPGRADE,
132 HELP_GET,
133 HELP_SET,
134 HELP_SPLIT,
75
76static int zpool_do_reguid(int, char **);
77
78static int zpool_do_attach(int, char **);
79static int zpool_do_detach(int, char **);
80static int zpool_do_replace(int, char **);
81static int zpool_do_split(int, char **);
82

--- 46 unchanged lines hidden (view full) ---

129 HELP_REPLACE,
130 HELP_REMOVE,
131 HELP_SCRUB,
132 HELP_STATUS,
133 HELP_UPGRADE,
134 HELP_GET,
135 HELP_SET,
136 HELP_SPLIT,
135 HELP_REGUID
137 HELP_REGUID,
138 HELP_REOPEN
136} zpool_help_t;
137
138
139typedef struct zpool_command {
140 const char *name;
141 int (*func)(int, char **);
142 zpool_help_t usage;
143} zpool_command_t;

--- 18 unchanged lines hidden (view full) ---

162 { NULL },
163 { "list", zpool_do_list, HELP_LIST },
164 { "iostat", zpool_do_iostat, HELP_IOSTAT },
165 { "status", zpool_do_status, HELP_STATUS },
166 { NULL },
167 { "online", zpool_do_online, HELP_ONLINE },
168 { "offline", zpool_do_offline, HELP_OFFLINE },
169 { "clear", zpool_do_clear, HELP_CLEAR },
139} zpool_help_t;
140
141
142typedef struct zpool_command {
143 const char *name;
144 int (*func)(int, char **);
145 zpool_help_t usage;
146} zpool_command_t;

--- 18 unchanged lines hidden (view full) ---

165 { NULL },
166 { "list", zpool_do_list, HELP_LIST },
167 { "iostat", zpool_do_iostat, HELP_IOSTAT },
168 { "status", zpool_do_status, HELP_STATUS },
169 { NULL },
170 { "online", zpool_do_online, HELP_ONLINE },
171 { "offline", zpool_do_offline, HELP_OFFLINE },
172 { "clear", zpool_do_clear, HELP_CLEAR },
173 { "reopen", zpool_do_reopen, HELP_REOPEN },
170 { NULL },
171 { "attach", zpool_do_attach, HELP_ATTACH },
172 { "detach", zpool_do_detach, HELP_DETACH },
173 { "replace", zpool_do_replace, HELP_REPLACE },
174 { "split", zpool_do_split, HELP_SPLIT },
175 { NULL },
176 { "scrub", zpool_do_scrub, HELP_SCRUB },
177 { NULL },

--- 58 unchanged lines hidden (view full) ---

236 return (gettext("\toffline [-t] <pool> <device> ...\n"));
237 case HELP_ONLINE:
238 return (gettext("\tonline [-e] <pool> <device> ...\n"));
239 case HELP_REPLACE:
240 return (gettext("\treplace [-f] <pool> <device> "
241 "[new-device]\n"));
242 case HELP_REMOVE:
243 return (gettext("\tremove <pool> <device> ...\n"));
174 { NULL },
175 { "attach", zpool_do_attach, HELP_ATTACH },
176 { "detach", zpool_do_detach, HELP_DETACH },
177 { "replace", zpool_do_replace, HELP_REPLACE },
178 { "split", zpool_do_split, HELP_SPLIT },
179 { NULL },
180 { "scrub", zpool_do_scrub, HELP_SCRUB },
181 { NULL },

--- 58 unchanged lines hidden (view full) ---

240 return (gettext("\toffline [-t] <pool> <device> ...\n"));
241 case HELP_ONLINE:
242 return (gettext("\tonline [-e] <pool> <device> ...\n"));
243 case HELP_REPLACE:
244 return (gettext("\treplace [-f] <pool> <device> "
245 "[new-device]\n"));
246 case HELP_REMOVE:
247 return (gettext("\tremove <pool> <device> ...\n"));
248 case HELP_REOPEN:
249 return (""); /* Undocumented command */
244 case HELP_SCRUB:
245 return (gettext("\tscrub [-s] <pool> ...\n"));
246 case HELP_STATUS:
247 return (gettext("\tstatus [-vx] [-T d|u] [pool] ... [interval "
248 "[count]]\n"));
249 case HELP_UPGRADE:
250 return (gettext("\tupgrade [-v]\n"
251 "\tupgrade [-V version] <-a | pool ...>\n"));

--- 1852 unchanged lines hidden (view full) ---

2104 nvlist_free(pools);
2105 nvlist_free(policy);
2106 free(searchdirs);
2107
2108 return (err ? 1 : 0);
2109}
2110
2111typedef struct iostat_cbdata {
250 case HELP_SCRUB:
251 return (gettext("\tscrub [-s] <pool> ...\n"));
252 case HELP_STATUS:
253 return (gettext("\tstatus [-vx] [-T d|u] [pool] ... [interval "
254 "[count]]\n"));
255 case HELP_UPGRADE:
256 return (gettext("\tupgrade [-v]\n"
257 "\tupgrade [-V version] <-a | pool ...>\n"));

--- 1852 unchanged lines hidden (view full) ---

2110 nvlist_free(pools);
2111 nvlist_free(policy);
2112 free(searchdirs);
2113
2114 return (err ? 1 : 0);
2115}
2116
2117typedef struct iostat_cbdata {
2112 zpool_list_t *cb_list;
2113 int cb_verbose;
2114 int cb_iteration;
2118 boolean_t cb_verbose;
2115 int cb_namewidth;
2119 int cb_namewidth;
2120 int cb_iteration;
2121 zpool_list_t *cb_list;
2116} iostat_cbdata_t;
2117
2118static void
2119print_iostat_separator(iostat_cbdata_t *cb)
2120{
2121 int i = 0;
2122
2123 for (i = 0; i < cb->cb_namewidth; i++)

--- 453 unchanged lines hidden (view full) ---

2577 }
2578
2579 pool_list_free(list);
2580
2581 return (ret);
2582}
2583
2584typedef struct list_cbdata {
2122} iostat_cbdata_t;
2123
2124static void
2125print_iostat_separator(iostat_cbdata_t *cb)
2126{
2127 int i = 0;
2128
2129 for (i = 0; i < cb->cb_namewidth; i++)

--- 453 unchanged lines hidden (view full) ---

2583 }
2584
2585 pool_list_free(list);
2586
2587 return (ret);
2588}
2589
2590typedef struct list_cbdata {
2591 boolean_t cb_verbose;
2592 int cb_namewidth;
2585 boolean_t cb_scripted;
2593 boolean_t cb_scripted;
2586 boolean_t cb_first;
2587 zprop_list_t *cb_proplist;
2588} list_cbdata_t;
2589
2590/*
2591 * Given a list of columns to display, output appropriate headers for each one.
2592 */
2593static void
2594 zprop_list_t *cb_proplist;
2595} list_cbdata_t;
2596
2597/*
2598 * Given a list of columns to display, output appropriate headers for each one.
2599 */
2600static void
2594print_header(zprop_list_t *pl)
2601print_header(list_cbdata_t *cb)
2595{
2602{
2603 zprop_list_t *pl = cb->cb_proplist;
2596 const char *header;
2597 boolean_t first = B_TRUE;
2598 boolean_t right_justify;
2604 const char *header;
2605 boolean_t first = B_TRUE;
2606 boolean_t right_justify;
2607 size_t width = 0;
2599
2600 for (; pl != NULL; pl = pl->pl_next) {
2601 if (pl->pl_prop == ZPROP_INVAL)
2602 continue;
2603
2608
2609 for (; pl != NULL; pl = pl->pl_next) {
2610 if (pl->pl_prop == ZPROP_INVAL)
2611 continue;
2612
2613 width = pl->pl_width;
2614 if (first && cb->cb_verbose) {
2615 /*
2616 * Reset the width to accommodate the verbose listing
2617 * of devices.
2618 */
2619 width = cb->cb_namewidth;
2620 }
2621
2604 if (!first)
2605 (void) printf(" ");
2606 else
2607 first = B_FALSE;
2608
2609 header = zpool_prop_column_name(pl->pl_prop);
2610 right_justify = zpool_prop_align_right(pl->pl_prop);
2611
2612 if (pl->pl_next == NULL && !right_justify)
2613 (void) printf("%s", header);
2614 else if (right_justify)
2622 if (!first)
2623 (void) printf(" ");
2624 else
2625 first = B_FALSE;
2626
2627 header = zpool_prop_column_name(pl->pl_prop);
2628 right_justify = zpool_prop_align_right(pl->pl_prop);
2629
2630 if (pl->pl_next == NULL && !right_justify)
2631 (void) printf("%s", header);
2632 else if (right_justify)
2615 (void) printf("%*s", pl->pl_width, header);
2633 (void) printf("%*s", width, header);
2616 else
2634 else
2617 (void) printf("%-*s", pl->pl_width, header);
2635 (void) printf("%-*s", width, header);
2636
2618 }
2619
2620 (void) printf("\n");
2621}
2622
2623/*
2624 * Given a pool and a list of properties, print out all the properties according
2625 * to the described layout.
2626 */
2627static void
2637 }
2638
2639 (void) printf("\n");
2640}
2641
2642/*
2643 * Given a pool and a list of properties, print out all the properties according
2644 * to the described layout.
2645 */
2646static void
2628print_pool(zpool_handle_t *zhp, zprop_list_t *pl, int scripted)
2647print_pool(zpool_handle_t *zhp, list_cbdata_t *cb)
2629{
2648{
2649 zprop_list_t *pl = cb->cb_proplist;
2630 boolean_t first = B_TRUE;
2631 char property[ZPOOL_MAXPROPLEN];
2632 char *propstr;
2633 boolean_t right_justify;
2650 boolean_t first = B_TRUE;
2651 char property[ZPOOL_MAXPROPLEN];
2652 char *propstr;
2653 boolean_t right_justify;
2634 int width;
2654 size_t width;
2635
2636 for (; pl != NULL; pl = pl->pl_next) {
2655
2656 for (; pl != NULL; pl = pl->pl_next) {
2657
2658 width = pl->pl_width;
2659 if (first && cb->cb_verbose) {
2660 /*
2661 * Reset the width to accommodate the verbose listing
2662 * of devices.
2663 */
2664 width = cb->cb_namewidth;
2665 }
2666
2637 if (!first) {
2667 if (!first) {
2638 if (scripted)
2668 if (cb->cb_scripted)
2639 (void) printf("\t");
2640 else
2641 (void) printf(" ");
2642 } else {
2643 first = B_FALSE;
2644 }
2645
2646 right_justify = B_FALSE;
2647 if (pl->pl_prop != ZPROP_INVAL) {
2669 (void) printf("\t");
2670 else
2671 (void) printf(" ");
2672 } else {
2673 first = B_FALSE;
2674 }
2675
2676 right_justify = B_FALSE;
2677 if (pl->pl_prop != ZPROP_INVAL) {
2648 if (zpool_get_prop(zhp, pl->pl_prop, property,
2678 if (pl->pl_prop == ZPOOL_PROP_EXPANDSZ &&
2679 zpool_get_prop_int(zhp, pl->pl_prop, NULL) == 0)
2680 propstr = "-";
2681 else if (zpool_get_prop(zhp, pl->pl_prop, property,
2649 sizeof (property), NULL) != 0)
2650 propstr = "-";
2651 else
2652 propstr = property;
2653
2654 right_justify = zpool_prop_align_right(pl->pl_prop);
2655 } else {
2656 propstr = "-";
2657 }
2658
2682 sizeof (property), NULL) != 0)
2683 propstr = "-";
2684 else
2685 propstr = property;
2686
2687 right_justify = zpool_prop_align_right(pl->pl_prop);
2688 } else {
2689 propstr = "-";
2690 }
2691
2659 width = pl->pl_width;
2660
2661 /*
2662 * If this is being called in scripted mode, or if this is the
2663 * last column and it is left-justified, don't include a width
2664 * format specifier.
2665 */
2692
2693 /*
2694 * If this is being called in scripted mode, or if this is the
2695 * last column and it is left-justified, don't include a width
2696 * format specifier.
2697 */
2666 if (scripted || (pl->pl_next == NULL && !right_justify))
2698 if (cb->cb_scripted || (pl->pl_next == NULL && !right_justify))
2667 (void) printf("%s", propstr);
2668 else if (right_justify)
2669 (void) printf("%*s", width, propstr);
2670 else
2671 (void) printf("%-*s", width, propstr);
2672 }
2673
2674 (void) printf("\n");
2675}
2676
2699 (void) printf("%s", propstr);
2700 else if (right_justify)
2701 (void) printf("%*s", width, propstr);
2702 else
2703 (void) printf("%-*s", width, propstr);
2704 }
2705
2706 (void) printf("\n");
2707}
2708
2709static void
2710print_one_column(zpool_prop_t prop, uint64_t value, boolean_t scripted)
2711{
2712 char propval[64];
2713 boolean_t fixed;
2714 size_t width = zprop_width(prop, &fixed, ZFS_TYPE_POOL);
2715
2716 zfs_nicenum(value, propval, sizeof (propval));
2717
2718 if (prop == ZPOOL_PROP_EXPANDSZ && value == 0)
2719 (void) strlcpy(propval, "-", sizeof (propval));
2720
2721 if (scripted)
2722 (void) printf("\t%s", propval);
2723 else
2724 (void) printf(" %*s", width, propval);
2725}
2726
2727void
2728print_list_stats(zpool_handle_t *zhp, const char *name, nvlist_t *nv,
2729 list_cbdata_t *cb, int depth)
2730{
2731 nvlist_t **child;
2732 vdev_stat_t *vs;
2733 uint_t c, children;
2734 char *vname;
2735 boolean_t scripted = cb->cb_scripted;
2736
2737 verify(nvlist_lookup_uint64_array(nv, ZPOOL_CONFIG_VDEV_STATS,
2738 (uint64_t **)&vs, &c) == 0);
2739
2740 if (name != NULL) {
2741 if (scripted)
2742 (void) printf("\t%s", name);
2743 else if (strlen(name) + depth > cb->cb_namewidth)
2744 (void) printf("%*s%s", depth, "", name);
2745 else
2746 (void) printf("%*s%s%*s", depth, "", name,
2747 (int)(cb->cb_namewidth - strlen(name) - depth), "");
2748
2749 /* only toplevel vdevs have capacity stats */
2750 if (vs->vs_space == 0) {
2751 if (scripted)
2752 (void) printf("\t-\t-\t-");
2753 else
2754 (void) printf(" - - -");
2755 } else {
2756 print_one_column(ZPOOL_PROP_SIZE, vs->vs_space,
2757 scripted);
2758 print_one_column(ZPOOL_PROP_CAPACITY, vs->vs_alloc,
2759 scripted);
2760 print_one_column(ZPOOL_PROP_FREE,
2761 vs->vs_space - vs->vs_alloc, scripted);
2762 }
2763 print_one_column(ZPOOL_PROP_EXPANDSZ, vs->vs_esize,
2764 scripted);
2765 (void) printf("\n");
2766 }
2767
2768 if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN,
2769 &child, &children) != 0)
2770 return;
2771
2772 for (c = 0; c < children; c++) {
2773 uint64_t ishole = B_FALSE;
2774
2775 if (nvlist_lookup_uint64(child[c],
2776 ZPOOL_CONFIG_IS_HOLE, &ishole) == 0 && ishole)
2777 continue;
2778
2779 vname = zpool_vdev_name(g_zfs, zhp, child[c], B_FALSE);
2780 print_list_stats(zhp, vname, child[c], cb, depth + 2);
2781 free(vname);
2782 }
2783
2784 /*
2785 * Include level 2 ARC devices in iostat output
2786 */
2787 if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_L2CACHE,
2788 &child, &children) != 0)
2789 return;
2790
2791 if (children > 0) {
2792 (void) printf("%-*s - - - - - "
2793 "-\n", cb->cb_namewidth, "cache");
2794 for (c = 0; c < children; c++) {
2795 vname = zpool_vdev_name(g_zfs, zhp, child[c],
2796 B_FALSE);
2797 print_list_stats(zhp, vname, child[c], cb, depth + 2);
2798 free(vname);
2799 }
2800 }
2801}
2802
2803
2677/*
2678 * Generic callback function to list a pool.
2679 */
2680int
2681list_callback(zpool_handle_t *zhp, void *data)
2682{
2683 list_cbdata_t *cbp = data;
2804/*
2805 * Generic callback function to list a pool.
2806 */
2807int
2808list_callback(zpool_handle_t *zhp, void *data)
2809{
2810 list_cbdata_t *cbp = data;
2811 nvlist_t *config;
2812 nvlist_t *nvroot;
2684
2813
2685 if (cbp->cb_first) {
2686 if (!cbp->cb_scripted)
2687 print_header(cbp->cb_proplist);
2688 cbp->cb_first = B_FALSE;
2689 }
2814 config = zpool_get_config(zhp, NULL);
2690
2815
2691 print_pool(zhp, cbp->cb_proplist, cbp->cb_scripted);
2816 print_pool(zhp, cbp);
2817 if (!cbp->cb_verbose)
2818 return (0);
2692
2819
2820 verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
2821 &nvroot) == 0);
2822 print_list_stats(zhp, NULL, nvroot, cbp, 0);
2823
2693 return (0);
2694}
2695
2696/*
2697 * zpool list [-H] [-o prop[,prop]*] [-T d|u] [pool] ... [interval [count]]
2698 *
2699 * -H Scripted mode. Don't display headers, and separate properties
2700 * by a single tab.

--- 6 unchanged lines hidden (view full) ---

2707 */
2708int
2709zpool_do_list(int argc, char **argv)
2710{
2711 int c;
2712 int ret;
2713 list_cbdata_t cb = { 0 };
2714 static char default_props[] =
2824 return (0);
2825}
2826
2827/*
2828 * zpool list [-H] [-o prop[,prop]*] [-T d|u] [pool] ... [interval [count]]
2829 *
2830 * -H Scripted mode. Don't display headers, and separate properties
2831 * by a single tab.

--- 6 unchanged lines hidden (view full) ---

2838 */
2839int
2840zpool_do_list(int argc, char **argv)
2841{
2842 int c;
2843 int ret;
2844 list_cbdata_t cb = { 0 };
2845 static char default_props[] =
2715 "name,size,allocated,free,capacity,dedupratio,health,altroot";
2846 "name,size,allocated,free,capacity,dedupratio,"
2847 "health,altroot";
2716 char *props = default_props;
2717 unsigned long interval = 0, count = 0;
2848 char *props = default_props;
2849 unsigned long interval = 0, count = 0;
2850 zpool_list_t *list;
2851 boolean_t first = B_TRUE;
2718
2719 /* check options */
2852
2853 /* check options */
2720 while ((c = getopt(argc, argv, ":Ho:T:")) != -1) {
2854 while ((c = getopt(argc, argv, ":Ho:T:v")) != -1) {
2721 switch (c) {
2722 case 'H':
2723 cb.cb_scripted = B_TRUE;
2724 break;
2725 case 'o':
2726 props = optarg;
2727 break;
2728 case 'T':
2729 get_timestamp_arg(*optarg);
2730 break;
2855 switch (c) {
2856 case 'H':
2857 cb.cb_scripted = B_TRUE;
2858 break;
2859 case 'o':
2860 props = optarg;
2861 break;
2862 case 'T':
2863 get_timestamp_arg(*optarg);
2864 break;
2865 case 'v':
2866 cb.cb_verbose = B_TRUE;
2867 break;
2731 case ':':
2732 (void) fprintf(stderr, gettext("missing argument for "
2733 "'%c' option\n"), optopt);
2734 usage(B_FALSE);
2735 break;
2736 case '?':
2737 (void) fprintf(stderr, gettext("invalid option '%c'\n"),
2738 optopt);

--- 4 unchanged lines hidden (view full) ---

2743 argc -= optind;
2744 argv += optind;
2745
2746 get_interval_count(&argc, argv, &interval, &count);
2747
2748 if (zprop_get_list(g_zfs, props, &cb.cb_proplist, ZFS_TYPE_POOL) != 0)
2749 usage(B_FALSE);
2750
2868 case ':':
2869 (void) fprintf(stderr, gettext("missing argument for "
2870 "'%c' option\n"), optopt);
2871 usage(B_FALSE);
2872 break;
2873 case '?':
2874 (void) fprintf(stderr, gettext("invalid option '%c'\n"),
2875 optopt);

--- 4 unchanged lines hidden (view full) ---

2880 argc -= optind;
2881 argv += optind;
2882
2883 get_interval_count(&argc, argv, &interval, &count);
2884
2885 if (zprop_get_list(g_zfs, props, &cb.cb_proplist, ZFS_TYPE_POOL) != 0)
2886 usage(B_FALSE);
2887
2751 cb.cb_first = B_TRUE;
2888 if ((list = pool_list_get(argc, argv, &cb.cb_proplist, &ret)) == NULL)
2889 return (1);
2752
2890
2891 if (argc == 0 && !cb.cb_scripted && pool_list_count(list) == 0) {
2892 (void) printf(gettext("no pools available\n"));
2893 zprop_free_list(cb.cb_proplist);
2894 return (0);
2895 }
2896
2753 for (;;) {
2897 for (;;) {
2898 pool_list_update(list);
2754
2899
2900 if (pool_list_count(list) == 0)
2901 break;
2902
2903 cb.cb_namewidth = 0;
2904 (void) pool_list_iter(list, B_FALSE, get_namewidth, &cb);
2905
2755 if (timestamp_fmt != NODATE)
2756 print_timestamp(timestamp_fmt);
2757
2906 if (timestamp_fmt != NODATE)
2907 print_timestamp(timestamp_fmt);
2908
2758 ret = for_each_pool(argc, argv, B_TRUE, &cb.cb_proplist,
2759 list_callback, &cb);
2760
2761 if (argc == 0 && cb.cb_first && !cb.cb_scripted) {
2762 (void) printf(gettext("no pools available\n"));
2763 zprop_free_list(cb.cb_proplist);
2764 return (0);
2909 if (!cb.cb_scripted && (first || cb.cb_verbose)) {
2910 print_header(&cb);
2911 first = B_FALSE;
2765 }
2912 }
2913 ret = pool_list_iter(list, B_TRUE, list_callback, &cb);
2766
2767 if (interval == 0)
2768 break;
2769
2770 if (count != 0 && --count == 0)
2771 break;
2772
2773 (void) sleep(interval);

--- 603 unchanged lines hidden (view full) ---

3377
3378 ret = zpool_reguid(zhp);
3379
3380 zpool_close(zhp);
3381 return (ret);
3382}
3383
3384
2914
2915 if (interval == 0)
2916 break;
2917
2918 if (count != 0 && --count == 0)
2919 break;
2920
2921 (void) sleep(interval);

--- 603 unchanged lines hidden (view full) ---

3525
3526 ret = zpool_reguid(zhp);
3527
3528 zpool_close(zhp);
3529 return (ret);
3530}
3531
3532
3533/*
3534 * zpool reopen <pool>
3535 *
3536 * Reopen the pool so that the kernel can update the sizes of all vdevs.
3537 *
3538 * NOTE: This command is currently undocumented. If the command is ever
3539 * exposed then the appropriate usage() messages will need to be made.
3540 */
3541int
3542zpool_do_reopen(int argc, char **argv)
3543{
3544 int ret = 0;
3545 zpool_handle_t *zhp;
3546 char *pool;
3547
3548 argc--;
3549 argv++;
3550
3551 if (argc != 1)
3552 return (2);
3553
3554 pool = argv[0];
3555 if ((zhp = zpool_open_canfail(g_zfs, pool)) == NULL)
3556 return (1);
3557
3558 ret = zpool_reopen(zhp);
3559 zpool_close(zhp);
3560 return (ret);
3561}
3562
3385typedef struct scrub_cbdata {
3386 int cb_type;
3387 int cb_argc;
3388 char **cb_argv;
3389} scrub_cbdata_t;
3390
3391int
3392scrub_callback(zpool_handle_t *zhp, void *data)

--- 1347 unchanged lines hidden ---
3563typedef struct scrub_cbdata {
3564 int cb_type;
3565 int cb_argc;
3566 char **cb_argv;
3567} scrub_cbdata_t;
3568
3569int
3570scrub_callback(zpool_handle_t *zhp, void *data)

--- 1347 unchanged lines hidden ---