From patchwork Mon Sep 8 06:45:57 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 206 Return-Path: X-Original-To: patchwork@ozlabs.org Delivered-To: patchwork@ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2D620DDE1D for ; Mon, 8 Sep 2008 16:46:07 +1000 (EST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.68 #1 (Red Hat Linux)) id 1KcaVd-0006s3-6L; Mon, 08 Sep 2008 06:46:01 +0000 Received: from relay03.pair.com ([209.68.5.17]) by bombadil.infradead.org with smtp (Exim 4.68 #1 (Red Hat Linux)) id 1KcaVb-0006rZ-TC for linux-mtd@lists.infradead.org; Mon, 08 Sep 2008 06:46:00 +0000 Received: (qmail 70706 invoked by uid 0); 8 Sep 2008 06:45:58 -0000 Received: from unknown (HELO localhost.localdomain) (unknown) by unknown with SMTP; 8 Sep 2008 06:45:58 -0000 X-pair-Authenticated: 66.134.71.115 From: Grant Erickson To: linux-mtd@lists.infradead.org Subject: [PATCH 6/6] [MTD-UTILS] nanddump: Add Support for Quiet Option Date: Sun, 7 Sep 2008 23:45:57 -0700 Message-Id: <1220856357-22854-1-git-send-email-gerickson@nuovations.com> X-Mailer: git-send-email 1.6.0.1 Organization: Nuovation System Designs, LLC X-Spam-Score: -1.0 (-) X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary: Content analysis details: (-1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.68.5.17 listed in list.dnswl.org] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+patchwork=ozlabs.org@lists.infradead.org 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 diff --git a/nanddump.c b/nanddump.c index b8332f9..678d684 100644 --- a/nanddump.c +++ b/nanddump.c @@ -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) {