From: John Hodge Date: Fri, 11 Nov 2011 05:00:40 +0000 (+0800) Subject: Modules/FDDv2 - Fixed calling _ReadWithinTrack when no bytes remaining X-Git-Tag: rel0.14~123 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=1345302e0da9fe44b05709d5b3d2aa5889c55d9e;p=tpg%2Facess2.git Modules/FDDv2 - Fixed calling _ReadWithinTrack when no bytes remaining --- diff --git a/Modules/Storage/FDDv2/main.c b/Modules/Storage/FDDv2/main.c index bbe79f9c..0821a589 100644 --- a/Modules/Storage/FDDv2/main.c +++ b/Modules/Storage/FDDv2/main.c @@ -184,7 +184,7 @@ Uint64 FDD_ReadFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) if( Offset ) { int len; - if(rem_len > BYTES_PER_TRACK-Offset) + if(rem_len > BYTES_PER_TRACK - Offset) len = BYTES_PER_TRACK - Offset; else len = rem_len; @@ -194,15 +194,18 @@ Uint64 FDD_ReadFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) track ++; } - while( rem_len > BYTES_PER_TRACK ) + if( rem_len > 0) { - FDD_int_ReadWriteWithinTrack(disk, track, 0, 0, BYTES_PER_TRACK, dest); - dest += BYTES_PER_TRACK; - rem_len -= BYTES_PER_TRACK; - track ++; - } + while( rem_len > BYTES_PER_TRACK ) + { + FDD_int_ReadWriteWithinTrack(disk, track, 0, 0, BYTES_PER_TRACK, dest); + dest += BYTES_PER_TRACK; + rem_len -= BYTES_PER_TRACK; + track ++; + } - FDD_int_ReadWriteWithinTrack(disk, track, 0, 0, rem_len, dest); + FDD_int_ReadWriteWithinTrack(disk, track, 0, 0, rem_len, dest); + } LEAVE('X', Length); return Length; @@ -218,6 +221,9 @@ int FDD_int_ReadWriteWithinTrack(int Disk, int Track, int bWrite, size_t Offset, if( Offset + Length > BYTES_PER_TRACK ) return 1; + if( Length == 0 ) + return 0; + ENTER("iDisk iTrack bbWrite xOffset xLength pBuffer", Disk, Track, bWrite, Offset, Length, Buffer);