diff --git a/docs/history.txt b/docs/history.txt index 1b2cb6a..a3d6c65 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,29 @@ +2001 Apr 2 - Build 2023 +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Fixes Bart: Volkov Commander revealed a few bugs: + -int 21/ah=55 forgot to set current psp to child psp. + -memory allocation: mem_access_mode was a signed byte, and hence 0x80 was + translated to 0xff80 and not 0x0080 when converting to a COUNT. Hence + changed it to become a UBYTE. + -An error in memmgr.c: search again in low mem for modes 0x80,81,82, not + 0x40,0x41,0x42 + * execrh.asm & int2f.asm: made code executable on a 8088 (no push + constant) + * entry.asm: made sure dos_crit_sect is executed when required to. + * Another redirector fix. int 2f/1122 needed DS=current psp. This caused a + bug for me: after compiling FreeCOM on a redirected drive "dir" did not + work any more. + * The nansi.sys problem: as it was, the initialisation phase of nansi + called int/ah=30, which checked control-break, which checks the console + driver, which at that point is the still not initialized nansi. This + messed up the request header passed to it. A solution I found is to link + a device into the device chain _after_ initialisation, not before. + * Redirector fix: network.c uses fmemcpy instead of fsncopy. + * Fixed INT 21/AH=6 (direct console input). + Tom: + * DE_NFILES instead of DE_FILENOTFOUND to allow Volkov Commander to browse empty + drives. + * Fixed bug wrt zero terminated device names (should be spaces terminated). 2001 Mar 30 - Build 2023 -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + Fixes Tom: Kernel alloc initialises to 0. This avoids some weird errors. diff --git a/kernel/config.c b/kernel/config.c index de44f74..0967909 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -40,6 +40,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.16 2001/04/02 23:18:30 bartoldeman + * Misc, zero terminated device names and redirector bugs fixed. + * * Revision 1.15 2001/03/30 22:27:42 bartoldeman * Saner lastdrive handling. * @@ -1034,16 +1037,6 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) for ( ; ; ) { - struct dhdr FAR *previous_nul_dhp; - - previous_nul_dhp = nul_dev.dh_next; - - next_dhp = dhp->dh_next; - - /* Link in device driver and save nul_dev pointer to next */ - dhp->dh_next = nul_dev.dh_next; - nul_dev.dh_next = dhp; - /* that's a nice hack >:-) although we don't want HIMEM.SYS,(it's not free), other people @@ -1068,8 +1061,12 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) /* end of HIMEM.SYS HACK */ result=init_device(dhp, pTmp, mode, top); - if(result){ - nul_dev.dh_next = previous_nul_dhp; /* return orig pointer if error */ + + if(!result){ + next_dhp = dhp->dh_next; + /* Link in device driver and save nul_dev pointer to next */ + dhp->dh_next = nul_dev.dh_next; + nul_dev.dh_next = dhp; } /* multiple devices end */ diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 0e09f53..da67c3d 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,6 +37,9 @@ static BYTE *dosfnsRcsId = "$Id$"; * /// Added SHARE support. 2000/09/04 Ron Cemer * * $Log$ + * Revision 1.14 2001/04/02 23:18:30 bartoldeman + * Misc, zero terminated device names and redirector bugs fixed. + * * Revision 1.13 2001/03/30 22:27:42 bartoldeman * Saner lastdrive handling. * @@ -277,8 +280,8 @@ UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, BOOL force_binary) { sft FAR *s; - WORD sys_idx; - sfttbl FAR *sp; +/* WORD sys_idx;*/ +/*sfttbl FAR *sp;*/ UCOUNT ReadCount; /* Test that the handle is valid */ @@ -406,8 +409,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) { sft FAR *s; - WORD sys_idx; - sfttbl FAR *sp; +/* WORD sys_idx;*/ +/*sfttbl FAR *sp;*/ UCOUNT WriteCount; /* Test that the handle is valid */ @@ -496,7 +499,7 @@ UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) } else { - REG WORD c, + REG WORD /*c,*/ cnt = n, spaces_left = 0, next_pos, @@ -703,7 +706,7 @@ static WORD get_free_hndl(void) return 0xff; } -static sft FAR *get_free_sft(WORD FAR * sft_idx) +sft FAR *get_free_sft(WORD FAR * sft_idx) { WORD sys_idx = 0; sfttbl FAR *sp; @@ -769,8 +772,8 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib) WORD hndl, sft_idx; sft FAR *sftp; struct dhdr FAR *dhp; - BYTE FAR *froot; - WORD i; +/* BYTE FAR *froot;*/ +/* WORD i;*/ COUNT result, drive; /* get a free handle */ @@ -940,8 +943,8 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) WORD sft_idx; sft FAR *sftp; struct dhdr FAR *dhp; - BYTE FAR *froot; - WORD i; +/* BYTE FAR *froot;*/ +/* WORD i;*/ COUNT drive, result; /* /// Added to adjust for filenames which begin with ".\" @@ -1192,12 +1195,13 @@ COUNT DosChangeDir(BYTE FAR * s) REG COUNT drive; COUNT result; BYTE FAR *p; - - /* don't do wildcard CHDIR --TE*/ - /* although this should be handled somewhere else */ + + /* don't do wildcard CHDIR --TE*/ for (p = s; *p; p++) if (*p == '*' || *p == '?') return DE_PATHNOTFND; + + drive = get_verify_drive(s); if (drive < 0 ) { @@ -1263,7 +1267,7 @@ COUNT DosFindNext(void) COUNT DosGetFtime(COUNT hndl, date FAR * dp, time FAR * tp) { sft FAR *s; - sfttbl FAR *sp; +/*sfttbl FAR *sp;*/ /* Test that the handle is valid */ if (hndl < 0) @@ -1292,7 +1296,7 @@ COUNT DosGetFtime(COUNT hndl, date FAR * dp, time FAR * tp) COUNT DosSetFtime(COUNT hndl, date FAR * dp, time FAR * tp) { sft FAR *s; - sfttbl FAR *sp; +/*sfttbl FAR *sp;*/ /* Test that the handle is valid */ if (hndl < 0) @@ -1469,7 +1473,7 @@ COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2) drive1 = get_verify_drive(path1); result = truename(path1, PriPathName, FALSE); - if (result != SUCCESS) { + if (result != SUCCESS) { return result; } drive2 = get_verify_drive(path2); @@ -1575,21 +1579,22 @@ struct dhdr FAR * IsDevice(BYTE FAR * fname) struct dhdr FAR *dhp; BYTE FAR *froot; WORD i; + BYTE tmpPathName[FNAME_SIZE+1]; /* check for a device */ froot = get_root(fname); for (i = 0; i < FNAME_SIZE; i++) { if (*froot != '\0' && *froot != '.') - SecPathName[i] = *froot++; + tmpPathName[i] = *froot++; else break; } for (; i < FNAME_SIZE; i++) - SecPathName[i] = ' '; + tmpPathName[i] = ' '; - SecPathName[i] = 0; + tmpPathName[i] = 0; /* /// BUG!!! This is absolutely wrong. A filename of "NUL.LST" must be treated EXACTLY the same as a filename of "NUL". The existence or @@ -1600,10 +1605,23 @@ struct dhdr FAR * IsDevice(BYTE FAR * fname) if (*froot != '.') { */ + for (dhp = (struct dhdr FAR *)&nul_dev; dhp != (struct dhdr FAR *)-1; dhp = dhp->dh_next) { - if (fnmatch((BYTE FAR *) SecPathName, (BYTE FAR *) dhp->dh_name, FNAME_SIZE, FALSE)) + + /* BUGFIX: MSCD000<00> should be handled like MSCD000<20> TE */ + + char dev_name_buff[FNAME_SIZE]; + + int namelen = fstrlen(dhp->dh_name); + + memset(dev_name_buff, ' ', FNAME_SIZE); + + fmemcpy(dev_name_buff,dhp->dh_name, min(namelen,FNAME_SIZE)); + + if (fnmatch((BYTE FAR *) tmpPathName, (BYTE FAR *) dev_name_buff, FNAME_SIZE, FALSE)) { + memcpy(SecPathName, tmpPathName, i+1); return dhp; } } diff --git a/kernel/entry.asm b/kernel/entry.asm index bf4ad99..e211299 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.10 2001/04/02 23:18:30 bartoldeman +; Misc, zero terminated device names and redirector bugs fixed. +; ; Revision 1.9 2001/03/30 19:30:06 bartoldeman ; Misc fixes and implementation of SHELLHIGH. See history.txt for details. ; @@ -280,6 +283,7 @@ int21_reentry: jne int21_1 int21_user: + call dos_crit_sect mov bp,sp push ss push bp diff --git a/kernel/execrh.asm b/kernel/execrh.asm index fa5738b..63fbad8 100644 --- a/kernel/execrh.asm +++ b/kernel/execrh.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.5 2001/04/02 23:18:30 bartoldeman +; Misc, zero terminated device names and redirector bugs fixed. +; ; Revision 1.4 2001/03/21 02:56:25 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -102,16 +105,34 @@ _execrh: push es ; sometimes it get lost push ds - lds si,[bp+8] ; ds:si = device header - les bx,[bp+4] ; es:bx = request header + lds si,[bp+8] ; ds:si = device header + les bx,[bp+4] ; es:bx = request header + + push ds ; needed later + push si + + mov bp, execrh_ret1 ; construct return frame + push cs + push bp + + push ds ; call far the strategy + push word [si+6] - push cs ; do this, the right way! - push word exit_execrh ; like 68k code - push ds - push word [ds:si+8] ; interrupt - push ds - push word [ds:si+6] ; strategy retf +execrh_ret1: + pop si ; these were saved + pop ds + + mov bp, execrh_ret2 ; construct return frame + push cs + push bp + + push ds ; call far the interrupt + push word [si+8] + + retf +execrh_ret2: + exit_execrh: sti ; damm driver turn off ints cld ; has gone backwards pop ds diff --git a/kernel/fatdir.c b/kernel/fatdir.c index ec10e7c..773bccb 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,9 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.13 2001/04/02 23:18:30 bartoldeman + * Misc, zero terminated device names and redirector bugs fixed. + * * Revision 1.12 2001/03/30 22:27:42 bartoldeman * Saner lastdrive handling. * @@ -167,9 +170,9 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) struct f_node FAR *fnp; COUNT drive; BYTE *p; - WORD i, - x; - BYTE *s; + WORD i; + /*TEunused x; */ +/* BYTE *s;*/ struct cds FAR *cdsp; BYTE *pszPath = &TempCDS.cdsCurrentPath[2]; @@ -209,18 +212,19 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) release_f_node(fnp); return NULL; } - TempCDS.cdsDpb = CDSp->cds_table[drive].cdsDpb; cdsp = &CDSp->cds_table[drive]; + TempCDS.cdsDpb = cdsp->cdsDpb; + TempCDS.cdsCurrentPath[0] = 'A' + drive; TempCDS.cdsCurrentPath[1] = ':'; TempCDS.cdsJoinOffset = 2; - x = cdsp->cdsJoinOffset; + i = cdsp->cdsJoinOffset; /* Generate full path name */ - ParseDosPath(dirname, (COUNT *) 0, pszPath, (BYTE FAR *) & cdsp->cdsCurrentPath[x]); + ParseDosPath(dirname, (COUNT *) 0, pszPath, (BYTE FAR *) & cdsp->cdsCurrentPath[i]); /* for testing only for now */ #if 0 @@ -346,8 +350,9 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) COUNT dir_read(REG struct f_node FAR * fnp) { - REG i; - REG j; +/* REG i; */ +/* REG j; */ + struct buffer FAR *bp; /* Directories need to point to their current offset, not for */ @@ -584,7 +589,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) REG COUNT i; COUNT nDrive; BYTE *p; - BYTE FAR *ptr; +/* BYTE FAR *ptr;*/ static BYTE local_name[FNAME_SIZE + 1], local_ext[FEXT_SIZE + 1]; @@ -678,35 +683,26 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) } } if (!wild) { - struct dhdr FAR *dhp; - for (dhp = (struct dhdr FAR *)&nul_dev; - dhp != (struct dhdr FAR *)-1; - dhp = dhp->dh_next) { - if (fnmatch - ((BYTE FAR *)&Name, - (BYTE FAR *)dhp->dh_name, - FNAME_SIZE, - FALSE)) { - /* Found a matching device. */ - dmp->dm_entry = 0; - dmp->dm_cluster = 0; - dmp->dm_flags.f_dmod = 0; - dmp->dm_flags.f_droot = 0; - dmp->dm_flags.f_dnew = 0; - dmp->dm_flags.f_ddir = 0; - dmp->dm_flags.f_dfull = 0; - dmp->dm_dirstart = 0; - dmp->dm_attr_fnd = D_DEVICE; - dmp->dm_time = dos_gettime(); - dmp->dm_date = dos_getdate(); - dmp->dm_size = 0L; - for (d = 0; ( (d < FNAME_SIZE) && (Name[d] != ' ') ); d++) - dmp->dm_name[d] = Name[d]; - dmp->dm_name[d] = '\0'; - return SUCCESS; + if (IsDevice(Name)) { + /* Found a matching device. */ + dmp->dm_entry = 0; + dmp->dm_cluster = 0; + dmp->dm_flags.f_dmod = 0; + dmp->dm_flags.f_droot = 0; + dmp->dm_flags.f_dnew = 0; + dmp->dm_flags.f_ddir = 0; + dmp->dm_flags.f_dfull = 0; + dmp->dm_dirstart = 0; + dmp->dm_attr_fnd = D_DEVICE; + dmp->dm_time = dos_gettime(); + dmp->dm_date = dos_getdate(); + dmp->dm_size = 0L; + for (d = 0; ( (d < FNAME_SIZE) && (Name[d] != ' ') ); d++) + dmp->dm_name[d] = Name[d]; + dmp->dm_name[d] = '\0'; + return SUCCESS; } } - } } /* /// End of additions. - Ron Cemer */ @@ -779,8 +775,8 @@ COUNT dos_findnext(void) REG dmatch FAR *dmp = (dmatch FAR *) dta; REG struct f_node FAR *fnp; BOOL found = FALSE; - BYTE FAR *p; - BYTE FAR *q; +/* BYTE FAR *p;*/ +/* BYTE FAR *q;*/ COUNT nDrive; /* assign our match parameters pointer. */ @@ -809,7 +805,7 @@ COUNT dos_findnext(void) #if 0 printf("findnext: %c %s\n", - nDrive + 'A', (cdsp->cdsFlags & CDSNETWDRV)?"remote":"local"); + nDrive + 'A', (current_ldt->cdsFlags & CDSNETWDRV)?"remote":"local"); #endif if (current_ldt->cdsFlags & CDSNETWDRV) @@ -891,7 +887,7 @@ COUNT dos_findnext(void) /* return the result */ release_f_node(fnp); - return found ? SUCCESS : DE_FILENOTFND; + return found ? SUCCESS : DE_NFILES; } static VOID pop_dmp(dmatch FAR * dmp, struct f_node FAR * fnp) diff --git a/kernel/globals.h b/kernel/globals.h index c8a6935..005b8dc 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -36,6 +36,9 @@ static BYTE *Globals_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/04/02 23:18:30 bartoldeman + * Misc, zero terminated device names and redirector bugs fixed. + * * Revision 1.9 2001/03/30 20:11:14 bartoldeman * Truly got DOS=HIGH reporting for INT21/AX=0x3306 working now. * @@ -480,8 +483,10 @@ extern BYTE extern struct dhdr nul_dev; extern BYTE - LocalPath[PARSE_MAX + 3], /* Room for drive spec */ - mem_access_mode, /* memory allocation scheme */ + LocalPath[PARSE_MAX + 3]; /* Room for drive spec */ +extern UBYTE + mem_access_mode; /* memory allocation scheme */ +extern BYTE ErrorMode, /* Critical error flag */ InDOS, /* In DOS critical section */ OpenMode, /* File Open Attributes */ diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 57ce2e8..9da2917 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.8 2001/04/02 23:18:30 bartoldeman +; Misc, zero terminated device names and redirector bugs fixed. +; ; Revision 1.7 2001/03/21 02:56:26 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -95,6 +98,7 @@ segment HMA_TEXT extern _nul_dev:wrt DGROUP extern _umb_start:wrt DGROUP extern _UMB_top:wrt DGROUP + extern _cu_psp:wrt DGROUP extern _syscall_MUX14:wrt HMA_TEXT global reloc_call_int2f_handler @@ -210,7 +214,7 @@ int2f_skip1: xor ax,ax les di,[bp+18] ; do return data stuff mov [es:di],cx - jmp short int2f_rfner + jmp int2f_rfner int2f_r_2: cmp al,0ch ; Get Remote DPB jne short int2f_r_3 @@ -262,9 +266,15 @@ int2f_r_6: xor ax,ax jmp short int2f_rfner int2f_r_7: + cmp al,022h ; Terminate process + jne short int2f_r_8 + mov ds,[_cu_psp] + call int2f_call + jmp short int2f_rfner ; ; everything else goes through here. ; +int2f_r_8: call int2f_call jc int2f_rfner xor ax,ax @@ -364,12 +374,13 @@ _Umb_Test push es ; save driver entry point push bx - mov dx,0xffff ; go for broke! - mov ax,1000h ; get the umb's push cs ; setup far return - push word umbt1 + mov ax, umbt1 + push ax push es ; push the driver entry point push bx + mov dx,0xffff ; go for broke! + mov ax,1000h ; get the umb's retf ; Call the driver umbt1: ; @@ -389,11 +400,12 @@ umbtc: pop bx ; restore driver entry pop es - mov ax,1000h ; dx set with largest size push cs - push word umbt2 + mov ax, umbt2 + push ax push es push bx + mov ax,1000h ; dx set with largest size retf umbt2: cmp ax,1 diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 085200f..a205d12 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.19 2001/04/02 23:18:30 bartoldeman + * Misc, zero terminated device names and redirector bugs fixed. + * * Revision 1.18 2001/03/30 22:27:42 bartoldeman * Saner lastdrive handling. * @@ -428,13 +431,13 @@ dispatch: sto(r->DL); else if (StdinBusy()) { - r->AL = 0x00; - r->FLAGS |= FLG_ZERO; + r->FLAGS &= ~FLG_ZERO; + r->AL = _sti(); } else { - r->FLAGS &= ~FLG_ZERO; - r->AL = _sti(); + r->AL = 0x00; + r->FLAGS |= FLG_ZERO; } break; @@ -1294,6 +1297,7 @@ dispatch: /* Dos Create New Psp & set p_size */ case 0x55: new_psp((psp FAR *) MK_FP(r->DX, 0), r->SI); + cu_psp = r->DX; break; /* Dos Rename */ @@ -1343,12 +1347,13 @@ dispatch: switch (r->AL) { case 0x00: - r->AX = mem_access_mode; + r->AL = mem_access_mode; + r->AH = 0; break; case 0x01: { - switch (r->BX) + switch (r->BL) { case LAST_FIT: case LAST_FIT_U: @@ -1360,7 +1365,7 @@ dispatch: case FIRST_FIT: case FIRST_FIT_U: case FIRST_FIT_UO: - mem_access_mode = r->BX; + mem_access_mode = r->BL; break; default: diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 353cf4c..3e881fd 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -35,6 +35,9 @@ static BYTE *memmgrRcsId = "$Id$"; /* * $Log$ + * Revision 1.11 2001/04/02 23:18:30 bartoldeman + * Misc, zero terminated device names and redirector bugs fixed. + * * Revision 1.10 2001/03/30 19:30:06 bartoldeman * Misc fixes and implementation of SHELLHIGH. See history.txt for details. * @@ -286,9 +289,9 @@ searchAgain: if (!foundSeg || !foundSeg->m_size) { /* no block to fullfill the request */ - if((mode != LARGEST) && (mode & FIRST_FIT_UO) && + if((mode != LARGEST) && (mode & FIRST_FIT_U) && uppermem_link && uppermem_root) { - mode &= !FIRST_FIT_UO; + mode &= ~FIRST_FIT_U; goto searchAgain; } if (asize) @@ -603,6 +606,7 @@ COUNT DosGetLargestBlock(UWORD FAR * block) } #endif +#ifdef DEBUG VOID show_chain(void) { mcb FAR *p, FAR *u; @@ -617,6 +621,7 @@ VOID show_chain(void) p = nxtMCB(p); } } +#endif VOID mcb_print(mcb FAR * mcbp) { diff --git a/kernel/network.c b/kernel/network.c index 7d0afad..75db9da 100644 --- a/kernel/network.c +++ b/kernel/network.c @@ -36,6 +36,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/04/02 23:18:30 bartoldeman + * Misc, zero terminated device names and redirector bugs fixed. + * * Revision 1.9 2001/03/30 19:30:06 bartoldeman * Misc fixes and implementation of SHELLHIGH. See history.txt for details. * @@ -144,12 +147,12 @@ COUNT Remote_find(UWORD func, BYTE FAR * name, REG dmatch FAR * dmp ) else test = (VOID FAR *) &TempBuffer; - fsncopy(dta, (BYTE FAR *) &TempBuffer, 21); + fmemcpy((BYTE FAR *) &TempBuffer, dta, 21); p = dta; dta = (BYTE FAR *) &TempBuffer; i = int2f_Remote_call(func, 0, 0, 0, test, 0, 0); dta = p; - fsncopy((BYTE FAR *) &TempBuffer, dta, 21); + fmemcpy(dta, (BYTE FAR *) &TempBuffer, 21); if (i != 0) return i; diff --git a/kernel/newstuff.c b/kernel/newstuff.c index fa270f7..8bb0a92 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -31,6 +31,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/04/02 23:18:30 bartoldeman + * Misc, zero terminated device names and redirector bugs fixed. + * * Revision 1.9 2001/03/30 22:27:42 bartoldeman * Saner lastdrive handling. * @@ -113,6 +116,10 @@ static BYTE *mainRcsId = "$Id$"; #include "globals.h" #include "proto.h" +/* + TE-TODO: if called repeatedly by same process, + last allocation must be freed. if handle count < 20, copy back to PSP +*/ int SetJFTSize(UWORD nHandles) { UWORD block, @@ -236,13 +243,27 @@ COUNT get_verify_drive(char FAR *src) * MSD returns \\D.\A.\????????.??? with SHSUCDX. So, this code is not * compatible MSD Func 60h. */ + +/*TE TODO: + + experimenting with NUL on MSDOS 7.0 (win95) + + WIN95 FREEDOS + TRUENAME NUL C:/NUL OK + TRUENAME .\NUL C:\DOS\NUL + TRUENAME ..\NUL C:\NUL + TRUENAME ..\..\NUL path not found + TRUENAME Z:NUL invalid drive (not lastdrive!!) + TRUENAME A:NUL A:/NUL OK + TRUENAME A:\NUL A:\NUL + +*/ + COUNT truename(char FAR * src, char FAR * dest, COUNT t) { static char buf[128] = "A:\\\0\0\0\0\0\0\0\0\0"; - /* /// Changed to FNAME_SIZE from 8 for cleanliness. - Ron Cemer */ - static char Name[FNAME_SIZE]; char *bufp = buf + 3; - COUNT i, n, rootEndPos = 2; /* renamed x to rootEndPos - Ron Cemer */ + COUNT i, rootEndPos = 2; /* renamed x to rootEndPos - Ron Cemer */ struct cds FAR *cdsp; struct dhdr FAR *dhp; BYTE FAR *froot; @@ -258,8 +279,8 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) { buf[0] = (src[0] | 0x20) + 'A' - 'a'; - if (buf[0] >= lastdrive + 'A') - return DE_PATHNOTFND; + if (buf[0] >= lastdrive + 'A') /* BUG:should be: drive exists */ + return DE_INVLDDRV; src += 2; } @@ -282,62 +303,44 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) MSD returns X:/CON for truename con. Not X:\CON */ /* check for a device */ - froot = get_root(src); - for (d = 0; d < FNAME_SIZE; d++) - { - if (*froot != '\0' && *froot != '.') - Name[d] = *froot++; - else - break; - } - for (; d < FNAME_SIZE; d++) - Name[d] = ' '; + if ((dhp = IsDevice(src)) != NULL) + { + + froot = get_root(src); /* /// Bugfix: NUL.LST is the same as NUL. This is true for all devices. On a device name, the extension is irrelevant as long as the name matches. - Ron Cemer */ -#if (0) - /* if we have an extension, can't be a device */ - if (*froot != '.') - { -#endif - for (dhp = (struct dhdr FAR *)&nul_dev; dhp != (struct dhdr FAR *)-1; dhp = dhp->dh_next) - { - if (fnmatch((BYTE FAR *) &Name, (BYTE FAR *) dhp->dh_name, FNAME_SIZE, FALSE)) - { - buf[2] ='/'; - /* /// Bug: should be only copying up to first space. - - Ron Cemer - for (d = 0; d < FNAME_SIZE || Name[d] == ' '; d++) */ - for (d = 0; ( (d < FNAME_SIZE) && (Name[d] != ' ') ); d++) - *bufp++ = Name[d]; - /* /// DOS will return C:/NUL.LST if you pass NUL.LST in. - DOS will also return C:/NUL.??? if you pass NUL.* in. - Code added here to support this. - - Ron Cemer */ - while ( (*froot != '.') && (*froot != '\0') ) froot++; - if (*froot) froot++; - if (*froot) { - *bufp++ = '.'; - for (i = 0; i < FEXT_SIZE; i++) { - if ( (*froot == '\0') || (*froot == '.') ) - break; - if (*froot == '*') { - for (; i < FEXT_SIZE; i++) *bufp++ = '?'; - break; - } - *bufp++ = *froot++; + + buf[2] ='/'; + /* /// Bug: should be only copying up to first space. + - Ron Cemer */ + + for (d = 0; d < FNAME_SIZE && dhp->dh_name[d] != 0 && dhp->dh_name[d] != ' '; d++) + *bufp++ = dhp->dh_name[d]; + /* /// DOS will return C:/NUL.LST if you pass NUL.LST in. + DOS will also return C:/NUL.??? if you pass NUL.* in. + Code added here to support this. + - Ron Cemer */ + while ( (*froot != '.') && (*froot != '\0') ) froot++; + if (*froot) froot++; + if (*froot) { + *bufp++ = '.'; + for (i = 0; i < FEXT_SIZE; i++) { + if ( (*froot == '\0') || (*froot == '.') ) + break; + if (*froot == '*') { + for (; i < FEXT_SIZE; i++) *bufp++ = '?'; + break; } + *bufp++ = *froot++; } - /* /// End of code additions. - Ron Cemer */ - goto exit_tn; - } } -#if (0) + /* /// End of code additions. - Ron Cemer */ + goto exit_tn; } -#endif cdsp = &CDSp->cds_table[i]; current_ldt = cdsp; @@ -370,7 +373,7 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) else src++; -move_name: +/*move_name:*/ /* /// The block inside the "#if (0) ... #endif" is seriously broken. New code added below to replace it.