kernel 2026a final changes (mainly FCB fixes)

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@353 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2002-02-16 19:20:20 +00:00
parent 251fa29181
commit b2496a6fbd
12 changed files with 163 additions and 225 deletions

View File

@ -57,6 +57,10 @@ MENUDEFAULT=0,1 ( configuration 0, wait 1 second)
Although this is definitively worse then MSDOS menuing possibilities, Although this is definitively worse then MSDOS menuing possibilities,
IMHO it's better then nothing IMHO it's better then nothing
the selected configuration can be determined in AUTOEXEC.BAT in the
environment variable CONFIG like
if %CONFIG% == 0 echo configuration 0 selected
thus my config.sys now looks like thus my config.sys now looks like

View File

@ -1,9 +1,17 @@
2002 Feb 17 - Build 2026a
-------- Bart Oldeman (bart@dosemu.org)
+ Changes Martin + Changes Martin
* fixed SYS for non-Watcom compilers * fixed SYS for non-Watcom compilers
+ Changes Tom
* set CONFIG environment variable to selected number of CONFIG.SYS
menu entry, for example for use in AUTOEXEC.BAT.
+ Changes Bart + Changes Bart
* FCB and network redirector fixes * fixed FCBOpen
(FCBOpen was broken; it appears that clearing CF before calling * network redirector fixes ; it appears that clearing CF before calling
the redirector is safer then setting CF) the redirector is safer than setting CF
* allow creating, renaming and deleting volume labels using FCBs
* fix renaming with wildcards using FCBs
* some dosfns.c and fcbfns.c clean-ups
2002 Feb 9 - Build 2026 2002 Feb 9 - Build 2026
-------- Bart Oldeman (bart@dosemu.org) -------- Bart Oldeman (bart@dosemu.org)
+ Changes Tom + Changes Tom

View File

@ -47,6 +47,7 @@ static BYTE *fat_hRcsId =
#define D_DEVICE 0x40 /* device bit */ #define D_DEVICE 0x40 /* device bit */
#define D_LFN (D_RDONLY | D_HIDDEN | D_SYSTEM | D_VOLID) #define D_LFN (D_RDONLY | D_HIDDEN | D_SYSTEM | D_VOLID)
#define D_ALL (D_RDONLY | D_HIDDEN | D_SYSTEM | D_DIR | D_ARCHIVE)
/* FAT file name constants */ /* FAT file name constants */
#define FNAME_SIZE 8 #define FNAME_SIZE 8

View File

@ -49,6 +49,6 @@ static BYTE *date_hRcsId =
#define REVISION_MINOR 1 #define REVISION_MINOR 1
#define REVISION_SEQ 26 #define REVISION_SEQ 26
#define BUILD "2026" #define BUILD "2026"
#define SUB_BUILD "" #define SUB_BUILD "a"
#define KERNEL_VERSION_STRING "1.1.26" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ #define KERNEL_VERSION_STRING "1.1.26a" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */
#define KERNEL_BUILD_STRING "2026" /*#BUILD SUB_BUILD */ #define KERNEL_BUILD_STRING "2026a" /*#BUILD SUB_BUILD */

View File

@ -128,7 +128,7 @@ BYTE askThisSingleCommand = FALSE; /* ?device= device?= */
BYTE DontAskThisSingleCommand = FALSE; /* !files= */ BYTE DontAskThisSingleCommand = FALSE; /* !files= */
COUNT MenuTimeout = -1; COUNT MenuTimeout = -1;
BYTE MenuSelected = '2'; BYTE MenuSelected = 0;
BYTE MenuLine = 0; BYTE MenuLine = 0;
UCOUNT Menus = 0; UCOUNT Menus = 0;

View File

@ -37,7 +37,6 @@ static BYTE *dosfnsRcsId =
COUNT get_free_hndl(VOID); COUNT get_free_hndl(VOID);
sft FAR * get_free_sft(COUNT *); sft FAR * get_free_sft(COUNT *);
BOOL cmatch(COUNT, COUNT, COUNT);
f_node_ptr xlt_fd(COUNT); f_node_ptr xlt_fd(COUNT);
@ -306,7 +305,7 @@ UCOUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err)
} }
#endif #endif
UCOUNT DosWriteSft(sft FAR * s, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) UCOUNT DosWriteSft(sft FAR * s, UCOUNT n, const BYTE FAR * bp, COUNT FAR * err)
{ {
UCOUNT WriteCount; UCOUNT WriteCount;
@ -334,7 +333,7 @@ UCOUNT DosWriteSft(sft FAR * s, UCOUNT n, BYTE FAR * bp, COUNT FAR * err)
save_dta = dta; save_dta = dta;
lpCurSft = s; lpCurSft = s;
current_filepos = s->sft_posit; /* needed for MSCDEX */ current_filepos = s->sft_posit; /* needed for MSCDEX */
dta = bp; dta = (BYTE FAR *)bp;
WriteCount = remote_write(s, n, &rc); WriteCount = remote_write(s, n, &rc);
dta = save_dta; dta = save_dta;
*err = rc; *err = rc;
@ -412,7 +411,7 @@ UCOUNT DosWriteSft(sft FAR * s, UCOUNT n, BYTE FAR * bp, COUNT FAR * err)
rq.r_length = sizeof(request); rq.r_length = sizeof(request);
rq.r_command = C_OUTPUT; rq.r_command = C_OUTPUT;
rq.r_count = 1; rq.r_count = 1;
rq.r_trans = bp; rq.r_trans = (BYTE FAR *)bp;
rq.r_status = 0; rq.r_status = 0;
execrh((request FAR *) & rq, s->sft_dev); execrh((request FAR *) & rq, s->sft_dev);
if (!(rq.r_status & S_ERROR)) if (!(rq.r_status & S_ERROR))
@ -627,26 +626,27 @@ BYTE FAR *get_root(BYTE FAR * fname)
return ++froot; return ++froot;
} }
/* Ascii only file name match routines */ /* initialize SFT fields (for open/creat) for character devices */
STATIC BOOL cmatch(COUNT s, COUNT d, COUNT mode) STATIC void DeviceOpenSft(struct dhdr FAR *dhp, sft FAR *sftp)
{ {
if (s >= 'a' && s <= 'z') int i;
s -= 'a' - 'A';
if (d >= 'a' && d <= 'z')
d -= 'a' - 'A';
if (mode && s == '?' && (d >= 'A' && s <= 'Z'))
return TRUE;
return s == d;
}
BOOL fnmatch(BYTE FAR * s, BYTE FAR * d, COUNT n, COUNT mode) sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */
{ sftp->sft_count += 1;
while (n--) sftp->sft_flags =
{ ((dhp->
if (!cmatch(*s++, *d++, mode)) dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF;
return FALSE; fmemcpy(sftp->sft_name, dhp->dh_name, FNAME_SIZE);
}
return TRUE; /* pad with spaces */
for (i = FNAME_SIZE + FEXT_SIZE - 1; sftp->sft_name[i] == '\0'; i--)
sftp->sft_name[i] = ' ';
/* and uppercase */
DosUpFMem(sftp->sft_name, FNAME_SIZE + FEXT_SIZE);
sftp->sft_dev = dhp;
sftp->sft_date = dos_getdate();
sftp->sft_time = dos_gettime();
} }
COUNT DosCreatSft(BYTE * fname, COUNT attrib) COUNT DosCreatSft(BYTE * fname, COUNT attrib)
@ -657,13 +657,6 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib)
WORD result; WORD result;
COUNT drive; COUNT drive;
/* NEVER EVER allow directories to be created */
attrib &= 0xff;
if (attrib & ~(D_RDONLY | D_HIDDEN | D_SYSTEM | D_ARCHIVE))
{
return DE_ACCESS;
}
/* now get a free system file table entry */ /* now get a free system file table entry */
if ((sftp = get_free_sft(&sft_idx)) == (sft FAR *) - 1) if ((sftp = get_free_sft(&sft_idx)) == (sft FAR *) - 1)
return DE_TOOMANY; return DE_TOOMANY;
@ -674,21 +667,12 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib)
sftp->sft_psp = cu_psp; sftp->sft_psp = cu_psp;
sftp->sft_mode = SFT_MRDWR; sftp->sft_mode = SFT_MRDWR;
sftp->sft_attrib = attrib; 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; DeviceOpenSft(dhp, sftp);
sftp->sft_flags =
((dhp->
dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF;
fmemcpy(sftp->sft_name, (BYTE FAR *) SecPathName,
FNAME_SIZE + FEXT_SIZE);
sftp->sft_dev = dhp;
sftp->sft_date = dos_getdate();
sftp->sft_time = dos_gettime();
return sft_idx; return sft_idx;
} }
@ -727,7 +711,7 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib)
DosGetFile(fname, sftp->sft_name); DosGetFile(fname, sftp->sft_name);
dos_getftime(sftp->sft_status, dos_getftime(sftp->sft_status,
(date FAR *) & sftp->sft_date, (date FAR *) & sftp->sft_date,
(time FAR *) & sftp->sft_time); (time FAR *) & sftp->sft_time);
return sft_idx; return sft_idx;
} }
else else
@ -748,6 +732,13 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib)
psp FAR *p = MK_FP(cu_psp, 0); psp FAR *p = MK_FP(cu_psp, 0);
COUNT sft_idx, hndl, result; COUNT sft_idx, hndl, result;
/* NEVER EVER allow directories to be created */
attrib = (BYTE) attrib;
if (attrib & ~(D_RDONLY | D_HIDDEN | D_SYSTEM | D_ARCHIVE))
{
return DE_ACCESS;
}
/* get a free handle */ /* get a free handle */
if ((hndl = get_free_hndl()) < 0) if ((hndl = get_free_hndl()) < 0)
return hndl; return hndl;
@ -867,17 +858,7 @@ COUNT DosOpenSft(BYTE * fname, COUNT mode)
dhp = IsDevice(fname); dhp = IsDevice(fname);
if (dhp) if (dhp)
{ {
sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ DeviceOpenSft(dhp, sftp);
sftp->sft_count += 1;
sftp->sft_flags =
((dhp->
dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF;
fmemcpy(sftp->sft_name, (BYTE FAR *) SecPathName,
FNAME_SIZE + FEXT_SIZE);
sftp->sft_dev = dhp;
sftp->sft_date = dos_getdate();
sftp->sft_time = dos_gettime();
return sft_idx; return sft_idx;
} }
@ -1260,8 +1241,8 @@ COUNT DosChangeDir(BYTE FAR * s)
Copy the path to the current directory Copy the path to the current directory
structure. structure.
Some redirectors do not write back to the CDS. Some redirectors do not write back to the CDS.
SHSUCdX needs this. jt SHSUCdX needs this. jt
*/ */
fstrcpy(current_ldt->cdsCurrentPath, PriPathName); fstrcpy(current_ldt->cdsCurrentPath, PriPathName);
if (PriPathName[7] == 0) if (PriPathName[7] == 0)
@ -1571,7 +1552,7 @@ UBYTE DosSelectDrv(UBYTE drv)
return lastdrive; return lastdrive;
} }
COUNT DosDelete(BYTE FAR * path) COUNT DosDelete(BYTE FAR * path, int attrib)
{ {
COUNT result, drive; COUNT result, drive;
@ -1597,11 +1578,11 @@ COUNT DosDelete(BYTE FAR * path)
} }
else else
{ {
return dos_delete(PriPathName); return dos_delete(PriPathName, attrib);
} }
} }
COUNT DosRenameTrue(BYTE * path1, BYTE * path2) COUNT DosRenameTrue(BYTE * path1, BYTE * path2, int attrib)
{ {
COUNT drive1, drive2; COUNT drive1, drive2;
@ -1623,7 +1604,7 @@ COUNT DosRenameTrue(BYTE * path1, BYTE * path2)
} }
else else
{ {
return dos_rename(PriPathName, SecPathName); return dos_rename(PriPathName, SecPathName, attrib);
} }
} }
@ -1643,7 +1624,7 @@ COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2)
return result; return result;
} }
return DosRenameTrue(PriPathName, SecPathName); return DosRenameTrue(PriPathName, SecPathName, D_ALL);
} }
COUNT DosMkdir(BYTE FAR * dir) COUNT DosMkdir(BYTE FAR * dir)
@ -1737,27 +1718,12 @@ COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock)
* This seems to work well. * This seems to work well.
*/ */
/* check for a device */
struct dhdr FAR *IsDevice(BYTE FAR * fname) struct dhdr FAR *IsDevice(BYTE FAR * fname)
{ {
struct dhdr FAR *dhp; struct dhdr FAR *dhp;
BYTE FAR *froot; char FAR *froot = get_root(fname);
WORD i; int 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 != '.')
tmpPathName[i] = *froot++;
else
break;
}
for (; i < FNAME_SIZE; i++)
tmpPathName[i] = ' ';
tmpPathName[i] = 0;
/* /// BUG!!! This is absolutely wrong. A filename of "NUL.LST" must be /* /// BUG!!! This is absolutely wrong. A filename of "NUL.LST" must be
treated EXACTLY the same as a filename of "NUL". The existence or treated EXACTLY the same as a filename of "NUL". The existence or
@ -1775,24 +1741,28 @@ struct dhdr FAR *IsDevice(BYTE FAR * fname)
/* BUGFIX: MSCD000<00> should be handled like MSCD000<20> TE */ /* BUGFIX: MSCD000<00> should be handled like MSCD000<20> TE */
char dev_name_buff[FNAME_SIZE]; for (i = 0; i < FNAME_SIZE; i++)
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); char c1 = froot[i];
return dhp; if (c1 == '.' || c1 == '\0')
{
/* check if remainder of device name consists of spaces or nulls */
for (; i < FNAME_SIZE; i++)
{
char c2 = dhp->dh_name[i];
if (c2 != ' ' && c2 != '\0')
break;
}
break;
}
if (DosUpFChar(c1) != DosUpFChar(dhp->dh_name[i]))
break;
} }
if (i == FNAME_SIZE)
return dhp;
} }
return (struct dhdr FAR *)0; return NULL;
} }
/* /// Added for SHARE. - Ron Cemer */ /* /// Added for SHARE. - Ron Cemer */

View File

@ -517,7 +517,8 @@ COUNT dos_findfirst(UCOUNT attr, BYTE * name)
while (dir_read(fnp) == 1) while (dir_read(fnp) == 1)
{ {
/* Test the attribute and return first found */ /* Test the attribute and return first found */
if ((fnp->f_dir.dir_attrib & ~(D_RDONLY | D_ARCHIVE)) == D_VOLID) if ((fnp->f_dir.dir_attrib & ~(D_RDONLY | D_ARCHIVE)) == D_VOLID &&
fnp->f_dir.dir_name[0] != DELETED)
{ {
dmp->dm_dircluster = fnp->f_dirstart; /* TE */ dmp->dm_dircluster = fnp->f_dirstart; /* TE */
memcpy(&SearchDir, &fnp->f_dir, sizeof(struct dirent)); memcpy(&SearchDir, &fnp->f_dir, sizeof(struct dirent));

View File

@ -40,7 +40,7 @@ BYTE *RcsId = "$Id$";
f_node_ptr xlt_fd(COUNT); f_node_ptr xlt_fd(COUNT);
COUNT xlt_fnp(f_node_ptr); COUNT xlt_fnp(f_node_ptr);
f_node_ptr split_path(BYTE *, BYTE *, BYTE *); f_node_ptr split_path(BYTE *, BYTE *, BYTE *);
BOOL find_fname(f_node_ptr, BYTE *, BYTE *); BOOL find_fname(f_node_ptr, BYTE *, BYTE *, int);
/* /// Added - Ron Cemer */ /* /// Added - Ron Cemer */
STATIC void merge_file_changes(f_node_ptr fnp, int collect); STATIC void merge_file_changes(f_node_ptr fnp, int collect);
/* /// Added - Ron Cemer */ /* /// Added - Ron Cemer */
@ -97,7 +97,7 @@ COUNT dos_open(BYTE * path, COUNT flag)
/* Look for the file. If we can't find it, just return a not */ /* Look for the file. If we can't find it, just return a not */
/* found error. */ /* found error. */
if (!find_fname(fnp, szFileName, szFileExt)) if (!find_fname(fnp, szFileName, szFileExt, D_ALL))
{ {
dir_close(fnp); dir_close(fnp);
return DE_FILENOTFND; return DE_FILENOTFND;
@ -277,7 +277,7 @@ f_node_ptr split_path(BYTE * path, BYTE * fname, BYTE * fext)
return fnp; return fnp;
} }
STATIC BOOL find_fname(f_node_ptr fnp, BYTE * fname, BYTE * fext) STATIC BOOL find_fname(f_node_ptr fnp, BYTE * fname, BYTE * fext, int attr)
{ {
BOOL found = FALSE; BOOL found = FALSE;
@ -290,7 +290,7 @@ STATIC BOOL find_fname(f_node_ptr fnp, BYTE * fname, BYTE * fext)
if (fcmp(fname, (BYTE *) fnp->f_dir.dir_name, FNAME_SIZE) if (fcmp(fname, (BYTE *) fnp->f_dir.dir_name, FNAME_SIZE)
&& fcmp(fext, (BYTE *) fnp->f_dir.dir_ext, FEXT_SIZE) && fcmp(fext, (BYTE *) fnp->f_dir.dir_ext, FEXT_SIZE)
&& ((fnp->f_dir.dir_attrib & D_VOLID) == 0)) && (fnp->f_dir.dir_attrib & ~(D_RDONLY | D_ARCHIVE | attr)) == 0)
{ {
found = TRUE; found = TRUE;
break; break;
@ -417,7 +417,7 @@ STATIC void copy_file_changes(f_node_ptr src, f_node_ptr dst)
dst->f_dir.dir_time = src->f_dir.dir_time; dst->f_dir.dir_time = src->f_dir.dir_time;
} }
COUNT dos_creat(BYTE * path, COUNT attrib) COUNT dos_creat(BYTE * path, int attrib)
{ {
REG f_node_ptr fnp; REG f_node_ptr fnp;
@ -430,7 +430,7 @@ COUNT dos_creat(BYTE * path, COUNT attrib)
/* Check that we don't have a duplicate name, so if we */ /* Check that we don't have a duplicate name, so if we */
/* find one, truncate it. */ /* find one, truncate it. */
if (find_fname(fnp, szFileName, szFileExt)) if (find_fname(fnp, szFileName, szFileExt, D_ALL | attrib))
{ {
/* The only permissable attribute is archive, */ /* The only permissable attribute is archive, */
/* check for any other bit set. If it is, give */ /* check for any other bit set. If it is, give */
@ -542,7 +542,7 @@ STATIC COUNT delete_dir_entry(f_node_ptr fnp)
return SUCCESS; return SUCCESS;
} }
COUNT dos_delete(BYTE * path) COUNT dos_delete(BYTE * path, int attrib)
{ {
REG f_node_ptr fnp; REG f_node_ptr fnp;
@ -555,13 +555,13 @@ COUNT dos_delete(BYTE * path)
/* Check that we don't have a duplicate name, so if we */ /* Check that we don't have a duplicate name, so if we */
/* find one, it's an error. */ /* find one, it's an error. */
if (find_fname(fnp, szFileName, szFileExt)) if (find_fname(fnp, szFileName, szFileExt, attrib))
{ {
/* The only permissable attribute is archive, */ /* Do not delete directories or r/o files */
/* TE +hidden + system */ /* lfn entries and volume labels are only found */
/* check for any other bit set. If it is, give */ /* by find_fname() if attrib is set to a */
/* an access error. */ /* special value */
if (fnp->f_dir.dir_attrib & ~(D_ARCHIVE | D_HIDDEN | D_SYSTEM)) if (fnp->f_dir.dir_attrib & (D_RDONLY | D_DIR))
{ {
dir_close(fnp); dir_close(fnp);
return DE_ACCESS; return DE_ACCESS;
@ -599,7 +599,7 @@ COUNT dos_rmdir(BYTE * path)
/* Check that we don't have a duplicate name, so if we */ /* Check that we don't have a duplicate name, so if we */
/* find one, it's an error. */ /* find one, it's an error. */
if (find_fname(fnp, szFileName, szFileExt)) if (find_fname(fnp, szFileName, szFileExt, D_ALL))
{ {
/* The only permissable attribute is directory, */ /* The only permissable attribute is directory, */
/* check for any other bit set. If it is, give */ /* check for any other bit set. If it is, give */
@ -668,7 +668,7 @@ COUNT dos_rmdir(BYTE * path)
} }
} }
COUNT dos_rename(BYTE * path1, BYTE * path2) COUNT dos_rename(BYTE * path1, BYTE * path2, int attrib)
{ {
REG f_node_ptr fnp1; REG f_node_ptr fnp1;
REG f_node_ptr fnp2; REG f_node_ptr fnp2;
@ -684,7 +684,7 @@ COUNT dos_rename(BYTE * path1, BYTE * path2)
/* Check that we don't have a duplicate name, so if we find */ /* Check that we don't have a duplicate name, so if we find */
/* one, it's an error. */ /* one, it's an error. */
if (find_fname(fnp2, szFileName, szFileExt)) if (find_fname(fnp2, szFileName, szFileExt, attrib))
{ {
dir_close(fnp2); dir_close(fnp2);
return DE_ACCESS; return DE_ACCESS;
@ -698,7 +698,7 @@ COUNT dos_rename(BYTE * path1, BYTE * path2)
return DE_PATHNOTFND; return DE_PATHNOTFND;
} }
if (!find_fname(fnp1, szFileName, szFileExt)) if (!find_fname(fnp1, szFileName, szFileExt, attrib))
{ {
/* No such file, return the error */ /* No such file, return the error */
dir_close(fnp1); dir_close(fnp1);
@ -1101,7 +1101,7 @@ COUNT dos_mkdir(BYTE * dir)
/* Check that we don't have a duplicate name, so if we */ /* Check that we don't have a duplicate name, so if we */
/* find one, it's an error. */ /* find one, it's an error. */
if (find_fname(fnp, szFileName, szFileExt)) if (find_fname(fnp, szFileName, szFileExt, D_ALL))
{ {
dir_close(fnp); dir_close(fnp);
return DE_ACCESS; return DE_ACCESS;
@ -1828,7 +1828,7 @@ STATIC COUNT dos_extend(f_node_ptr fnp)
} }
/* Write block to disk */ /* Write block to disk */
UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) UCOUNT writeblock(COUNT fd, const VOID FAR * buffer, UCOUNT count, COUNT * err)
{ {
REG f_node_ptr fnp; REG f_node_ptr fnp;
struct buffer FAR *bp; struct buffer FAR *bp;

View File

@ -38,7 +38,6 @@ static BYTE *RcsId =
#define FCB_ERR_NODATA 1 #define FCB_ERR_NODATA 1
#define FCB_ERR_EOF 3 #define FCB_ERR_EOF 3
#define FCB_ERR_WRITE 1 #define FCB_ERR_WRITE 1
#define D_ALL D_NORMAL | D_RDONLY | D_HIDDEN | D_SYSTEM | D_DIR | D_ARCHIVE
#ifdef PROTO #ifdef PROTO
fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb); fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb);
@ -82,7 +81,7 @@ VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps,
#define PARSE_RET_BADDRIVE 0xff #define PARSE_RET_BADDRIVE 0xff
#ifndef IPL #ifndef IPL
WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb) WORD FcbParseFname(int wTestMode, const BYTE FAR ** lpFileName, fcb FAR * lpFcb)
{ {
COUNT nIndex; COUNT nIndex;
WORD wRetCodeName = FALSE, wRetCodeExt = FALSE; WORD wRetCodeName = FALSE, wRetCodeExt = FALSE;
@ -156,7 +155,7 @@ WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb)
return (wRetCodeName | wRetCodeExt) ? PARSE_RET_WILD : PARSE_RET_NOWILD; return (wRetCodeName | wRetCodeExt) ? PARSE_RET_WILD : PARSE_RET_NOWILD;
} }
BYTE FAR * ParseSkipWh(BYTE FAR * lpFileName) const BYTE FAR * ParseSkipWh(const BYTE FAR * lpFileName)
{ {
while (*lpFileName == ' ' || *lpFileName == '\t') while (*lpFileName == ' ' || *lpFileName == '\t')
++lpFileName; ++lpFileName;
@ -191,7 +190,7 @@ BOOL TestFieldSeps(BYTE FAR * lpFileName)
} }
#endif #endif
BYTE FAR * GetNameField(BYTE FAR * lpFileName, BYTE FAR * lpDestField, const BYTE FAR * GetNameField(const BYTE FAR * lpFileName, BYTE FAR * lpDestField,
COUNT nFieldSize, BOOL * pbWildCard) COUNT nFieldSize, BOOL * pbWildCard)
{ {
COUNT nIndex = 0; COUNT nIndex = 0;
@ -466,7 +465,9 @@ BOOL FcbOpenCreate(xfcb FAR * lpXfcb, BOOL Create)
if (Create) if (Create)
{ {
sft_idx = DosCreatSft(PriPathName, 0); /* pass attribute without constraints (dangerous for directories) */
int attr = (lpXfcb->xfcb_flag == 0xff ? lpXfcb->xfcb_attrib : 0);
sft_idx = DosCreatSft(PriPathName, attr);
} }
else else
{ {
@ -559,21 +560,22 @@ BOOL FcbDelete(xfcb FAR * lpXfcb)
} }
else else
{ {
int attr = (lpXfcb->xfcb_flag == 0xff ? lpXfcb->xfcb_attrib : D_ALL);
BYTE FAR *lpOldDta = dta; BYTE FAR *lpOldDta = dta;
dmatch Dmatch; dmatch Dmatch;
dta = (BYTE FAR *) & Dmatch; dta = (BYTE FAR *) & Dmatch;
if (DosFindFirst if (DosFindFirst(attr, SecPathName) != SUCCESS)
(D_ALL,
SecPathName[1] == ':' ? &SecPathName[2] : SecPathName) != SUCCESS)
{ {
dta = lpOldDta; dta = lpOldDta;
return FALSE; return FALSE;
} }
do do
{ {
truename(Dmatch.dm_name, SecPathName, FALSE); SecPathName[0] = 'A' + FcbDrive - 1;
if (DosDelete(SecPathName) != SUCCESS) SecPathName[1] = ':';
strcpy(&SecPathName[2], Dmatch.dm_name);
if (DosDelete(SecPathName, attr) != SUCCESS)
{ {
dta = lpOldDta; dta = lpOldDta;
return FALSE; return FALSE;
@ -592,7 +594,8 @@ BOOL FcbRename(xfcb FAR * lpXfcb)
/* Build a traditional DOS file name */ /* Build a traditional DOS file name */
lpRenameFcb = (rfcb FAR *) CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); lpRenameFcb = (rfcb FAR *) CommonFcbInit(lpXfcb, SecPathName, &FcbDrive);
wAttr = (lpXfcb->xfcb_flag == 0xff ? lpXfcb->xfcb_attrib : D_ALL);
/* check for a device */ /* check for a device */
if (IsDevice(SecPathName)) if (IsDevice(SecPathName))
{ {
@ -604,9 +607,7 @@ BOOL FcbRename(xfcb FAR * lpXfcb)
dmatch Dmatch; dmatch Dmatch;
dta = (BYTE FAR *) & Dmatch; dta = (BYTE FAR *) & Dmatch;
if (DosFindFirst if (DosFindFirst(wAttr, SecPathName) != SUCCESS)
(D_ALL,
SecPathName[1] == ':' ? &SecPathName[2] : SecPathName) != SUCCESS)
{ {
dta = lpOldDta; dta = lpOldDta;
return FALSE; return FALSE;
@ -615,65 +616,34 @@ BOOL FcbRename(xfcb FAR * lpXfcb)
do do
{ {
fcb LocalFcb; fcb LocalFcb;
BYTE *pToName, *pszFrom; BYTE *pToName;
BYTE FAR *pFromPattern; const BYTE FAR *pFromPattern = Dmatch.dm_name;
COUNT nIndex; int i;
/* First, expand the find match into fcb style */
/* file name entry */
/* Fill with blanks first */
memset(LocalFcb.fcb_fname, ' ', FNAME_SIZE);
memset(LocalFcb.fcb_fext, ' ', FEXT_SIZE);
/* next move in the file name while overwriting */
/* the filler blanks */
pszFrom = Dmatch.dm_name;
pToName = LocalFcb.fcb_fname;
for (nIndex = 0; nIndex < FNAME_SIZE; nIndex++)
{
if (*pszFrom != 0 && *pszFrom != '.')
*pToName++ = *pszFrom++;
else if (*pszFrom == '.')
{
++pszFrom;
break;
}
else
break;
}
if (*pszFrom != '\0')
{
pToName = LocalFcb.fcb_fext;
for (nIndex = 0; nIndex < FEXT_SIZE; nIndex++)
{
if (*pszFrom != '\0')
*pToName++ = *pszFrom++;
else
break;
}
}
FcbParseFname(0, &pFromPattern, &LocalFcb);
/* Overlay the pattern, skipping '?' */ /* Overlay the pattern, skipping '?' */
/* I'm cheating because this assumes that the */ /* I'm cheating because this assumes that the */
/* struct alignments are on byte boundaries */ /* struct alignments are on byte boundaries */
pToName = LocalFcb.fcb_fname; pToName = LocalFcb.fcb_fname;
for (pFromPattern = lpRenameFcb->renNewName, pFromPattern = lpRenameFcb->renNewName;
nIndex = 0; nIndex < FNAME_SIZE + FEXT_SIZE; nIndex++) for (i = 0; i < FNAME_SIZE + FEXT_SIZE; i++)
{ {
if (*pFromPattern != '?') if (*pFromPattern != '?')
*pToName++ = *pFromPattern++; *pToName = *pFromPattern;
else pToName++;
++pFromPattern; pFromPattern++;
} }
SecPathName[0] = 'A' + FcbDrive - 1;
SecPathName[1] = ':';
strcpy(&SecPathName[2], Dmatch.dm_name);
truename(SecPathName, PriPathName, FALSE);
/* now to build a dos name again */ /* now to build a dos name again */
LocalFcb.fcb_drive = 0; LocalFcb.fcb_drive = FcbDrive;
FcbNameInit((fcb FAR *) & LocalFcb, SecPathName, &FcbDrive); FcbNameInit((fcb FAR *) & LocalFcb, SecPathName, &FcbDrive);
truename(Dmatch.dm_name, PriPathName, FALSE); if (DosRenameTrue(PriPathName, SecPathName, wAttr) != SUCCESS)
if (DosRenameTrue(PriPathName, SecPathName) != SUCCESS)
{ {
dta = lpOldDta; dta = lpOldDta;
return FALSE; return FALSE;

View File

@ -532,9 +532,7 @@ dispatch:
/* Parse File Name */ /* Parse File Name */
case 0x29: case 0x29:
{ {
BYTE FAR *lpFileName; const BYTE FAR *lpFileName = MK_FP(r->DS, r->SI);
lpFileName = MK_FP(r->DS, r->SI);
r->AL = FcbParseFname(r->AL, &lpFileName, MK_FP(r->ES, r->DI)); r->AL = FcbParseFname(r->AL, &lpFileName, MK_FP(r->ES, r->DI));
r->DS = FP_SEG(lpFileName); r->DS = FP_SEG(lpFileName);
r->SI = FP_OFF(lpFileName); r->SI = FP_OFF(lpFileName);
@ -820,7 +818,7 @@ dispatch:
/* Dos Delete File */ /* Dos Delete File */
case 0x41: case 0x41:
rc = DosDelete((BYTE FAR *) FP_DS_DX); rc = DosDelete((BYTE FAR *) FP_DS_DX, D_ALL);
if (rc < 0) if (rc < 0)
goto error_exit; goto error_exit;
break; break;
@ -1416,7 +1414,7 @@ dispatch:
CLEAR_CARRY_FLAG(); CLEAR_CARRY_FLAG();
break; break;
/* Flush file buffer -- COMMIT FILE -- dummy function right now. */ /* Flush file buffer -- COMMIT FILE. */
case 0x68: case 0x68:
case 0x6a: case 0x6a:
if ((rc = DosCommit(r->BX)) < 0) if ((rc = DosCommit(r->BX)) < 0)

View File

@ -393,43 +393,30 @@ STATIC VOID signon()
STATIC void kernel() STATIC void kernel()
{ {
#if 0
BYTE FAR *ep, *sp;
#endif
exec_blk exb; exec_blk exb;
CommandTail Cmd; CommandTail Cmd;
int rc; int rc;
#ifndef KDB extern char MenuSelected;
static BYTE master_env[] = "PATH=.\0\0\0\0\0";
/* static BYTE *path = "PATH=.";*/
#endif
#ifdef KDB BYTE master_env[32];
kdb(); char *masterenv_ptr = master_env;
#else
#if 0
/* create the master environment area */
if (allocmem(0x2, &exb.exec.env_seg)) /* build the startup environment */
init_fatal("cannot allocate master environment space");
/* populate it with the minimum environment */ memset(master_env,0,sizeof(master_env));
++exb.exec.env_seg;
ep = MK_FP(exb.exec.env_seg, 0);
for (sp = path; *sp != 0;) /* initial path setting. is this useful ?? */
*ep++ = *sp++; masterenv_ptr += sprintf(masterenv_ptr, "PATH=.");
/* export the current selected config menu */
if (MenuSelected)
{
masterenv_ptr += sprintf(masterenv_ptr, "CONFIG=%c", MenuSelected);
}
*ep++ = '\0';
*ep++ = '\0';
*((int FAR *)ep) = 0;
ep += sizeof(int);
#else
exb.exec.env_seg = DOS_PSP + 8; exb.exec.env_seg = DOS_PSP + 8;
fmemcpy(MK_FP(exb.exec.env_seg, 0), master_env, sizeof(master_env)); fmemcpy(MK_FP(exb.exec.env_seg, 0), master_env, sizeof(master_env));
#endif
#endif
RootPsp = ~0; RootPsp = ~0;

View File

@ -67,7 +67,6 @@ sft FAR *get_sft(UCOUNT);
/* dosfns.c */ /* dosfns.c */
BYTE FAR *get_root(BYTE FAR *); BYTE FAR *get_root(BYTE FAR *);
BOOL fnmatch(BYTE FAR *, BYTE FAR *, COUNT, COUNT);
BOOL check_break(void); BOOL check_break(void);
UCOUNT GenericReadSft(sft far * sftp, UCOUNT n, BYTE FAR * bp, UCOUNT GenericReadSft(sft far * sftp, UCOUNT n, BYTE FAR * bp,
COUNT FAR * err, BOOL force_binary); COUNT FAR * err, BOOL force_binary);
@ -76,7 +75,7 @@ COUNT SftSeek(sft FAR * sftp, LONG new_pos, COUNT mode);
#define GenericRead(hndl, n, bp, err, t) GenericReadSft(get_sft(hndl), n, bp, err, t) #define GenericRead(hndl, n, bp, err, t) GenericReadSft(get_sft(hndl), n, bp, err, t)
#define DosRead(hndl, n, bp, err) GenericRead(hndl, n, bp, err, FALSE) #define DosRead(hndl, n, bp, err) GenericRead(hndl, n, bp, err, FALSE)
#define DosReadSft(sftp, n, bp, err) GenericReadSft(sftp, n, bp, err, FALSE) #define DosReadSft(sftp, n, bp, err) GenericReadSft(sftp, n, bp, err, FALSE)
UCOUNT DosWriteSft(sft FAR * sftp, UCOUNT n, BYTE FAR * bp, UCOUNT DosWriteSft(sft FAR * sftp, UCOUNT n, const BYTE FAR * bp,
COUNT FAR * err); COUNT FAR * err);
#define DosWrite(hndl, n, bp, err) DosWriteSft(get_sft(hndl), n, bp, err) #define DosWrite(hndl, n, bp, err) DosWriteSft(get_sft(hndl), n, bp, 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);
@ -102,9 +101,9 @@ COUNT DosSetFtimeSft(WORD sft_idx, date dp, time 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, int attrib);
COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2); COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2);
COUNT DosRenameTrue(BYTE * path1, BYTE * path2); COUNT DosRenameTrue(BYTE * path1, BYTE * path2, int attrib);
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);
@ -145,10 +144,10 @@ BOOL fcmp_wild(BYTE FAR * s1, BYTE FAR * s2, COUNT n);
VOID touc(BYTE * s, COUNT n); VOID touc(BYTE * s, COUNT n);
COUNT dos_close(COUNT fd); COUNT dos_close(COUNT fd);
COUNT dos_commit(COUNT fd); COUNT dos_commit(COUNT fd);
COUNT dos_creat(BYTE * path, COUNT attrib); COUNT dos_creat(BYTE * path, int attrib);
COUNT dos_delete(BYTE * path); COUNT dos_delete(BYTE * path, int attrib);
COUNT dos_rmdir(BYTE * path); COUNT dos_rmdir(BYTE * path);
COUNT dos_rename(BYTE * path1, BYTE * path2); COUNT dos_rename(BYTE * path1, BYTE * path2, int attrib);
date dos_getdate(void); date dos_getdate(void);
time dos_gettime(void); time dos_gettime(void);
COUNT dos_getftime(COUNT fd, date FAR * dp, time FAR * tp); COUNT dos_getftime(COUNT fd, date FAR * dp, time FAR * tp);
@ -160,9 +159,9 @@ COUNT dos_mkdir(BYTE * dir);
BOOL last_link(f_node_ptr fnp); BOOL last_link(f_node_ptr fnp);
COUNT map_cluster(REG f_node_ptr fnp, COUNT mode); COUNT map_cluster(REG f_node_ptr fnp, COUNT mode);
UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err); UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err);
UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err); UCOUNT writeblock(COUNT fd, const VOID FAR * buffer, UCOUNT count, COUNT * err);
COUNT dos_read(COUNT fd, VOID FAR * buffer, UCOUNT count); COUNT dos_read(COUNT fd, VOID FAR * buffer, UCOUNT count);
COUNT dos_write(COUNT fd, VOID FAR * buffer, UCOUNT count); COUNT dos_write(COUNT fd, const VOID FAR * buffer, UCOUNT count);
LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin); LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin);
CLUSTER dos_free(struct dpb FAR * dpbp); CLUSTER dos_free(struct dpb FAR * dpbp);
@ -205,11 +204,11 @@ VOID DosCharOutput(COUNT c);
VOID DosDisplayOutput(COUNT c); VOID DosDisplayOutput(COUNT c);
VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps, VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps,
UCOUNT FAR * nc, BYTE FAR ** mdp); UCOUNT FAR * nc, BYTE FAR ** mdp);
WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb); WORD FcbParseFname(int wTestMode, const BYTE FAR ** lpFileName, fcb FAR * lpFcb);
BYTE FAR *ParseSkipWh(BYTE FAR * lpFileName); const BYTE FAR *ParseSkipWh(const BYTE FAR * lpFileName);
BOOL TestCmnSeps(BYTE FAR * lpFileName); BOOL TestCmnSeps(BYTE FAR * lpFileName);
BOOL TestFieldSeps(BYTE FAR * lpFileName); BOOL TestFieldSeps(BYTE FAR * lpFileName);
BYTE FAR *GetNameField(BYTE FAR * lpFileName, BYTE FAR * lpDestField, const BYTE FAR *GetNameField(const BYTE FAR * lpFileName, BYTE FAR * lpDestField,
COUNT nFieldSize, BOOL * pbWildCard); COUNT nFieldSize, BOOL * pbWildCard);
typedef BOOL FcbFunc_t (xfcb FAR *, COUNT *, UCOUNT); typedef BOOL FcbFunc_t (xfcb FAR *, COUNT *, UCOUNT);
FcbFunc_t FcbRead, FcbWrite; FcbFunc_t FcbRead, FcbWrite;
@ -253,10 +252,10 @@ VOID DosUmbLink(BYTE n);
VOID mcb_print(mcb FAR * mcbp); VOID mcb_print(mcb FAR * mcbp);
/* misc.c */ /* misc.c */
VOID ASMCFUNC strcpy(REG BYTE * d, REG BYTE * s); VOID ASMCFUNC strcpy(REG BYTE * d, REG const BYTE * s);
VOID ASMCFUNC fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n); VOID ASMCFUNC fmemcpy(REG VOID FAR * d, REG const VOID FAR * s, REG COUNT n);
VOID ASMCFUNC fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); VOID ASMCFUNC fstrcpy(REG BYTE FAR * d, REG const BYTE FAR * s);
void ASMCFUNC memcpy(REG void *d, REG VOID * s, REG COUNT n); void ASMCFUNC memcpy(REG void *d, REG const VOID * s, REG COUNT n);
void ASMCFUNC fmemset(REG VOID FAR * s, REG int ch, REG COUNT n); void ASMCFUNC fmemset(REG VOID FAR * s, REG int ch, REG COUNT n);
void ASMCFUNC memset(REG VOID * s, REG int ch, REG COUNT n); void ASMCFUNC memset(REG VOID * s, REG int ch, REG COUNT n);