summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2014-03-28 04:14:40 +0000
committermarcel <marcel@FreeBSD.org>2014-03-28 04:14:40 +0000
commit533cda2b92026993e23c410ba270433e3defaf3e (patch)
tree510532c33c6c0d6719f3b3e11ebc6ae692c62f6d
parent4cf1c78a4377ad2825b5bc32a97c4a27a1b50e99 (diff)
downloadFreeBSD-src-533cda2b92026993e23c410ba270433e3defaf3e.zip
FreeBSD-src-533cda2b92026993e23c410ba270433e3defaf3e.tar.gz
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.
-rw-r--r--mkimg.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/mkimg.c b/mkimg.c
index 3c374dc..913a756 100644
--- a/mkimg.c
+++ b/mkimg.c
@@ -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);
OpenPOWER on IntegriCloud