Commit 3a65ba66 authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Rewrote Service_IdentifyDisc partly because it was an unreadable mess but...

Rewrote Service_IdentifyDisc partly because it was an unreadable mess but mainly so it can handle fixed discs too - this will be useful for DOS format USB mass storage.

Also it will have a go at interpreting the partition table on fixed discs.
Tweak to filetyping logic (again!).

Version 0.74. Tagged as 'DOSFS-0_74'
parent c8eadf60
......@@ -65,7 +65,7 @@ INCLUDES = -IC:
# DFLAGS should be NULL for any non-debugging release
DFLAGS = -dPCMCIA${PCMCIA}
#DFLAGS = -dPCMCIA${PCMCIA} -dTRACE -dTUBE=0
#DFLAGS = -dPCMCIA${PCMCIA} -dTRACE -dTUBE=1
#
# Program specific options:
......
/* (0.73)
/* (0.74)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.68.
*
*/
#define Module_MajorVersion_CMHG 0.73
#define Module_MajorVersion_CMHG 0.74
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 06 Mar 2003
#define Module_Date_CMHG 23 May 2003
#define Module_MajorVersion "0.73"
#define Module_Version 73
#define Module_MajorVersion "0.74"
#define Module_Version 74
#define Module_MinorVersion ""
#define Module_Date "06 Mar 2003"
#define Module_Date "23 May 2003"
#define Module_ApplicationDate "06-Mar-03"
#define Module_ApplicationDate "23-May-03"
#define Module_ComponentName "DOSFS"
#define Module_ComponentPath "RiscOS/Sources/FileSys/ImageFS/DOSFS"
#define Module_FullVersion "0.73"
#define Module_HelpVersion "0.73 (06 Mar 2003)"
#define Module_LibraryVersionInfo "0:73"
#define Module_FullVersion "0.74"
#define Module_HelpVersion "0.74 (23 May 2003)"
#define Module_LibraryVersionInfo "0:74"
This diff is collapsed.
......@@ -313,10 +313,12 @@ static void map_FILE_ROStype(DOS_direntry *dentry,word dosext,time5byte *le)
_kernel_swi_regs rset ;
int value = -1;
/* Try to determine whether this really is a ROS filetype or a win95 'creation date' */
if (((dentry->FILE_reserved[1] & 0xF0) == 0) && (dentry->FILE_reserved[4] == 0))
/* Try to determine whether this really is a ROS filetype */
if (((dentry->FILE_reserved[1] & 0xF0) == 0) || ((dentry->FILE_reserved[1] & 0xF0) == 0xF0))
{
value = get_FILE_ROStype(dentry);
/* DOSFS's capable of *SETTYPE &000 also set the top 4 bits */
if ((value == 0) && ((dentry->FILE_reserved[1] & 0xF0) != 0xF0)) value = -1;
tracef1("filetype lookup,found in spare bytes 0x%X3\n", value);
}
/* No filetype in the spare bytes,so have a look through DOSmap */
......@@ -806,8 +808,6 @@ static char *buildFILEname(DOS_direntry *dentry,char *name)
int index ;
int loop ;
/* assert(name != NULL); JRS 5/3/92 removed unnecessary conditional malloc here, name is malloced and tested by all callers */
/* "dentry" should contain a valid filename */
/* copy prefix characters (or upto a space) into the filename buffer */
for (index=0; ((cptr[index] > ' ') && (index < namsize)); index++)
......
......@@ -26,9 +26,7 @@
#include "h.DOSFSctl"
#include "h.debug"
#include "h.FSerrors"
#if 1 /* SMC_FIX_RO_5593 */
#include "h.MsgTrans"
#endif
#include "h.MsgTrans"
/*-------------------------------------------------------------------------*/
......@@ -36,52 +34,8 @@ _kernel_oserror *_syserr ; /* global error pointer */
/*---------------------------------------------------------------------------*/
#if 1 /* SMC_FIX_RO_5593 */
/* The following is used to construct MessageTrans tokens for errors. */
#define ERROR_FMT "ERR%2.2X"
#else
static errentry errlist[] = {
{0x00,NO, "Filing system operation not supported"},
{0x01,YES,"File \"%s\" not found"},
{0x02,YES,"Directory \"%s\" not found"},
{0x03,YES,"Object \"%s\" not a file"},
{0x04,YES,"File \"%s\" already open"},
{0x05,NO, "C heap exhausted"},
{0x06,NO, "Failed to load DOS FAT sectors"},
{0x07,YES,"\"%s\" contains wild cards"},
{0x08,YES,"Failed to save \"%s\""},
{0x09,NO, "Name translation failed"},
{0x0A,NO, "Image read failed"},
{0x0B,NO, "Image write failed"},
{0x0C,NO, "Cluster chain is not consistent"},
{0x0D,NO, "Feature not yet implemented"},
{0x0E,NO, "Disc full"},
{0x0F,NO, "Transfer request is not sector multiple"},
{0x10,NO, "DOS disc does NOT have 512byte sectors"},
{0x11,NO, "DOS image not formatted"},
{0x12,NO, "Winchester image does NOT contain a bootable partition"},
{0x13,NO, "Winchester bootable partition is NOT MSDOS"},
{0x14,NO, "Already exists"},
{0x15,NO, "Types don't match"},
{0x16,YES,"Failed to create directory \"%s\""},
{0x17,YES,"Directory \"%s\" not empty"},
{0x18,NO, "EOF"},
{0x19,NO, "Directory full"},
{0x1A,NO, "Failed to ensure file length"},
{0x1B,NO, "DOS BOOT block contains invalid information"},
{0x1C,NO, "Invalid MSDOS extension character given"},
{0x1D,NO, "MSDOS extension given longer than 3 characters"},
{0x1E,NO, "Image type not supported (invalid magic number)"},
{0x1F,NO, "MS-DOS discs do not have boot options"},
{0x20,NO, "Desired format cannot be supported"},
{0x21,YES,"Invalid name \"%s\" (cannot translate to MS-DOS name)"},
{0x22,NO ,"Invalid drive specifier"},
{0x22,NO ,"Unknown keyboard read error"},
{0x23,NO ,"CLUSTER in use"},
{0x00,NO, "<end of error message list>"},
} ; /* errlist[] */
#endif
_kernel_oserror _gerror = {0} ; /* static error structure */
_kernel_oserror *_syserr ; /* static pointer to the error structure */
......@@ -93,21 +47,15 @@ _kernel_oserror *_syserr ; /* static pointer to the error structure */
_kernel_oserror *global_error(int number)
{
/* return a pointer to the "_kernel_oserror" block for error "number" */
#if 1 /* SMC_FIX_RO_5593 */
char token[8];
_kernel_oserror *err;
char *buf = _gerror.errmess;
int bufsz = 252;
#endif
_gerror.errnum = ext_err(number) ;
#if 1 /* SMC_FIX_RO_5593 */
/* lookup Messages file for error text */
sprintf(token, ERROR_FMT, number);
if ((err = msgtrans_lookup(token, &buf, &bufsz, 0, 0, 0, 0)) != NULL)
return err;
#else
sprintf(&(_gerror.errmess[0]),errlist[number].errtext) ;
#endif
tracef2("DOSFS: global_error: &%08X \"%s\"\n",_gerror.errnum,_gerror.errmess);
return(_syserr) ;
}
......@@ -121,21 +69,15 @@ _kernel_oserror *global_error(int number)
_kernel_oserror *global_errorP(int number,char *par1)
{
/* return a pointer to the "_kernel_oserror" block for error "number" */
#if 1 /* SMC_FIX_RO_5593 */
char token[8];
_kernel_oserror *err;
char *buf = _gerror.errmess;
int bufsz = 252;
#endif
_gerror.errnum = ext_err(number) ;
#if 1 /* SMC_FIX_RO_5593 */
/* lookup Messages file for error text */
sprintf(token, ERROR_FMT, number);
if ((err = msgtrans_lookup(token, &buf, &bufsz, par1, 0, 0, 0)) != NULL)
return err;
#else
sprintf(&(_gerror.errmess[0]),errlist[number].errtext,par1) ;
#endif
tracef2("DOSFS: global_errorP: &%08X \"%s\"\n",_syserr->errnum,_syserr->errmess) ;
return(_syserr) ;
}
......@@ -161,13 +103,7 @@ int exported_error_number(int number)
void global_error1(int number,char *par1)
{
/* place error number and message into "_syserr" */
#if 1 /* SMC_FIX_RO_5593 */
global_errorP(number, par1);
#else
_gerror.errnum = ext_err(errlist[number].errnum) ;
sprintf(&(_gerror.errmess[0]),errlist[number].errtext,par1) ;
tracef2("DOSFS: global_error1: &%08X \"%s\"\n",_syserr->errnum,_syserr->errmess) ;
#endif
return ;
}
......
......@@ -285,7 +285,7 @@ void MSDOStoRISCOS(word MStime,word MSdate,time5byte *outtime)
}
/*---------------------------------------------------------------------------*/
#if 0
#if 0 /* not used at the moment */
char *MSDOStoSTRING(word MSDOStime,word MSDOSdate)
{
/* convert time/date to standard time string */
......
......@@ -22,12 +22,6 @@
/*-------------------------------------------------------------------------*/
#if 0 /* SMC_REDUCE_RMA */
extern DOS_bootsector default_dbsector ;
#endif
/*-------------------------------------------------------------------------*/
#endif /* __BOOTblock_h */
/*-------------------------------------------------------------------------*/
......
......@@ -50,7 +50,6 @@ extern FILEhand *FILE_list ;
/*-------------------------------------------------------------------------*/
/* DOS disc type descriptions */
#if 1 /* SMC_REDUCE_RMA */
typedef struct DOSdiscinfo {
/* format identifier */ char *idtext;
/* format table entry */ byte findex;
......@@ -61,22 +60,6 @@ typedef struct DOSdiscinfo {
/* secs/FAT */ byte secsFAT;
/* root directory size */ byte rootsize;
} DOSdiscinfo;
#else
typedef struct DOSdiscinfo {
/* shape identity byte */byte magic_ID ;
#if 1 /* SMC_FIX_RO_5593 */
/* Show in format menu? */byte in_menu;
#endif
/* format table entry */word findex ;
/* format identifier */char *idtext ;
/* brief disc description */char *description ;
#if 1 /* SMC_FIX_RO_5593 */
/* MsgTrans help token */char *help;
#endif
} DOSdiscinfo ;
extern DOSdiscinfo DOS_formats[] ;
#endif
/*-------------------------------------------------------------------------*/
......
......@@ -36,10 +36,7 @@
#define file_sep ('.') /* standard MSDOS file seperator */
#define dir_sep ('\\') /* standard MSDOS directory seperator */
#if 1 /* SMC_DIR_CACHE */
#define dir_sep_string "\\"
#endif
#define eco_dir_sep ('/') /* MSDOS extension identifier under RISC OS */
/* valid DOS filename characters (NOTE: lower case treated as upper) */
......@@ -109,16 +106,11 @@ typedef struct {
(((d)->FILE_reserved[1] & 0x0F) << 8) \
)
/* when putting the type,clear the Windows creation date field so we can */
/* more reliably spot filetype &000 on discs tinkered with by Win2k */
/* As a side effect Win98 seems to think the file was created in 1601! */
/* when putting the type,if zero set the top 4 bits to aid filetype deduction later */
#define put_FILE_ROStype(d,v) { \
(d)->FILE_reserved[0] = ((v >> 0) & 0xFF) ; \
(d)->FILE_reserved[1] = ((v >> 8) & 0x0F) ; \
(d)->FILE_reserved[2] = 0 ; \
(d)->FILE_reserved[3] = 0 ; \
(d)->FILE_reserved[4] = 0 ; \
(d)->FILE_reserved[5] = 0 ; \
if (v == 0) (d)->FILE_reserved[1] = 0xF0 ; \
}
#define erase_ROStype(d) { \
......@@ -187,6 +179,7 @@ typedef struct {
#define DOS_BOOT_sector (1) /* always sector 1 track 0 */
#define DOS_FAT_sector (2) /* always sector 2 track 0 */
#define DOS_PARTITION_sector (DOS_BOOT_sector) /* always sec 1 cyl 0 head 0 */
#define DOS_PARTITION_signature (0xAA55)
typedef struct {
byte BOOT_JMP[3] ; /* JMP (&EA &xxxx) or (&EB &xx &90) */
......@@ -213,6 +206,8 @@ typedef struct {
byte hidden ;
byte hiddenHI ;
byte code[480] ;
byte BOOT_signature ; /* identifier 0x55 */
byte BOOT_signatureHI ; /* identifier 0xAA */
} floppy ;
struct {
byte hidden ; /* number of hidden sectors */
......@@ -234,11 +229,11 @@ typedef struct {
byte resl[8] ; /* actually "FATnn ", where nn=12/16 */
byte code[384] ;
byte partitions[4*sizeof(partition_entry)] ;
byte BOOT_signature ; /* identifier 0x55 */
byte BOOT_signatureHI ; /* identifier 0xAA */
} wini ;
} BOOT_extra ;
byte BOOT_signature ; /* identifier 0x55 */
byte BOOT_signatureHI ; /* identifier 0xAA */
} DOS_bootsector ;
} BOOT_extra ;
} DOS_bootsector ;
/*---------------------------------------------------------------------------*/
......@@ -523,9 +518,7 @@ typedef struct FILEhand {
typedef struct DIRin {
DOSdisc *ihand ; /* image file handle */
#if 1 /* SMC_DIR_CACHE */
char *dir_name ; /* directory path name */
#endif
int dir_root ; /* directory is ROOT DIR */
word dir_sector ; /* SIN of DIR on disc */
word dir_size ; /* size of DIR in bytes */
......
......@@ -86,10 +86,6 @@ typedef struct format_spec {
/* reserved (NULL) */ word reserved8 ;
} format_spec ;
#if 0 /* SMC_REDUCE_RMA */
extern format_spec DOS_formatinfo[] ;
#endif
/*-------------------------------------------------------------------------*/
/* Supported formats description structure:
*
......
......@@ -53,7 +53,7 @@
#endif
#if TRACE || WRITE || TRACE_MEM || TRACE_SWIS
extern writef(char *,...);
extern int writef(char *,...);
#define WRITEF 1
#else
#define WRITEF 0
......@@ -115,7 +115,7 @@ void trace_off(void) ;
#define writef8(s,a,b,c,d,e,f,g,h) ;
#endif
#if TRACE_MEM
#if TRACE_MEM
extern void *_my_malloc(char *file, int line, int size);
extern void _my_free(void *addr);
extern void show_mem_trace(void);
......
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