From 246b0037a8314c3c5ebe216c386904674c683fc4 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 8 Aug 2021 03:52:58 -0400 Subject: [PATCH] initial implementation of extended seek (0x7142 - LONG LSEEK with 64-bit file position) --- kernel/dosfns.c | 14 +++++++++++--- kernel/inthndlr.c | 23 ++++++++++++++++++----- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 23d9974..74a0c10 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -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; } diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 788cc5d..73dada8 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -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,