Commit ddfde4f4 authored by Robert Sprowson's avatar Robert Sprowson Committed by ROOL
Browse files

Preserve full load/exec for untyped files

Rather than turning any untyped file into ",lxa" suffix (and in the reverse direction giving the base address of the Kernel back), support ",llllllll-xxxxxxxx" style suffixes like RPCEmu does in order to preserve the full load and execution addresses.

Xlate.c: Extra code to parse the suffix, and simplification of existing suffix checkers.
CoreFn.c/Xlate.h: Need to pass on the exec address too for when creating new files via Xlt_AddROType.
Makefile/LanMan_MH: Case of CMHG file changed to match sources.

Version 2.68. Tagged as 'OmniLanManFS-2_68'
parent 1c0801eb
...@@ -19,14 +19,14 @@ COMPONENT = LanManFS ...@@ -19,14 +19,14 @@ COMPONENT = LanManFS
OBJS = Xlate Transact Stats SMB RPC Printers Omni NetBIOS NBIP \ OBJS = Xlate Transact Stats SMB RPC Printers Omni NetBIOS NBIP \
NameCache Logon LLC LanMan CoreFn buflib Attr \ NameCache Logon LLC LanMan CoreFn buflib Attr \
Interface Auth md5c md4c Interface Auth md5c md4c
CINCLUDES = -ITCPIPLibs:,C: CINCLUDES = ${TCPIPINC}
HDRS = HDRS =
CMHGFILE = Lanman_MH CMHGFILE = LanMan_MH
CMHGDEPENDS = LanMan LLC Logon NBIP Omni CMHGDEPENDS = LanMan LLC Logon NBIP Omni
LIBS = ${NET4LIBS} ${ASMUTILS} LIBS = ${NET4LIBS} ${ASMUTILS}
RES_PATH = ThirdParty.OmniClient RES_PATH = ThirdParty.OmniClient
CDEFINES = -DCOMPAT_INET4 -DLONGNAMES ${OPTIONS} CDEFINES = -DCOMPAT_INET4 -DLONGNAMES ${OPTIONS}
CFLAGS = -Wp CFLAGS = ${C_NOWARN_NON_ANSI_INCLUDES}
CDFLAGS = -DDEBUG -DDEBUGLIB -DTRACE -Dprintf=module_printf CDFLAGS = -DDEBUG -DDEBUGLIB -DTRACE -Dprintf=module_printf
ROMCDEFINES = -DROM ROMCDEFINES = -DROM
CMHGDEFINES = ${OPTIONS} CMHGDEFINES = ${OPTIONS}
......
/* (2.67) /* (2.68)
* *
* This file is automatically maintained by srccommit, do not edit manually. * This file is automatically maintained by srccommit, do not edit manually.
* *
*/ */
#define Module_MajorVersion_CMHG 2.67 #define Module_MajorVersion_CMHG 2.68
#define Module_MinorVersion_CMHG #define Module_MinorVersion_CMHG
#define Module_Date_CMHG 19 May 2021 #define Module_Date_CMHG 28 Aug 2021
#define Module_MajorVersion "2.67" #define Module_MajorVersion "2.68"
#define Module_Version 267 #define Module_Version 268
#define Module_MinorVersion "" #define Module_MinorVersion ""
#define Module_Date "19 May 2021" #define Module_Date "28 Aug 2021"
#define Module_ApplicationDate "19-May-21" #define Module_ApplicationDate "28-Aug-21"
#define Module_ComponentName "OmniLanManFS" #define Module_ComponentName "OmniLanManFS"
#define Module_FullVersion "2.67" #define Module_FullVersion "2.68"
#define Module_HelpVersion "2.67 (19 May 2021)" #define Module_HelpVersion "2.68 (28 Aug 2021)"
#define Module_LibraryVersionInfo "2:67" #define Module_LibraryVersionInfo "2:68"
...@@ -391,7 +391,7 @@ _kernel_oserror *fsentry_func ( int *R ) ...@@ -391,7 +391,7 @@ _kernel_oserror *fsentry_func ( int *R )
Xlt_RemoveROType ( DOSnamebuf + DOS_NAME_LEN ); Xlt_RemoveROType ( DOSnamebuf + DOS_NAME_LEN );
if ((da.attr & ATTR_DIR) == 0) if ((da.attr & ATTR_DIR) == 0)
{ {
Xlt_AddROType ( DOSnamebuf + DOS_NAME_LEN, ra.loadaddr ); Xlt_AddROType ( DOSnamebuf + DOS_NAME_LEN, ra.loadaddr, ra.execaddr );
} }
} }
} }
...@@ -540,7 +540,7 @@ _kernel_oserror *fsentry_file( int *R ) ...@@ -540,7 +540,7 @@ _kernel_oserror *fsentry_file( int *R )
Xlt_CnvROtoDOS(&ra, &da, CNV_DATETIME | CNV_ATTRIBS ); Xlt_CnvROtoDOS(&ra, &da, CNV_DATETIME | CNV_ATTRIBS );
#ifdef LONGNAMES #ifdef LONGNAMES
strncpy(DOSnamebuf + DOS_NAME_LEN, DOSnamebuf, DOS_NAME_LEN); strncpy(DOSnamebuf + DOS_NAME_LEN, DOSnamebuf, DOS_NAME_LEN);
if (Xlt_AddROType(DOSnamebuf, ra.loadaddr)) { if (Xlt_AddROType(DOSnamebuf, ra.loadaddr, ra.execaddr)) {
/* We changed the filetype - therefore delete old file */ /* We changed the filetype - therefore delete old file */
err = SMB_Delete(DOSnamebuf + DOS_NAME_LEN); err = SMB_Delete(DOSnamebuf + DOS_NAME_LEN);
if (err != OK && err != EFILENOTFOUND) { if (err != OK && err != EFILENOTFOUND) {
...@@ -615,7 +615,7 @@ _kernel_oserror *fsentry_file( int *R ) ...@@ -615,7 +615,7 @@ _kernel_oserror *fsentry_file( int *R )
; ;
else { else {
strncpy(DOSnamebuf + DOS_NAME_LEN, DOSnamebuf, DOS_NAME_LEN); strncpy(DOSnamebuf + DOS_NAME_LEN, DOSnamebuf, DOS_NAME_LEN);
if (Xlt_AddROType(DOSnamebuf + DOS_NAME_LEN, ra.loadaddr)) { if (Xlt_AddROType(DOSnamebuf + DOS_NAME_LEN, ra.loadaddr, ra.execaddr)) {
err = SMB_Rename(DOSnamebuf, DOSnamebuf + DOS_NAME_LEN); err = SMB_Rename(DOSnamebuf, DOSnamebuf + DOS_NAME_LEN);
if (err != OK) break; if (err != OK) break;
strcpy(DOSnamebuf, DOSnamebuf + DOS_NAME_LEN); strcpy(DOSnamebuf, DOSnamebuf + DOS_NAME_LEN);
...@@ -652,7 +652,7 @@ _kernel_oserror *fsentry_file( int *R ) ...@@ -652,7 +652,7 @@ _kernel_oserror *fsentry_file( int *R )
; ;
else { else {
strncpy(DOSnamebuf + DOS_NAME_LEN, DOSnamebuf, DOS_NAME_LEN); strncpy(DOSnamebuf + DOS_NAME_LEN, DOSnamebuf, DOS_NAME_LEN);
if (Xlt_AddROType(DOSnamebuf + DOS_NAME_LEN, ra.loadaddr)) { if (Xlt_AddROType(DOSnamebuf + DOS_NAME_LEN, ra.loadaddr, ra.execaddr)) {
err = SMB_Rename(DOSnamebuf, DOSnamebuf + DOS_NAME_LEN); err = SMB_Rename(DOSnamebuf, DOSnamebuf + DOS_NAME_LEN);
if (err != OK) break; if (err != OK) break;
strcpy(DOSnamebuf, DOSnamebuf + DOS_NAME_LEN); strcpy(DOSnamebuf, DOSnamebuf + DOS_NAME_LEN);
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#ifdef LONGNAMES #ifdef LONGNAMES
#define FileChar_TypedNamePrefix ',' #define FileChar_TypedNamePrefix ','
#define FileChar_UntypedNameSep '-'
#define FileString_DeadFile "xxx" #define FileString_DeadFile "xxx"
#define FileString_UntypedFile "lxa" #define FileString_UntypedFile "lxa"
...@@ -679,6 +680,45 @@ static void Xlt_NameDOStoROX2 ( char *dst, char *src, RISCOS_ATTRIBS *pRA ) ...@@ -679,6 +680,45 @@ static void Xlt_NameDOStoROX2 ( char *dst, char *src, RISCOS_ATTRIBS *pRA )
} }
} }
static bool Xlt_ValidLoadExec ( const char *suffix )
{
bool sep = false;
int lhs = 0, rhs = 0;
/* Quick exit if no separator */
if (strchr ( suffix, FileChar_UntypedNameSep ) == NULL)
return false;
/* Rules: each half must be comprised only of hex digits
* min 1 digit, max 8 digits
* no whitespace
* must be one separator in between
* Returns true if rules are met.
*/
while (*suffix)
{
if (isxdigit ( *suffix ))
{
if (sep) rhs++; else lhs++;
}
else
{
if (*suffix == FileChar_UntypedNameSep)
{
if (sep) return false; /* Already seen a separator */
if (lhs == 0) return false; /* Not seen any hex digits */
sep = true;
}
else
{
return false; /* Neither hex digit nor separator */
}
}
suffix++;
}
return (bool)(lhs > 0 && lhs <= 8 && rhs > 0 && rhs <= 8);
}
/* This function copies the string src to dst. Once it gets past the /* This function copies the string src to dst. Once it gets past the
* level'th character, it maps each character through the RISC OS->DOS * level'th character, it maps each character through the RISC OS->DOS
* character conversion table. * character conversion table.
...@@ -767,10 +807,12 @@ static err_t Xlt_NameXlateCallbackX2 ( BYTE *entry, int format, bool *taken, voi ...@@ -767,10 +807,12 @@ static err_t Xlt_NameXlateCallbackX2 ( BYTE *entry, int format, bool *taken, voi
res = EOUTOFMEM; res = EOUTOFMEM;
break; break;
} }
else if (e == ',' && d == 0) { #ifdef LONGNAMES
else if (e == FileChar_TypedNamePrefix && d == 0) {
/* Might have been a filetype suffix */ /* Might have been a filetype suffix */
int type, num; int type, num;
if ((sscanf(eptr, "%x%n", &type, &num) == 1 && num == 3) if ((sscanf(eptr, "%x%n", &type, &num) == 1 && num == 3)
|| Xlt_ValidLoadExec(eptr)
|| strcmp(eptr, FileString_DeadFile) == 0 || strcmp(eptr, FileString_DeadFile) == 0
|| strcmp(eptr, FileString_UntypedFile) == 0) { || strcmp(eptr, FileString_UntypedFile) == 0) {
/* It was */ /* It was */
...@@ -778,6 +820,7 @@ static err_t Xlt_NameXlateCallbackX2 ( BYTE *entry, int format, bool *taken, voi ...@@ -778,6 +820,7 @@ static err_t Xlt_NameXlateCallbackX2 ( BYTE *entry, int format, bool *taken, voi
break; break;
} }
} }
#endif
else { else {
if (!Xlt_ContentiousCharCheck(e, d)) { if (!Xlt_ContentiousCharCheck(e, d)) {
/* No match */ /* No match */
...@@ -1163,7 +1206,7 @@ err_t Xlt_SplitLeafnameX2 ( char *leafname, RISCOS_ATTRIBS *pRA, ...@@ -1163,7 +1206,7 @@ err_t Xlt_SplitLeafnameX2 ( char *leafname, RISCOS_ATTRIBS *pRA,
char **terminator) char **terminator)
{ {
int type, len; int type, len;
char *term, *oldname; char *term, *pre;
err_t res = ENOTPRESENT; err_t res = ENOTPRESENT;
_kernel_swi_regs rset; _kernel_swi_regs rset;
...@@ -1178,56 +1221,59 @@ err_t Xlt_SplitLeafnameX2 ( char *leafname, RISCOS_ATTRIBS *pRA, ...@@ -1178,56 +1221,59 @@ err_t Xlt_SplitLeafnameX2 ( char *leafname, RISCOS_ATTRIBS *pRA,
debug1("Xlt_SplitLeafnameX2('%s',...)\n", leafname); debug1("Xlt_SplitLeafnameX2('%s',...)\n", leafname);
term = strchr(leafname, '\0'); term = strchr(leafname, '\0');
oldname = leafname; pre = strrchr(leafname, FileChar_TypedNamePrefix);
if ((term - leafname) > 4) if (pre && (term - leafname) > 4)
{ {
/* Ah good,it's at least 5 letters long */ if ((term - pre) == 1+3) /* Try most common form first */
leafname = term - 4; {
if (leafname[0] == FileChar_TypedNamePrefix) /* At least 5 letters long and of the form ",ttt" */
{ if (stricmp(pre+1, FileString_UntypedFile) == 0)
/* At least 5 letters long and of the form ",ttt" */ {
if (stricmp(leafname+1, FileString_UntypedFile) == 0) debug0("File is untyped (,lxa)\n");
{ pRA->loadaddr = pRA->execaddr = LM_Vars.untyped_address;
debug0("File is untyped (,lxa)\n"); *terminator = pre;
pRA->loadaddr = pRA->execaddr = LM_Vars.untyped_address; return OK;
*terminator = leafname; }
res = OK; if (stricmp(pre+1, FileString_DeadFile) == 0)
} {
else debug0("File is DEADDEAD\n");
{ pRA->loadaddr = pRA->execaddr = deaddead;
if (stricmp(leafname+1, FileString_DeadFile) == 0) *terminator = pre;
{ return OK;
debug0("File is DEADDEAD\n"); }
pRA->loadaddr = pRA->execaddr = deaddead; if (sscanf(pre+1, "%x%n", &type, &len) == 1 && len == 3)
*terminator = leafname; {
res = OK; /* note. sscanf returns the number of conversions which were
} * successfully performed. the %n conversion never fails and
else * does not count towards the total number of conversions, but
{ * holds the number of characters consumed from the source
if (sscanf(leafname+1, "%x%n", &type, &len) == 1 && len == 3) * string. Therefore, provided that len was 3, then we have
{ * consumed three hex digits.
/* note. sscanf returns the number of conversions which were */
* successfully performed. the %n conversion never fails and pRA->loadaddr = ENCODE_FILETYPE(pRA->loadaddr, type);
* does not count towards the total number of conversions, but *terminator = pre;
* holds the number of characters consumed from the source debug3("Filetype is %#03x; load/exec=%#08x %#08x\n", type,
* string. Therefore, provided that len was 3, then we have pRA->loadaddr, pRA->execaddr);
* consumed three hex digits. return OK;
*/ }
pRA->loadaddr = ENCODE_FILETYPE(pRA->loadaddr, type); }
*terminator = leafname; if ((term - pre) >= 1+3 && Xlt_ValidLoadExec(pre + 1)) /* Less likely */
debug3("Filetype is %#03x; load/exec=%#08x %#08x\n", type, {
pRA->loadaddr, pRA->execaddr); uint load, exec;
res = OK; /* At least long enough for ",l-x" and not more than ",llllllll-xxxxxxxx" */
} if (sscanf(pre+1, "%x-%x", &load, &exec) == 2)
} {
} debug2("File is untyped load/exec=%#08x %#08x\n", load, exec);
} pRA->loadaddr = load; pRA->execaddr = exec;
} *terminator = pre;
return OK;
}
}
}
/* No ",ttt" or ",llll-xxxx" was found, try the mimemap for ".ext" */
if (res != OK) if (res != OK)
{ {
/* No ",ttt" was found,try the mimemap for ".ext" */
leafname = oldname;
/* This function can get called with "A:\dosname.txt" paths or "riscosname/txt" leafs */ /* This function can get called with "A:\dosname.txt" paths or "riscosname/txt" leafs */
if (leafname[1] == ':') if (leafname[1] == ':')
{ {
...@@ -1294,11 +1340,11 @@ err_t Xlt_RemoveROType ( char *name ) ...@@ -1294,11 +1340,11 @@ err_t Xlt_RemoveROType ( char *name )
/* Adds the type suffix for a RISC OS filename. The type is extracted /* Adds the type suffix for a RISC OS filename. The type is extracted
* from the passed load address, unless DOS name is sufficient * from the passed load address, unless DOS name is sufficient
*/ */
int Xlt_AddROType ( char *leafname, uint loadaddr ) int Xlt_AddROType ( char *leafname, uint loadaddr, uint execaddr )
{ {
RISCOS_ATTRIBS RA; RISCOS_ATTRIBS RA;
char *nterm, *term; char *nterm, *term;
char typebuf[8],ftypebuf[8]; char typebuf[20], ftypebuf[8];
int ftype; int ftype;
typebuf[0] = FileChar_TypedNamePrefix; typebuf[0] = FileChar_TypedNamePrefix;
...@@ -1306,7 +1352,7 @@ int Xlt_AddROType ( char *leafname, uint loadaddr ) ...@@ -1306,7 +1352,7 @@ int Xlt_AddROType ( char *leafname, uint loadaddr )
strcpy(typebuf+1, FileString_DeadFile); strcpy(typebuf+1, FileString_DeadFile);
} }
else if (!IS_FILETYPED(loadaddr)) { else if (!IS_FILETYPED(loadaddr)) {
strcpy(typebuf+1, FileString_UntypedFile); sprintf(typebuf+1, "%x-%x", loadaddr, execaddr);
} }
else { else {
const int type = GET_FILETYPE(loadaddr); const int type = GET_FILETYPE(loadaddr);
......
...@@ -86,8 +86,8 @@ extern err_t Xlt_SplitLeafnameX2 ( char *leafname, RISCOS_ATTRIBS *pRA, ...@@ -86,8 +86,8 @@ extern err_t Xlt_SplitLeafnameX2 ( char *leafname, RISCOS_ATTRIBS *pRA,
extern err_t Xlt_RemoveROType ( char *name ); extern err_t Xlt_RemoveROType ( char *name );
/* Alters the filename specified so that it co-incides with the /* Alters the filename specified so that it co-incides with the
* type encoded in the given "load addr" parameter, * type encoded in the given "load/exec addr" parameter,
* Returns 1 if it changed the filetype, 0 otherwise * Returns 1 if it changed the filetype, 0 otherwise
*/ */
extern int Xlt_AddROType ( char *leafname, uint loadaddr ); extern int Xlt_AddROType ( char *leafname, uint loadaddr, uint execaddr );
#endif #endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment