Skip to content

Commit 9abcb8f

Browse files
committed
fix extended 7303 success check for EDR based DOS kernels
1 parent 67c1aca commit 9abcb8f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/misc.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,14 @@ unsigned long extended_dos_getdiskfree(unsigned drive, int *error)
364364
intdosx( &r, &r, &s );
365365

366366
/* see if call supported, if not then fallback to older get disk free API call */
367-
if (!(r.w.cflag & 0x01) && (r.h.al))
367+
/* Note: from RBIL returning AL=0 (with carry unchanged/clear) means unimplemented,
368+
in such cases AH is unchanged, so will AH will still by 0x73, i.e. returning AX=0x7300
369+
EDR kernel returns with AX=0 if successful so error must check AX=7300 instead of just AL for 0
370+
FreeDOS kernel returns with AX unchanged, i.e. 0x7303 on success
371+
If returns carry set then AX is undefined, but an error.
372+
(carry OR (AX == 0x7300)) indicates error, so we check for NOT (carry OR (AX == 0x7300))
373+
*/
374+
if (!(r.w.cflag & 0x01) && (r.w.ax != 0x7300)) /* call available and successfully returned */
368375
{
369376
/* calculate free space, but handle some overflow cases (or switch to 64bit values) */
370377
clustersize = FAT32_Free_Space.sectors_per_cluster * FAT32_Free_Space.bytes_per_sector;

0 commit comments

Comments
 (0)