[PATCH [mtd-utils] 3/3] nandwrite: add --input-{skip,size} options
Gupta, Pekon
pekon at ti.com
Fri May 10 00:52:40 EDT 2013
> On Thursday 09 May 2013 06:42:01 Gupta, Pekon wrote:
> > > pagelen = mtd.min_io_size + ((writeoob) ? mtd.oob_size : 0);
> > > + imglen = inputsize ? : pagelen;
> > > + if (inputskip) {
> > > + errmsg("seeking stdin does not work");
> > > + goto closeall;
> > > + }
> > > } else {
> > > - struct stat st;
> > > - if (fstat(ifd, &st)) {
> > > - sys_errmsg("unable to stat input image");
> > > + if (!inputsize) {
> > > + struct stat st;
> > > + if (fstat(ifd, &st)) {
> > > + sys_errmsg("unable to stat input
> > > image");
> > > + goto closeall;
> > > + }
> > > + imglen = st.st_size;
> > > + } else
> > > + imglen = inputsize;
> >
> > [Pekon]: It would be good to check that both 'inputsize' & 'inputskip'
> > are multiples of:
> > - mtd->writesize : if not using '-o' option, OR
> > - (mtd->writesize + mtd->oobsize): is using '-o' option.
> > Or Simply, both arguments should be aligned to 'pagelen' boundary.
>
> mmm, i don't think so. the input alignment (inputskip) is entirely
> irrelevant
> to the output.
>
[Pekon]: I'm coming from the back-ground that most users 'dd' or
'nanddump' to generate write-data for 'nandwrite'.
Thus the write-data would be mostly 'pagelen' aligned.
Example:
If the write-data contains OOB data, and user forgets to take that
into account while calculating 'inputskip' offset, then everything
would be wrongly shifted by the offset.
So you need not flag an Error, but a warning may do, so user is
hinted at his mistake.
> as for inputsize, we already do that check. if you read the code further
> (like 5 lines below the diff here), you'll see the --pad flag handling.
>
[Pekon]: Ok.. yes, its there..
> -mike
with regards, pekon
More information about the linux-mtd
mailing list