Commit 186192a3 authored by Ben Avison's avatar Ben Avison
Browse files

Multiple fixes.

Detail:
  Too many to list here: see doc/RPSChanges.
Admin:
  Received from Rob Sprowson approx 2009-02-08. Builds, but not tested by ROOL.

Version 2.32. Tagged as 'LanManFS-2_32'
parent 3ba506cd
...@@ -14,4 +14,4 @@ ...@@ -14,4 +14,4 @@
| |
Dir <Obey$Dir> Dir <Obey$Dir>
wimpslot 4000k wimpslot 4000k
amu_machine rm.LanManFSD OPTIONS=-DCHECK_ARMBOOT_EXISTS SPRITES=RAM amu_machine rm.LanManFSD OPTIONS=-DCHECK_ARMBOOT_EXISTS ROMSPRITES=FALSE
/* (2.31) /* (2.32)
* *
* This file is automatically maintained by srccommit, do not edit manually. * This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1. * Last processed by srccommit version: 1.1.
* *
*/ */
#define Module_MajorVersion_CMHG 2.31 #define Module_MajorVersion_CMHG 2.32
#define Module_MinorVersion_CMHG #define Module_MinorVersion_CMHG
#define Module_Date_CMHG 15 Apr 2009 #define Module_Date_CMHG 15 Apr 2009
#define Module_MajorVersion "2.31" #define Module_MajorVersion "2.32"
#define Module_Version 231 #define Module_Version 232
#define Module_MinorVersion "" #define Module_MinorVersion ""
#define Module_Date "15 Apr 2009" #define Module_Date "15 Apr 2009"
...@@ -18,6 +18,6 @@ ...@@ -18,6 +18,6 @@
#define Module_ComponentName "LanManFS" #define Module_ComponentName "LanManFS"
#define Module_ComponentPath "RiscOS/Sources/Networking/Omni/Protocols/LanManFS" #define Module_ComponentPath "RiscOS/Sources/Networking/Omni/Protocols/LanManFS"
#define Module_FullVersion "2.31" #define Module_FullVersion "2.32"
#define Module_HelpVersion "2.31 (15 Apr 2009)" #define Module_HelpVersion "2.32 (15 Apr 2009)"
#define Module_LibraryVersionInfo "2:31" #define Module_LibraryVersionInfo "2:32"
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "xlate.h" #include "xlate.h"
#include "omni.h" #include "omni.h"
#include "LanMan.h" #include "LanMan.h"
#include "LMVars.h"
/* "Default" filetype logic ------------------------------------- */ /* "Default" filetype logic ------------------------------------- */
...@@ -54,14 +55,13 @@ struct ext_type ...@@ -54,14 +55,13 @@ struct ext_type
int type; int type;
}; };
static struct ext_type FTypes[] = static const struct ext_type FTypes[] =
{ {
{ "TXT", 0xFFF }, /* Text */ { "TXT", 0xFFF }, /* Text */
{ "C", 0xFFF }, { "C", 0xFFF },
{ "H", 0xFFF }, { "H", 0xFFF },
{ "ASM", 0xFFF }, { "ASM", 0xFFF },
{ "ARC", 0xDDC }, /* Spark */ { "JPG", 0xC85 }, /* JPEG */
{ "TIF", 0xFF0 }, /* TIFF File */
{ "PS", 0xFF5 }, /* Postscript */ { "PS", 0xFF5 }, /* Postscript */
{ NULL, 0 } { NULL, 0 }
}; };
...@@ -70,7 +70,7 @@ static struct ext_type FTypes[] = ...@@ -70,7 +70,7 @@ static struct ext_type FTypes[] =
static void GetDefaultType ( char *leafname, RISCOS_ATTRIBS *ra ) static void GetDefaultType ( char *leafname, RISCOS_ATTRIBS *ra )
{ {
struct ext_type *pET; const struct ext_type *pET;
int ftype; int ftype;
_kernel_swi_regs rset ; _kernel_swi_regs rset ;
...@@ -86,11 +86,12 @@ static void GetDefaultType ( char *leafname, RISCOS_ATTRIBS *ra ) ...@@ -86,11 +86,12 @@ static void GetDefaultType ( char *leafname, RISCOS_ATTRIBS *ra )
leafname = strchr(leafname, '.'); leafname = strchr(leafname, '.');
if ( leafname == NULL ) /* No extension */ if ( leafname == NULL ) /* No extension */
{ {
debug1("No suffix,assuming Text filetype for '%s'\n", leafname ); debug2("Assuming filetype %03x for '%s' due to no suffix\n", LM_Vars.default_type, leafname );
ra->loadaddr = Default_FileType << 8; ra->loadaddr = (ra->loadaddr & 0xFFF000FF) |
return; (LM_Vars.default_type << 8);
} return;
}
leafname++; /* Skip '.' */ leafname++; /* Skip '.' */
...@@ -99,11 +100,12 @@ static void GetDefaultType ( char *leafname, RISCOS_ATTRIBS *ra ) ...@@ -99,11 +100,12 @@ static void GetDefaultType ( char *leafname, RISCOS_ATTRIBS *ra )
rset.r[1] = (int)leafname; rset.r[1] = (int)leafname;
rset.r[2] = MMM_TYPE_RISCOS; rset.r[2] = MMM_TYPE_RISCOS;
if (_kernel_swi(MimeMap_Translate, &rset, &rset) == NULL) if (_kernel_swi(MimeMap_Translate, &rset, &rset) == NULL)
{ {
ra->loadaddr = rset.r[3] << 8; ra->loadaddr = (ra->loadaddr & 0xFFF000FF) |
debug2("Mimemap gave type %X for '%s'\n", rset.r[3], leafname ); (rset.r[3] << 8);
return; debug2("Mimemap gave type %X for '%s'\n", rset.r[3], leafname );
} return;
}
/* Look through the feable small table */ /* Look through the feable small table */
for ( pET = FTypes; pET->ext != NULL; pET++ ) for ( pET = FTypes; pET->ext != NULL; pET++ )
...@@ -111,7 +113,7 @@ static void GetDefaultType ( char *leafname, RISCOS_ATTRIBS *ra ) ...@@ -111,7 +113,7 @@ static void GetDefaultType ( char *leafname, RISCOS_ATTRIBS *ra )
if ( strcmp ( pET->ext, leafname ) == 0 ) if ( strcmp ( pET->ext, leafname ) == 0 )
{ {
ra->loadaddr = (ra->loadaddr & 0xFFF000FF) | ra->loadaddr = (ra->loadaddr & 0xFFF000FF) |
(pET->type << 8); (pET->type << 8);
return; return;
} }
} }
...@@ -365,7 +367,6 @@ err_t Attr_GetInfo ( char *filename, char *leafname, ...@@ -365,7 +367,6 @@ err_t Attr_GetInfo ( char *filename, char *leafname,
return Attr_GetInfoX2 ( filename, leafname, pRA ); return Attr_GetInfoX2 ( filename, leafname, pRA );
#endif #endif
if ( SetFileName(filename) != OK ) if ( SetFileName(filename) != OK )
return EBADNAME; return EBADNAME;
......
...@@ -39,53 +39,23 @@ ...@@ -39,53 +39,23 @@
#include "NameCache.h" #include "NameCache.h"
/* Some globals ================================== */
#define NAMEBUF_LEN (2*DOS_NAME_LEN) #define NAMEBUF_LEN (2*DOS_NAME_LEN)
#define name_R(x) ((char *)R[x])
static char DOSnamebuf[NAMEBUF_LEN];
static char DOSnamebuf [NAMEBUF_LEN];
static err_t FileGetAttribs ( char *filename, DOS_ATTRIBS *pda, static err_t FileGetAttribs ( char *filename, DOS_ATTRIBS *pda,
RISCOS_ATTRIBS *pra ); RISCOS_ATTRIBS *pra );
#define name_R(x) ((char *)R[x]) /* Read-directory subroutines ======================================= */
/* Func subroutines=============================================== */
#define NAMES_ONLY 14
#define MOST_INFO 15
#define ALL_INFO 19
/* Read-directory subroutines --------- */
/* The directory entries can take one of three forms, taking up
a variable degree of space
NAMES_ONLY - 16 bytes (12 bytes of name, plus 0 terminator, plus
word rounding).
MOST_INFO - 36 bytes
ALL_INFO - 44 bytes
*/
static char RD_CurrentPath[DOS_NAME_LEN];
static int RD_Reason; static int RD_Reason;
static char *RD_BufPtr; static char *RD_BufPtr;
static int RD_BufLen; static int RD_BufLen;
static int RD_ReqCount; /* No. of entries required */ static int RD_ReqCount; /* No. of entries required */
static int RD_ReqOffset; /* Offset of currently required dir entry */ static int RD_CurCount; /* No. of entries given */
static int RD_CurOffset; /* Offset of next entry to be given to
Dir_CallbackFn */
/* ---------------- */
/* SNB: the blocks being written are those required by: /* Write one directory entry to the supplied buffer
* NAMES_ONLY => OS_GBPB 9 => (FSEntry_Func 14) * The directory entries can take one of three forms, taking up
* MOST_INFO => OS_GBPB 10 => (FSEntry_Func 15) * a variable degree of space
* ALL_INFO => OS_GBPB 11 => (FSEntry_Func 19)
*/ */
static char *WriteEntry ( int reason, char *ptr, BYTE *entry, int format ) static char *WriteEntry ( int reason, char *ptr, BYTE *entry, int format )
{ {
...@@ -97,7 +67,7 @@ static char *WriteEntry ( int reason, char *ptr, BYTE *entry, int format ) ...@@ -97,7 +67,7 @@ static char *WriteEntry ( int reason, char *ptr, BYTE *entry, int format )
int *IntPtr; int *IntPtr;
#ifndef LONGNAMES #ifndef LONGNAMES
(void) format; (void) format;
#else #else
if (format == 1) { if (format == 1) {
Xlt_ExpandSearchEntryX2(entry, DOSnamebuf, namebuf, &da, &ra); Xlt_ExpandSearchEntryX2(entry, DOSnamebuf, namebuf, &da, &ra);
...@@ -107,17 +77,18 @@ static char *WriteEntry ( int reason, char *ptr, BYTE *entry, int format ) ...@@ -107,17 +77,18 @@ static char *WriteEntry ( int reason, char *ptr, BYTE *entry, int format )
Xlt_ExpandSearchEntry(entry, DOSnamebuf, namebuf, &da, &ra); Xlt_ExpandSearchEntry(entry, DOSnamebuf, namebuf, &da, &ra);
name_len = strlen(namebuf) + 1; name_len = strlen(namebuf) + 1;
debug1("WriteEntry (%s)\n", namebuf);
switch ( reason ) switch ( reason )
{ {
case NAMES_ONLY: case FSEntry_Func_Reason_ReadDirectoryEntries:
rec_len = name_len; rec_len = name_len;
if (rec_len <= RD_BufLen) { if (rec_len <= RD_BufLen) {
memcpy(ptr, namebuf, name_len); memcpy(ptr, namebuf, name_len);
} }
break; break;
case MOST_INFO: case FSEntry_Func_Reason_ReadDirectoriesAndInformation:
rec_len = (20+name_len+3) & ~3; /* Round up to whole word */ rec_len = (20+name_len+3) & ~3; /* Round up to whole word */
if (rec_len <= RD_BufLen) { if (rec_len <= RD_BufLen) {
IntPtr = (int *)ptr; IntPtr = (int *)ptr;
...@@ -130,7 +101,7 @@ static char *WriteEntry ( int reason, char *ptr, BYTE *entry, int format ) ...@@ -130,7 +101,7 @@ static char *WriteEntry ( int reason, char *ptr, BYTE *entry, int format )
} }
break; break;
case ALL_INFO: case FSEntry_Func_Reason_ReadDirectoryEntriesAndInformation:
rec_len = (29+name_len)+3 & ~3; /* Round up to whole word */ rec_len = (29+name_len)+3 & ~3; /* Round up to whole word */
if (rec_len <= RD_BufLen) { if (rec_len <= RD_BufLen) {
IntPtr = (int *)ptr; IntPtr = (int *)ptr;
...@@ -151,10 +122,10 @@ static char *WriteEntry ( int reason, char *ptr, BYTE *entry, int format ) ...@@ -151,10 +122,10 @@ static char *WriteEntry ( int reason, char *ptr, BYTE *entry, int format )
} }
if (rec_len > RD_BufLen) { if (rec_len > RD_BufLen) {
debug2("WriteEntry detects a buffer overflow (%d > %d)\n", debug2("WriteEntry detects a buffer overflow (%d > %d)\n",
rec_len, RD_BufLen); rec_len, RD_BufLen);
RD_BufLen = -1; RD_BufLen = -1;
return NULL; return NULL;
} }
RD_BufLen -= rec_len; RD_BufLen -= rec_len;
...@@ -163,7 +134,7 @@ static char *WriteEntry ( int reason, char *ptr, BYTE *entry, int format ) ...@@ -163,7 +134,7 @@ static char *WriteEntry ( int reason, char *ptr, BYTE *entry, int format )
/* ------------------------------ */ /* ------------------------------ */
static err_t Dir_CallbackFn ( BYTE *entry, int format, void *pw ) static err_t Dir_CallbackFn ( BYTE *entry, int format, bool *taken, void *pw )
{ {
(void) pw; (void) pw;
#ifdef LONGNAMES #ifdef LONGNAMES
...@@ -187,48 +158,49 @@ static err_t Dir_CallbackFn ( BYTE *entry, int format, void *pw ) ...@@ -187,48 +158,49 @@ static err_t Dir_CallbackFn ( BYTE *entry, int format, void *pw )
} }
} }
// debug3 ("Entry: current %d req %d count %d\n", *taken = false;
// RD_CurOffset, RD_ReqOffset, RD_ReqCount ); if ( RD_ReqCount > 0 )
if ( RD_ReqOffset == RD_CurOffset )
{ {
if ( RD_ReqCount > 0 ) char *w_result = WriteEntry ( RD_Reason, RD_BufPtr, entry, format );
{ if (w_result != NULL) {
char *w_result = WriteEntry ( RD_Reason, RD_BufPtr, entry, format ); RD_BufPtr = w_result;
if (w_result != NULL) { RD_ReqCount--;
RD_BufPtr = w_result; RD_CurCount++;
RD_ReqCount--; *taken = true;
RD_ReqOffset++; }
} else {
else { debug0("Oh dear - client ran out of buffer space!\n");
debug0("Oh dear - client ran out of buffer space!\n"); return EOUTOFMEM;
RD_CurOffset++;
return EOUTOFMEM;
}
} }
} }
RD_CurOffset++;
return OK; return OK;
} }
/* ----------------- */ /* ----------------- */
/* Called in 2 situations
* - starting a search from scratch (dir_offset = 0)
* - continuing a search (dir_offset != 0)
* The underlying SMB routine must track whether it has been called
* recursively or from within Xlt_NameROtoDOSX2_sub and deal with
* abandoning searches appropriately.
*/
static err_t Func_ReadDir ( int reason, char *path_name, char *buffer, static err_t Func_ReadDir ( int reason, char *path_name, char *buffer,
int n_names, int dir_offset, int buflen, int *pOutNread, int n_names, int dir_offset, int buflen, int *pOutNread,
int *pOutNextOffset ) int *pOutNextOffset )
{ {
static Transact_SearchContext scon; static Transact_SearchContext con;
int tmp; int one_name;
err_t res; err_t res;
debug2 ( "\n\n>> ReadDir reason %d path %s", reason, path_name ); debug2 ( "\n\n>> ReadDir reason %d path %s", reason, path_name );
debug2 ( " offset %d count %d\n", dir_offset, n_names ); debug2 ( " offset %d count %d", dir_offset, n_names );
debug1 ( " buflen %d\n", buflen);
/* Make sure the number of names we read will fit into buffer ---- */ /* Make sure the number of names we read will fit into buffer */
one_name = (reason == FSEntry_Func_Reason_ReadDirectoryEntries) ? 16 :
tmp = (reason == NAMES_ONLY) ? 16 : (reason == FSEntry_Func_Reason_ReadDirectoriesAndInformation) ? 36 : 44;
(reason == MOST_INFO) ? 36 : 44;
#ifdef LONGNAMES #ifdef LONGNAMES
/* Of course, the above calculation assumes that the filename is at most /* Of course, the above calculation assumes that the filename is at most
...@@ -245,132 +217,119 @@ static err_t Func_ReadDir ( int reason, char *path_name, char *buffer, ...@@ -245,132 +217,119 @@ static err_t Func_ReadDir ( int reason, char *path_name, char *buffer,
* unnecessary buffer overruns - especially when there are not very * unnecessary buffer overruns - especially when there are not very
* many files with long names or even no files with long names. * many files with long names or even no files with long names.
*/ */
/* There is no code inside this #ifdef - it just marks my comment. */
#endif #endif
if ( n_names*tmp > buflen ) n_names = buflen/tmp; if ( (n_names * one_name) > buflen ) n_names = buflen/one_name;
if ( n_names <= 0 ) return EBADPARAM; if ( n_names <= 0 ) return EBADPARAM;
debug1( "Adjusted count=%d\n", n_names );
RD_Reason = reason; RD_Reason = reason;
RD_BufPtr = buffer; RD_BufPtr = buffer;
RD_BufLen = buflen; RD_BufLen = buflen;
RD_CurCount = 0;
RD_ReqCount = n_names; RD_ReqCount = n_names;
RD_ReqOffset = dir_offset;
debug1("Actual count=%d\n", n_names );
/* Convert path adding wildcard search spec */ /* Convert path adding wildcard search spec */
res = Xlt_ConvertPath( path_name, DOSnamebuf ); res = Xlt_ConvertPath( path_name, DOSnamebuf );
if ( res != OK ) return res; if ( res != OK ) return res;
if ( DOSnamebuf[strlen( DOSnamebuf ) - 1] != '\\' )
tmp = strlen(DOSnamebuf); strcat( DOSnamebuf, "\\");
#ifdef LONGNAMES #ifdef LONGNAMES
if ( DOSnamebuf[tmp-1] == '\\' ) strcat( DOSnamebuf, "*" );
strcpy( DOSnamebuf+tmp, "*" );
else
strcpy( DOSnamebuf+tmp, "\\*" );
#else #else
if ( DOSnamebuf[tmp-1] == '\\' ) strcat( DOSnamebuf, "????????.???" );
strcpy( DOSnamebuf+tmp, "????????.???" );
else
strcpy( DOSnamebuf+tmp, "\\????????.???" );
#endif #endif
/* Start a new search? ----------------------------------- */ /* Start a new search? */
if (dir_offset == 0)
if ( RD_ReqOffset == 0 || /* New start */
RD_ReqOffset < RD_CurOffset || /* Going back in search */
strcmp(DOSnamebuf, RD_CurrentPath) != 0 ) /* New directory */
{ {
debug1("\n>> Start search (%s)\n", DOSnamebuf); debug2( ">> Start search (%s) count %d\n", DOSnamebuf, RD_ReqCount);
strcpy ( RD_CurrentPath, DOSnamebuf); con.resume_key = 0;
RD_CurOffset = 0; res = SMB_ReadDirEntries ( DOSnamebuf, RD_ReqCount,
res = SMB_ReadDirEntries ( DOSnamebuf, RD_ReqCount+RD_ReqOffset, Dir_CallbackFn, NULL, &con );
Dir_CallbackFn, NULL, &scon );
} }
else else {
con.resume_key = dir_offset;
res = OK; res = OK;
}
/* Continue search, if needs be */ /* Continue search, if needs be */
while ( res == OK && /* More names available */ while ( res == OK && /* More names available */
RD_ReqCount > 0 ) /* More names wanted */ RD_ReqCount > 0 ) /* More names wanted */
{ {
debug0("\n>> Continue search\n"); debug3( ">> Continue search (%s) count %d resume %08x\n", DOSnamebuf, RD_ReqCount, con.resume_key);
res = SMB_ReadDirEntries ( NULL, RD_ReqCount+RD_ReqOffset-RD_CurOffset, res = SMB_ReadDirEntries ( DOSnamebuf, RD_ReqCount,
Dir_CallbackFn, NULL, &scon ); Dir_CallbackFn, NULL, &con );
} }
/* Process results */ /* Process results */
if (res == EOUTOFMEM && RD_BufLen == -1) { if (res == EOUTOFMEM && RD_BufLen == -1) {
/* Special result when client buffer space exhausted */ /* Special result when client buffer space exhausted */
debug0("Client buffer space was exhausted\n"); debug0("Client buffer space was exhausted\n");
res = OK; res = OK;
} }
debug2("End search, res=%d RD_ReqCount=%d\n", res, RD_ReqCount); debug2("End search, res=%d RD_ReqCount=%d\n", res, RD_ReqCount);
if ( res != OK ) /* Ran out of files, or error */ if ( res != OK ) { /* Ran out of files, or error */
{
RD_CurrentPath[0] = 0; /* Stop any repeat searches */
*pOutNextOffset = -1; *pOutNextOffset = -1;
} }
else else
{ *pOutNextOffset = con.resume_key;
if (RD_BufLen < 0) {
/* OK - was out of buffer space, force restart */
*pOutNextOffset = RD_ReqOffset;
//RD_CurOffset = 0;
//RD_CurrentPath[0] = 0;
}
else {
*pOutNextOffset = RD_ReqOffset;
}
}
*pOutNread = RD_ReqOffset-dir_offset;
*pOutNread = RD_CurCount;
if ( res == ENOMOREFILES ) if ( res == ENOMOREFILES )
return OK; return OK;
return res; return res;
} }
#if 0 /* Never called */
static err_t Func_ReadFreeSpace ( int sixtyfourbit, char *name, int *R ) static err_t Func_ReadFreeSpace ( int sixtyfourbit, char *name, int *R )
{ {
_kernel_swi_regs r; _kernel_swi_regs r;
_kernel_oserror *err; _kernel_oserror *err;
struct disk_size_response dsr;
if (sixtyfourbit)
r.r[0] = 2; {
r.r[2] = (int) &dsr; fspc_64 dsr[3];
r.r[3] = (int) name;
err = Omni_FreeOp_SWI(&r); r.r[0] = 4;
if (err != NULL) r.r[2] = (int) &dsr;
return ENOTPRESENT; r.r[3] = (int) name;
err = Omni_FreeOp_SWI(&r);
R[0] = dsr.freeblks; if (err != NULL)
if (sixtyfourbit) { return ENOTPRESENT;
R[1] = R[4] = 0;
R[0] = dsr[1].lo;
R[1] = dsr[1].hi;
R[2] = 0x7FFFFFFF; R[2] = 0x7FFFFFFF;
R[3] = dsr.totalblks; R[3] = dsr[0].lo;
R[4] = dsr[0].hi;
} }
else { else
{
struct disk_size_response dsr;
r.r[0] = 2;
r.r[2] = (int) &dsr;
r.r[3] = (int) name;
err = Omni_FreeOp_SWI(&r);
if (err != NULL)
return ENOTPRESENT;
R[0] = dsr.freeblks;
R[1] = 0x7FFFFFFF; R[1] = 0x7FFFFFFF;
R[2] = dsr.totalblks; R[2] = dsr.totalblks;
} }
return OK; return OK;
} }
#endif