Skip to content

Commit 8d29d66

Browse files
committed
test for uninitialized dpb on INT25,26 and always allow rw block zero
The problem is that ISFAT32 macro only tests for dpb->fatsize = 0, and not also for xfatsize != 0. So the ISFAT32 macro returns a "false positive" on uninitialized dpbs, where both fatsize and xfatsize are zero. This fixes #200. However, the dpb is not properly initialized via a media check by an INT25,26 yet. This commit makes sure that written sectors are removed from the block cache.
1 parent 654e7b7 commit 8d29d66

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

kernel/inthndlr.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,6 +1812,7 @@ VOID ASMCFUNC int2526_handler(WORD mode, struct int25regs FAR * r)
18121812
UWORD nblks;
18131813
BYTE FAR *buf;
18141814
UBYTE drv;
1815+
struct dpb FAR *dpbp;
18151816

18161817
if (mode == 0x26)
18171818
mode = DSKWRITEINT26;
@@ -1822,17 +1823,23 @@ VOID ASMCFUNC int2526_handler(WORD mode, struct int25regs FAR * r)
18221823
/* high bit of AL set, so mask it together with AH */
18231824
/* otherwise we might access a non-existing unit */
18241825

1825-
if (drv >= lastdrive)
1826+
dpbp = get_dpb(drv);
1827+
1828+
if (drv >= lastdrive || dpbp == NULL)
18261829
{
18271830
r->ax = 0x201;
18281831
SET_CARRY_FLAG();
18291832
return;
18301833
}
18311834

1835+
nblks = r->cx;
1836+
blkno = r->dx;
1837+
18321838
#ifdef WITHFAT32
18331839
{
1834-
struct dpb FAR *dpbp = get_dpb(drv);
1835-
if (dpbp != NULL && ISFAT32(dpbp))
1840+
/* if reading / writing block other than bootsecter,
1841+
prevent using INT25,26 on initialized FAT32 */
1842+
if ((blkno != 0) && ISFAT32(dpbp) && (dpbp->dpb_xfatsize != 0))
18361843
{
18371844
r->ax = 0x207;
18381845
SET_CARRY_FLAG();
@@ -1841,9 +1848,6 @@ VOID ASMCFUNC int2526_handler(WORD mode, struct int25regs FAR * r)
18411848
}
18421849
#endif
18431850

1844-
nblks = r->cx;
1845-
blkno = r->dx;
1846-
18471851
buf = MK_FP(r->ds, r->bx);
18481852

18491853
if (nblks == 0xFFFF)
@@ -1856,6 +1860,7 @@ VOID ASMCFUNC int2526_handler(WORD mode, struct int25regs FAR * r)
18561860

18571861
InDOS++;
18581862

1863+
DeleteBlockInBufferCache(blkno, blkno, drv, XFR_WRITE);
18591864
r->ax = dskxfer(drv, blkno, buf, nblks, mode);
18601865

18611866
CLEAR_CARRY_FLAG();

0 commit comments

Comments
 (0)