diff options
author | Grant Erickson <gerickson@nuovations.com> | 2008-09-07 20:45:57 +0000 |
---|---|---|
committer | Josh Boyer <jwboyer@gmail.com> | 2008-09-08 10:28:57 -0400 |
commit | 41c53b6f2d756ae995c3ffa4455576515427c5e0 (patch) | |
tree | ff850836f5cfb5cf0feb63652c7437294f9f4227 /nanddump.c | |
parent | 864d88dc1bb2127b9b714c5d15083ca8cb5a93c2 (diff) |
nanddump: Add Support for Quiet Option
Added support for the '-q,--quiet' option to suppress diagnostic output.
Made the new option mutually-exclusive with the pretty print option.
Signed-off-by: Grant Erickson <gerickson@nuovations.com>
Acked-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: Josh Boyer <jwboyer@gmail.com>
Diffstat (limited to 'nanddump.c')
-rw-r--r-- | nanddump.c | 36 |
1 files changed, 26 insertions, 10 deletions
@@ -52,6 +52,7 @@ static void display_help (void) "-o --omitoob Omit oob data\n" "-b --omitbad Omit bad blocks from the dump\n" "-p --prettyprint Print nice (hexdump)\n" +"-q --quiet Don't display progress and status messages\n" "-s addr --startaddress=addr Start address\n" ); exit(EXIT_SUCCESS); @@ -81,6 +82,7 @@ static unsigned long length; // dump length static const char *mtddev; // mtd device name static const char *dumpfile; // dump file name static bool omitbad = false; +static bool quiet = false; // suppress diagnostic output static void process_options (int argc, char * const argv[]) { @@ -88,7 +90,7 @@ static void process_options (int argc, char * const argv[]) for (;;) { int option_index = 0; - static const char *short_options = "bs:f:il:opn"; + static const char *short_options = "bs:f:il:opqn"; static const struct option long_options[] = { {"help", no_argument, 0, 0}, {"version", no_argument, 0, 0}, @@ -100,6 +102,7 @@ static void process_options (int argc, char * const argv[]) {"startaddress", required_argument, 0, 's'}, {"length", required_argument, 0, 'l'}, {"noecc", no_argument, 0, 'n'}, + {"quiet", no_argument, 0, 'q'}, {0, 0, 0, 0}, }; @@ -144,6 +147,9 @@ static void process_options (int argc, char * const argv[]) case 'p': pretty_print = true; break; + case 'q': + quiet = true; + break; case 'n': noecc = true; break; @@ -153,6 +159,12 @@ static void process_options (int argc, char * const argv[]) } } + if (quiet && pretty_print) { + fprintf(stderr, "The quiet and pretty print options are mutually-\n" + "exclusive. Choose one or the other.\n"); + exit(EXIT_FAILURE); + } + if ((argc - optind) != 1 || error) display_help (); @@ -239,10 +251,12 @@ int main(int argc, char * const argv[]) /* check if we can read ecc stats */ if (!ioctl(fd, ECCGETSTATS, &stat1)) { eccstats = true; - fprintf(stderr, "ECC failed: %d\n", stat1.failed); - fprintf(stderr, "ECC corrected: %d\n", stat1.corrected); - fprintf(stderr, "Number of bad blocks: %d\n", stat1.badblocks); - fprintf(stderr, "Number of bbt blocks: %d\n", stat1.bbtblocks); + if (!quiet) { + fprintf(stderr, "ECC failed: %d\n", stat1.failed); + fprintf(stderr, "ECC corrected: %d\n", stat1.corrected); + fprintf(stderr, "Number of bad blocks: %d\n", stat1.badblocks); + fprintf(stderr, "Number of bbt blocks: %d\n", stat1.bbtblocks); + } } else perror("No ECC status information available"); } @@ -266,12 +280,14 @@ int main(int argc, char * const argv[]) bs = meminfo.writesize; /* Print informative message */ - fprintf(stderr, "Block size %u, page size %u, OOB size %u\n", - meminfo.erasesize, meminfo.writesize, meminfo.oobsize); - fprintf(stderr, - "Dumping data starting at 0x%08x and ending at 0x%08x...\n", - (unsigned int) start_addr, (unsigned int) end_addr); + if (!quiet) { + fprintf(stderr, "Block size %u, page size %u, OOB size %u\n", + meminfo.erasesize, meminfo.writesize, meminfo.oobsize); + fprintf(stderr, + "Dumping data starting at 0x%08x and ending at 0x%08x...\n", + (unsigned int) start_addr, (unsigned int) end_addr); + } /* Dump the flash contents */ for (ofs = start_addr; ofs < end_addr ; ofs+=bs) { |