public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: kerolasa@iki.fi
Subject: [PATCH 7/9] isosize: move file name printing after error determination
Date: Sun, 16 Feb 2014 23:54:20 +0000	[thread overview]
Message-ID: <1392594862-15807-7-git-send-email-kerolasa@iki.fi> (raw)
In-Reply-To: <1392594862-15807-1-git-send-email-kerolasa@iki.fi>

Earlier the filename printing was buffered, and exit at error made output
to appear in front of prompt.  Output below demonstrates the brokenness.

prompt> isosize /etc /
isosize: /etc: might not be an ISO filesystem
isosize: read error on /etc: Is a directory
/etc: prompt>

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 disk-utils/isosize.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/disk-utils/isosize.c b/disk-utils/isosize.c
index 4c16ec5..f90029e 100644
--- a/disk-utils/isosize.c
+++ b/disk-utils/isosize.c
@@ -125,7 +125,7 @@ struct iso_primary_descriptor
 	unsigned char unused5			[ISODCL (1396, 2048)];
 };
 
-static void isosize(char *filenamep, int xflag, long divisor)
+static void isosize(int argc, char *filenamep, int xflag, long divisor)
 {
 	int fd, nsecs, ssize;
 	struct iso_primary_descriptor ipd;
@@ -145,6 +145,8 @@ static void isosize(char *filenamep, int xflag, long divisor)
 	/* isonum_723 returns nowadays always 2048 */
 	ssize = isonum_723(ipd.logical_block_size, xflag);
 
+	if (1 < argc)
+		printf("%s: ", filenamep);
 	if (xflag) {
 		printf(_("sector count: %d, sector size: %d\n"), nsecs, ssize);
 	} else {
@@ -220,11 +222,8 @@ int main(int argc, char **argv)
 	if (ct <= 0)
 		usage(stderr);
 
-	for (j = optind; j < argc; j++) {
-		if (ct > 1)
-			printf("%s: ", argv[j]);
-		isosize(argv[j], xflag, divisor);
-	}
+	for (j = optind; j < argc; j++)
+		isosize(ct, argv[j], xflag, divisor);
 
 	return EXIT_SUCCESS;
 }
-- 
1.9.0


  parent reply	other threads:[~2014-02-16 23:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-16 23:54 [PATCH 1/9] tests: avoid executing dirname(1) command Sami Kerola
2014-02-16 23:54 ` [PATCH 2/9] tests: make tests to run parallel Sami Kerola
2014-02-17 14:11   ` Karel Zak
2014-02-16 23:54 ` [PATCH 3/9] tools: add usage information to checkconfig.sh Sami Kerola
2014-02-16 23:54 ` [PATCH 4/9] docs: make hexdump.1 color specification easier to understand Sami Kerola
2014-02-16 23:54 ` [PATCH 5/9] tests: align last.1 with recent phantom detection Sami Kerola
2014-02-16 23:54 ` [PATCH 6/9] swaplabel: wrong version number in check Sami Kerola
2014-02-16 23:54 ` Sami Kerola [this message]
2014-02-16 23:54 ` [PATCH 8/9] tests: add isosize --sectors and --divisor tests Sami Kerola
2014-02-16 23:54 ` [PATCH 9/9] isosize: make --divisor to require argument Sami Kerola

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1392594862-15807-7-git-send-email-kerolasa@iki.fi \
    --to=kerolasa@iki.fi \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox