diff --git a/docs/history.txt b/docs/history.txt index 15865e5..b1183be 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -16,6 +16,9 @@ * distinguish between the builtin DOS version and the settable DOS version. * console.asm now accepts extended scancodes (modified by Bart) + * added BOOTONLY option to SYS (modified by Bart) ++ Changes David Bolen + * add support for UNC-style paths (that start with "\\") + Changes Bart * flip some slashes in drivers/*.asm (enables cross-assembly on Linux) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 3357bb8..032bb13 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -92,7 +92,7 @@ STATIC int remote_lock_unlock(sft FAR *sftp, /* SFT for file */ /* get current directory structure for drive return NULL if the CDS is not valid or the drive is not within range */ -struct cds FAR *get_cds(int drive) +struct cds FAR *get_cds(unsigned drive) { struct cds FAR *cdsp; unsigned flags; @@ -966,7 +966,8 @@ COUNT DosChangeDir(BYTE FAR * s) return result; } - if (strlen(PriPathName) > sizeof(current_ldt->cdsCurrentPath) - 1) + if ((FP_OFF(current_ldt) != 0xFFFF) && + (strlen(PriPathName) > sizeof(current_ldt->cdsCurrentPath) - 1)) return DE_PATHNOTFND; #if defined(CHDIR_DEBUG) @@ -988,8 +989,12 @@ COUNT DosChangeDir(BYTE FAR * s) SHSUCdX needs this. jt */ fstrcpy(current_ldt->cdsCurrentPath, PriPathName); - if (PriPathName[7] == 0) - current_ldt->cdsCurrentPath[8] = 0; /* Need two Zeros at the end */ + if (FP_OFF(current_ldt) != 0xFFFF) + { + fstrcpy(current_ldt->cdsCurrentPath, PriPathName); + if (PriPathName[7] == 0) + current_ldt->cdsCurrentPath[8] = 0; /* Need two Zeros at the end */ + } return SUCCESS; } @@ -1271,7 +1276,7 @@ COUNT DosRenameTrue(BYTE * path1, BYTE * path2, int attrib) { return DE_DEVICE; /* not same device */ } - if (current_ldt->cdsFlags & CDSNETWDRV) + if (FP_OFF(current_ldt) == 0xFFFF || (current_ldt->cdsFlags & CDSNETWDRV)) return remote_rename(); return dos_rename(path1, path2, attrib); diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 7219177..28a75e5 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -108,7 +108,7 @@ int DosMkTmp(BYTE FAR * pathname, UWORD attr) #define DEBUG_TRUENAME #endif -#define drLetterToNr(dr) ((dr) - 'A') +#define drLetterToNr(dr) ((unsigned char)((dr) - 'A')) /* Convert an uppercased drive letter into the drive index */ #define drNrToLetter(dr) ((dr) + 'A') /* the other direction */ @@ -117,22 +117,6 @@ int DosMkTmp(BYTE FAR * pathname, UWORD attr) is always a logical drive letter associated with a path spec. This letter is also the index into the CDS */ -COUNT get_verify_drive(const char FAR * src) -{ - int drive; - - /* Do we have a drive? */ - if (src[1] == ':') - drive = drLetterToNr(DosUpFChar(src[0])); - else - drive = default_drive; - - if (get_cds(drive) == NULL) - return DE_PATHNOTFND; - - return drive; -} - /* Definition of functions for the handling of the Current Directory Structure. @@ -260,7 +244,7 @@ COUNT get_verify_drive(const char FAR * src) #define addChar(c) \ { \ - if (p - dest >= SFTMAX) PATH_ERROR; /* path too long */ \ + if (p >= dest + SFTMAX) PATH_ERROR; /* path too long */ \ *p++ = c; \ } @@ -321,6 +305,7 @@ COUNT truename(const char FAR * src, char * dest, COUNT mode) struct cds FAR *cdsEntry; char *p = dest; /* dynamic pointer into dest */ char *rootPos; + char src0; enum { DONT_ADD, ADD, ADD_UNLESS_LAST } addSep; tn_printf(("truename(%S)\n", src)); @@ -330,14 +315,37 @@ COUNT truename(const char FAR * src, char * dest, COUNT mode) /* In opposite of the TRUENAME shell command, an empty string is rejected by MS DOS 6 */ - if (src[0] == '\0') + src0 = src[0]; + if (src0 == '\0') return DE_FILENOTFND; - result = get_verify_drive(src); - if (result < SUCCESS) - return result; + if (src0 == '\\' && src[1] == '\\') { + const char FAR *unc_src = src; + /* Flag UNC paths and short circuit processing. Set current LDT */ + /* to sentinel (offset 0xFFFF) for redirector processing. */ + tn_printf(("Truename: UNC detected\n")); + do { + src0 = unc_src[0]; + addChar(src0); + unc_src++; + } while (src0); + current_ldt = (struct cds FAR *)MK_FP(0xFFFF,0xFFFF); + tn_printf(("Returning path: \"%s\"\n", dest)); + /* Flag as network - drive bits are empty but shouldn't get */ + /* referenced for network with empty current_ldt. */ + return IS_NETWORK; + } + + /* Do we have a drive? */ + if (src[1] == ':') + result = drLetterToNr(DosUpFChar(src0)); + else + result = default_drive; + + cdsEntry = get_cds(result); + if (cdsEntry == NULL) + return DE_PATHNOTFND; - cdsEntry = &CDSp[result]; tn_printf(("CDS entry: #%u @%p (%u) '%S'\n", result, cdsEntry, cdsEntry->cdsBackslashOffset, cdsEntry->cdsCurrentPath)); /* is the current_ldt thing necessary for compatibly?? diff --git a/kernel/proto.h b/kernel/proto.h index 791ffc1..5ff35bc 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -111,7 +111,7 @@ BOOL IsShareInstalled(void); COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock); sft FAR *idx_to_sft(int SftIndex); int get_sft_idx(UCOUNT hndl); -struct cds FAR *get_cds(int dsk); +struct cds FAR *get_cds(unsigned dsk); COUNT DosTruename(const char FAR * src, char FAR * dest); /*dosidle.asm */ @@ -340,7 +340,6 @@ VOID InitPSP(VOID); /* newstuff.c */ int SetJFTSize(UWORD nHandles); int DosMkTmp(BYTE FAR * pathname, UWORD attr); -COUNT get_verify_drive(const char FAR * src); COUNT truename(const char FAR * src, char * dest, COUNT t); /* network.c */ diff --git a/kernel/systime.c b/kernel/systime.c index d32e55a..d7d8394 100644 --- a/kernel/systime.c +++ b/kernel/systime.c @@ -92,6 +92,10 @@ void DosGetTime(struct dostime *dt) int DosSetTime(const struct dostime *dt) { + if (dt->hour > 23 || dt->minute > 59 || + dt->second > 59 || dt->hundredth > 99) + return DE_INVLDDATA; + /* for ClkRecord.clkDays */ ExecuteClockDriverRequest(C_INPUT);