[PATCH [mtd-utils] 3/3] nandwrite: add --input-{skip,size} options

Gupta, Pekon pekon at ti.com
Thu May 9 06:42:01 EDT 2013


>  	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.


with regards, pekon



More information about the linux-mtd mailing list