From fdb58291c49f9757f16f85d5fb2d46ab550ff32b Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 11 Oct 2003 23:58:51 +0000 Subject: [PATCH] Fix FCB problems with int21/ah=27,28 (RandomBlockIO) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@715 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fcbfns.c | 19 +++++++++++++------ kernel/inthndlr.c | 4 ++-- kernel/proto.h | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 6942b13..0c71a95 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -337,19 +337,26 @@ void FcbCalcRec(xfcb FAR * lpXfcb) lpFcb->fcb_curec = lpFcb->fcb_rndm & 127; } -UBYTE FcbRandomBlockIO(xfcb FAR * lpXfcb, COUNT nRecords, int mode) +UBYTE FcbRandomBlockIO(xfcb FAR * lpXfcb, UWORD *nRecords, int mode) { - UCOUNT recno = 0; - UBYTE nErrorCode; + unsigned recno; + UBYTE nErrorCode = FCB_SUCCESS; FcbCalcRec(lpXfcb); /* Convert to fcb if necessary */ lpFcb = ExtFcbToFcb(lpXfcb); - do - nErrorCode = FcbReadWrite(lpXfcb, recno++, mode); - while ((--nRecords > 0) && (nErrorCode == 0)); + for (recno = 0; recno < *nRecords; recno++) + { + nErrorCode = FcbReadWrite(lpXfcb, recno, mode); + /* end-of-file, partial read should count last record */ + if (nErrorCode == FCB_ERR_EOF) + recno++; + if (nErrorCode != FCB_SUCCESS) + break; + } + *nRecords = recno; /* Now update the fcb */ lpFcb->fcb_rndm = FcbRec(); diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 556ea69..1290538 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -658,12 +658,12 @@ dispatch: /* Read random record(s) using FCB */ case 0x27: - lr.AL = FcbRandomBlockIO(FP_DS_DX, lr.CX, XFR_READ); + lr.AL = FcbRandomBlockIO(FP_DS_DX, &lr.CX, XFR_READ); break; /* Write random record(s) using FCB */ case 0x28: - lr.AL = FcbRandomBlockIO(FP_DS_DX, lr.CX, XFR_WRITE); + lr.AL = FcbRandomBlockIO(FP_DS_DX, &lr.CX, XFR_WRITE); break; /* Parse File Name */ diff --git a/kernel/proto.h b/kernel/proto.h index c28c1ad..c82c76a 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -210,7 +210,7 @@ const BYTE FAR *GetNameField(const BYTE FAR * lpFileName, BYTE FAR * lpDestField UBYTE FcbReadWrite(xfcb FAR *, UCOUNT, int); UBYTE FcbGetFileSize(xfcb FAR * lpXfcb); void FcbSetRandom(xfcb FAR * lpXfcb); -UBYTE FcbRandomBlockIO(xfcb FAR * lpXfcb, COUNT nRecords, int mode); +UBYTE FcbRandomBlockIO(xfcb FAR * lpXfcb, UWORD *nRecords, int mode); UBYTE FcbRandomIO(xfcb FAR * lpXfcb, int mode); UBYTE FcbOpen(xfcb FAR * lpXfcb, unsigned flags); int FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive);