mirror of
https://github.com/FDOS/kernel.git
synced 2025-07-13 00:44:29 +02:00
Seek changes:
* merge unstable kernel optimizations * enable seek for int2f/AX=1228 * -1 is a valid offset, so we need to process the return code seperately git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@1429 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
parent
288a2f396b
commit
e0ca8d76e2
@ -129,7 +129,7 @@ typedef struct sfttbl {
|
||||
#define SFT_FCONOUT 0x0002 /* device is console output */
|
||||
#define SFT_FCONIN 0x0001 /* device is console input */
|
||||
|
||||
/* Covienence defines */
|
||||
/* Convenience defines */
|
||||
#define sft_dcb sft_dcb_or_dev._sft_dcb
|
||||
#define sft_dev sft_dcb_or_dev._sft_dev
|
||||
|
||||
@ -137,3 +137,7 @@ typedef struct sfttbl {
|
||||
#define sft_flags_hi sft_flags_union._split_sft_flags._sft_flags_hi
|
||||
#define sft_flags_lo sft_flags_union._split_sft_flags._sft_flags_lo
|
||||
|
||||
/* defines for LSEEK */
|
||||
#define SEEK_SET 0u
|
||||
#define SEEK_CUR 1u
|
||||
#define SEEK_END 2u
|
||||
|
@ -305,14 +305,14 @@ long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode)
|
||||
}
|
||||
}
|
||||
|
||||
COUNT SftSeek(int sft_idx, LONG new_pos, COUNT mode)
|
||||
COUNT SftSeek(int sft_idx, LONG new_pos, unsigned mode)
|
||||
{
|
||||
sft FAR *s = idx_to_sft(sft_idx);
|
||||
if (FP_OFF(s) == (size_t) -1)
|
||||
return DE_INVLDHNDL;
|
||||
|
||||
/* Test for invalid mode */
|
||||
if (mode < 0 || mode > 2)
|
||||
if (mode > SEEK_END)
|
||||
return DE_INVLDFUNC;
|
||||
|
||||
lpCurSft = s;
|
||||
@ -320,12 +320,13 @@ COUNT SftSeek(int sft_idx, LONG new_pos, COUNT mode)
|
||||
/* Do special return for character devices */
|
||||
if (s->sft_flags & SFT_FDEVICE)
|
||||
{
|
||||
s->sft_posit = 0l;
|
||||
return SUCCESS;
|
||||
new_pos = 0;
|
||||
}
|
||||
|
||||
/* seek from end of file */
|
||||
if (mode == 2)
|
||||
else if (mode == SEEK_CUR)
|
||||
{
|
||||
new_pos += s->sft_posit;
|
||||
}
|
||||
else if (mode == SEEK_END) /* seek from end of file */
|
||||
{
|
||||
/*
|
||||
* RB list has it as Note:
|
||||
@ -339,29 +340,24 @@ COUNT SftSeek(int sft_idx, LONG new_pos, COUNT mode)
|
||||
*/
|
||||
if ((s->sft_flags & SFT_FSHARED) &&
|
||||
(s->sft_mode & (O_DENYREAD | O_DENYNONE)))
|
||||
s->sft_posit = remote_lseek(s, new_pos);
|
||||
new_pos = remote_lseek(s, new_pos);
|
||||
else
|
||||
s->sft_posit = s->sft_size + new_pos;
|
||||
new_pos += s->sft_size;
|
||||
}
|
||||
else if (mode == 0)
|
||||
s->sft_posit = new_pos;
|
||||
else /* mode == 1 */
|
||||
s->sft_posit += new_pos;
|
||||
|
||||
s->sft_posit = new_pos;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
ULONG DosSeek(unsigned hndl, LONG new_pos, COUNT mode)
|
||||
ULONG DosSeek(unsigned hndl, LONG new_pos, COUNT mode, int *rc)
|
||||
{
|
||||
int sft_idx = get_sft_idx(hndl);
|
||||
COUNT result;
|
||||
|
||||
/* Get the SFT block that contains the SFT */
|
||||
result = SftSeek(sft_idx, new_pos, mode);
|
||||
if (result == SUCCESS)
|
||||
{
|
||||
*rc = SftSeek(sft_idx, new_pos, mode);
|
||||
if (*rc == SUCCESS)
|
||||
return idx_to_sft(sft_idx)->sft_posit;
|
||||
}
|
||||
return (ULONG)-1;
|
||||
return *rc;
|
||||
}
|
||||
|
||||
STATIC long get_free_hndl(void)
|
||||
|
@ -931,17 +931,14 @@ dispatch:
|
||||
case 0x42:
|
||||
if (lr.AL > 2)
|
||||
goto error_invalid;
|
||||
lrc = DosSeek(lr.BX, (LONG)((((ULONG) (lr.CX)) << 16) | lr.DX), lr.AL);
|
||||
if (lrc == -1)
|
||||
{
|
||||
lrc = DE_INVLDHNDL;
|
||||
}
|
||||
else
|
||||
lrc = DosSeek(lr.BX, (LONG)((((ULONG) (lr.CX)) << 16) | lr.DX), lr.AL,
|
||||
&rc);
|
||||
if (rc == SUCCESS)
|
||||
{
|
||||
lr.DX = (UWORD)(lrc >> 16);
|
||||
lrc = (UWORD) lrc;
|
||||
lr.AX = (UWORD) lrc;
|
||||
}
|
||||
goto long_check;
|
||||
goto short_check;
|
||||
|
||||
/* Get/Set File Attributes */
|
||||
case 0x43:
|
||||
@ -1957,19 +1954,13 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r)
|
||||
CritErrCode = SUCCESS;
|
||||
if (r.BP < 0x4200 || r.BP > 0x4202)
|
||||
goto error_invalid;
|
||||
#if 0
|
||||
lrc = DosSeek(r.BX, MK_ULONG(r.CX, r.DX), r.BP & 0xff, &rc);
|
||||
if (rc == SUCCESS)
|
||||
{
|
||||
sft FAR *s = get_sft(r.BX);
|
||||
if ((rc = _SftSeek(s, MK_ULONG(r.CX, r.DX), r.BP & 0xff)) >= SUCCESS)
|
||||
{
|
||||
r.DX = hiword (s->sft_posit);
|
||||
r.AX = loword (s->sft_posit);
|
||||
}
|
||||
r.DX = (UWORD)(lrc >> 16);
|
||||
r.AX = (UWORD) lrc;
|
||||
}
|
||||
goto short_check;
|
||||
#else
|
||||
goto error_invalid;
|
||||
#endif
|
||||
|
||||
case 0x29: /* read from file */
|
||||
r.FLAGS &= ~FLG_CARRY;
|
||||
|
@ -80,14 +80,14 @@ const char FAR *get_root(const char FAR *);
|
||||
BOOL check_break(void);
|
||||
UCOUNT GenericReadSft(sft far * sftp, UCOUNT n, void FAR * bp,
|
||||
COUNT * err, BOOL force_binary);
|
||||
COUNT SftSeek(int sft_idx, LONG new_pos, COUNT mode);
|
||||
COUNT SftSeek(int sft_idx, LONG new_pos, unsigned mode);
|
||||
/*COUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err); */
|
||||
void BinarySftIO(int sft_idx, void *bp, int mode);
|
||||
#define BinaryIO(hndl, bp, mode) BinarySftIO(get_sft_idx(hndl), bp, mode)
|
||||
long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode);
|
||||
#define DosRead(hndl, n, bp) DosRWSft(get_sft_idx(hndl), n, bp, XFR_READ)
|
||||
#define DosWrite(hndl, n, bp) DosRWSft(get_sft_idx(hndl), n, bp, XFR_WRITE)
|
||||
ULONG DosSeek(unsigned hndl, LONG new_pos, COUNT mode);
|
||||
ULONG DosSeek(unsigned hndl, LONG new_pos, COUNT mode, int *rc);
|
||||
long DosOpen(char FAR * fname, unsigned flags, unsigned attrib);
|
||||
COUNT CloneHandle(unsigned hndl);
|
||||
long DosDup(unsigned Handle);
|
||||
|
Loading…
x
Reference in New Issue
Block a user