Author: wmb Date: 2007-11-20 08:40:33 +0100 (Tue, 20 Nov 2007) New Revision: 738
Modified: ofw/fs/fatfs/write.fth Log: OLPC trac 5029 - Fixed a problem that caused files written from OFW to be 0x400 bytes too short in certain cases.
Modified: ofw/fs/fatfs/write.fth =================================================================== --- ofw/fs/fatfs/write.fth 2007-11-19 23:48:42 UTC (rev 737) +++ ofw/fs/fatfs/write.fth 2007-11-20 07:40:33 UTC (rev 738) @@ -80,7 +80,7 @@ \ If we need more cluster(s) and \ we're at or beyond the end of the file, add new cluster(s) dup 0> - current-position fh_length l@ > last-cluster? or and if + current-position fh_length l@ > last-cluster? or and if extend-file ?dup if ?flush-fat-cache nip exit then extended? on else \ same cluster? @@ -94,17 +94,19 @@ ?flush-fat-cache true exit then
- \ If this is a partial cluster without extension, - \ then adjust the length field - remaining @ /cluster < extended? @ invert and if + \ Adjust the length field unless extend-file already did it + extended? @ 0= if current-position remaining @ + fh_length l! then
\ Continue with the rest of the transfer #cont-cls @ /cluster * dup bufadr +! negate remaining +!
- next-cl# @ ?dup if 1st-cl# ! 1 #cont-cls ! next-cl# off - else 1st-cl# off #cont-cls off then + next-cl# @ ?dup if + 1st-cl# ! 1 #cont-cls ! next-cl# off + else + 1st-cl# off #cont-cls off + then
last-cluster? 0= if to-next-cluster then repeat drop ( )