Explicitly flush output at end of each zevent
[zfs.git] / cmd / zpool / zpool_main.c
index 5ad9378..19f1f28 100644 (file)
@@ -246,7 +246,7 @@ get_usage(zpool_help_t idx) {
        case HELP_REMOVE:
                return (gettext("\tremove <pool> <device> ...\n"));
        case HELP_REOPEN:
-               return (""); /* Undocumented command */
+               return (gettext("\treopen <pool>\n"));
        case HELP_SCRUB:
                return (gettext("\tscrub [-s] <pool> ...\n"));
        case HELP_STATUS:
@@ -3612,22 +3612,37 @@ zpool_do_reguid(int argc, char **argv)
  * zpool reopen <pool>
  *
  * Reopen the pool so that the kernel can update the sizes of all vdevs.
- *
- * NOTE: This command is currently undocumented.  If the command is ever
- * exposed then the appropriate usage() messages will need to be made.
  */
 int
 zpool_do_reopen(int argc, char **argv)
 {
+       int c;
        int ret = 0;
        zpool_handle_t *zhp;
        char *pool;
 
+       /* check options */
+       while ((c = getopt(argc, argv, "")) != -1) {
+               switch (c) {
+               case '?':
+                       (void) fprintf(stderr, gettext("invalid option '%c'\n"),
+                           optopt);
+                       usage(B_FALSE);
+               }
+       }
+
        argc--;
        argv++;
 
-       if (argc != 1)
-               return (2);
+       if (argc < 1) {
+               (void) fprintf(stderr, gettext("missing pool name\n"));
+               usage(B_FALSE);
+       }
+
+       if (argc > 1) {
+               (void) fprintf(stderr, gettext("too many arguments\n"));
+               usage(B_FALSE);
+       }
 
        pool = argv[0];
        if ((zhp = zpool_open_canfail(g_zfs, pool)) == NULL)
@@ -3970,7 +3985,10 @@ status_callback(zpool_handle_t *zhp, void *data)
         * If we were given 'zpool status -x', only report those pools with
         * problems.
         */
-       if (reason == ZPOOL_STATUS_OK && cbp->cb_explain) {
+       if (cbp->cb_explain &&
+           (reason == ZPOOL_STATUS_OK ||
+           reason == ZPOOL_STATUS_VERSION_OLDER ||
+           reason == ZPOOL_STATUS_FEAT_DISABLED)) {
                if (!cbp->cb_allpools) {
                        (void) printf(gettext("pool '%s' is healthy\n"),
                            zpool_get_name(zhp));
@@ -4090,8 +4108,8 @@ status_callback(zpool_handle_t *zhp, void *data)
                    "but some features are unavailable.\n"));
                (void) printf(gettext("action: Upgrade the pool using 'zpool "
                    "upgrade'.  Once this is done, the\n\tpool will no longer "
-                   "be accessible on software that does not support feature\n"
-                   "\tflags.\n"));
+                   "be accessible on software that does not support\n\t"
+                   "feature flags.\n"));
                break;
 
        case ZPOOL_STATUS_VERSION_NEWER:
@@ -5225,6 +5243,7 @@ zpool_do_events_next(ev_opts_t *opts)
                        zpool_do_events_nvprint(nvl, 8);
                        printf(gettext("\n"));
                }
+               (void) fflush(stdout);
 
                nvlist_free(nvl);
        }