[U-Boot] [PATCH] fs: fat: fix bug when write size is less than a sector size

Wolfgang Denk wd at denx.de
Fri Jul 19 13:20:34 CEST 2013


Dear Josh Wu,

In message <51E90A3D.6000007 at atmel.com> you wrote:
> 
> > Why would this be needed?  The case of a partial write is covered
> > further down below in the code, in the "if (size % mydata->sect_size)"
> > part...
> 
> The call of disk_write() will pass the sector size as 0. That will cause 
> the mmc driver stalled.

I think instead of "sector size" you mean the number of sectors.  The
sector size is fixed.

Big question: why should we call disk_write() at all when the count is
zero? Maybe a simple

	if ((size / mydata->sect_size) > 0) {
		if (disk_write(startsect, size / mydata->sect_size, buffer) < 0) {
			...
		}
	}

would fix this issue?


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Der Irrtum wiederholt sich immerfort in der Tat.  Deshalb muß man das
Wahre unermüdlich in Worten wiederholen.                     - Goethe


More information about the U-Boot mailing list