initial implementation of extended seek (0x7142 - LONG LSEEK with 64-bit file position)

This commit is contained in:
Kenneth J Davis 2021-08-08 03:52:58 -04:00
parent 15900d7827
commit 246b0037a8
2 changed files with 29 additions and 8 deletions

View File

@ -306,7 +306,7 @@ long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode)
return rwblock(sft_idx, bp, n, mode);
}
COUNT SftSeek(int sft_idx, LONG new_pos, unsigned mode)
COUNT SftSeek2(int sft_idx, LONG new_pos, unsigned mode, UDWORD * p_result)
{
sft FAR *s = idx_to_sft(sft_idx);
if (FP_OFF(s) == (size_t) -1)
@ -347,17 +347,25 @@ COUNT SftSeek(int sft_idx, LONG new_pos, unsigned mode)
}
s->sft_posit = new_pos;
*p_result = new_pos;
return SUCCESS;
}
COUNT SftSeek(int sft_idx, LONG new_pos, unsigned mode)
{
UDWORD result;
return SftSeek2(sft_idx, new_pos, mode, &result);
}
ULONG DosSeek(unsigned hndl, LONG new_pos, COUNT mode, int *rc)
{
int sft_idx = get_sft_idx(hndl);
UDWORD result;
/* Get the SFT block that contains the SFT */
*rc = SftSeek(sft_idx, new_pos, mode);
*rc = SftSeek2(sft_idx, new_pos, mode, &result);
if (*rc == SUCCESS)
return idx_to_sft(sft_idx)->sft_posit;
return result;
return *rc;
}

View File

@ -952,8 +952,7 @@ dispatch:
case 0x42:
if (lr.AL > 2)
goto error_invalid;
lrc = DosSeek(lr.BX, (LONG)((((ULONG) (lr.CX)) << 16) | lr.DX), lr.AL,
&rc);
lrc = DosSeek(lr.BX, (LONG)MK_ULONG(lr.CX, lr.DX), lr.AL, &rc);
if (rc == SUCCESS)
{
lr.DX = (UWORD)(lrc >> 16);
@ -1601,8 +1600,9 @@ lfn_findclose:
goto unsupp;
#endif
#endif
/* EDR-DOS LFN - Long LSEEK - SET CURRENT 64-bit FILE POSITION */
case 0x42:
/* Win95 LFN - get file info by handle */
case 0x42: /* ??? */
case 0xa6: {
/* only passed to redirector supported for now */
iregs saved_r;
@ -1621,8 +1621,11 @@ lfn_findclose:
rc = DE_INVLDHNDL;
goto error_exit;
}
if (!(s->sft_flags & SFT_FSHARED))
goto unsupp; /* unsupported on local fs yet */
if (!(s->sft_flags & SFT_FSHARED)) {
if (lr.AL != 0x42) {
goto unsupp; /* unsupported on local fs yet */
}
}
/* call to redirector */
saved_r = *r;
r->ES = FP_SEG(s);
@ -2201,6 +2204,16 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs FAR *pr)
rc = DosClose(r.BX);
goto short_check;
case 0x42: /* 64-bit move file pointer */
{
/* r.(DS:DX) points to 64-bit file position instead of r.(CX:DX) being 32-bit file position */
UWORD FAR *filepos = MK_FP(r.DS, r.DX);
if (*(filepos+1) != 0) /* we currently only handle lower 32 bits, upper 32 bits must be 0 */
goto error_invalid;
r.BP = (UWORD)r.CL;
r.CX = *filepos;
/* fall through to 32-bit move file pointer (0x28) */
}
case 0x28: /* move file pointer */
/*
* RBIL says: "sets user stack frame pointer to dummy buffer,