From: Andreas Engel <andreas.engel@marconi.com>
To: linux-mtd@lists.infradead.org
Subject: [PATCH][MTD-UTILS] flashcp.c: Add new option -f/--full
Date: Mon, 04 Dec 2006 09:58:00 +0100 [thread overview]
Message-ID: <4573E318.4040604@marconi.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 254 bytes --]
This patch adds the option -f/--full which erases the whole flash
partition instead of just the sectors necessary for writing the file.
This might come in handy when copying filesystem images.
Signed-off-by: Andreas Engel <andreas.engel@ericsson.com>
[-- Attachment #2: flashcp.patch --]
[-- Type: text/x-patch, Size: 2061 bytes --]
diff --git a/flashcp.c b/flashcp.c
index 64b2eca..ef51d37 100644
--- a/flashcp.c
+++ b/flashcp.c
@@ -71,6 +71,7 @@ typedef int bool;
#define FLAG_HELP 0x02
#define FLAG_FILENAME 0x04
#define FLAG_DEVICE 0x08
+#define FLAG_FULLERASE 0x10
/* error levels */
#define LOG_NORMAL 1
@@ -99,6 +100,7 @@ static void showusage (const char *progn
"\n"
" -h | --help Show this help message\n"
" -v | --verbose Show progress reports\n"
+ " -f | --full Erase whole partition\n"
" <filename> File which you want to copy to flash\n"
" <device> Flash device to write to (e.g. /dev/mtd0, /dev/mtd1, etc.)\n"
"\n",
@@ -184,10 +186,11 @@ int main (int argc,char *argv[])
for (;;) {
int option_index = 0;
- static const char *short_options = "hv";
+ static const char *short_options = "hvf";
static const struct option long_options[] = {
{"help", no_argument, 0, 'h'},
{"verbose", no_argument, 0, 'v'},
+ {"full", no_argument, 0, 'f'},
{0, 0, 0, 0},
};
@@ -206,6 +209,10 @@ int main (int argc,char *argv[])
flags |= FLAG_VERBOSE;
DEBUG("Got FLAG_VERBOSE\n");
break;
+ case 'f':
+ flags |= FLAG_FULLERASE;
+ DEBUG("Got FLAG_FULLERASE\n");
+ break;
default:
DEBUG("Unknown parameter: %s\n",argv[option_index]);
showusage (progname,true);
@@ -257,8 +264,10 @@ int main (int argc,char *argv[])
#warning "Check for smaller erase regions"
erase.start = 0;
- erase.length = filestat.st_size & ~(mtd.erasesize - 1);
- if (filestat.st_size % mtd.erasesize) erase.length += mtd.erasesize;
+ erase.length = (flags & FLAG_FULLERASE) ? mtd.size : filestat.st_size;
+ if (erase.length % mtd.erasesize)
+ erase.length = (erase.length & ~(mtd.erasesize - 1)) + mtd.erasesize;
+
if (flags & FLAG_VERBOSE)
{
/* if the user wants verbose output, erase 1 block at a time and show him/her what's going on */
@@ -388,4 +397,3 @@ int main (int argc,char *argv[])
exit (EXIT_SUCCESS);
}
-
reply other threads:[~2006-12-04 8:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4573E318.4040604@marconi.com \
--to=andreas.engel@marconi.com \
--cc=linux-mtd@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.