FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@267 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2001-07-23 12:47:42 +00:00
parent 03865c6b69
commit 77e49f87c7
8 changed files with 402 additions and 508 deletions

View File

@ -36,6 +36,9 @@ static BYTE *charioRcsId = "$Id$";
/* /*
* $Log$ * $Log$
* Revision 1.10 2001/07/23 12:47:42 bartoldeman
* FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf
*
* Revision 1.9 2001/06/03 14:16:17 bartoldeman * Revision 1.9 2001/06/03 14:16:17 bartoldeman
* BUFFERS tuning and misc bug fixes/cleanups (2024c). * BUFFERS tuning and misc bug fixes/cleanups (2024c).
* *
@ -185,9 +188,7 @@ VOID cso(COUNT c)
VOID sto(COUNT c) VOID sto(COUNT c)
{ {
static COUNT scratch; /* make this static to save stack space */ DosWrite(STDOUT, 1, (BYTE FAR *) & c, (COUNT FAR *) &UnusedRetVal);
DosWrite(STDOUT, 1, (BYTE FAR *) & c, (COUNT FAR *) &scratch);
} }
VOID mod_sto(REG UCOUNT c) VOID mod_sto(REG UCOUNT c)
@ -224,13 +225,12 @@ VOID Do_DosIdle_loop(void)
UCOUNT _sti(void) UCOUNT _sti(void)
{ {
static COUNT scratch;
UBYTE c; UBYTE c;
/* /*
* XXX: If there's a read error, this will just keep retrying the read until * XXX: If there's a read error, this will just keep retrying the read until
* the error disappears. Maybe it should do something else instead. -- ror4 * the error disappears. Maybe it should do something else instead. -- ror4
*/ */
while (GenericRead(STDIN, 1, (BYTE FAR *) & c, (COUNT FAR *) & scratch, TRUE) while (GenericRead(STDIN, 1, (BYTE FAR *) & c, (COUNT FAR *) & UnusedRetVal, TRUE)
!= 1) ; != 1) ;
return c; return c;
} }

View File

@ -37,6 +37,9 @@ static BYTE *dosfnsRcsId = "$Id$";
* /// Added SHARE support. 2000/09/04 Ron Cemer * /// Added SHARE support. 2000/09/04 Ron Cemer
* *
* $Log$ * $Log$
* Revision 1.21 2001/07/23 12:47:42 bartoldeman
* FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf
*
* Revision 1.20 2001/07/22 01:58:58 bartoldeman * Revision 1.20 2001/07/22 01:58:58 bartoldeman
* Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX
* *
@ -182,9 +185,8 @@ static BYTE *dosfnsRcsId = "$Id$";
#include "globals.h" #include "globals.h"
sft FAR *get_sft(UCOUNT); COUNT get_free_hndl(VOID);
WORD get_free_hndl(VOID); sft FAR *get_free_sft(COUNT *);
sft FAR *get_free_sft(WORD FAR *);
BOOL cmatch(COUNT, COUNT, COUNT); BOOL cmatch(COUNT, COUNT, COUNT);
f_node_ptr xlt_fd(COUNT); f_node_ptr xlt_fd(COUNT);
@ -257,34 +259,41 @@ static VOID DosGetFile(BYTE * lpszPath, BYTE FAR * lpszDosFileName)
fbcopy((BYTE FAR *) szLclExt, &lpszDosFileName[FNAME_SIZE], FEXT_SIZE); fbcopy((BYTE FAR *) szLclExt, &lpszDosFileName[FNAME_SIZE], FEXT_SIZE);
} }
sft FAR *get_sft(UCOUNT hndl) sft FAR *idx_to_sft(COUNT SftIndex)
{ {
psp FAR *p = MK_FP(cu_psp, 0);
WORD sys_idx;
sfttbl FAR *sp; sfttbl FAR *sp;
if (hndl >= p->ps_maxfiles) if (SftIndex < 0)
return (sft FAR *) - 1; return (sft FAR *) - 1;
/* Get the SFT block that contains the SFT */ /* Get the SFT block that contains the SFT */
if (p->ps_filetab[hndl] == 0xff) for (sp = sfthead; sp != (sfttbl FAR *) - 1;
return (sft FAR *) - 1; sp = sp->sftt_next)
sys_idx = p->ps_filetab[hndl];
for (sp = sfthead; sp != (sfttbl FAR *) - 1; sp = sp->sftt_next)
{ {
if (sys_idx < sp->sftt_count) if (SftIndex < sp->sftt_count)
break; /* finally, point to the right entry */
return (sft FAR *) & (sp->sftt_table[SftIndex]);
else else
sys_idx -= sp->sftt_count; SftIndex -= sp->sftt_count;
} }
/* If not found, return an error */ /* If not found, return an error */
if (sp == (sfttbl FAR *) - 1) return (sft FAR *) - 1;
return (sft FAR *) - 1; }
/* finally, point to the right entry */ STATIC COUNT get_sft_idx(UCOUNT hndl)
return (sft FAR *) & (sp->sftt_table[sys_idx]); {
psp FAR *p = MK_FP(cu_psp, 0);
if (hndl >= p->ps_maxfiles)
return DE_INVLDHNDL;
return p->ps_filetab[hndl] == 0xff ? DE_INVLDHNDL : p->ps_filetab[hndl];
}
sft FAR *get_sft(UCOUNT hndl)
{
/* Get the SFT block that contains the SFT */
return idx_to_sft(get_sft_idx(hndl));
} }
/* /*
@ -298,17 +307,8 @@ UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err,
BOOL force_binary) BOOL force_binary)
{ {
sft FAR *s; sft FAR *s;
/* WORD sys_idx;*/
/*sfttbl FAR *sp;*/
UCOUNT ReadCount; UCOUNT ReadCount;
/* Test that the handle is valid */
if (hndl < 0)
{
*err = DE_INVLDHNDL;
return 0;
}
/* Get the SFT block that contains the SFT */ /* Get the SFT block that contains the SFT */
if ((s = get_sft(hndl)) == (sft FAR *) - 1) if ((s = get_sft(hndl)) == (sft FAR *) - 1)
{ {
@ -436,17 +436,8 @@ UCOUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err)
UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err)
{ {
sft FAR *s; sft FAR *s;
/* WORD sys_idx;*/
/*sfttbl FAR *sp;*/
UCOUNT WriteCount; UCOUNT WriteCount;
/* Test that the handle is valid */
if (hndl < 0)
{
*err = DE_INVLDHNDL;
return 0;
}
/* Get the SFT block that contains the SFT */ /* Get the SFT block that contains the SFT */
if ((s = get_sft(hndl)) == (sft FAR *) - 1) if ((s = get_sft(hndl)) == (sft FAR *) - 1)
{ {
@ -685,10 +676,6 @@ COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos)
sft FAR *s; sft FAR *s;
COUNT result; COUNT result;
/* Test that the handle is valid */
if (hndl < 0)
return DE_INVLDHNDL;
/* Get the SFT block that contains the SFT */ /* Get the SFT block that contains the SFT */
if ((s = get_sft(hndl)) == (sft FAR *) - 1) if ((s = get_sft(hndl)) == (sft FAR *) - 1)
return DE_INVLDHNDL; return DE_INVLDHNDL;
@ -700,7 +687,7 @@ COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos)
return result; return result;
} }
STATIC WORD get_free_hndl(void) STATIC COUNT get_free_hndl(void)
{ {
psp FAR *p = MK_FP(cu_psp, 0); psp FAR *p = MK_FP(cu_psp, 0);
WORD hndl; WORD hndl;
@ -710,12 +697,12 @@ STATIC WORD get_free_hndl(void)
if (p->ps_filetab[hndl] == 0xff) if (p->ps_filetab[hndl] == 0xff)
return hndl; return hndl;
} }
return 0xff; return DE_TOOMANY;
} }
sft FAR *get_free_sft(WORD FAR * sft_idx) sft FAR *get_free_sft(COUNT *sft_idx)
{ {
WORD sys_idx = 0; COUNT sys_idx = 0;
sfttbl FAR *sp; sfttbl FAR *sp;
/* Get the SFT block that contains the SFT */ /* Get the SFT block that contains the SFT */
@ -773,15 +760,13 @@ BOOL fnmatch(BYTE FAR * s, BYTE FAR * d, COUNT n, COUNT mode)
return TRUE; return TRUE;
} }
COUNT DosCreat(BYTE FAR * fname, COUNT attrib) COUNT DosCreatSft(BYTE * fname, COUNT attrib)
{ {
psp FAR *p = MK_FP(cu_psp, 0); COUNT sft_idx;
WORD hndl, sft_idx;
sft FAR *sftp; sft FAR *sftp;
struct dhdr FAR *dhp; struct dhdr FAR *dhp;
/* BYTE FAR *froot;*/ WORD result;
/* WORD i;*/ COUNT drive;
COUNT result, drive;
/* NEVER EVER allow directories to be created */ /* NEVER EVER allow directories to be created */
if (attrib & ~(D_RDONLY|D_HIDDEN|D_SYSTEM|D_ARCHIVE)) if (attrib & ~(D_RDONLY|D_HIDDEN|D_SYSTEM|D_ARCHIVE))
@ -789,30 +774,28 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib)
return DE_ACCESS; return DE_ACCESS;
} }
/* get a free handle */ /* now get a free system file table entry */
if ((hndl = get_free_hndl()) == 0xff) if ((sftp = get_free_sft(&sft_idx)) == (sft FAR *) - 1)
return DE_TOOMANY; return DE_TOOMANY;
/* now get a free system file table entry */ fmemset(sftp, 0, sizeof(sft));
if ((sftp = get_free_sft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1)
return DE_TOOMANY;
sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */
sftp->sft_psp = cu_psp;
sftp->sft_mode = SFT_MRDWR;
sftp->sft_attrib = attrib;
sftp->sft_psp = cu_psp;
/* check for a device */ /* check for a device */
dhp = IsDevice(fname); dhp = IsDevice(fname);
if ( dhp ) if ( dhp )
{ {
sftp->sft_count += 1; sftp->sft_count += 1;
sftp->sft_mode = SFT_MRDWR;
sftp->sft_attrib = attrib;
sftp->sft_flags = sftp->sft_flags =
((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF;
sftp->sft_psp = cu_psp;
fbcopy((BYTE FAR *) SecPathName, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); fbcopy((BYTE FAR *) SecPathName, sftp->sft_name, FNAME_SIZE + FEXT_SIZE);
sftp->sft_dev = dhp; sftp->sft_dev = dhp;
p->ps_filetab[hndl] = sft_idx; return sft_idx;
return hndl;
} }
drive = get_verify_drive(fname); drive = get_verify_drive(fname);
@ -820,27 +803,21 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib)
return drive; return drive;
} }
result = truename(fname, PriPathName, FALSE);
if (result != SUCCESS) {
return result;
}
if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) {
lpCurSft = (sfttbl FAR *)sftp; lpCurSft = (sfttbl FAR *)sftp;
sftp->sft_mode = attrib; sftp->sft_mode = attrib;
result = -int2f_Remote_call(REM_CREATE, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, attrib)); result = -int2f_Remote_call(REM_CREATE, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, attrib));
if (result == SUCCESS) { if (result == SUCCESS) {
sftp->sft_count += 1; sftp->sft_count += 1;
p->ps_filetab[hndl] = sft_idx; return sft_idx;
return hndl; }
}
return result; return result;
} }
/* /// Added for SHARE. - Ron Cemer */ /* /// Added for SHARE. - Ron Cemer */
if (IsShareInstalled()) { if (IsShareInstalled()) {
if ((sftp->sft_shroff = share_open_check if ((sftp->sft_shroff = share_open_check
((char far *)PriPathName, ((char far *)fname,
cu_psp, cu_psp,
0x02, /* read-write */ 0x02, /* read-write */
0)) < 0) /* compatibility mode */ 0)) < 0) /* compatibility mode */
@ -848,17 +825,13 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib)
} }
/* /// End of additions for SHARE. - Ron Cemer */ /* /// End of additions for SHARE. - Ron Cemer */
sftp->sft_status = dos_creat(PriPathName, attrib); sftp->sft_status = dos_creat(fname, attrib);
if (sftp->sft_status >= 0) if (sftp->sft_status >= 0)
{ {
p->ps_filetab[hndl] = sft_idx;
sftp->sft_count += 1; sftp->sft_count += 1;
sftp->sft_mode = SFT_MRDWR;
sftp->sft_attrib = attrib;
sftp->sft_flags = drive; sftp->sft_flags = drive;
sftp->sft_psp = cu_psp; DosGetFile(fname, sftp->sft_name);
DosGetFile(PriPathName, sftp->sft_name); return sft_idx;
return hndl;
} else { } else {
/* /// Added for SHARE *** CURLY BRACES ADDED ALSO!!! ***. - Ron Cemer */ /* /// Added for SHARE *** CURLY BRACES ADDED ALSO!!! ***. - Ron Cemer */
if (IsShareInstalled()) { if (IsShareInstalled()) {
@ -870,6 +843,29 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib)
} }
} }
COUNT DosCreat(BYTE FAR * fname, COUNT attrib)
{
psp FAR *p = MK_FP(cu_psp, 0);
COUNT sft_idx, hndl, result;
/* get a free handle */
if ((hndl = get_free_hndl()) < 0)
return hndl;
result = truename(fname, PriPathName, FALSE);
if (result != SUCCESS) {
return result;
}
sft_idx = DosCreatSft(PriPathName, attrib);
if (sft_idx < SUCCESS)
return sft_idx;
p->ps_filetab[hndl] = sft_idx;
return hndl;
}
COUNT CloneHandle(COUNT hndl) COUNT CloneHandle(COUNT hndl)
{ {
sft FAR *sftp; sft FAR *sftp;
@ -900,8 +896,8 @@ COUNT DosDup(COUNT Handle)
return DE_INVLDHNDL; return DE_INVLDHNDL;
/* now get a free handle */ /* now get a free handle */
if ((NewHandle = get_free_hndl()) == 0xff) if ((NewHandle = get_free_hndl()) < 0)
return DE_TOOMANY; return NewHandle;
/* If everything looks ok, bump it up. */ /* If everything looks ok, bump it up. */
if ((Sftp->sft_flags & (SFT_FDEVICE | SFT_FSHARED)) || (Sftp->sft_status >= 0)) if ((Sftp->sft_flags & (SFT_FDEVICE | SFT_FSHARED)) || (Sftp->sft_status >= 0))
@ -948,40 +944,30 @@ COUNT DosForceDup(COUNT OldHandle, COUNT NewHandle)
return DE_INVLDHNDL; return DE_INVLDHNDL;
} }
COUNT DosOpen(BYTE FAR * fname, COUNT mode) COUNT DosOpenSft(BYTE * fname, COUNT mode)
{ {
psp FAR *p = MK_FP(cu_psp, 0); COUNT sft_idx;
WORD hndl;
WORD sft_idx;
sft FAR *sftp; sft FAR *sftp;
struct dhdr FAR *dhp; struct dhdr FAR *dhp;
COUNT drive, result; COUNT drive, result;
/* /// Added to adjust for filenames which begin with ".\" OpenMode = (BYTE) mode;
The problem was manifesting itself in the inability
to run an program whose filename (without the extension)
was longer than six characters and the PATH variable
contained ".", unless you explicitly specified the full
path to the executable file.
Jun 11, 2000 - rbc */
if ( (fname[0] == '.') && ((fname[1] == '\\') || (fname[1] == '/'))) fname += 2;
/* test if mode is in range */ /* test if mode is in range */
if ((mode & ~SFT_OMASK) != 0) if ((mode & ~SFT_OMASK) != 0)
return DE_INVLDACC; return DE_INVLDACC;
mode &= 3; mode &= 3;
/* get a free handle */
if ((hndl = get_free_hndl()) == 0xff)
return DE_TOOMANY;
OpenMode = (BYTE) mode; OpenMode = (BYTE) mode;
/* now get a free system file table entry */ /* now get a free system file table entry */
if ((sftp = get_free_sft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1) if ((sftp = get_free_sft(&sft_idx)) == (sft FAR *) - 1)
return DE_TOOMANY; return DE_TOOMANY;
fmemset(sftp, 0, sizeof(sft)); fmemset(sftp, 0, sizeof(sft));
sftp->sft_psp = cu_psp;
sftp->sft_mode = mode;
/* check for a device */ /* check for a device */
dhp = IsDevice(fname); dhp = IsDevice(fname);
@ -989,18 +975,15 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode)
{ {
sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */
sftp->sft_mode = mode;
sftp->sft_count += 1; sftp->sft_count += 1;
sftp->sft_flags = sftp->sft_flags =
((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF;
sftp->sft_psp = cu_psp;
fbcopy((BYTE FAR *) SecPathName, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); fbcopy((BYTE FAR *) SecPathName, sftp->sft_name, FNAME_SIZE + FEXT_SIZE);
sftp->sft_dev = dhp; sftp->sft_dev = dhp;
sftp->sft_date = dos_getdate(); sftp->sft_date = dos_getdate();
sftp->sft_time = dos_gettime(); sftp->sft_time = dos_gettime();
p->ps_filetab[hndl] = sft_idx; return sft_idx;
return hndl;
} }
drive = get_verify_drive(fname); drive = get_verify_drive(fname);
@ -1008,29 +991,21 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode)
return drive; return drive;
} }
result = truename(fname, PriPathName, FALSE);
if (result != SUCCESS) {
return result;
}
if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) {
lpCurSft = (sfttbl FAR *)sftp; lpCurSft = (sfttbl FAR *)sftp;
result = -int2f_Remote_call(REM_OPEN, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, mode)); result = -int2f_Remote_call(REM_OPEN, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, mode));
if (result == SUCCESS) { if (result == SUCCESS) {
sftp->sft_count += 1; sftp->sft_count += 1;
p->ps_filetab[hndl] = sft_idx; return sft_idx;
return hndl;
} }
return result; return result;
} }
sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */
sftp->sft_mode = mode; /* /// Added for SHARE. - Ron Cemer */
/* /// Added for SHARE. - Ron Cemer */
if (IsShareInstalled()) { if (IsShareInstalled()) {
if ((sftp->sft_shroff = share_open_check if ((sftp->sft_shroff = share_open_check
((char far *)PriPathName, ((char far *)fname,
(unsigned short)cu_psp, (unsigned short)cu_psp,
mode & 0x03, mode & 0x03,
(mode >> 2) & 0x07)) < 0) (mode >> 2) & 0x07)) < 0)
@ -1038,7 +1013,7 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode)
} }
/* /// End of additions for SHARE. - Ron Cemer */ /* /// End of additions for SHARE. - Ron Cemer */
sftp->sft_status = dos_open(PriPathName, mode); sftp->sft_status = dos_open(fname, mode);
if (sftp->sft_status >= 0) if (sftp->sft_status >= 0)
{ {
@ -1052,14 +1027,16 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode)
{ {
return DE_ACCESS; return DE_ACCESS;
} }
p->ps_filetab[hndl] = sft_idx;
sftp->sft_size = dos_getfsize(sftp->sft_status);
dos_getftime(sftp->sft_status,
(date FAR *) & sftp->sft_date,
(time FAR *) & sftp->sft_time);
sftp->sft_count += 1; sftp->sft_count += 1;
sftp->sft_mode = mode; sftp->sft_mode = mode;
sftp->sft_flags = drive; sftp->sft_flags = drive;
sftp->sft_psp = cu_psp; DosGetFile(fname, sftp->sft_name);
DosGetFile(PriPathName, sftp->sft_name); return sft_idx;
return hndl;
} else { } else {
/* /// Added for SHARE *** CURLY BRACES ADDED ALSO!!! ***. - Ron Cemer */ /* /// Added for SHARE *** CURLY BRACES ADDED ALSO!!! ***. - Ron Cemer */
if (IsShareInstalled()) { if (IsShareInstalled()) {
@ -1071,33 +1048,47 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode)
} }
} }
COUNT DosClose(COUNT hndl) COUNT DosOpen(BYTE FAR * fname, COUNT mode)
{ {
psp FAR *p = MK_FP(cu_psp, 0); psp FAR *p = MK_FP(cu_psp, 0);
sft FAR *s; COUNT sft_idx, result, hndl;
/* Test that the handle is valid */ /* get a free handle */
if (hndl < 0) if ((hndl = get_free_hndl()) < 0)
return DE_INVLDHNDL; return hndl;
/* Get the SFT block that contains the SFT */ result = truename(fname, PriPathName, FALSE);
if ((s = get_sft(hndl)) == (sft FAR *) - 1) if (result != SUCCESS) {
return result;
}
sft_idx = DosOpenSft(PriPathName, mode);
if (sft_idx < SUCCESS)
return sft_idx;
p->ps_filetab[hndl] = sft_idx;
return hndl;
}
COUNT DosCloseSft(WORD sft_idx)
{
sft FAR *s = idx_to_sft(sft_idx);
if (s == (sft FAR *) - 1)
return DE_INVLDHNDL; return DE_INVLDHNDL;
/* If this is not opened another error */ /* If this is not opened another error */
if (s->sft_count == 0) /* The second condition is a sanity check and necessary for FcbCloseAll */
if (s->sft_count == 0 || (s->sft_count == 1 && s->sft_psp != cu_psp))
return DE_ACCESS; return DE_ACCESS;
lpCurSft = (sfttbl FAR *) s; lpCurSft = (sfttbl FAR *) s;
/* /*
remote sub sft_count. remote sub sft_count.
*/ */
p->ps_filetab[hndl] = 0xff;
if (s->sft_flags & SFT_FSHARED) if (s->sft_flags & SFT_FSHARED)
{ return -int2f_Remote_call(REM_CLOSE, 0, 0, 0, (VOID FAR *) s, 0, 0);
int2f_Remote_call(REM_CLOSE, 0, 0, 0, (VOID FAR *) s, 0, 0);
return SUCCESS;
}
/* now just drop the count if a device, else */ /* now just drop the count if a device, else */
/* call file system handler */ /* call file system handler */
@ -1120,6 +1111,18 @@ COUNT DosClose(COUNT hndl)
} }
} }
COUNT DosClose(COUNT hndl)
{
psp FAR *p = MK_FP(cu_psp, 0);
COUNT ret;
/* Get the SFT block that contains the SFT */
ret = DosCloseSft(get_sft_idx(hndl));
if (ret != DE_INVLDHNDL && ret != DE_ACCESS)
p->ps_filetab[hndl] = 0xff;
return ret;
}
VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, COUNT FAR * nc) VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, COUNT FAR * nc)
{ {
struct dpb FAR *dpbp; struct dpb FAR *dpbp;
@ -1332,10 +1335,6 @@ COUNT DosGetFtime(COUNT hndl, date FAR * dp, time FAR * tp)
sft FAR *s; sft FAR *s;
/*sfttbl FAR *sp;*/ /*sfttbl FAR *sp;*/
/* Test that the handle is valid */
if (hndl < 0)
return DE_INVLDHNDL;
/* Get the SFT block that contains the SFT */ /* Get the SFT block that contains the SFT */
if ((s = get_sft(hndl)) == (sft FAR *) - 1) if ((s = get_sft(hndl)) == (sft FAR *) - 1)
return DE_INVLDHNDL; return DE_INVLDHNDL;
@ -1356,17 +1355,12 @@ COUNT DosGetFtime(COUNT hndl, date FAR * dp, time FAR * tp)
return dos_getftime(s->sft_status, dp, tp); return dos_getftime(s->sft_status, dp, tp);
} }
COUNT DosSetFtime(COUNT hndl, date FAR * dp, time FAR * tp) COUNT DosSetFtimeSft(WORD sft_idx, date FAR * dp, time FAR * tp)
{ {
sft FAR *s;
/*sfttbl FAR *sp;*/
/* Test that the handle is valid */
if (hndl < 0)
return DE_INVLDHNDL;
/* Get the SFT block that contains the SFT */ /* Get the SFT block that contains the SFT */
if ((s = get_sft(hndl)) == (sft FAR *) - 1) sft FAR *s = idx_to_sft(sft_idx);
if (s == (sft FAR *) - 1)
return DE_INVLDHNDL; return DE_INVLDHNDL;
/* If this is not opened another error */ /* If this is not opened another error */
@ -1544,33 +1538,42 @@ COUNT DosDelete(BYTE FAR *path)
} }
} }
COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2) COUNT DosRenameTrue(BYTE * path1, BYTE * path2)
{ {
COUNT result, drive1, drive2; COUNT drive1, drive2;
if (IsDevice(path1) || IsDevice(path2)) { if (IsDevice(path1) || IsDevice(path2)) {
return DE_FILENOTFND; return DE_FILENOTFND;
} }
drive1 = get_verify_drive(path1); drive1 = get_verify_drive(path1);
drive2 = get_verify_drive(path2);
if ((drive1 != drive2) || (drive1 < 0)) {
return DE_INVLDDRV;
}
current_ldt = &CDSp->cds_table[drive1];
if (CDSp->cds_table[drive1].cdsFlags & CDSNETWDRV) {
return -int2f_Remote_call(REM_RENAME, 0, 0, 0, 0, 0, 0);
} else {
return dos_rename(PriPathName, SecPathName);
}
}
COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2)
{
COUNT result;
result = truename(path1, PriPathName, FALSE); result = truename(path1, PriPathName, FALSE);
if (result != SUCCESS) { if (result != SUCCESS) {
return result; return result;
} }
drive2 = get_verify_drive(path2);
result = truename(path2, SecPathName, FALSE); result = truename(path2, SecPathName, FALSE);
if (result != SUCCESS) { if (result != SUCCESS) {
return result; return result;
} }
if ((drive1 != drive2) || (drive1 < 0)) {
return DE_INVLDDRV; return DosRenameTrue(PriPathName, SecPathName);
}
current_ldt = &CDSp->cds_table[drive1];
if (CDSp->cds_table[drive1].cdsFlags & CDSNETWDRV) {
return -int2f_Remote_call(REM_RENAME, 0, 0, 0, 0, 0, 0);
} else {
return dos_rename(PriPathName, SecPathName);
}
} }
COUNT DosMkdir(BYTE FAR * dir) COUNT DosMkdir(BYTE FAR * dir)
@ -1630,9 +1633,6 @@ COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock)
/* Invalid function unless SHARE is installed. */ /* Invalid function unless SHARE is installed. */
if (!IsShareInstalled()) return DE_INVLDFUNC; if (!IsShareInstalled()) return DE_INVLDFUNC;
/* Test that the handle is valid */
if (hndl < 0) return DE_INVLDHNDL;
/* Get the SFT block that contains the SFT */ /* Get the SFT block that contains the SFT */
if ((s = get_sft(hndl)) == (sft FAR *) -1) return DE_INVLDHNDL; if ((s = get_sft(hndl)) == (sft FAR *) -1) return DE_INVLDHNDL;

View File

@ -36,6 +36,9 @@ static BYTE *fatdirRcsId = "$Id$";
/* /*
* $Log$ * $Log$
* Revision 1.19 2001/07/23 12:47:42 bartoldeman
* FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf
*
* Revision 1.18 2001/07/22 01:58:58 bartoldeman * Revision 1.18 2001/07/22 01:58:58 bartoldeman
* Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX
* *
@ -358,6 +361,7 @@ COUNT dir_read(REG f_node_ptr fnp)
/* REG j; */ /* REG j; */
struct buffer FAR *bp; struct buffer FAR *bp;
REG UWORD secsize = fnp->f_dpb->dpb_secsize;
/* Directories need to point to their current offset, not for */ /* Directories need to point to their current offset, not for */
/* next op. Therefore, if it is anything other than the first */ /* next op. Therefore, if it is anything other than the first */
@ -382,7 +386,7 @@ COUNT dir_read(REG f_node_ptr fnp)
{ {
if (fnp->f_flags.f_droot) if (fnp->f_flags.f_droot)
{ {
if ((fnp->f_diroff / fnp->f_dpb->dpb_secsize if ((fnp->f_diroff / secsize
+ fnp->f_dpb->dpb_dirstrt) + fnp->f_dpb->dpb_dirstrt)
>= fnp->f_dpb->dpb_data) >= fnp->f_dpb->dpb_data)
{ {
@ -390,18 +394,15 @@ COUNT dir_read(REG f_node_ptr fnp)
return 0; return 0;
} }
bp = getblock((ULONG) (fnp->f_diroff / fnp->f_dpb->dpb_secsize bp = getblock((ULONG) (fnp->f_diroff / secsize
+ fnp->f_dpb->dpb_dirstrt), + fnp->f_dpb->dpb_dirstrt),
fnp->f_dpb->dpb_unit); fnp->f_dpb->dpb_unit);
bp->b_flag &= ~(BFR_DATA | BFR_FAT);
bp->b_flag |= BFR_DIR | BFR_VALID;
#ifdef DISPLAY_GETBLOCK #ifdef DISPLAY_GETBLOCK
printf("DIR (dir_read)\n"); printf("DIR (dir_read)\n");
#endif #endif
} }
else else
{ {
REG UWORD secsize = fnp->f_dpb->dpb_secsize;
/* Do a "seek" to the directory position */ /* Do a "seek" to the directory position */
fnp->f_offset = fnp->f_diroff; fnp->f_offset = fnp->f_diroff;
@ -444,8 +445,6 @@ COUNT dir_read(REG f_node_ptr fnp)
fnp->f_dpb->dpb_data) fnp->f_dpb->dpb_data)
+ fnp->f_sector, + fnp->f_sector,
fnp->f_dpb->dpb_unit); fnp->f_dpb->dpb_unit);
bp->b_flag &= ~(BFR_DATA | BFR_FAT);
bp->b_flag |= BFR_DIR | BFR_VALID;
#ifdef DISPLAY_GETBLOCK #ifdef DISPLAY_GETBLOCK
printf("DIR (dir_read)\n"); printf("DIR (dir_read)\n");
#endif #endif
@ -453,15 +452,18 @@ COUNT dir_read(REG f_node_ptr fnp)
/* Now that we have the block for our entry, get the */ /* Now that we have the block for our entry, get the */
/* directory entry. */ /* directory entry. */
if (bp != NULL) if (bp == NULL)
getdirent((BYTE FAR *) & bp->b_buffer[((UWORD)fnp->f_diroff) % fnp->f_dpb->dpb_secsize],
(struct dirent FAR *)&fnp->f_dir);
else
{ {
fnp->f_flags.f_dfull = TRUE; fnp->f_flags.f_dfull = TRUE;
return 0; return 0;
} }
bp->b_flag &= ~(BFR_DATA | BFR_FAT);
bp->b_flag |= BFR_DIR | BFR_VALID;
getdirent((BYTE FAR *) & bp->b_buffer[((UWORD)fnp->f_diroff) % fnp->f_dpb->dpb_secsize],
(struct dirent FAR *)&fnp->f_dir);
/* Update the fnode's directory info */ /* Update the fnode's directory info */
fnp->f_flags.f_dfull = FALSE; fnp->f_flags.f_dfull = FALSE;
fnp->f_flags.f_dmod = FALSE; fnp->f_flags.f_dmod = FALSE;
@ -479,6 +481,7 @@ COUNT dir_read(REG f_node_ptr fnp)
COUNT dir_write(REG f_node_ptr fnp) COUNT dir_write(REG f_node_ptr fnp)
{ {
struct buffer FAR *bp; struct buffer FAR *bp;
REG UWORD secsize = fnp->f_dpb->dpb_secsize;
/* Update the entry if it was modified by a write or create... */ /* Update the entry if it was modified by a write or create... */
if (fnp->f_flags.f_dmod) if (fnp->f_flags.f_dmod)
@ -488,11 +491,9 @@ COUNT dir_write(REG f_node_ptr fnp)
if (fnp->f_flags.f_droot) if (fnp->f_flags.f_droot)
{ {
bp = getblock( bp = getblock(
(ULONG) ((UWORD)fnp->f_diroff / fnp->f_dpb->dpb_secsize (ULONG) ((UWORD)fnp->f_diroff / secsize
+ fnp->f_dpb->dpb_dirstrt), + fnp->f_dpb->dpb_dirstrt),
fnp->f_dpb->dpb_unit); fnp->f_dpb->dpb_unit);
bp->b_flag &= ~(BFR_DATA | BFR_FAT);
bp->b_flag |= BFR_DIR | BFR_VALID;
#ifdef DISPLAY_GETBLOCK #ifdef DISPLAY_GETBLOCK
printf("DIR (dir_write)\n"); printf("DIR (dir_write)\n");
#endif #endif
@ -503,7 +504,6 @@ COUNT dir_write(REG f_node_ptr fnp)
/* can continually update the same directory entry. */ /* can continually update the same directory entry. */
else else
{ {
REG UWORD secsize = fnp->f_dpb->dpb_secsize;
/* Do a "seek" to the directory position */ /* Do a "seek" to the directory position */
/* and convert the fnode to a directory fnode. */ /* and convert the fnode to a directory fnode. */
@ -558,8 +558,10 @@ COUNT dir_write(REG f_node_ptr fnp)
return 0; return 0;
} }
putdirent((struct dirent FAR *)&fnp->f_dir, putdirent((struct dirent FAR *)&fnp->f_dir,
(VOID FAR *) & bp->b_buffer[(UWORD)fnp->f_diroff % fnp->f_dpb->dpb_secsize]); (VOID FAR *) & bp->b_buffer[(UWORD)fnp->f_diroff % fnp->f_dpb->dpb_secsize]);
bp->b_flag |= BFR_DIRTY | BFR_VALID;
bp->b_flag &= ~(BFR_DATA | BFR_FAT);
bp->b_flag |= BFR_DIR | BFR_DIRTY | BFR_VALID;
} }
return DIRENT_SIZE; return DIRENT_SIZE;
} }
@ -801,16 +803,19 @@ COUNT dos_findnext(void)
/* If found, transfer it to the dmatch structure */ /* If found, transfer it to the dmatch structure */
if (found) if (found)
{ {
#if 0
extern VOID FAR *FcbFindFirstDirPtr; extern VOID FAR *FcbFindFirstDirPtr;
if (FcbFindFirstDirPtr) if (FcbFindFirstDirPtr)
{ {
/* this works MUCH better, then converting /* this works MUCH better, then converting
83 -> ASCIIZ ->83; 83 -> ASCIIZ ->83;
specifically ".", ".." specifically ".", ".."
But completely bypasses the network case!
*/ */
fmemcpy(FcbFindFirstDirPtr, &fnp->f_dir, 32); fmemcpy(FcbFindFirstDirPtr, &fnp->f_dir, 32);
} }
#endif
pop_dmp(dmp, fnp); pop_dmp(dmp, fnp);
} }

View File

@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$";
/* /*
* $Log$ * $Log$
* Revision 1.14 2001/07/23 12:47:42 bartoldeman
* FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf
*
* Revision 1.13 2001/07/22 01:58:58 bartoldeman * Revision 1.13 2001/07/22 01:58:58 bartoldeman
* Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX
* *
@ -144,18 +147,14 @@ static BYTE *RcsId = "$Id$";
fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb); fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb);
fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, COUNT * pCurDrive); fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, COUNT * pCurDrive);
void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive); void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive);
sft FAR *FcbGetSft(COUNT SftIndex);
VOID FcbNextRecord(fcb FAR * lpFcb); VOID FcbNextRecord(fcb FAR * lpFcb);
/* sft FAR *FcbGetFreeSft(WORD FAR * sft_idx); */
BOOL FcbCalcRec(xfcb FAR * lpXfcb); BOOL FcbCalcRec(xfcb FAR * lpXfcb);
VOID MoveDirInfo(dmatch FAR * lpDmatch, struct dirent FAR * lpDir); VOID MoveDirInfo(dmatch * lpDmatch, fcb FAR * lpDir);
#else #else
fcb FAR *ExtFcbToFcb(); fcb FAR *ExtFcbToFcb();
fcb FAR *CommonFcbInit(); fcb FAR *CommonFcbInit();
void FcbNameInit(); void FcbNameInit();
sft FAR *FcbGetSft();
VOID FcbNextRecord(); VOID FcbNextRecord();
/* sft FAR *FcbGetFreeSft(); */
BOOL FcbCalcRec(); BOOL FcbCalcRec();
VOID MoveDirInfo(); VOID MoveDirInfo();
#endif #endif
@ -166,7 +165,7 @@ VOID MoveDirInfo();
static dmatch Dmatch; static dmatch Dmatch;
VOID FAR *FcbFindFirstDirPtr = NULL; /* VOID FAR *FcbFindFirstDirPtr = NULL; */
VOID FatGetDrvData(UCOUNT drive, COUNT FAR * spc, COUNT FAR * bps, VOID FatGetDrvData(UCOUNT drive, COUNT FAR * spc, COUNT FAR * bps,
@ -274,6 +273,19 @@ WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb)
*lpFileName += 2; *lpFileName += 2;
} }
/* special cases: '.' and '..' */
if (**lpFileName == '.')
{
lpFcb->fcb_fname[0]='.';
++*lpFileName;
if (**lpFileName == '.')
{
lpFcb->fcb_fname[1]='.';
++*lpFileName;
}
return PARSE_RET_NOWILD;
}
/* Now to format the file name into the string */ /* Now to format the file name into the string */
*lpFileName = GetNameField(*lpFileName, (BYTE FAR *) lpFcb->fcb_fname, FNAME_SIZE, (BOOL *) & wRetCodeName); *lpFileName = GetNameField(*lpFileName, (BYTE FAR *) lpFcb->fcb_fname, FNAME_SIZE, (BOOL *) & wRetCodeName);
@ -352,26 +364,6 @@ BYTE FAR *GetNameField(BYTE FAR * lpFileName, BYTE FAR * lpDestField,
return lpFileName; return lpFileName;
} }
static sft FAR *FcbGetSft(COUNT SftIndex)
{
/* Get the SFT block that contains the SFT */
for (lpCurSft = sfthead; lpCurSft != (sfttbl FAR *) - 1;
lpCurSft = lpCurSft->sftt_next)
{
if (SftIndex < lpCurSft->sftt_count)
break;
else
SftIndex -= lpCurSft->sftt_count;
}
/* If not found, return an error */
if (lpCurSft == (sfttbl FAR *) - 1)
return (sft FAR *) - 1;
/* finally, point to the right entry */
return (sft FAR *) & (lpCurSft->sftt_table[SftIndex]);
}
static VOID FcbNextRecord(fcb FAR * lpFcb) static VOID FcbNextRecord(fcb FAR * lpFcb)
{ {
if (++lpFcb->fcb_curec > 128) if (++lpFcb->fcb_curec > 128)
@ -399,7 +391,7 @@ BOOL FcbRead(xfcb FAR * lpXfcb, COUNT * nErrorCode)
lpFcb = ExtFcbToFcb(lpXfcb); lpFcb = ExtFcbToFcb(lpXfcb);
/* Get the SFT block that contains the SFT */ /* Get the SFT block that contains the SFT */
if ((s = FcbGetSft(lpFcb->fcb_sftno)) == (sft FAR *) - 1) if ((s = idx_to_sft(lpFcb->fcb_sftno)) == (sft FAR *) - 1)
return FALSE; return FALSE;
/* If this is not opened another error */ /* If this is not opened another error */
@ -470,7 +462,7 @@ BOOL FcbWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode)
lpFcb = ExtFcbToFcb(lpXfcb); lpFcb = ExtFcbToFcb(lpXfcb);
/* Get the SFT block that contains the SFT */ /* Get the SFT block that contains the SFT */
if ((s = FcbGetSft(lpFcb->fcb_sftno)) == (sft FAR *) - 1) if ((s = idx_to_sft(lpFcb->fcb_sftno)) == (sft FAR *) - 1)
return FALSE; return FALSE;
/* If this is not opened another error */ /* If this is not opened another error */
@ -517,24 +509,23 @@ BOOL FcbWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode)
BOOL FcbGetFileSize(xfcb FAR * lpXfcb) BOOL FcbGetFileSize(xfcb FAR * lpXfcb)
{ {
COUNT FcbDrive, COUNT FcbDrive, hndl;
FileNum;
/* Build a traditional DOS file name */ /* Build a traditional DOS file name */
lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive);
/* check for a device */ /* check for a device */
if (IsDevice(PriPathName) || (lpFcb->fcb_recsiz == 0)) if (IsDevice(SecPathName) || (lpFcb->fcb_recsiz == 0))
{ {
return FALSE; return FALSE;
} }
FileNum = dos_open(PriPathName, O_RDONLY); hndl = DosOpen(SecPathName, O_RDONLY);
if (FileNum >= 0) if (hndl >= 0)
{ {
LONG fsize; LONG fsize;
/* Get the size */ /* Get the size */
fsize = dos_getfsize(FileNum); fsize = DosGetFsize(hndl);
/* compute the size and update the fcb */ /* compute the size and update the fcb */
lpFcb->fcb_rndm = fsize / lpFcb->fcb_recsiz; lpFcb->fcb_rndm = fsize / lpFcb->fcb_recsiz;
@ -542,7 +533,7 @@ BOOL FcbGetFileSize(xfcb FAR * lpXfcb)
++lpFcb->fcb_rndm; ++lpFcb->fcb_rndm;
/* close the file and leave */ /* close the file and leave */
return dos_close(FileNum) == SUCCESS; return DosClose(hndl) == SUCCESS;
} }
else else
return FALSE; return FALSE;
@ -631,47 +622,33 @@ BOOL FcbRandomIO(xfcb FAR * lpXfcb, COUNT * nErrorCode,
} }
/* /*
static sft FAR *FcbGetFreeSft(WORD FAR * sft_idx) static sft FAR *FcbGetFreeSft(COUNT * sft_idx)
see get_free_sft in dosfns.c see get_free_sft in dosfns.c
*/ */
BOOL FcbCreate(xfcb FAR * lpXfcb) BOOL FcbCreate(xfcb FAR * lpXfcb)
{ {
WORD sft_idx; COUNT sft_idx, FcbDrive;
sft FAR *sftp;
struct dhdr FAR *dhp; struct dhdr FAR *dhp;
COUNT FcbDrive;
/* get a free system file table entry */
if ((sftp = get_free_sft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1)
return DE_TOOMANY;
/* Build a traditional DOS file name */ /* Build a traditional DOS file name */
lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive);
sft_idx = DosCreatSft(PriPathName, 0);
if (sft_idx < 0)
return FALSE;
/* check for a device */ /* check for a device */
dhp = IsDevice(PriPathName); dhp = IsDevice(PriPathName);
if (dhp || ((sftp->sft_status = dos_creat(PriPathName, 0)) >= 0)) lpFcb->fcb_sftno = sft_idx;
{ lpFcb->fcb_curec = 0;
sftp->sft_count += 1; lpFcb->fcb_recsiz = (dhp ? 0 : 128);
sftp->sft_mode = O_RDWR; if (!dhp) lpFcb->fcb_drive = FcbDrive;
sftp->sft_attrib = 0; lpFcb->fcb_fsize = 0;
sftp->sft_flags = dhp ? lpFcb->fcb_date = dos_getdate();
((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF : 0; lpFcb->fcb_time = dos_gettime();
sftp->sft_psp = cu_psp; lpFcb->fcb_rndm = 0;
fbcopy(lpFcb->fcb_fname, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); return TRUE;
sftp->sft_dev = dhp;
lpFcb->fcb_sftno = sft_idx;
lpFcb->fcb_curec = 0;
lpFcb->fcb_recsiz = (dhp ? 0 : 128);
if (!dhp) lpFcb->fcb_drive = FcbDrive;
lpFcb->fcb_fsize = 0;
lpFcb->fcb_date = dos_getdate();
lpFcb->fcb_time = dos_gettime();
lpFcb->fcb_rndm = 0;
return TRUE;
}
return FALSE;
} }
STATIC fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb) STATIC fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb)
@ -697,8 +674,11 @@ STATIC fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer,
return lpFcb; return lpFcb;
} }
void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive) void FcbNameInit(fcb FAR * lpFcb, BYTE * szBuffer, COUNT * pCurDrive)
{ {
BYTE loc_szBuffer[FNAME_SIZE+1+FEXT_SIZE+1];
BYTE *pszBuffer = loc_szBuffer;
/* Build a traditional DOS file name */ /* Build a traditional DOS file name */
if (lpFcb->fcb_drive != 0) if (lpFcb->fcb_drive != 0)
{ {
@ -711,107 +691,46 @@ void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive)
{ {
*pCurDrive = default_drive + 1; *pCurDrive = default_drive + 1;
} }
ConvertName83ToNameSZ((BYTE FAR *)pszBuffer, (BYTE FAR *) lpFcb->fcb_fname); ConvertName83ToNameSZ((BYTE FAR *)pszBuffer, (BYTE FAR *) lpFcb->fcb_fname);
truename(loc_szBuffer, szBuffer, FALSE);
/* /* XXX fix truename error handling */
lpszFcbFname = (BYTE FAR *) lpFcb->fcb_fname;
for (loop = FNAME_SIZE; --loop >= 0; )
{
if (*lpszFcbFname != ' ')
*pszBuffer++ = *lpszFcbFname++;
else
break;
}
lpszFcbFext = (BYTE FAR *) lpFcb->fcb_fext;
if (*lpszFcbFext != ' ')
{
*pszBuffer++ = '.';
for (loop = FEXT_SIZE; --loop >= 0; )
{
if (*lpszFcbFext != ' ')
*pszBuffer++ = *lpszFcbFext++;
else
break;
}
}
*pszBuffer = '\0';
*/
} }
BOOL FcbOpen(xfcb FAR * lpXfcb) BOOL FcbOpen(xfcb FAR * lpXfcb)
{ {
WORD sft_idx;
sft FAR *sftp; sft FAR *sftp;
struct dhdr FAR *dhp; struct dhdr FAR *dhp;
COUNT FcbDrive; COUNT FcbDrive, sft_idx;
/* get a free system file table entry */
if ((sftp = get_free_sft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1)
return DE_TOOMANY;
/* Build a traditional DOS file name */ /* Build a traditional DOS file name */
lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive);
sft_idx = DosOpenSft(PriPathName, O_RDWR);
if (sft_idx < 0)
return FALSE;
/* check for a device */ /* check for a device */
lpFcb->fcb_curec = 0;
lpFcb->fcb_rndm = 0;
lpFcb->fcb_sftno = sft_idx;
dhp = IsDevice(PriPathName); dhp = IsDevice(PriPathName);
if (dhp ) if (dhp )
{ {
sftp->sft_count += 1; lpFcb->fcb_recsiz = 0;
sftp->sft_mode = O_RDWR; lpFcb->fcb_fsize = 0;
sftp->sft_attrib = 0; lpFcb->fcb_date = dos_getdate();
sftp->sft_flags = lpFcb->fcb_time = dos_gettime();
((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF;
sftp->sft_psp = cu_psp;
fbcopy(lpFcb->fcb_fname, sftp->sft_name, FNAME_SIZE + FEXT_SIZE);
sftp->sft_dev = dhp;
lpFcb->fcb_sftno = sft_idx;
lpFcb->fcb_curec = 0;
lpFcb->fcb_recsiz = 0;
lpFcb->fcb_fsize = 0;
lpFcb->fcb_date = dos_getdate();
lpFcb->fcb_time = dos_gettime();
lpFcb->fcb_rndm = 0;
return TRUE;
}
fbcopy((BYTE FAR *) & lpFcb->fcb_fname, (BYTE FAR *) & sftp->sft_name, FNAME_SIZE + FEXT_SIZE);
if ((UCOUNT)FcbDrive >= lastdrive) {
return DE_INVLDDRV;
}
if (CDSp->cds_table[FcbDrive].cdsFlags & CDSNETWDRV) {
COUNT result;
lpCurSft = (sfttbl FAR *)sftp;
result = -int2f_Remote_call(REM_OPEN, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, O_RDWR));
sftp->sft_status = result;
}
else {
sftp->sft_status = dos_open(PriPathName, O_RDWR);
sftp->sft_size = dos_getfsize(sftp->sft_status);
dos_getftime(sftp->sft_status,
(date FAR *) & sftp->sft_date,
(time FAR *) & sftp->sft_time);
}
if (sftp->sft_status >= 0)
{
lpFcb->fcb_drive = FcbDrive;
lpFcb->fcb_sftno = sft_idx;
lpFcb->fcb_curec = 0;
lpFcb->fcb_recsiz = 128;
lpFcb->fcb_fsize = sftp->sft_size;
lpFcb->fcb_date = sftp->sft_date;
lpFcb->fcb_time = sftp->sft_time;
lpFcb->fcb_rndm = 0;
sftp->sft_count += 1;
sftp->sft_mode = O_RDWR;
sftp->sft_attrib = 0;
sftp->sft_flags = 0;
sftp->sft_psp = cu_psp;
return TRUE;
} }
else else
return FALSE; {
sftp = idx_to_sft(sft_idx);
lpFcb->fcb_drive = FcbDrive;
lpFcb->fcb_recsiz = 128;
lpFcb->fcb_fsize = sftp->sft_size;
lpFcb->fcb_date = sftp->sft_date;
lpFcb->fcb_time = sftp->sft_time;
}
return TRUE;
} }
BOOL FcbDelete(xfcb FAR * lpXfcb) BOOL FcbDelete(xfcb FAR * lpXfcb)
@ -819,18 +738,14 @@ BOOL FcbDelete(xfcb FAR * lpXfcb)
COUNT FcbDrive; COUNT FcbDrive;
/* Build a traditional DOS file name */ /* Build a traditional DOS file name */
CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); CommonFcbInit(lpXfcb, SecPathName, &FcbDrive);
if ((UCOUNT)FcbDrive >= lastdrive) { if ((UCOUNT)FcbDrive >= lastdrive) {
return DE_INVLDDRV; return DE_INVLDDRV;
} }
current_ldt = &CDSp->cds_table[FcbDrive];
if (CDSp->cds_table[FcbDrive].cdsFlags & CDSNETWDRV) {
return -int2f_Remote_call(REM_DELETE, 0, 0, 0, 0, 0, 0);
}
/* check for a device */ /* check for a device */
if (IsDevice(PriPathName)) if (IsDevice(SecPathName))
{ {
return FALSE; return FALSE;
} }
@ -840,20 +755,21 @@ BOOL FcbDelete(xfcb FAR * lpXfcb)
dmatch Dmatch; dmatch Dmatch;
dta = (BYTE FAR *) & Dmatch; dta = (BYTE FAR *) & Dmatch;
if (dos_findfirst(D_ALL, PriPathName[1] == ':' ? &PriPathName[2] : PriPathName) != SUCCESS) if (DosFindFirst(D_ALL, SecPathName[1] == ':' ? &SecPathName[2] : SecPathName) != SUCCESS)
{ {
dta = lpOldDta; dta = lpOldDta;
return FALSE; return FALSE;
} }
do do
{ {
if (dos_delete(Dmatch.dm_name) != SUCCESS) truename(Dmatch.dm_name, SecPathName, FALSE);
if (DosDelete(SecPathName) != SUCCESS)
{ {
dta = lpOldDta; dta = lpOldDta;
return FALSE; return FALSE;
} }
} }
while (dos_findnext() == SUCCESS); while (DosFindNext() == SUCCESS);
dta = lpOldDta; dta = lpOldDta;
return TRUE; return TRUE;
} }
@ -865,10 +781,10 @@ BOOL FcbRename(xfcb FAR * lpXfcb)
COUNT FcbDrive; COUNT FcbDrive;
/* Build a traditional DOS file name */ /* Build a traditional DOS file name */
lpRenameFcb = (rfcb FAR *) CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); lpRenameFcb = (rfcb FAR *) CommonFcbInit(lpXfcb, SecPathName, &FcbDrive);
/* check for a device */ /* check for a device */
if (IsDevice(PriPathName)) if (IsDevice(SecPathName))
{ {
return FALSE; return FALSE;
} }
@ -878,7 +794,7 @@ BOOL FcbRename(xfcb FAR * lpXfcb)
dmatch Dmatch; dmatch Dmatch;
dta = (BYTE FAR *) & Dmatch; dta = (BYTE FAR *) & Dmatch;
if (dos_findfirst(D_ALL, PriPathName[1] == ':' ? &PriPathName[2] : PriPathName) != SUCCESS) if (DosFindFirst(D_ALL, SecPathName[1] == ':' ? &SecPathName[2] : SecPathName) != SUCCESS)
{ {
dta = lpOldDta; dta = lpOldDta;
return FALSE; return FALSE;
@ -942,74 +858,38 @@ BOOL FcbRename(xfcb FAR * lpXfcb)
/* now to build a dos name again */ /* now to build a dos name again */
LocalFcb.fcb_drive = 0; LocalFcb.fcb_drive = 0;
FcbNameInit((fcb FAR *) & LocalFcb, PriPathName, &FcbDrive); FcbNameInit((fcb FAR *) & LocalFcb, SecPathName, &FcbDrive);
if (dos_rename(Dmatch.dm_name, truename(Dmatch.dm_name, PriPathName, FALSE);
PriPathName[1] == ':' ? &PriPathName[2] : PriPathName) != SUCCESS)
if (DosRenameTrue(PriPathName, SecPathName) != SUCCESS)
{ {
dta = lpOldDta; dta = lpOldDta;
return FALSE; return FALSE;
} }
} }
while (dos_findnext() == SUCCESS); while (DosFindNext() == SUCCESS);
dta = lpOldDta; dta = lpOldDta;
return TRUE; return TRUE;
} }
} }
#if 0
/* TE:the MoveDirInfo() is now done by simply copying the dirEntry into the FCB /* TE:the MoveDirInfo() is now done by simply copying the dirEntry into the FCB
this prevents problems with ".", ".." and saves code this prevents problems with ".", ".." and saves code
BO:use FcbParseFname: avoid redirector problems and is there anyway
*/ */
VOID MoveDirInfo(dmatch * lpDmatch, fcb FAR * lpDir)
void MoveDirInfo(dmatch FAR * lpDmatch, struct dirent FAR * lpDir)
{ {
BYTE FAR *lpToName, BYTE FAR *lpszFrom = lpDmatch->dm_name;
FAR * lpszFrom;
COUNT nIndex;
/* First, expand the find match into dir style */ /* First, expand the find match into dir style */
/* file name entry */ FcbParseFname(PARSE_DFLT_DRIVE | PARSE_SEP_STOP, &lpszFrom, lpDir);
/* Fill with blanks first */ /* lpDir->dir_attrib = lpDmatch->dm_attr_fnd; XXX for extended fcb! */
lpDir->fcb_time = lpDmatch->dm_time;
fmemset(lpDir->dir_name, ' ', FNAME_SIZE); lpDir->fcb_date = lpDmatch->dm_date;
fmemset(lpDir->dir_ext , ' ', FEXT_SIZE ); lpDir->fcb_dirclst = lpDmatch->dm_cluster;
lpDir->fcb_fsize = lpDmatch->dm_size;
/* next move in the file name while overwriting */
/* the filler blanks */
lpszFrom = lpDmatch->dm_name;
lpToName = (BYTE FAR *)lpDir->dir_name;
for (nIndex = 0; nIndex < FNAME_SIZE; nIndex++)
{
if (*lpszFrom != 0 && *lpszFrom != '.')
*lpToName++ = *lpszFrom++;
else
break;
}
if (*lpszFrom != '\0')
{
if (*lpszFrom == '.')
++lpszFrom;
lpToName = (BYTE FAR *)lpDir->dir_ext;
for (nIndex = 0; nIndex < FEXT_SIZE; nIndex++)
{
if (*lpszFrom != '\0')
*lpToName++ = *lpszFrom++;
else
break;
}
}
for (nIndex = 0; nIndex < 10; nIndex++)
lpDir->dir_reserved[nIndex] = 0;
lpDir->dir_attrib = lpDmatch->dm_attr_fnd;
lpDir->dir_time = lpDmatch->dm_time;
lpDir->dir_date = lpDmatch->dm_date;
lpDir->dir_start = lpDmatch->dm_cluster;
lpDir->dir_size = lpDmatch->dm_size;
} }
#endif
BOOL FcbClose(xfcb FAR * lpXfcb) BOOL FcbClose(xfcb FAR * lpXfcb)
{ {
@ -1019,52 +899,37 @@ BOOL FcbClose(xfcb FAR * lpXfcb)
lpFcb = ExtFcbToFcb(lpXfcb); lpFcb = ExtFcbToFcb(lpXfcb);
/* Get the SFT block that contains the SFT */ /* Get the SFT block that contains the SFT */
if ((s = FcbGetSft(lpFcb->fcb_sftno)) == (sft FAR *) - 1) if ((s = idx_to_sft(lpFcb->fcb_sftno)) == (sft FAR *) - 1)
return FALSE; return FALSE;
/* If this is not opened another error */ /* change time and set file size */
if (s->sft_count == 0) s->sft_size = lpFcb->fcb_fsize;
return FALSE; if (!(s->sft_flags & SFT_FSHARED))
dos_setfsize(s->sft_status, lpFcb->fcb_fsize);
DosSetFtimeSft(lpFcb->fcb_sftno, (date FAR *) &lpFcb->fcb_date, (time FAR *) &lpFcb->fcb_time);
return DosCloseSft(lpFcb->fcb_sftno) == SUCCESS;
}
if (s->sft_flags & SFT_FSHARED) /* close all files opened by FCBs
{ DosCloseSft checks the open count (has to be 1) and current psp
int2f_Remote_call(REM_CLOSE, 0, 0, 0, (VOID FAR *) s, 0, 0); */
} VOID FcbCloseAll()
{
COUNT idx = 0;
/* now just drop the count if a device, else */ for (idx = 0; DosCloseSft(idx) != DE_INVLDHNDL; idx++)
/* call file system handler */ ;
if (s->sft_flags & SFT_FDEVICE)
{
s->sft_count -= 1;
return TRUE;
}
else
{
s->sft_count -= 1;
if (s->sft_count > 0)
return SUCCESS;
else
{
/* change time and set file size */
dos_setftime(s->sft_status,
(date FAR *) & lpFcb->fcb_date,
(time FAR *) & lpFcb->fcb_time);
dos_setfsize(s->sft_status,
lpFcb->fcb_fsize);
return dos_close(s->sft_status) == SUCCESS;
}
}
} }
BOOL FcbFindFirst(xfcb FAR * lpXfcb) BOOL FcbFindFirst(xfcb FAR * lpXfcb)
{ {
BYTE FAR *lpDir; fcb FAR *lpDir;
COUNT FcbDrive; COUNT FcbDrive;
psp FAR *lpPsp = MK_FP(cu_psp, 0); psp FAR *lpPsp = MK_FP(cu_psp, 0);
/* First, move the dta to a local and change it around to match */ /* First, move the dta to a local and change it around to match */
/* our functions. */ /* our functions. */
lpDir = (BYTE FAR *) dta; lpDir = (fcb FAR *) dta;
dta = (BYTE FAR *) & Dmatch; dta = (BYTE FAR *) & Dmatch;
/* Next initialze local variables by moving them from the fcb */ /* Next initialze local variables by moving them from the fcb */
@ -1072,28 +937,28 @@ BOOL FcbFindFirst(xfcb FAR * lpXfcb)
if (lpXfcb->xfcb_flag == 0xff) if (lpXfcb->xfcb_flag == 0xff)
{ {
wAttr = lpXfcb->xfcb_attrib; wAttr = lpXfcb->xfcb_attrib;
fbcopy(lpXfcb, lpDir, 7); /* fbcopy(lpXfcb, lpDir, 7);
lpDir += 7; lpDir += 7;
BO:WHY???
*/
} }
else else
wAttr = D_ALL; wAttr = D_ALL;
*lpDir++ = FcbDrive; /* *lpDir++ = FcbDrive; */
FcbFindFirstDirPtr = lpDir; /* FcbFindFirstDirPtr = lpDir; */
if (dos_findfirst(wAttr, SecPathName) != SUCCESS) if (DosFindFirst(wAttr, SecPathName) != SUCCESS)
{ {
FcbFindFirstDirPtr = NULL; /* FcbFindFirstDirPtr = NULL;*/
dta = lpPsp->ps_dta; dta = lpPsp->ps_dta;
return FALSE; return FALSE;
} }
FcbFindFirstDirPtr = NULL; /* FcbFindFirstDirPtr = NULL; */
/* MoveDirInfo(&Dmatch, lpDir);
MoveDirInfo((dmatch FAR *) & Dmatch, (struct dirent FAR *)lpDir);
*/
lpFcb->fcb_dirclst = Dmatch.dm_dirstart; lpFcb->fcb_dirclst = Dmatch.dm_dirstart;
lpFcb->fcb_strtclst = Dmatch.dm_entry; lpFcb->fcb_strtclst = Dmatch.dm_entry;
@ -1115,13 +980,13 @@ BOOL FcbFindFirst(xfcb FAR * lpXfcb)
BOOL FcbFindNext(xfcb FAR * lpXfcb) BOOL FcbFindNext(xfcb FAR * lpXfcb)
{ {
BYTE FAR *lpDir; fcb FAR *lpDir;
COUNT FcbDrive; COUNT FcbDrive;
psp FAR *lpPsp = MK_FP(cu_psp, 0); psp FAR *lpPsp = MK_FP(cu_psp, 0);
/* First, move the dta to a local and change it around to match */ /* First, move the dta to a local and change it around to match */
/* our functions. */ /* our functions. */
lpDir = (BYTE FAR *) dta; lpDir = (fcb FAR *) dta;
dta = (BYTE FAR *) & Dmatch; dta = (BYTE FAR *) & Dmatch;
/* Next initialze local variables by moving them from the fcb */ /* Next initialze local variables by moving them from the fcb */
@ -1129,14 +994,17 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb)
if ((xfcb FAR *) lpFcb != lpXfcb) if ((xfcb FAR *) lpFcb != lpXfcb)
{ {
wAttr = lpXfcb->xfcb_attrib; wAttr = lpXfcb->xfcb_attrib;
/*
fbcopy(lpXfcb, lpDir, 7); fbcopy(lpXfcb, lpDir, 7);
lpDir += 7; lpDir += 7;
BO:WHY???
*/
} }
else else
wAttr = D_ALL; wAttr = D_ALL;
/* Reconstrct the dirmatch structure from the fcb */ /* Reconstrct the dirmatch structure from the fcb */
*lpDir++ = FcbDrive; /* *lpDir++ = FcbDrive; */
Dmatch.dm_drive = lpFcb->fcb_sftno; Dmatch.dm_drive = lpFcb->fcb_sftno;
fbcopy(lpFcb->fcb_fname, (BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE); fbcopy(lpFcb->fcb_fname, (BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE);
@ -1147,20 +1015,18 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb)
Dmatch.dm_cluster = lpFcb->fcb_dirclst; Dmatch.dm_cluster = lpFcb->fcb_dirclst;
Dmatch.dm_dirstart= lpFcb->fcb_dirclst; Dmatch.dm_dirstart= lpFcb->fcb_dirclst;
FcbFindFirstDirPtr = lpDir; /* FcbFindFirstDirPtr = lpDir; */
if (dos_findnext() != SUCCESS) if (DosFindNext() != SUCCESS)
{ {
FcbFindFirstDirPtr = NULL; /* FcbFindFirstDirPtr = NULL; */
dta = lpPsp->ps_dta; dta = lpPsp->ps_dta;
CritErrCode = 0x12; CritErrCode = 0x12;
return FALSE; return FALSE;
} }
FcbFindFirstDirPtr = NULL; /*FcbFindFirstDirPtr = NULL;*/
/* MoveDirInfo(&Dmatch, lpDir);
MoveDirInfo((dmatch FAR *) & Dmatch, (struct dirent FAR *)lpDir);
*/
lpFcb->fcb_dirclst = Dmatch.dm_dirstart; lpFcb->fcb_dirclst = Dmatch.dm_dirstart;
lpFcb->fcb_strtclst = Dmatch.dm_entry; lpFcb->fcb_strtclst = Dmatch.dm_entry;

View File

@ -567,9 +567,10 @@ StandardBios: /* old way to get parameters */
driveParam->driveno = drive; driveParam->driveno = drive;
DebugPrintf(("drive parameters %02x - %04lu-%u-%u", DebugPrintf(("drive parameters %02x - %04lu-%u-%u",
drive,driveParam->chs.Cylinder, drive,
drive,driveParam->chs.Head, driveParam->chs.Cylinder,
drive,driveParam->chs.Sector)); driveParam->chs.Head,
driveParam->chs.Sector));
DebugPrintf((" total size %luMB\n\n",driveParam->total_sectors/2048)); DebugPrintf((" total size %luMB\n\n",driveParam->total_sectors/2048));

View File

@ -37,6 +37,9 @@ BYTE *RcsId = "$Id$";
/* /*
* $Log$ * $Log$
* Revision 1.27 2001/07/23 12:47:42 bartoldeman
* FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf
*
* Revision 1.26 2001/07/22 01:58:58 bartoldeman * Revision 1.26 2001/07/22 01:58:58 bartoldeman
* Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX
* *
@ -1174,8 +1177,6 @@ dispatch:
|| ((psp FAR *) (MK_FP(cu_psp, 0)))->ps_parent == cu_psp) || ((psp FAR *) (MK_FP(cu_psp, 0)))->ps_parent == cu_psp)
break; break;
tsr = FALSE; tsr = FALSE;
int2f_Remote_call(REM_PROCESS_END, 0, 0, 0, 0, 0, 0);
int2f_Remote_call(REM_CLOSEALL, 0, 0, 0, 0, 0, 0);
if (ErrorMode) if (ErrorMode)
{ {
ErrorMode = FALSE; ErrorMode = FALSE;

View File

@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$";
/* /*
* $Log$ * $Log$
* Revision 1.19 2001/07/23 12:47:42 bartoldeman
* FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf
*
* Revision 1.18 2001/07/22 01:58:58 bartoldeman * Revision 1.18 2001/07/22 01:58:58 bartoldeman
* Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX
* *
@ -219,29 +222,35 @@ COUNT SftSeek(sft FAR *sftp, LONG new_pos, COUNT mode);
UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err); UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err);
COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos); COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos);
COUNT DosCreat(BYTE FAR * fname, COUNT attrib); COUNT DosCreat(BYTE FAR * fname, COUNT attrib);
COUNT DosCreatSft(BYTE * fname, COUNT attrib);
COUNT CloneHandle(COUNT hndl); COUNT CloneHandle(COUNT hndl);
COUNT DosDup(COUNT Handle); COUNT DosDup(COUNT Handle);
COUNT DosForceDup(COUNT OldHandle, COUNT NewHandle); COUNT DosForceDup(COUNT OldHandle, COUNT NewHandle);
COUNT DosOpen(BYTE FAR * fname, COUNT mode); COUNT DosOpen(BYTE FAR * fname, COUNT mode);
COUNT DosOpenSft(BYTE * fname, COUNT mode);
COUNT DosClose(COUNT hndl); COUNT DosClose(COUNT hndl);
COUNT DosCloseSft(WORD sft_idx);
VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, COUNT FAR * nc); VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, COUNT FAR * nc);
COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s); COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s);
COUNT DosChangeDir(BYTE FAR * s); COUNT DosChangeDir(BYTE FAR * s);
COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name); COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name);
COUNT DosFindNext(void); COUNT DosFindNext(void);
COUNT DosGetFtime(COUNT hndl, date FAR * dp, time FAR * tp); COUNT DosGetFtime(COUNT hndl, date FAR * dp, time FAR * tp);
COUNT DosSetFtime(COUNT hndl, date FAR * dp, time FAR * tp); COUNT DosSetFtimeSft(WORD sft_idx, date FAR * dp, time FAR * tp);
#define DosSetFtime(hndl, dp, tp) DosSetFtimeSft(get_sft_idx(hndl), (dp), (tp))
COUNT DosGetFattr(BYTE FAR * name); COUNT DosGetFattr(BYTE FAR * name);
COUNT DosSetFattr(BYTE FAR * name, UWORD attrp); COUNT DosSetFattr(BYTE FAR * name, UWORD attrp);
UBYTE DosSelectDrv(UBYTE drv); UBYTE DosSelectDrv(UBYTE drv);
COUNT DosDelete(BYTE FAR *path); COUNT DosDelete(BYTE FAR *path);
COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2); COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2);
COUNT DosRenameTrue(BYTE * path1, BYTE * path2);
COUNT DosMkdir(BYTE FAR * dir); COUNT DosMkdir(BYTE FAR * dir);
COUNT DosRmdir(BYTE FAR * dir); COUNT DosRmdir(BYTE FAR * dir);
struct dhdr FAR * IsDevice(BYTE FAR * FileName); struct dhdr FAR * IsDevice(BYTE FAR * FileName);
BOOL IsShareInstalled(void); BOOL IsShareInstalled(void);
COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock); COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock);
sft FAR *get_free_sft(WORD FAR * sft_idx); sft FAR *idx_to_sft(COUNT SftIndex);
COUNT get_sft_idx(UCOUNT hndl);
/*dosidle.asm */ /*dosidle.asm */
VOID DosIdle_int(void); VOID DosIdle_int(void);
@ -348,8 +357,9 @@ void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive);
BOOL FcbOpen(xfcb FAR * lpXfcb); BOOL FcbOpen(xfcb FAR * lpXfcb);
BOOL FcbDelete(xfcb FAR * lpXfcb); BOOL FcbDelete(xfcb FAR * lpXfcb);
BOOL FcbRename(xfcb FAR * lpXfcb); BOOL FcbRename(xfcb FAR * lpXfcb);
void MoveDirInfo(dmatch FAR * lpDmatch, struct dirent FAR * lpDir); VOID MoveDirInfo(dmatch * lpDmatch, fcb FAR * lpDir);
BOOL FcbClose(xfcb FAR * lpXfcb); BOOL FcbClose(xfcb FAR * lpXfcb);
VOID FcbCloseAll(VOID);
BOOL FcbFindFirst(xfcb FAR * lpXfcb); BOOL FcbFindFirst(xfcb FAR * lpXfcb);
BOOL FcbFindNext(xfcb FAR * lpXfcb); BOOL FcbFindNext(xfcb FAR * lpXfcb);
@ -476,6 +486,7 @@ COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname);
VOID new_psp(psp FAR * p, int psize); VOID new_psp(psp FAR * p, int psize);
VOID return_user(void); VOID return_user(void);
COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp); COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp);
LONG DosGetFsize(COUNT hndl);
VOID InitPSP(VOID); VOID InitPSP(VOID);
/* newstuff.c */ /* newstuff.c */

View File

@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$";
/* /*
* $Log$ * $Log$
* Revision 1.16 2001/07/23 12:47:42 bartoldeman
* FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf
*
* Revision 1.15 2001/07/22 01:58:58 bartoldeman * Revision 1.15 2001/07/22 01:58:58 bartoldeman
* Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX
* *
@ -207,10 +210,6 @@ LONG DosGetFsize(COUNT hndl)
sft FAR *s; sft FAR *s;
/* sfttbl FAR *sp;*/ /* sfttbl FAR *sp;*/
/* Test that the handle is valid */
if (hndl < 0)
return DE_INVLDHNDL;
/* Get the SFT block that contains the SFT */ /* Get the SFT block that contains the SFT */
if ((s = get_sft(hndl)) == (sft FAR *) - 1) if ((s = get_sft(hndl)) == (sft FAR *) - 1)
return DE_INVLDHNDL; return DE_INVLDHNDL;
@ -389,8 +388,8 @@ VOID new_psp(psp FAR * p, int psize)
RootPsp = FP_SEG(p); RootPsp = FP_SEG(p);
} }
static VOID patchPSP(UWORD pspseg, UWORD envseg, CommandTail FAR * cmdline static UWORD patchPSP(UWORD pspseg, UWORD envseg, exec_blk FAR *exb,
,BYTE FAR * fnam) BYTE FAR * fnam)
{ {
psp FAR *psp; psp FAR *psp;
mcb FAR *pspmcb; mcb FAR *pspmcb;
@ -401,9 +400,11 @@ static VOID patchPSP(UWORD pspseg, UWORD envseg, CommandTail FAR * cmdline
++pspseg; ++pspseg;
psp = MK_FP(pspseg, 0); psp = MK_FP(pspseg, 0);
/* complete the psp by adding the command line */ /* complete the psp by adding the command line and FCBs */
fbcopy(cmdline->ctBuffer, psp->ps_cmd, 127); fbcopy(exb->exec.cmd_line->ctBuffer, psp->ps_cmd, 127);
psp->ps_cmd_count = cmdline->ctCount; fbcopy(exb->exec.fcb_1, &psp->ps_fcb1, 16);
fbcopy(exb->exec.fcb_2, &psp->ps_fcb2, 16);
psp->ps_cmd_count = exb->exec.cmd_line->ctCount;
/* identify the mcb as this functions' */ /* identify the mcb as this functions' */
pspmcb->m_psp = pspseg; pspmcb->m_psp = pspseg;
@ -438,6 +439,11 @@ set_name:
if (i < 8) if (i < 8)
pspmcb->m_name[i] = '\0'; pspmcb->m_name[i] = '\0';
/* return value: AX value to be passed based on FCB values */
return ((psp->ps_fcb1.fcb_drive<lastdrive &&
CDSp->cds_table[psp->ps_fcb1.fcb_drive].cdsFlags & CDSVALID) ? 0 : 0xff) +
((psp->ps_fcb2.fcb_drive<lastdrive &&
CDSp->cds_table[psp->ps_fcb2.fcb_drive].cdsFlags & CDSVALID) ? 0 : 0xff) * 0x100;
} }
COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
@ -559,37 +565,37 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
setvec(0x22, (VOID(INRPT FAR *) (VOID)) MK_FP(user_r->CS, user_r->IP)); setvec(0x22, (VOID(INRPT FAR *) (VOID)) MK_FP(user_r->CS, user_r->IP));
new_psp(p, mem + asize); new_psp(p, mem + asize);
patchPSP(mem - 1, env, exp->exec.cmd_line, namep); asize = patchPSP(mem - 1, env, exp, namep); /* asize=fcbcode for ax */
/* build the user area on the stack */
*((UWORD FAR *) MK_FP(mem, 0xfffe)) = (UWORD) 0;
irp = MK_FP(mem, (0xfffe - sizeof(iregs)));
/* start allocating REGs */
irp->ES = irp->DS = mem;
irp->CS = mem;
irp->IP = 0x100;
irp->AX = 0xffff; /* for now, until fcb code is in */
irp->BX =
irp->CX =
irp->DX =
irp->SI =
irp->DI =
irp->BP = 0;
irp->FLAGS = 0x200;
/* Transfer control to the executable */ /* Transfer control to the executable */
p->ps_parent = cu_psp; p->ps_parent = cu_psp;
p->ps_prevpsp = (BYTE FAR *) MK_FP(cu_psp, 0); p->ps_prevpsp = (BYTE FAR *) MK_FP(cu_psp, 0);
q->ps_stack = (BYTE FAR *) user_r; q->ps_stack = (BYTE FAR *) user_r;
user_r->FLAGS &= ~FLG_CARRY; user_r->FLAGS &= ~FLG_CARRY;
cu_psp = mem;
dta = p->ps_dta;
switch (mode) switch (mode)
{ {
case LOADNGO: case LOADNGO:
{ {
cu_psp = mem; *((UWORD FAR *) MK_FP(mem, 0xfffe)) = (UWORD) 0;
dta = p->ps_dta;
/* build the user area on the stack */
irp = MK_FP(mem, (0xfffe - sizeof(iregs)));
/* start allocating REGs */
irp->ES = irp->DS = mem;
irp->CS = mem;
irp->IP = 0x100;
irp->AX = asize; /* fcbcode */
irp->BX =
irp->CX =
irp->DX =
irp->SI =
irp->DI =
irp->BP = 0;
irp->FLAGS = 0x200;
if (InDOS) if (InDOS)
--InDOS; --InDOS;
@ -600,9 +606,9 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
break; break;
} }
case LOAD: case LOAD:
cu_psp = mem; exp->exec.stack = MK_FP(mem, 0xfffe);
exp->exec.stack = (BYTE FAR *) irp; *((UWORD FAR *)exp->exec.stack) = asize;
exp->exec.start_addr = MK_FP(irp->CS, irp->IP); exp->exec.start_addr = MK_FP(mem, 0x100);
return SUCCESS; return SUCCESS;
} }
@ -626,12 +632,15 @@ VOID return_user(void)
setvec(0x24, p->ps_isv24); setvec(0x24, p->ps_isv24);
/* And free all process memory if not a TSR return */ /* And free all process memory if not a TSR return */
int2f_Remote_call(REM_PROCESS_END, 0, 0, 0, 0, 0, 0);
if (!tsr) if (!tsr)
{ {
int2f_Remote_call(REM_CLOSEALL, 0, 0, 0, 0, 0, 0);
for (i = 0; i < p->ps_maxfiles; i++) for (i = 0; i < p->ps_maxfiles; i++)
{ {
DosClose(i); DosClose(i);
} }
FcbCloseAll();
FreeProcessMem(cu_psp); FreeProcessMem(cu_psp);
} }
@ -917,25 +926,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
setvec(0x22, (VOID(INRPT FAR *) (VOID)) MK_FP(user_r->CS, user_r->IP)); setvec(0x22, (VOID(INRPT FAR *) (VOID)) MK_FP(user_r->CS, user_r->IP));
new_psp(p, mem + asize); new_psp(p, mem + asize);
patchPSP(mem - 1, env, exp->exec.cmd_line, namep); asize = patchPSP(mem - 1, env, exp, namep); /* asize = fcbcode */
/* build the user area on the stack */
irp = MK_FP(header.exInitSS + start_seg,
((header.exInitSP - sizeof(iregs)) & 0xffff));
/* start allocating REGs */
/* Note: must match es & ds memory segment */
irp->ES = irp->DS = mem;
irp->CS = header.exInitCS + start_seg;
irp->IP = header.exInitIP;
irp->AX = 0xffff; /* for now, until fcb code is in */
irp->BX =
irp->CX =
irp->DX =
irp->SI =
irp->DI =
irp->BP = 0;
irp->FLAGS = 0x200;
/* Transfer control to the executable */ /* Transfer control to the executable */
p->ps_parent = cu_psp; p->ps_parent = cu_psp;
@ -946,6 +937,24 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
switch (mode) switch (mode)
{ {
case LOADNGO: case LOADNGO:
/* build the user area on the stack */
irp = MK_FP(header.exInitSS + start_seg,
((header.exInitSP - sizeof(iregs)) & 0xffff));
/* start allocating REGs */
/* Note: must match es & ds memory segment */
irp->ES = irp->DS = mem;
irp->CS = header.exInitCS + start_seg;
irp->IP = header.exInitIP;
irp->AX = asize; /* asize = fcbcode */
irp->BX =
irp->CX =
irp->DX =
irp->SI =
irp->DI =
irp->BP = 0;
irp->FLAGS = 0x200;
cu_psp = mem; cu_psp = mem;
dta = p->ps_dta; dta = p->ps_dta;
@ -958,8 +967,9 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
case LOAD: case LOAD:
cu_psp = mem; cu_psp = mem;
exp->exec.stack = (BYTE FAR *) irp; exp->exec.stack = MK_FP(header.exInitSS + start_seg, header.exInitSP);
exp->exec.start_addr = MK_FP(irp->CS, irp->IP); *((UWORD FAR *) exp->exec.stack) = asize; /* fcbcode */
exp->exec.start_addr = MK_FP(header.exInitCS + start_seg, header.exInitIP);
return SUCCESS; return SUCCESS;
} }
return DE_INVLDFMT; return DE_INVLDFMT;