Skip to content

Commit 27aea86

Browse files
author
Damien Le Moal
committed
tools: read_zones: fix message output
Use stderr for errors. Signed-off-by: Damien Le Moal <[email protected]>
1 parent ea759c9 commit 27aea86

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

tools/read_zone/zbc_read_zone.c

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -43,30 +43,31 @@ static void zbc_read_zone_sigcatcher(int sig)
4343
zbc_read_zone_abort = 1;
4444
}
4545

46-
static int zbc_read_zone_usage(char *prog)
46+
static int zbc_read_zone_usage(FILE *out, char *prog)
4747
{
48-
printf("Usage: %s [options] <dev> <zone no> <I/O size (B)>\n"
49-
" Read from a zone up to the zone write pointer position\n"
50-
" or until specified number of I/Os are all executed.\n"
51-
"Options:\n"
52-
" -h | --help : Display this help message and exit\n"
53-
" -v : Verbose mode\n"
54-
" -scsi : Force the use of SCSI passthrough commands\n"
55-
" -ata : Force the use of ATA passthrough commands\n"
56-
" -dio : Use direct I/Os\n"
57-
" -vio <num> : Use vectored I/Os with <num> buffers of\n"
58-
" <I/O size> bytes, resulting in an actual\n"
59-
" I/O size of <num> x <I/O size> B\n"
60-
" -nio <num> : Limit the number of I/Os to <num>\n"
61-
" -p <num> : Expect all bytes that are read to have the\n"
62-
" value <num>. In case of a mismatch, the\n"
63-
" offset of the mismatch is printed\n"
64-
" -f <file> : Write the content of the zone to <file>\n"
65-
" If <file> is \"-\", the zone content is\n"
66-
" written to the standard output\n"
67-
" -ofst <ofst> : Read the zone starting at sector <ofst>\n"
68-
" instead of from the zone start sector\n",
69-
basename(prog));
48+
fprintf(out,
49+
"Usage: %s [options] <dev> <zone no> <I/O size (B)>\n"
50+
" Read from a zone up to the zone write pointer position\n"
51+
" or until specified number of I/Os are all executed.\n"
52+
"Options:\n"
53+
" -h | --help : Display this help message and exit\n"
54+
" -v : Verbose mode\n"
55+
" -scsi : Force the use of SCSI passthrough commands\n"
56+
" -ata : Force the use of ATA passthrough commands\n"
57+
" -dio : Use direct I/Os\n"
58+
" -vio <num> : Use vectored I/Os with <num> buffers of\n"
59+
" <I/O size> bytes, resulting in an actual\n"
60+
" I/O size of <num> x <I/O size> B\n"
61+
" -nio <num> : Limit the number of I/Os to <num>\n"
62+
" -p <num> : Expect all bytes that are read to have the\n"
63+
" value <num>. In case of a mismatch, the\n"
64+
" offset of the mismatch is printed\n"
65+
" -f <file> : Write the content of the zone to <file>\n"
66+
" If <file> is \"-\", the zone content is\n"
67+
" written to the standard output\n"
68+
" -ofst <ofst> : Read the zone starting at sector <ofst>\n"
69+
" instead of from the zone start sector\n",
70+
basename(prog));
7071
return 1;
7172
}
7273

@@ -100,13 +101,13 @@ int main(int argc, char **argv)
100101

101102
/* Parse command line */
102103
if (argc < 4)
103-
return zbc_read_zone_usage(argv[0]);
104+
return zbc_read_zone_usage(stderr, argv[0]);
104105

105106
for (i = 1; i < (argc - 1); i++) {
106107

107108
if (strcmp(argv[i], "-h") == 0 ||
108109
strcmp(argv[i], "--help") == 0)
109-
return zbc_read_zone_usage(argv[0]);
110+
return zbc_read_zone_usage(stdout, argv[0]);
110111

111112
if (strcmp(argv[i], "-v") == 0) {
112113

0 commit comments

Comments
 (0)