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 @@
|
Dir <Obey$Dir>
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.
* 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_Date_CMHG 15 Apr 2009
#define Module_MajorVersion "2.31"
#define Module_Version 231
#define Module_MajorVersion "2.32"
#define Module_Version 232
#define Module_MinorVersion ""
#define Module_Date "15 Apr 2009"
......@@ -18,6 +18,6 @@
#define Module_ComponentName "LanManFS"
#define Module_ComponentPath "RiscOS/Sources/Networking/Omni/Protocols/LanManFS"
#define Module_FullVersion "2.31"
#define Module_HelpVersion "2.31 (15 Apr 2009)"
#define Module_LibraryVersionInfo "2:31"
#define Module_FullVersion "2.32"
#define Module_HelpVersion "2.32 (15 Apr 2009)"
#define Module_LibraryVersionInfo "2:32"
......@@ -40,6 +40,7 @@
#include "xlate.h"
#include "omni.h"
#include "LanMan.h"
#include "LMVars.h"
/* "Default" filetype logic ------------------------------------- */
......@@ -54,14 +55,13 @@ struct ext_type
int type;
};
static struct ext_type FTypes[] =
static const struct ext_type FTypes[] =
{
{ "TXT", 0xFFF }, /* Text */
{ "C", 0xFFF },
{ "H", 0xFFF },
{ "ASM", 0xFFF },
{ "ARC", 0xDDC }, /* Spark */
{ "TIF", 0xFF0 }, /* TIFF File */
{ "JPG", 0xC85 }, /* JPEG */
{ "PS", 0xFF5 }, /* Postscript */
{ NULL, 0 }
};
......@@ -70,7 +70,7 @@ static struct ext_type FTypes[] =
static void GetDefaultType ( char *leafname, RISCOS_ATTRIBS *ra )
{
struct ext_type *pET;
const struct ext_type *pET;
int ftype;
_kernel_swi_regs rset ;
......@@ -87,8 +87,9 @@ static void GetDefaultType ( char *leafname, RISCOS_ATTRIBS *ra )
leafname = strchr(leafname, '.');
if ( leafname == NULL ) /* No extension */
{
debug1("No suffix,assuming Text filetype for '%s'\n", leafname );
ra->loadaddr = Default_FileType << 8;
debug2("Assuming filetype %03x for '%s' due to no suffix\n", LM_Vars.default_type, leafname );
ra->loadaddr = (ra->loadaddr & 0xFFF000FF) |
(LM_Vars.default_type << 8);
return;
}
......@@ -100,7 +101,8 @@ static void GetDefaultType ( char *leafname, RISCOS_ATTRIBS *ra )
rset.r[2] = MMM_TYPE_RISCOS;
if (_kernel_swi(MimeMap_Translate, &rset, &rset) == NULL)
{
ra->loadaddr = rset.r[3] << 8;
ra->loadaddr = (ra->loadaddr & 0xFFF000FF) |
(rset.r[3] << 8);
debug2("Mimemap gave type %X for '%s'\n", rset.r[3], leafname );
return;
}
......@@ -365,7 +367,6 @@ err_t Attr_GetInfo ( char *filename, char *leafname,
return Attr_GetInfoX2 ( filename, leafname, pRA );
#endif
if ( SetFileName(filename) != OK )
return EBADNAME;
......
......@@ -39,53 +39,23 @@
#include "NameCache.h"
/* Some globals ================================== */
#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,
RISCOS_ATTRIBS *pra );
#define name_R(x) ((char *)R[x])
/* 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];
/* Read-directory subroutines ======================================= */
static int RD_Reason;
static char *RD_BufPtr;
static int RD_BufLen;
static int RD_ReqCount; /* No. of entries required */
static int RD_ReqOffset; /* Offset of currently required dir entry */
static int RD_CurOffset; /* Offset of next entry to be given to
Dir_CallbackFn */
static int RD_CurCount; /* No. of entries given */
/* ---------------- */
/* SNB: the blocks being written are those required by:
* NAMES_ONLY => OS_GBPB 9 => (FSEntry_Func 14)
* MOST_INFO => OS_GBPB 10 => (FSEntry_Func 15)
* ALL_INFO => OS_GBPB 11 => (FSEntry_Func 19)
/* Write one directory entry to the supplied buffer
* The directory entries can take one of three forms, taking up
* a variable degree of space
*/
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);
name_len = strlen(namebuf) + 1;
debug1("WriteEntry (%s)\n", namebuf);
switch ( reason )
{
case NAMES_ONLY:
case FSEntry_Func_Reason_ReadDirectoryEntries:
rec_len = name_len;
if (rec_len <= RD_BufLen) {
memcpy(ptr, namebuf, name_len);
}
break;
case MOST_INFO:
case FSEntry_Func_Reason_ReadDirectoriesAndInformation:
rec_len = (20+name_len+3) & ~3; /* Round up to whole word */
if (rec_len <= RD_BufLen) {
IntPtr = (int *)ptr;
......@@ -130,7 +101,7 @@ static char *WriteEntry ( int reason, char *ptr, BYTE *entry, int format )
}
break;
case ALL_INFO:
case FSEntry_Func_Reason_ReadDirectoryEntriesAndInformation:
rec_len = (29+name_len)+3 & ~3; /* Round up to whole word */
if (rec_len <= RD_BufLen) {
IntPtr = (int *)ptr;
......@@ -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;
#ifdef LONGNAMES
......@@ -187,48 +158,49 @@ static err_t Dir_CallbackFn ( BYTE *entry, int format, void *pw )
}
}
// debug3 ("Entry: current %d req %d count %d\n",
// RD_CurOffset, RD_ReqOffset, RD_ReqCount );
if ( RD_ReqOffset == RD_CurOffset )
{
*taken = false;
if ( RD_ReqCount > 0 )
{
char *w_result = WriteEntry ( RD_Reason, RD_BufPtr, entry, format );
if (w_result != NULL) {
RD_BufPtr = w_result;
RD_ReqCount--;
RD_ReqOffset++;
RD_CurCount++;
*taken = true;
}
else {
debug0("Oh dear - client ran out of buffer space!\n");
RD_CurOffset++;
return EOUTOFMEM;
}
}
}
RD_CurOffset++;
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,
int n_names, int dir_offset, int buflen, int *pOutNread,
int *pOutNextOffset )
{
static Transact_SearchContext scon;
int tmp;
static Transact_SearchContext con;
int one_name;
err_t res;
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 ---- */
tmp = (reason == NAMES_ONLY) ? 16 :
(reason == MOST_INFO) ? 36 : 44;
/* Make sure the number of names we read will fit into buffer */
one_name = (reason == FSEntry_Func_Reason_ReadDirectoryEntries) ? 16 :
(reason == FSEntry_Func_Reason_ReadDirectoriesAndInformation) ? 36 : 44;
#ifdef LONGNAMES
/* Of course, the above calculation assumes that the filename is at most
......@@ -245,104 +217,95 @@ static err_t Func_ReadDir ( int reason, char *path_name, char *buffer,
* unnecessary buffer overruns - especially when there are not very
* 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
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;
debug1( "Adjusted count=%d\n", n_names );
RD_Reason = reason;
RD_BufPtr = buffer;
RD_BufLen = buflen;
RD_CurCount = 0;
RD_ReqCount = n_names;
RD_ReqOffset = dir_offset;
debug1("Actual count=%d\n", n_names );
/* Convert path adding wildcard search spec */
res = Xlt_ConvertPath( path_name, DOSnamebuf );
if ( res != OK ) return res;
tmp = strlen(DOSnamebuf);
if ( DOSnamebuf[strlen( DOSnamebuf ) - 1] != '\\' )
strcat( DOSnamebuf, "\\");
#ifdef LONGNAMES
if ( DOSnamebuf[tmp-1] == '\\' )
strcpy( DOSnamebuf+tmp, "*" );
else
strcpy( DOSnamebuf+tmp, "\\*" );
strcat( DOSnamebuf, "*" );
#else
if ( DOSnamebuf[tmp-1] == '\\' )
strcpy( DOSnamebuf+tmp, "????????.???" );
else
strcpy( DOSnamebuf+tmp, "\\????????.???" );
strcat( DOSnamebuf, "????????.???" );
#endif
/* Start a new search? ----------------------------------- */
if ( RD_ReqOffset == 0 || /* New start */
RD_ReqOffset < RD_CurOffset || /* Going back in search */
strcmp(DOSnamebuf, RD_CurrentPath) != 0 ) /* New directory */
/* Start a new search? */
if (dir_offset == 0)
{
debug1("\n>> Start search (%s)\n", DOSnamebuf);
strcpy ( RD_CurrentPath, DOSnamebuf);
RD_CurOffset = 0;
res = SMB_ReadDirEntries ( DOSnamebuf, RD_ReqCount+RD_ReqOffset,
Dir_CallbackFn, NULL, &scon );
debug2( ">> Start search (%s) count %d\n", DOSnamebuf, RD_ReqCount);
con.resume_key = 0;
res = SMB_ReadDirEntries ( DOSnamebuf, RD_ReqCount,
Dir_CallbackFn, NULL, &con );
}
else
else {
con.resume_key = dir_offset;
res = OK;
}
/* Continue search, if needs be */
while ( res == OK && /* More names available */
RD_ReqCount > 0 ) /* More names wanted */
{
debug0("\n>> Continue search\n");
res = SMB_ReadDirEntries ( NULL, RD_ReqCount+RD_ReqOffset-RD_CurOffset,
Dir_CallbackFn, NULL, &scon );
debug3( ">> Continue search (%s) count %d resume %08x\n", DOSnamebuf, RD_ReqCount, con.resume_key);
res = SMB_ReadDirEntries ( DOSnamebuf, RD_ReqCount,
Dir_CallbackFn, NULL, &con );
}
/* Process results */
if (res == EOUTOFMEM && RD_BufLen == -1) {
/* Special result when client buffer space exhausted */
debug0("Client buffer space was exhausted\n");
res = OK;
}
debug2("End search, res=%d RD_ReqCount=%d\n", res, RD_ReqCount);
if ( res != OK ) /* Ran out of files, or error */
{
RD_CurrentPath[0] = 0; /* Stop any repeat searches */
if ( res != OK ) { /* Ran out of files, or error */
*pOutNextOffset = -1;
}
else
{
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;
*pOutNextOffset = con.resume_key;
*pOutNread = RD_CurCount;
if ( res == ENOMOREFILES )
return OK;
return res;
}
#if 0 /* Never called */
static err_t Func_ReadFreeSpace ( int sixtyfourbit, char *name, int *R )
{
_kernel_swi_regs r;
_kernel_oserror *err;
if (sixtyfourbit)
{
fspc_64 dsr[3];
r.r[0] = 4;
r.r[2] = (int) &dsr;
r.r[3] = (int) name;
err = Omni_FreeOp_SWI(&r);
if (err != NULL)
return ENOTPRESENT;
R[0] = dsr[1].lo;
R[1] = dsr[1].hi;
R[2] = 0x7FFFFFFF;
R[3] = dsr[0].lo;
R[4] = dsr[0].hi;
}
else
{
struct disk_size_response dsr;
r.r[0] = 2;
......@@ -353,24 +316,20 @@ static err_t Func_ReadFreeSpace ( int sixtyfourbit, char *name, int *R )
return ENOTPRESENT;
R[0] = dsr.freeblks;
if (sixtyfourbit) {
R[1] = R[4] = 0;
R[2] = 0x7FFFFFFF;
R[3] = dsr.totalblks;
}
else {
R[1] = 0x7FFFFFFF;
R[2] = dsr.totalblks;
}
return OK;
}
#endif
/* Func ============================================================= */
_kernel_oserror *fsentry_func ( int *R )
{
err_t err;
bool flushnames = false;
debug1("FS_func(%d)", R[0] );
......@@ -423,8 +382,10 @@ _kernel_oserror *fsentry_func ( int *R )
}
}
#endif
if ( err == OK )
if ( err == OK ) {
err = SMB_Rename ( DOSnamebuf, DOSnamebuf+DOS_NAME_LEN );
flushnames = true;
}
#ifdef LONGNAMES
if (SMB_IsLongNameFS(DOSnamebuf + DOS_NAME_LEN)) {
......@@ -476,11 +437,13 @@ _kernel_oserror *fsentry_func ( int *R )
case FSEntry_Func_Reason_BootFilingSystem:
LM_Boot();
err = OK;
flushnames = true;
break;
case FSEntry_Func_Reason_ShutDown:
/* On shutdown, disconnect all drives */
err = SMB_Shutdown();
flushnames = true;
break;
case FSEntry_Func_Reason_ReadDirectoryEntries:
......@@ -490,26 +453,13 @@ _kernel_oserror *fsentry_func ( int *R )
R[3], R[4], R[5], &R[3], &R[4] );
break;
case FSEntry_Func_Reason_ResolveWildcard:
/* Tell FileSwitch to do it itself */
R[4] = -1;
err = OK;
break;
case FSEntry_Func_Reason_ReadFreeSpace:
err = Func_ReadFreeSpace ( 0, name_R(1), R );
break;
case FSEntry_Func_Reason_ReadFreeSpace64:
err = Func_ReadFreeSpace ( 1, name_R(1), R );
break;
default:
err = EBADPARAM;
break;
}
#ifdef LONGNAMES
NameCache_Flush(ncf_FSFUNC_EXIT);
if (flushnames) NameCache_Flush(ncf_FSFUNC_EXIT);
#endif
return Xlt_Error(err);
......@@ -542,6 +492,7 @@ _kernel_oserror *fsentry_file( int *R )
int tmp;
DOS_ATTRIBS da;
RISCOS_ATTRIBS ra;
bool flushnames = false;
debug1("FS_file(%d)", R[0] );
......@@ -570,6 +521,7 @@ _kernel_oserror *fsentry_file( int *R )
ra.execaddr = R[3];
ra.flags = ROA_READ | ROA_WRITE;
Xlt_CnvROtoDOS(&ra, &da, CNV_DATETIME | CNV_ATTRIBS );
flushnames = true;
#ifdef LONGNAMES
strncpy(DOSnamebuf + DOS_NAME_LEN, DOSnamebuf, DOS_NAME_LEN);
if (Xlt_AddROType(DOSnamebuf, ra.loadaddr)) {
......@@ -637,6 +589,7 @@ _kernel_oserror *fsentry_file( int *R )
break;
}
flushnames = true;
if ( R[0] == FSEntry_File_Reason_WriteLoadAddress )
{
ra.loadaddr = R[2];
......@@ -675,6 +628,7 @@ _kernel_oserror *fsentry_file( int *R )
ra.loadaddr = R[2];
ra.execaddr = R[3];
ra.flags = R[5];
flushnames = true;
#ifdef LONGNAMES
{
......@@ -706,6 +660,7 @@ _kernel_oserror *fsentry_file( int *R )
R[3] = ra.execaddr;
R[4] = da.length;
R[5] = ra.flags;
flushnames = true;
if ( da.attr & ATTR_DIR )
{
......@@ -727,6 +682,7 @@ _kernel_oserror *fsentry_file( int *R )
case FSEntry_File_Reason_CreateDirectory:
Xlt_CnvRenameX2 ( DOSnamebuf, DOSnamebuf );
err = SMB_MkDir ( DOSnamebuf );
flushnames = true;
break;
/* Read information calls ---------------------------- */
......@@ -759,7 +715,7 @@ _kernel_oserror *fsentry_file( int *R )
}
#ifdef LONGNAMES
NameCache_Flush(ncf_FSFILE_EXIT);
if (flushnames) NameCache_Flush(ncf_FSFILE_EXIT);
#endif
return Xlt_Error(err);
......@@ -1058,6 +1014,7 @@ bool FS_Init(void)
for ( i=0; i<MAXFILES; i++ )
FileTbl[i].Free = true;
NextHandle = 0;
return true;
}
......@@ -43,7 +43,7 @@
#include "netbios.h"
#include "SMB.h"
#include "xlate.h"
#include "version.h"
#include "VersionNum"
#include "omni.h"
#include "printers.h"
#include "RPC.h"
......@@ -92,13 +92,6 @@ struct NETBIOS_TRANSPORT *NB_ActiveTransport; /* Selected net transport */
static pfnTransportInit NB_InitedTransport; /* Identify active transport */
static bool LM_Declared; /* True if we're registered as a filing system */
/* ------------------------------- */
char Default_FileTName[6];
int Default_FileType;
/* ------------------------------- */
#define CMOS_FSNUMBER 5
......@@ -340,21 +333,6 @@ static _kernel_oserror *Cmd_LanMan ( const char *args )
/* --------------------- */
#if 0
static char *(LM_local_num)(char *buf)
{
char *sep, *map, *space = buf;
if (_swix(Territory_ReadSymbols, _INR(0,1)|_OUT(0), -1, 1, &sep)) return buf;
if (_swix(Territory_ReadSymbols, _INR(0,1)|_OUT(0), -1, 2, &map)) return buf;
while (space && *sep) {
space = strchr(space, ' ');
if (space) *space = *sep;
}
return buf;
}
#endif
static _kernel_oserror *Cmd_Free ( const char *args )
{
_kernel_swi_regs r;
......@@ -376,18 +354,18 @@ static _kernel_oserror *Cmd_Free ( const char *args )
if (e == NULL) {
if (values[3] == 0 && values[5] == 0) {
printf("Bytes free &%08x\n", values[2] );
printf("Bytes free &%08X\n", values[2] );
if (values[4] != -1) {
printf("Bytes used &%08x\n", values[4] );
printf("Bytes used &%08X\n", values[4] );
}
else {
printf("Bytes used unavailable\n");
}
}
else {
printf("Bytes free &%08x%08x\n", values[3], values[2] );
printf("Bytes free &%08X%08X\n", values[3], values[2] );
if (values[4] != -1) {
printf("Bytes used &%08x%08x\n", values[5], values[4] );
printf("Bytes used &%08X%08X\n", values[5], values[4] );
}
else {
printf("Bytes used unavailable\n");
......@@ -484,6 +462,9 @@ static void SetDefaultVars ( void )
#endif
LM_Vars.initialised = LMInitState_Uninitialised;
LM_Vars.namemode = NM_FIRSTCAPS;
/* See where IP packets are going to be sent */
name = getenv("Inet$EtherType");
strcpyn ( LM_Vars.drivername,
(name==NULL) ? DEFAULT_ETHER_TYPE : name, NAME_LIMIT );
......@@ -500,10 +481,26 @@ static void SetDefaultVars ( void )
if ( name != NULL ) *name = 0;
}
/* Following 'get from CMOS' bits added 980127:RCE *
* to address user complain that it has to be typed in every time *
/* See if the user has overridden the default filetype */
name = getenv("LanMan$DefaultType");
if (name != NULL)
{
_swix(OS_FSControl, _INR(0,1)|_OUT(2), 31, name, &LM_Vars.default_type);
}
else
{
LM_Vars.default_type = CNV_DEFAULT_TYPE;
}