flashcp
Jörn Engel
joern at logfs.org
Thu Jul 19 20:28:21 EDT 2007
On Fri, 20 July 2007 01:23:46 +0200, Tobias Simon wrote:
>
> I just saw the following line, which is part of the original source:
> "if (filestat.st_size % mtd.erasesize) erase.length += mtd.erasesize;"
>
> ... or left there in conjunction with your "rounding down" code:
>
>
> --- flashcp_old.c 2007-07-20 01:15:28.000000000 +0200
> +++ flashcp_b.c 2007-07-20 01:14:02.000000000 +0200
> @@ -257,9 +257,12 @@
> #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;
> - if (flags & FLAG_VERBOSE)
> +
> + erase.length = (filestat.st_size / mtd.erasesize) * mtd.erasesize;
> + if (filestat.st_size % mtd.erasesize)
> + erase.length += 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 */
> int blocks = erase.length / mtd.erasesize;
Maybe something like this:
#define ODD_ALIGN(n, align) ((((n) + (align) - 1) / (align)) * (align))
...
erase.length = ODD_ALIGN(filestat.st_size, mtd.erasesize);
But I should really disengage now. I don't even know what flashcp is
supposed to do.
Jörn
--
Data expands to fill the space available for storage.
-- Parkinson's Law
More information about the linux-mtd
mailing list