Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Mar 2014 04:14:40 +0000 (UTC)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r263862 - user/marcel/mkimg
Message-ID:  <201403280414.s2S4EeXL061811@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marcel
Date: Fri Mar 28 04:14:40 2014
New Revision: 263862
URL: http://svnweb.freebsd.org/changeset/base/263862

Log:
  Write verbosity to stderr. The image may be written to stdout.
  While here, fix writing to stderr, by not calling errc()
  unconditionally, but only when there's an error.

Modified:
  user/marcel/mkimg/mkimg.c

Modified: user/marcel/mkimg/mkimg.c
==============================================================================
--- user/marcel/mkimg/mkimg.c	Fri Mar 28 03:49:49 2014	(r263861)
+++ user/marcel/mkimg/mkimg.c	Fri Mar 28 04:14:40 2014	(r263862)
@@ -337,8 +337,8 @@ mkimg(int bfd)
 	STAILQ_FOREACH(part, &partlist, link) {
 		block = scheme_metadata(SCHEME_META_PART_BEFORE, block);
 		if (verbose)
-			printf("partition %d: starting block %llu ... ",
-			    part->index + 1, (long long)block);
+			fprintf(stderr, "partition %d: starting block %llu "
+			    "... ", part->index + 1, (long long)block);
 		part->block = block;
 		error = mkimg_seek(tmpfd, block);
 		switch (part->kind) {
@@ -368,7 +368,7 @@ mkimg(int bfd)
 		part->size = (bytesize + secsz - 1) / secsz;
 		if (verbose) {
 			bytesize = part->size * secsz;
-			printf("size %llu bytes (%llu blocks)\n",
+			fprintf(stderr, "size %llu bytes (%llu blocks)\n",
 			     (long long)bytesize, (long long)part->size);
 		}
 		block = scheme_metadata(SCHEME_META_PART_AFTER,
@@ -478,22 +478,23 @@ main(int argc, char *argv[])
 		tmpfd = outfd;
 
 	if (verbose) {
-		printf("Logical sector size: %u\n", secsz);
-		printf("Physical block size: %u\n", blksz);
-		printf("Sectors per track:   %u\n", nsecs);
-		printf("Number of heads:     %u\n", nheads);
+		fprintf(stderr, "Logical sector size: %u\n", secsz);
+		fprintf(stderr, "Physical block size: %u\n", blksz);
+		fprintf(stderr, "Sectors per track:   %u\n", nsecs);
+		fprintf(stderr, "Number of heads:     %u\n", nheads);
 	}
 
 	mkimg(bcfd);
 
 	if (verbose)
-		printf("Number of cylinders: %u\n", ncyls);
+		fprintf(stderr, "Number of cylinders: %u\n", ncyls);
 
 	if (tmpfd != outfd) {
 		error = mkimg_seek(tmpfd, 0);
 		if (error == 0)
 			error = fdcopy(tmpfd, outfd, NULL);
-		errc(EX_IOERR, error, "writing to stdout");
+		if (error)
+			errc(EX_IOERR, error, "writing to stdout");
 	}
 
 	return (0);



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