Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Oct 2015 11:52:58 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r289313 - in head/cddl/contrib/opensolaris: cmd/zfs lib/libzfs/common
Message-ID:  <201510141152.t9EBqwKv034053@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Wed Oct 14 11:52:58 2015
New Revision: 289313
URL: https://svnweb.freebsd.org/changeset/base/289313

Log:
  MFV r289311: 5764 "zfs send -nv" directs output to stderr
  
  Reviewed by: Matthew Ahrens <mahrens@delphix.com>
  Reviewed by: Paul Dagnelie <paul.dagnelie@delphix.com>
  Reviewed by: Basil Crow <basil.crow@delphix.com>
  Reviewed by: Steven Hartland <killing@multiplay.co.uk>
  Reviewed by: Bayard Bell <buffer.g.overflow@gmail.com>
  Approved by: Dan McDonald <danmcd@omniti.com>
  Author: Manoj Joseph <manoj.joseph@delphix.com>
  
  illumos/illumos-gate@dc5f28a3c341db7c241bba77ddc109c141072f27

Modified:
  head/cddl/contrib/opensolaris/cmd/zfs/zfs.8
  head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
Directory Properties:
  head/cddl/contrib/opensolaris/   (props changed)
  head/cddl/contrib/opensolaris/lib/libzfs/   (props changed)

Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs.8
==============================================================================
--- head/cddl/contrib/opensolaris/cmd/zfs/zfs.8	Wed Oct 14 11:36:55 2015	(r289312)
+++ head/cddl/contrib/opensolaris/cmd/zfs/zfs.8	Wed Oct 14 11:52:58 2015	(r289313)
@@ -2630,6 +2630,9 @@ useful in conjunction with the
 or
 .Fl P
 flags to determine what data will be sent.
+In this case, the verbose output will be written to
+standard output (contrast with a non-dry-run, where the stream is written
+to standard output and the verbose output goes to standard error).
 .It Fl P
 Print machine-parsable verbose information about the stream package generated.
 .It Fl v

Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
==============================================================================
--- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c	Wed Oct 14 11:36:55 2015	(r289312)
+++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c	Wed Oct 14 11:52:58 2015	(r289313)
@@ -818,7 +818,8 @@ typedef struct send_dump_data {
 	char prevsnap[ZFS_MAXNAMELEN];
 	uint64_t prevsnap_obj;
 	boolean_t seenfrom, seento, replicate, doall, fromorigin;
-	boolean_t verbose, dryrun, parsable, progress, embed_data, large_block;
+	boolean_t verbose, dryrun, parsable, progress, embed_data, std_out;
+	boolean_t large_block;
 	int outfd;
 	boolean_t err;
 	nvlist_t *fss;
@@ -1047,6 +1048,7 @@ dump_snapshot(zfs_handle_t *zhp, void *a
 	int err;
 	boolean_t isfromsnap, istosnap, fromorigin;
 	boolean_t exclude = B_FALSE;
+	FILE *fout = sdd->std_out ? stdout : stderr;
 
 	err = 0;
 	thissnap = strchr(zhp->zfs_name, '@') + 1;
@@ -1121,30 +1123,30 @@ dump_snapshot(zfs_handle_t *zhp, void *a
 
 		if (sdd->parsable) {
 			if (sdd->prevsnap[0] != '\0') {
-				(void) fprintf(stderr, "incremental\t%s\t%s",
+				(void) fprintf(fout, "incremental\t%s\t%s",
 				    sdd->prevsnap, zhp->zfs_name);
 			} else {
-				(void) fprintf(stderr, "full\t%s",
+				(void) fprintf(fout, "full\t%s",
 				    zhp->zfs_name);
 			}
 		} else {
-			(void) fprintf(stderr, dgettext(TEXT_DOMAIN,
+			(void) fprintf(fout, dgettext(TEXT_DOMAIN,
 			    "send from @%s to %s"),
 			    sdd->prevsnap, zhp->zfs_name);
 		}
 		if (err == 0) {
 			if (sdd->parsable) {
-				(void) fprintf(stderr, "\t%llu\n",
+				(void) fprintf(fout, "\t%llu\n",
 				    (longlong_t)size);
 			} else {
 				char buf[16];
 				zfs_nicenum(size, buf, sizeof (buf));
-				(void) fprintf(stderr, dgettext(TEXT_DOMAIN,
+				(void) fprintf(fout, dgettext(TEXT_DOMAIN,
 				    " estimated size is %s\n"), buf);
 			}
 			sdd->size += size;
 		} else {
-			(void) fprintf(stderr, "\n");
+			(void) fprintf(fout, "\n");
 		}
 	}
 
@@ -1388,6 +1390,7 @@ zfs_send(zfs_handle_t *zhp, const char *
 	int pipefd[2];
 	dedup_arg_t dda = { 0 };
 	int featureflags = 0;
+	FILE *fout;
 
 	(void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
 	    "cannot send '%s'"), zhp->zfs_name);
@@ -1515,6 +1518,9 @@ zfs_send(zfs_handle_t *zhp, const char *
 	sdd.filter_cb_arg = cb_arg;
 	if (debugnvp)
 		sdd.debugnv = *debugnvp;
+	if (sdd.verbose && sdd.dryrun)
+		sdd.std_out = B_TRUE;
+	fout = sdd.std_out ? stdout : stderr;
 
 	/*
 	 * Some flags require that we place user holds on the datasets that are
@@ -1554,12 +1560,12 @@ zfs_send(zfs_handle_t *zhp, const char *
 
 		if (flags->verbose) {
 			if (flags->parsable) {
-				(void) fprintf(stderr, "size\t%llu\n",
+				(void) fprintf(fout, "size\t%llu\n",
 				    (longlong_t)sdd.size);
 			} else {
 				char buf[16];
 				zfs_nicenum(sdd.size, buf, sizeof (buf));
-				(void) fprintf(stderr, dgettext(TEXT_DOMAIN,
+				(void) fprintf(fout, dgettext(TEXT_DOMAIN,
 				    "total estimated size is %s\n"), buf);
 			}
 		}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510141152.t9EBqwKv034053>