RTFSをver.44xからver.44zbへバージョンアップ

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/twl_wrapsdk/trunk@321 4ee2a332-4b2b-5046-8439-1ba90f034370
This commit is contained in:
shirait 2007-11-22 05:23:18 +00:00
parent 6751049144
commit a7449d85df
31 changed files with 2029 additions and 553 deletions

View File

@ -37,6 +37,8 @@
/*---------------------------------------------------------------------------*
extern変数
*---------------------------------------------------------------------------*/
extern void (*func_SDCARD_In)(void); /* カード挿入イベント用コールバック保存用 */
extern void (*func_SDCARD_Out)(void); /* カード排出イベント用コールバック保存用 */
extern int rtfs_first_stat_flag[26];
/*SDメモリカードのスペック構造体*/
@ -306,7 +308,7 @@ int nandRtfsCtrl( int driveno, int opcode, void* pargs)
case DEVCTL_WARMSTART: //attachのときしか呼ばれない
PRINTDEBUG( "DEVCTL_WARMSTART\n");
/*-- GoIdleセット --*/
sdmcGoIdle( NULL, NULL); //カード初期化シーケンス TODO:1ポートだけにする
sdmcGoIdle( func_SDCARD_In, func_SDCARD_Out); //カード初期化シーケンス TODO:1ポートだけにする
/*------------------*/
pdr->drive_flags |= (DRIVE_FLAGS_VALID | DRIVE_FLAGS_REMOVABLE | DRIVE_FLAGS_PARTITIONED);
pdr->drive_flags |= DRIVE_FLAGS_INSERTED;

View File

@ -1,5 +1,5 @@
/*---------------------------------------------------------------------------*
Project: CTR - SD driver
Project: TWL - SD driver
File: sdif_reg.h
Copyright 2006,2007 Nintendo. All rights reserved.

View File

@ -39,7 +39,7 @@ SRCS = apistat.c prfsapi.c rtlowl.c apickdsk.c apiwrite.c \
apifilio.c csjis.c rtdevio.c rtvfat.c apifilmv.c csjistab.c \
rtdrobj.c apifrmat.c csstrtab.c rtfat16.c apigetwd.c \
rtfat32.c apigfrst.c csunicod.c rtfatxx.c apiinfo.c \
portio.c apiinit.c portkern.c \
portio.c apiinit.c portkern.c apifastmv.c \
apimkdir.c apirealt.c \
prapipro.c apiregrs.c prblock.c apisetwd.c \
rtkernfn.c \

View File

@ -309,7 +309,12 @@ step_into_dir:
while (depth >= 0 && dir_index[depth] == -1)
{
if (!get_parent_path(from_path_buffer, from_path_buffer))
{
if(depth == 0) /* If we are at the root and have no more files, exit */
goto ex_it;
else
break;
}
pc_mpath(from_pattern_buffer, from_path_buffer, (byte *)ALL_FILES);
depth--;
}
@ -497,4 +502,3 @@ deltree(byte *path)
#endif
#endif /* (!INCLUDE_CS_UNICODE) BUGBUG - Not doing ENUM yet */

File diff suppressed because it is too large Load Diff

View File

@ -776,27 +776,36 @@ BOOLEAN _po_ulseek(PC_FILE *pfile, dword offset, dword *new_offset, int origin)
else if (origin == PSEEK_CUR_NEG) /* offset from current file pointer */
{
file_pointer = pfile->fptr;
if (file_pointer > offset)
if (file_pointer >= offset)
file_pointer -= offset;
else
file_pointer = 0;
{ /* Seek before beginning of file is an error */
p_errno = PEINVALIDPARMS;
goto errex;
}
}
else if (origin == PSEEK_END) /* offset from end of file */
{
file_pointer = pfile->pobj->finode->fsize;
if (file_pointer > offset)
if (file_pointer >= offset)
file_pointer -= offset;
else
file_pointer = 0;
{ /* Seek before beginning of file is an error */
p_errno = PEINVALIDPARMS;
goto errex;
}
}
else /* Illegal origin */
{
p_errno = PEINVALIDPARMS;
goto errex;
}
if (file_pointer >= pfile->pobj->finode->fsize)
if (file_pointer > pfile->pobj->finode->fsize)
{ /* Seek past end of file is an error */
p_errno = PEINVALIDPARMS;
goto errex;
}
if (file_pointer == pfile->pobj->finode->fsize)
{
file_pointer = pfile->pobj->finode->fsize;
@ -942,29 +951,44 @@ long _po_lseek(PC_FILE *pfile, long offset, int origin) /*__fn__*/
{
long ret_val;
int u_origin;
dword new_offset/*, u_offset*/;
dword new_offset, u_offset;
/*u_offset = offset;*/
u_offset = (dword) offset;
u_origin = origin;
if (origin == PSEEK_CUR) /* offset from current file pointer */
if (origin == PSEEK_SET) /* offset from beginning of file */
{
if (offset < 0)
{
/* Negative seek from beginning is an error */
rtfs_set_errno(PEINVALIDPARMS);
return(-1L);
}
}
else if (origin == PSEEK_CUR) /* offset from current file pointer */
{
if (offset < 0)
{
offset = -offset;
/*u_offset = (dword) offset;*/
u_offset = (dword) offset;
u_origin = PSEEK_CUR_NEG;
}
}
else if (origin == PSEEK_END) /* offset from end of file */
{
if (offset < 0)
if (offset <= 0)
{
offset = -offset;
/*u_offset = (dword) offset;*/
u_offset = (dword) offset;
}
else
{
/* Positve seek from end is an error */
rtfs_set_errno(PEINVALIDPARMS);
return(-1L);
}
}
if (!_po_ulseek(pfile, offset, &new_offset, u_origin))
if (!_po_ulseek(pfile, u_offset, &new_offset, u_origin))
ret_val = -1L;
else
ret_val = (long) new_offset;

View File

@ -137,7 +137,10 @@ BOOLEAN pc_mv(byte *old_name, byte *new_name) /*__apifn__*/
/* Find the parent and make sure it is a directory */
new_parent_obj = pc_fndnode(path);
if (!new_parent_obj || !pc_isadir(new_parent_obj) || pc_isavol(new_parent_obj))
{
p_errno = PEINVALIDPATH;
goto errex;
}
/* The cluster value old */

View File

@ -541,7 +541,7 @@ int nibs_per_entry,partition_status;
if (pgeometry->fmt_parms_valid)
{
if( ((pgeometry->fmt.numcyl * pgeometry->fmt.numhead * pgeometry->fmt.secptrk) / pgeometry->fmt.secpalloc) > 0xFFFF) {
return(pc_mkfs32(driveno, &pgeometry->fmt, TRUE)); /* TRUE == RAW IO */ //ctr modified
return(pc_mkfs32(driveno, &pgeometry->fmt, TRUE)); /* TRUE == RAW IO */
}else{
return(pc_mkfs16(driveno, &pgeometry->fmt, TRUE)); /* TRUE == RAW IO */
}
@ -611,15 +611,10 @@ int nibs_per_entry,partition_status;
fmt.secreserved = (word) 32;
if (pdr->drive_flags & DRIVE_FLAGS_PARTITIONED)
{
if (pgeometry->dev_geometry_lbas)
/* 10-24-2000 - New code to support lba formatting */
fmt.numhide = (unsigned long) 0; /*PS Does not work as fmt.secptrk here */
else
/* 10-24-2000 - This was the original code */
fmt.numhide = (unsigned long) fmt.secptrk;
fmt.numhide = pdr->partition_base;
}
else
fmt.numhide = (unsigned long) pgeometry->fmt.numhide; //ctr modified
fmt.numhide = (unsigned long) 0;
fmt.secpfat = (word) 0;
fmt.numroot = (word) 0;
fmt.mediadesc = (byte) 0xF8;
@ -627,8 +622,11 @@ int nibs_per_entry,partition_status;
}
else
{
if (pdr->drive_flags & DRIVE_FLAGS_PARTITIONED)
fmt.numhide = pdr->partition_base;
else
fmt.numhide = 0;
fmt.secreserved = (word) 1;
fmt.numhide = pgeometry->fmt.numhide; //ctr modified
fmt.secpfat = (word) secpfat;
fmt.numroot = (word) root_entries;
fmt.mediadesc = (byte) 0xF8;
@ -780,4 +778,3 @@ void get_format_parameters(dword nblocks, int *psectors_per_alloc, int *pnum_roo
*pnum_root_entries = num_root_entries;
}

View File

@ -19,6 +19,7 @@
#include <rtfs.h>
/***************************************************************************
PC_GFIRST - Get first entry in a directory to match a pattern.
@ -47,6 +48,7 @@
****************************************************************************/
void pc_upstat(DSTAT *statobj);
BOOLEAN pc_gfirst(DSTAT *statobj, byte *name) /*__apifn__*/
@ -59,7 +61,6 @@ BOOLEAN pc_gfirst(DSTAT *statobj, byte *name) /*__apifn__*/
CHECK_MEM(BOOLEAN, 0) /* Make sure memory is initted */
rtfs_set_errno(0); /* po_gfirst: clear error status */
rtfs_memset((byte *) statobj,0,sizeof(*statobj));
/* statobj->pobj = 0; */
/* statobj->pmom = 0; */
@ -110,7 +111,9 @@ BOOLEAN pc_gfirst(DSTAT *statobj, byte *name) /*__apifn__*/
who expects the drobj to own a finode happy but will not leave the
finode open which locks out unlink et al */
pc_freei(((DROBJ *)(statobj->pobj))->finode); /* Release the current */
((DROBJ *)(statobj->pobj))->finode = pc_alloci();
/* 3-07-07 - Change: Remove additional call to pc_alloci(). Was not needed and caused a leak
on a hot swap event when a gfirst is outstanding */
((DROBJ *)(statobj->pobj))->finode = 0;
/* END 9-20-94 */
/* Remember the unique number associated with the drive
mount. If the drive is closed before we call gnext or
@ -176,7 +179,7 @@ BOOLEAN pc_gnext(DSTAT *statobj) /*__apifn__*/
return(FALSE);
pdrive = pc_drno2dr(statobj->driveno);
if (statobj->drive_opencounter != pdrive->drive_opencounter)
{
{ /* Card was removed and re-inserted since pc_gfirst() */
rtfs_set_errno(PEINVALIDPARMS); /* pc_gnext: statobj is not valid */
release_drive_mount(statobj->driveno);/* Release lock, unmount if aborted */
return(FALSE);
@ -196,7 +199,9 @@ BOOLEAN pc_gnext(DSTAT *statobj) /*__apifn__*/
who expects the drobj to own a finode happy but will not leave the
finode open which locks out unlink et al */
pc_freei(((DROBJ *)(statobj->pobj))->finode); /* Release the current */
((DROBJ *)(statobj->pobj))->finode = pc_alloci();
/* 3-07-07 - Change: Remove additional call to pc_alloci(). Was not needed and caused a leak
on a hot swap event when a gfirst is outstanding */
((DROBJ *)(statobj->pobj))->finode = 0;
/* END 9-20-94 */
release_drive_mount(statobj->driveno);/* Release lock, unmount if aborted */
return(TRUE);
@ -231,6 +236,7 @@ BOOLEAN pc_gnext(DSTAT *statobj) /*__apifn__*/
PEINVALIDPARMS - statobj argument is not valid
****************************************************************************/
void pc_gdone(DSTAT *statobj) /*__apifn__*/
{
DDRIVE *pdrive;
@ -247,12 +253,14 @@ void pc_gdone(DSTAT *statobj) /*__apifn__*/
return;
pdrive = pc_drno2dr(statobj->driveno);
if (statobj->drive_opencounter != pdrive->drive_opencounter)
{
{ /* Card was removed and re-inserted since pc_gfirst() */
release_drive_mount(statobj->driveno);/* Release lock, unmount if aborted */
return;
}
if (statobj->pobj)
{
pc_freeobj((DROBJ *)statobj->pobj);
}
if (statobj->pmom)
pc_freeobj((DROBJ *)statobj->pmom);
release_drive_mount(statobj->driveno);/* Release lock, unmount if aborted */
@ -303,5 +311,3 @@ void pc_upstat(DSTAT *statobj) /*__fn__*/
(byte *)statobj->fext);
}
}

View File

@ -466,6 +466,10 @@ DEV_GEOMETRY geometry;
if (!pc_format_media(drivename, &geometry))
return(-1);
/* Get media parms again in case the format operation changed the parameters */
if (!pc_get_media_parms(drivename, &geometry))
return(-1);
if (!pc_format_volume(drivename, &geometry))
return(-1);
return (0);

View File

@ -176,7 +176,14 @@ int po_write(PCFD fd, byte *in_buff, int count) /*__apifn__*/
n_clusters = FATOP(pdrive)->fatop_alloc_chain(pdrive, &(pfile->fptr_cluster), n_clusters, TRUE);
if (!n_clusters)
{ /* Allocchain will set errno to PENOSPC or an IO or internal error */
/* Handle PENOSPC as a short write - otherwise it is an error that returns -1*/
if (get_errno() == PENOSPC)
break;
else
{
ret_val = (int) -1;
goto return_locked;
}
}
/* Calculate the last cluster in this chain. */

View File

@ -299,7 +299,6 @@ int index;
}
/* ******************************************************************** */
/* THIS IS THE MAIN PROGRAM FOR THE TEST SHELL */
/* ******************************************************************** */
@ -457,13 +456,39 @@ int nprinted = 0;
}
/* EJECT D: */
BOOLEAN ide_eject_media(int driveno);
void eject_driveno(int driveno)
{
DDRIVE *pdr;
pdr = pc_drno_to_drive_struct(driveno);
if (pdr)
{
pdr->dev_table_perform_device_ioctl(driveno, DEVCTL_REPORT_REMOVE, (void *) 0);
}
}
void eject_drivename(byte *drivename)
{
int driveno;
driveno = pc_parse_raw_drive(drivename);
if (driveno != -1)
eject_driveno(driveno);
}
int doeject(int agc, byte **agv) /*__fn__*/
{
RTFS_ARGSUSED_INT(agc);
RTFS_ARGSUSED_PVOID((void *)agv);
RTFS_PRINT_STRING_1(USTRING_TSTSH_02,PRFLG_NL); /* "Not implemented. See ide ioctl... " */
if (agc == 1)
{
if (!pc_set_default_drive(*agv))
{
RTFS_PRINT_STRING_1(USTRING_TSTSH_03,PRFLG_NL); /* "Set Default Drive Failed" */
return(-1);
}
else
{
eject_drivename(*agv);
}
}
return(0);
}
@ -916,7 +941,6 @@ int pc_seedir(byte *path) /*__fn__*/
fcount++;
rtfs_print_format_dir(display_buffer, &statobj);
/* Get the next */
if (!pc_gnext(&statobj))
break;
@ -955,7 +979,6 @@ int docat(int agc, byte **agv) /*__fn__*/
PCFD fd;
int nread;
if (agc == 1)
{
if ((fd = po_open(*agv, (word)(PO_BINARY|PO_RDONLY|PO_BUFFERED),(word) (PS_IWRITE | PS_IREAD) ) ) < 0)

View File

@ -506,7 +506,7 @@ BOOLEAN validate_filename(byte * filename, byte * ext)
BOOLEAN pc_cs_malias(byte *alias, byte *input_file, int try) /*__fn__*/
{
int n,s;
byte filename[9],fileext[4];
byte filename[10],fileext[4];
byte *p_in, *p_in_ext, *p_temp, *p_temp_2;
int char_len, jis_ext_len;
@ -581,9 +581,11 @@ BOOLEAN pc_cs_malias(byte *alias, byte *input_file, int try) /*__fn__*/
if (p_in_ext && p_temp>=p_in_ext) /* hit extension ? */
break;
char_len = jis_char_length(p_temp);
/* break and use ' ' if 2 bite jis overflows 6 */
if(s==5&&char_len==2)
/* break and use ' ' if 2 bite jis overflows 8 character limit */
/* Bug fix 2-1-07 , was if(s==5&&char_len==2) */
if(s==7&&char_len==2)
{
filename[7] = ' '; /* shift-jis first bytes clear */
break;
}
else if(*p_temp!=' ' && *p_temp !='.')
@ -602,7 +604,9 @@ BOOLEAN pc_cs_malias(byte *alias, byte *input_file, int try) /*__fn__*/
}
}
}
filename[8]=0; /* null terminate filename[] */
/* Null terminate the file at length 8, the alias digits will be right justified in
file name and the result will be copied, stripping out spaces */
filename[8]=0;
pc_ascii_str2upper(filename,filename);
pc_ascii_str2upper(fileext,fileext);
@ -630,7 +634,9 @@ BOOLEAN pc_cs_malias(byte *alias, byte *input_file, int try) /*__fn__*/
char_len = jis_char_length(p_temp);
if (s == 7 && char_len == 2)
{
break;
}
if(*p_temp!=' ')
{
*p_temp_2++=*p_temp++;
@ -639,11 +645,9 @@ BOOLEAN pc_cs_malias(byte *alias, byte *input_file, int try) /*__fn__*/
s += char_len;
if (s == 8)
break;
}
else
p_temp++;
}
if(jis_ext_len != 0)
{
@ -907,4 +911,3 @@ int l;
}
#endif

View File

@ -636,7 +636,7 @@ KS_CONSTANT RTFS_STRING_TABLE string_table[] = {
{USTRING_TSTSHHELP_19,(byte *)L"DIR PATH" },
{USTRING_TSTSHHELP_20,(byte *)L"DSKSEL D:" },
{USTRING_TSTSHHELP_21,(byte *)L"ECHO: [args]" },
{USTRING_TSTSHHELP_22,(byte *)L"EJECT (ejects LS-120)" },
{USTRING_TSTSHHELP_22,(byte *)L"EJECT (Trigger Remove Event)" },
{USTRING_TSTSHHELP_23,(byte *)L"FILLFILE PATH PATTERN NTIMES" },
{USTRING_TSTSHHELP_24,(byte *)L"FORMAT (routine will prompt for arguments)" },
{USTRING_TSTSHHELP_25,(byte *)L"GETATTR FILE" },
@ -880,7 +880,7 @@ KS_CONSTANT RTFS_STRING_TABLE string_table[] = {
{USTRING_TSTSHHELP_19,(byte *)"DIR PATH" },
{USTRING_TSTSHHELP_20,(byte *)"DSKSEL D:" },
{USTRING_TSTSHHELP_21,(byte *)"ECHO: [args]" },
{USTRING_TSTSHHELP_22,(byte *)"EJECT (ejects LS-120)" },
{USTRING_TSTSHHELP_22,(byte *)"EJECT (Trigger Remove Event)" },
{USTRING_TSTSHHELP_23,(byte *)"FILLFILE PATH PATTERN NTIMES" },
{USTRING_TSTSHHELP_24,(byte *)"FORMAT (routine will prompt for arguments)" },
{USTRING_TSTSHHELP_25,(byte *)"GETATTR FILE" },
@ -988,4 +988,3 @@ byte *rtfs_strtab_user_string(int string_id)
{
return(rtfs_strtab_string(string_table, string_id));
}

View File

@ -10,19 +10,14 @@
#include <rtfs.h>
#include <rtfsconf.h>
#if (RTFS_DEBUG_PRINT_ON == 1)
#if (CTR_DEF_ENVIRONMENT_DSEMU == 1)
#define PRINTDEBUG osTPrintf
#else
#include <ctr/vlink.h>
#define PRINTDEBUG vlink_dos_printf
#endif
#else
#define PRINTDEBUG i_no_print
static void i_no_print( const char *fmt, ... );
static void i_no_print( const char *fmt, ... ){ return; }
#endif
#if (RTFS_DEBUG_PRINT_ON == 1)
// #define PRINTDEBUG OS_TPrintf
#else
// #define PRINTDEBUG( ...) ((void)0)
#endif
// #define PRINTDEBUG OS_TPrintf
#define PRINTDEBUG( ...) ((void)0)
/*---------------------------------------------------------------------------*
globalÏ<EFBFBD>
@ -191,6 +186,11 @@ static void file_get_CHS_params( u32 file_sector_num)
mbytes = (file_sector_num >> 11);
while( 1) {
// if( mbytes < 1) {
// file_heads = 1;
// file_secptrack = 8;
// break;
// }
if( mbytes <= 2) {
file_heads = 2;
file_secptrack = 16;

View File

@ -11,7 +11,7 @@
*
* Description:
* This file contains porting layer tuning constants for configuring RTFS.
* It is included by rtfsconf.h.
* It is included by pcconf.h.
*
****************************************************************************/
@ -25,17 +25,14 @@
#define KS_CONSTANT const /* See porting reference guide for explanation */
#define KS_FAR /* See porting reference guide for explanation */
/* Compile time constants to control device inclusion and includion of
porting layer subroutines */
/* Compile time constants to control device inclusion
See the reference guide for an explanation
*/
#define INCLUDE_SD 0
#define INCLUDE_IDE 0 /* - Include the IDE driver */
#define INCLUDE_PCMCIA 0 /* - Include the pcmcia driver */
#define INCLUDE_PCMCIA_SRAM 0 /* - Include the pcmcia static ram card driver */
#define INCLUDE_COMPACT_FLASH 0 /* - Support compact flash (requires IDE and PCMCIA) */
#define INCLUDE_CDROM 0 /* - Support ATAPI CD (requires IDE) */
#define INCLUDE_FLASH_FTL 0 /* - Include the linear flash driver */
#define INCLUDE_ROMDISK 0 /* - Include the rom disk driver */
#define INCLUDE_RAMDISK 0 /* - Include the rom disk driver */
@ -43,8 +40,8 @@
#define INCLUDE_SMARTMEDIA 0 /* - Include the smart media flash card driver */
#define INCLUDE_FLOPPY 0 /* - Include the floppy disk driver */
#define INCLUDE_HOSTDISK 0 /* - Include the host disk disk simulator */
#define INCLUDE_WINDEV 0 /* - Include windows direct device access */
#define INCLUDE_UDMA 0 /* - Include ultra dma support for the ide driver */
#define INCLUDE_82365_PCMCTRL 0 /* - Include the 82365 pcmcia controller driver */
#endif /* __PORTCONF__ */

View File

@ -433,6 +433,7 @@ character (\n or \r).
void rtfs_port_puts(byte *buffer)
{
PRINTDEBUG( "%s\n", buffer); //ctr modified
OS_TPrintf( "%s\n", buffer); //ctr modified
/* Use cputs or some other console output function. If you have no console
output function then leave it blank */
/* cputs(buffer); */

View File

@ -16,14 +16,15 @@ static void pc_release_blk(BLKBUFFCNTXT *pbuffcntxt, BLKBUFF *pinblk);
static BLKBUFF *pc_allocate_blk(DDRIVE *pdrive, BLKBUFFCNTXT *pbuffcntxt);
/* Debugging tools to be removed in he final product */
#define DEBUG_BLOCK_CODE 0
#define DEBUG_FAT_CODE 0
void debug_check_blocks(BLKBUFFCNTXT *pbuffcntxt, int numblocks, char *where);
void debug_check_blocks(BLKBUFFCNTXT *pbuffcntxt, int numblocks, char *where, dword line);
void debug_check_fat(FATBUFFCNTXT *pfatbuffcntxt, char *where);
void debug_break(char *where, char *message);
void debug_break(char *where, dword line, char *message);
#if (DEBUG_BLOCK_CODE)
#define DEBUG_CHECK_BLOCKS(X,Y,Z) debug_check_blocks(X,Y,X);
#define DEBUG_CHECK_BLOCKS(X,Y,Z) debug_check_blocks(X,Y,Z,0);
#else
#define DEBUG_CHECK_BLOCKS(X,Y,Z)
#endif
@ -88,9 +89,9 @@ void pc_release_buf(BLKBUFF *pblk)
DEBUG_CHECK_BLOCKS(pblk->pdrive->pbuffcntxt, pblk->pdrive->pbuffcntxt->num_blocks, "Release")
#if (DEBUG_BLOCK_CODE)
if (!pblk->pdrive->mount_valid)
debug_break("release buf", "Mount not valid");
debug_break("release buf", __LINE__, "Mount not valid");
if (pblk->block_state != DIRBLOCK_COMMITTED && pblk->block_state != DIRBLOCK_UNCOMMITTED)
debug_break("release buf", "releasing buffer not in use list");
debug_break("release buf", __LINE__,"releasing buffer not in use list");
#endif
if (pblk->block_state != DIRBLOCK_COMMITTED && pblk->block_state != DIRBLOCK_UNCOMMITTED)
@ -99,8 +100,7 @@ void pc_release_buf(BLKBUFF *pblk)
if (pblk->use_count)
{
pblk->use_count -= 1;
if (!pblk->use_count)
pblk->pdrive->pbuffcntxt->num_free += 1;
/* 03-07-07 Changed. No longer increment num_free if usecount goes to zero */
}
OS_RELEASE_FSCRITICAL()
}
@ -147,9 +147,9 @@ BLKBUFFCNTXT *pbuffcntxt;
pc_release_blk(pbuffcntxt, pblk);
#if (DEBUG_BLOCK_CODE)
if (pblk->pnext && pblk->pnext->pprev != pblk)
debug_break("discard buf", "Buffer and populated pool inconsistent");
debug_break("discard buf", __LINE__,"Buffer and populated pool inconsistent");
if (pblk->pprev && pblk->pprev->pnext != pblk)
debug_break("discard buf", "Buffer and populated pool inconsistent");
debug_break("discard buf", __LINE__,"Buffer and populated pool inconsistent");
#endif
/* Unlink it from the populated pool double check link integrity */
if (pblk->pnext && pblk->pnext->pprev == pblk)
@ -183,6 +183,8 @@ Description
*****************************************************************************/
BLKBUFF *pc_read_blk(DDRIVE *pdrive, dword blockno) /*__fn__*/
{
BLKBUFF *pblk;
@ -256,6 +258,8 @@ BLKBUFF *pc_scratch_blk(void) /*__fn__*/
BLKBUFF *pblk;
OS_CLAIM_FSCRITICAL()
pblk = pc_allocate_blk(0, &prtfs_cfg->buffcntxt);
if (pblk)
prtfs_cfg->buffcntxt.scratch_alloc_count += 1;
OS_RELEASE_FSCRITICAL()
return (pblk);
}
@ -270,6 +274,7 @@ void pc_free_scratch_blk(BLKBUFF *pblk)
pbuffcntxt->pfree_blocks = pblk;
pblk->block_state = DIRBLOCK_FREE;
pbuffcntxt->num_free += 1;
pbuffcntxt->scratch_alloc_count -= 1;
OS_RELEASE_FSCRITICAL()
}
@ -473,57 +478,77 @@ BLKBUFF *pblk;
/* Allocate a block or re-use an un-committed one */
static BLKBUFF *pc_allocate_blk(DDRIVE *pdrive, BLKBUFFCNTXT *pbuffcntxt)
{
BLKBUFF *pblk, *pblkscan;
int num_free;
BLKBUFF *pfreeblk,*puncommitedblk, *pfoundblk, *pblkscan;
int populated_but_uncommited;
/* Note: pdrive may be NULL, do not dereference the pointer */
pblk = 0;
pfreeblk = pfoundblk = puncommitedblk = 0;
populated_but_uncommited = 0;
/* Use blocks that are on the freelist first */
if (pbuffcntxt->pfree_blocks)
{
pblk = pbuffcntxt->pfree_blocks;
pbuffcntxt->pfree_blocks = pblk->pnext;
pfreeblk = pbuffcntxt->pfree_blocks;
pbuffcntxt->pfree_blocks = pfreeblk->pnext;
pbuffcntxt->num_free -= 1;
}
else if (pbuffcntxt->ppopulated_blocks)
/* Scan the populated list. Count the number of uncommited blocks to set low water marks
and, if we haven't already allocated a block from the free list, select a replacement block. */
if (pbuffcntxt->ppopulated_blocks)
{
/* Find the oldest UNCOMMITED block (deepest into the list) */
int loop_guard = 0;
/* Count UNCOMMITED blocks and find the oldest UNCOMMITED block in the list */
pblkscan = pbuffcntxt->ppopulated_blocks;
num_free = 0;
while (pblkscan)
{
if (pblkscan->block_state == DIRBLOCK_UNCOMMITTED && !pblkscan->use_count)
{
pblk = pblkscan;
num_free += 1;
puncommitedblk = pblkscan;
populated_but_uncommited += 1;
}
pblkscan = pblkscan->pnext;
}
pbuffcntxt->num_free = num_free;
if (pblk)
/* Guard against endless loop */
if (loop_guard++ > pbuffcntxt->num_blocks)
{
pc_release_blk(pbuffcntxt, pblk); /* Remove it from buffer pool */
rtfs_set_errno(PEINTERNAL); /* pc_allocate_blk: Internal error*/
return(0);
}
}
/* If we don't already have a free block we'll reuse the oldest uncommitted block so release it */
if (!pfreeblk && puncommitedblk)
{
pc_release_blk(pbuffcntxt, puncommitedblk); /* Remove it from buffer pool */
/* Unlink it from the populated pool */
if (pblk->pnext)
pblk->pnext->pprev = pblk->pprev;
if (pblk->pprev)
pblk->pprev->pnext = pblk->pnext;
if (pbuffcntxt->ppopulated_blocks == pblk)
pbuffcntxt->ppopulated_blocks = pblk->pnext;
if (puncommitedblk->pnext)
puncommitedblk->pnext->pprev = puncommitedblk->pprev;
if (puncommitedblk->pprev)
puncommitedblk->pprev->pnext = puncommitedblk->pnext;
if (pbuffcntxt->ppopulated_blocks == puncommitedblk)
pbuffcntxt->ppopulated_blocks = puncommitedblk->pnext;
}
}
if (pblk)
if (pfreeblk)
pfoundblk = pfreeblk;
else
pfoundblk = puncommitedblk;
if (pfoundblk)
{ /* Put in a known state */
pbuffcntxt->num_free -= 1;
if (pbuffcntxt->num_free < pbuffcntxt->low_water)
pbuffcntxt->low_water = pbuffcntxt->num_free;
pblk->use_count = 0;
pblk->block_state = DIRBLOCK_ALLOCATED;
pblk->pdrive = pdrive;
/* 03-07-2007 using a different method to calculate low water mark. Previous method
undercounted the worst case buffer allocation requirements */
if (pbuffcntxt->num_free + populated_but_uncommited < pbuffcntxt->low_water)
pbuffcntxt->low_water = pbuffcntxt->num_free + populated_but_uncommited;
pfoundblk->use_count = 0;
pfoundblk->block_state = DIRBLOCK_ALLOCATED;
pfoundblk->pdrive = pdrive;
}
else
{
pbuffcntxt->num_alloc_failures += 1;
rtfs_set_errno(PERESOURCEBLOCK); /* pc_allocate_blk out of resources */
}
return(pblk);
return(pfoundblk);
}
/* Tomo */
/* Traverse a cluster chain and make sure that all blocks in the cluster
@ -959,7 +984,7 @@ static void pc_commit_fat_blk(FATBUFFCNTXT *pfatbuffcntxt, FATBUFF *pblk)
{
#if (DEBUG_FAT_CODE)
if (pblk->fat_block_state != FATBLOCK_UNCOMMITTED)
debug_break("commit fat block", "Not un-committed");
debug_break("commit fat block", __LINE__,"Not un-committed");
#endif
/* Remove from the uncommitted list */
if (pblk->pnext)
@ -1048,8 +1073,11 @@ FATBUFF *pblk, *pprev, *psorted_list, *psort, *pblk_source_scan;
}
#if (DEBUG_BLOCK_CODE || DEBUG_FAT_CODE)
void debug_break(char *where, char *message)
void debug_break(char *where, dword line, char *message)
{
if (line)
printf("%s (%d): %s\n", where, line, message);
else
printf("%s: %s\n", where, message);
}
#endif
@ -1127,32 +1155,41 @@ int numblocks;
#endif /* DEBUG_FAT_CODE */
#if (DEBUG_BLOCK_CODE)
void debug_check_blocks(BLKBUFFCNTXT *pbuffcntxt, int numblocks, char *where)
void debug_check_blocks(BLKBUFFCNTXT *pbuffcntxt, int numblocks, char *where, dword line)
{
BLKBUFF *pblk;
BLKBUFF *pblk_prev;
int nb = 0;
int nfreelist = 0;
int npopulatedlist = 0;
int i;
pblk = pbuffcntxt->pfree_blocks;
while (pblk)
{
nb += 1;
if (nb > numblocks)
debug_break(where, "Bad freelist");
debug_break(where,line, "Bad freelist");
pblk = pblk->pnext;
}
nfreelist = nb;
pblk = pbuffcntxt->ppopulated_blocks;
if (pblk && pblk->pprev)
debug_break(where, "Bad populated root");
debug_break(where,line, "Bad populated root");
while (pblk)
{
npopulatedlist += 1;
nb += 1;
if (nb > numblocks)
debug_break(where, "Bad populated list");
debug_break(where, line, "Bad populated list");
pblk = pblk->pnext;
}
/* Add in outstanding scratch allocates */
nb += pbuffcntxt->scratch_alloc_count;
if (nb != numblocks)
debug_break(where, "Leak");
debug_break(where, line, "Leak");
if (pbuffcntxt->ppopulated_blocks)
{
@ -1161,7 +1198,7 @@ int i;
while (pblk)
{
if (pblk->pprev != pblk_prev)
debug_break(where, "Bad link in populated list");
debug_break(where, line, "Bad link in populated list");
pblk_prev = pblk;
pblk = pblk->pnext;
}
@ -1173,16 +1210,111 @@ int i;
while (pblk)
{
if (i != (int) (pblk->blockno&pbuffcntxt->hash_mask))
debug_break(where, "Block in wrong hash slot");
debug_break(where, line, "Block in wrong hash slot");
nb += 1;
if (nb > numblocks)
debug_break(where, "Loop in hash table");
debug_break(where, line, "Loop in hash table");
pblk = pblk->pnext2;
}
}
}
/* Diagnostic to display list list contents for FINODE and DROBJ pools.
display_free_lists(char *in_where)
Prints:
FINODES on FREE list, FINODES on in use list.
Drobj structures on freelist,
drob structure count marked free by scanning the drobj pool sequentially
BLKBUFF buffer free count, and low water count
BLKBUFF buffers counted on populated list
BLKBUFF buffers counted on free list
If populated count and free list don't add up the remainder will be scratch
buffers.
To Do: Add counters for scratch buffer allocation and frees.
Useful for validating that no leaks are occuring.
Requires printf
*/
void display_free_lists(char *in_where)
{
FINODE *pfi;
DROBJ *pobj;
struct blkbuff *pblk;
int j, i, objcount, finodecount,populated_block_count,free_list_count;
objcount = finodecount = i = populated_block_count = free_list_count = 0;
pfi = prtfs_cfg->mem_finode_freelist;
while (pfi)
{
i++;
pfi = pfi->pnext;
}
finodecount = 0;
pfi = prtfs_cfg->inoroot;
while (pfi)
{
finodecount++;
pfi = pfi->pnext;
}
printf("%-10.10s:INODES free:%4.4d in-use:%4.4d total:%4.4d \n", in_where, i,finodecount,prtfs_cfg->cfg_NFINODES);
i = 0;
pobj = prtfs_cfg->mem_drobj_freelist;
while (pobj)
{
i++;
pobj = (DROBJ *) pobj->pdrive;
}
pobj = prtfs_cfg->mem_drobj_pool;
objcount = 0;
for (j = 0; j < prtfs_cfg->cfg_NDROBJS; j++, pobj++)
{
if (!pobj->is_free)
objcount += 1;
}
printf("%-10.10s:DROBJS free:%4.4d in-use:%4.4d total:%4.4d \n", in_where, i,objcount, prtfs_cfg->cfg_NDROBJS);
pblk = prtfs_cfg->buffcntxt.ppopulated_blocks; /* uses pnext/pprev */
populated_block_count = 0;
while (pblk)
{
populated_block_count += 1;
pblk = pblk->pnext;
}
printf("%-10.10s:BLKBUFS free:%4.4d in-use:%4.4d low w:%4.4d scratch:%4.4d total:%4.4d \n",in_where,
prtfs_cfg->buffcntxt.num_free,
populated_block_count,
prtfs_cfg->buffcntxt.low_water,
prtfs_cfg->buffcntxt.scratch_alloc_count,
prtfs_cfg->buffcntxt.num_blocks);
pblk = prtfs_cfg->buffcntxt.pfree_blocks;
free_list_count = 0;
while (pblk)
{
free_list_count += 1;
pblk = pblk->pnext;
}
if (free_list_count != prtfs_cfg->buffcntxt.num_free)
{
printf("%-10.10s:Error num_freelist == %d but %d elements on the freelist\n",in_where, prtfs_cfg->buffcntxt.num_free, free_list_count);
}
}
/* May be called to detect buffer pool leaks */
void check_blocks(DDRIVE *pdrive, char *prompt, dword line)
{
debug_check_blocks(pdrive->pbuffcntxt, pdrive->pbuffcntxt->num_blocks, prompt, line);
}
#endif /* (DEBUG_BLOCK_CODE) */

View File

@ -899,6 +899,7 @@ struct fsblockmap *newpbm;
if (!pfscntxt->blockmap_freelist)
{
error = 0;
replacement_block = fs_block_map_scan(pfscntxt,blockno,&error);
if (error) /* fs_block_map_scan set errno */
return(0);

View File

@ -166,10 +166,11 @@ int fs_test(byte *path)
}
#if (DO_INDEX_TEST)
#define BIG_TEST_SIZE (4 * (CFG_NUM_INDEX_BUFFERS * 128))
/* #define BIG_TEST_SIZE (4 * (CFG_NUM_INDEX_BUFFERS * 128)) */
#define BIG_TEST_SIZE 4096
dword map_check[BIG_TEST_SIZE];
static BOOLEAN fs_test_map_cache(dword num_to_map);
static BOOLEAN _fs_test_map_cache(dword num_to_map, BOOLEAN random_fill);
static BOOLEAN _fs_test_map_cache(dword num_to_map, int fill_op);
static BOOLEAN fs_test_index_errors(void);
BOOLEAN fs_test_indexing_main(byte *path)
@ -179,6 +180,11 @@ struct fsblockmap *save_freelist;
fs_test_nvio_delete_fsfile(path);
if (!open_index_test(path, FS_MODE_AUTORECOVER, TEST_BLOCKMAPSIZE, 0))
return(FALSE);
if (test_fscontext.num_remap_blocks > BIG_TEST_SIZE)
{
FSDEBUG("INDEX TEST: BIG_TEST_SIZE too small to run index test. recompile")
return(FALSE);
}
/* Test mapping with all fitting in cache */
FSDEBUG("INDEX TEST: Test mapping with cache > # journaled blocks")
if (!fs_test_map_cache(test_fscontext.blockmap_size-1))
@ -1614,7 +1620,10 @@ return_error:
fs_test_rm_file(path, filename);
return(0);
}
if (pc_get_file_extents(fd, 1, &seginfo, FALSE) != 1)
/* if (pc_get_file_extents(fd, 1, &seginfo, FALSE) != 1)
Use raw block numbers since we are comparing with the partition base
*/
if (pc_get_file_extents(fd, 1, &seginfo, TRUE) != 1)
goto return_error;
po_close(fd);
return(seginfo.block);

View File

@ -1,6 +1,162 @@
=================================================================
Functional changes between version 4.4zb versus version 4.4za (March 16, 2007)
=================================================================
Bug fixes:
Fixed a finode structure memory leak that could occur if a removal event occured
under certain conditions. The bug has been present since 1994.
Fixed a bug that was under reporting block buffer freelist low water mark values.
The bug was only in the calculation of the low water mark and did not cause any
runtime errors.
Fixed a problem with FAT32 info block access routines that ran unnecessarily
slowly and could read beyond the end of a buffer.
Features enhancements:
Implemented a shell command to simulate a card removal
Added a new display_free_lists() diagnostic routine to print current usage
stats. This routine may be called to monitor buffer usage.
Changes by file:
apigfrst.c - Fixed a bug that caused a leak of one finode structure if a card removal
event occured with an outstanding call to pc_gfirst() without a completed call
pc_gdone().
prblock.c - Fixed a bug that was causing an error in the calculation that produced incorrect
block buffer freelist low water mark values. The bug was only in the calculation of
the low water mark and did not cause any runtime errors.
rtfs.h - Modified the blkbuffcntxt structure to maintain a count of outstanding scratch
buffer allocations. This is used to correctly calculate low water usage and
for diagnostics.
prblock.c - Modified block diagnostic routines that is enabled by compiling with DEBUG_BLOCK_CODE
enabled in prblock.c
.. Include line numbers in diagnostics
.. Added a new dignostic
display_free_lists(char *comment_string)
this routine prints usage stats about DROBJ, FINODE and BLKBUFF structures.
It can be called to display snapshot of resource usage and to detect leaks.
rtfat32.c - Modified code that accesses the on disk FAT32 info structure. The structure is now
accessed at byte offset 484 in the info block. Prvious code was wasting cycles and
scanning the info block for the info block signature.
appcmdsh.c - Reprogrammed the shell's EJECT command to send a media removal event to
the specified drive id's device handler. This will trigger a remove event
for removable media device drivers.
appcmdsh.c - Implemented a callable routine named eject_driveno() that software can call to simulate
simulate a card removal. Useful for measuring the affects of card removals at specific
times
apiinit.c - Configure the host disk device driver as removable so it can process EJECT commands
from the command shell.
=================================================================
Functional changes between version 4.4za versus version 4.4y (February 16, 2007)
=================================================================
Note Version 44z was an unpublished interim release.
Bug Fixes:
.. rtfatxx.c - Changed fatxx_clnext() detect chain termination if the cluster value
is greater than xff7, xfff7 or xffffff7 for fat12, 16 , 32 respectively.
The current code detected only xfff, xffff and xfffffff as terminators.
.. rtkernfn.c Fixed a bug in rtfs_get_system_user(). If NUMUSERS is greater than
one and we are reclaiming the default user (0), because not enough
user structures are avaliable, make sure the current working directory objects are
freed and the finode access counts are reduced
.. rtfat32.c Added defensive code to check for a valid start hint from the info block.
if it is out of range set it to the first cluster in the FAT. Eliminates a possible
error trap if start hint in the info block is incorrect.
.. rtfat32.c Modified the info block flush routine to update the infoblock start hint with the
previous start hint read from the info block. This forces the start hint to be 3 always on
volume that have been formatted and written to by RTFS only.
.. prfstest.c - Minor bug fixes
.. csjis.c Fixed bug in JIS version of pc_cs_malias(). Was causing an error if the 8th character in the
filename was a 2 byte character sequence.
.. Bug in pc_emumerate - Added test to eliminate possible endless loop
.. po_write - Fixed error processing on cluster allocation failure. The code was always returning
a short write status, the number of bytes written, when the cluster allocation failed. This was
assuming that the underlying code failed because it detected disk full, not because of some other
error. The change tests the value of errno and if it is not set to PENOSPC, it return -1.
apifilmv.c - Fixed an error that was in some cases leaving errno at zero and returning an error status.
Now this condition sets ERRNO to PEINVALIDPATH;
.. Changed how hidden sectors are handled by the format utilities. Previous support
for hidden sectors was incorrect. The new method is correct. Hidden sectors are
ignored completely except during the format procedure when the bpb hidden sector
fields are set to the starting block of the partition.
apifrmat.c pc_format_volume changed the logic to set set numhide in the format
control structure to be the starting block number of the current partition.
apifrmat.c Obscure change that allows device drivers to specify format parameters for
32 bit formats. Previously supported only fat16/fat12 because the feature
was intended for floppy disks, to match IBM PC formats.
rtfat16.c - Changed the way hidden sectors are used in format
rtfat32.c - Changed the way hidden sectors are used in format
rtlowl.c - Fixed bug that was only initializig the low 16 bits of the
pdr->numhide, information field. This field is not used by RTFS.
New features:
.. Added a new device driver to Rtfs. The windev device is only available for the
windows emulation environment. The windev driver accesses block devices directly on
a windows platform using raw block accesses.
portconf.h - Added INCLUDE_WINDEV conditional constant.
drwindev.c - Source code for the direct block access driver
apiinit.c - Added code to mount a windev device if INCLUDE_WINDEV is
enabled in portconf.h
.. Include a new special purpose fast file move function.
apifastmv.c - New file containing pc_fast_mv().
pc_fast_mv - Move a file to a filename in another subdirectoy when you know
the destination filename does not already exist in that directory.
(designed for moving multiple files from one subdirectory to another
subdirectory that is initially empty.)
=================================================================
Functional changes between version 4.4y versus version 4.4x (November 3, 2006)
=================================================================
apifilio.c
Fixed parameter passing in seek functions to fix changes in beginning of
file and end of file processing that was introduced with po_ulseek in version
44v.
apiint.c
winhdisk.c
Added minor changes to these files forcing routines to query the device drive
again for media parms after a low level format. This was done in order to
support device drivers that may change media parameters during a low level format.
Functional changes between version 4.4x versus version 4.4ws (August 25, 2006)
=================================================================
winhdisk,c - Removed some unreferenced performance diagnostic code that was
winhdisk.c - Removed some unreferenced performance diagnostic code that was
inadverdantly placed in the file.
appcmdsh.c - Modified optional macro DISPLAY_ERRNO() to use RTFS print
routines instead of printf.

View File

@ -1205,6 +1205,7 @@ Returns
Nothing
****************************************************************************/
void pc_free_all_i( DDRIVE *pdrive) /*__fn__*/
{
FINODE *pfi;

View File

@ -137,7 +137,6 @@ BOOLEAN pc_mkfs16(int driveno, FMTPARMS *pfmt, BOOLEAN use_raw)
ltotsecs = pfmt->numcyl;
ltotsecs *= pfmt->secptrk;
ltotsecs *= pfmt->numhead;
ltotsecs -= pfmt->numhide; //ctr modified
if (ltotsecs > 0xffffL)
{
@ -157,7 +156,7 @@ BOOLEAN pc_mkfs16(int driveno, FMTPARMS *pfmt, BOOLEAN use_raw)
/* number heads */
fr_WORD ( &(b[26]), pfmt->numhead); /*X*/
/* number hidden sectors */
fr_WORD ( &(b[28]), pfmt->numhide); /*X*/ //ctr modified
fr_DWORD ( &(b[28]), pfmt->numhide);
/* number of duplicate fats */
b[16] = pfmt->numfats;
fr_WORD ( &(b[22]), (word)pfmt->secpfat); /*X*/
@ -231,7 +230,7 @@ BOOLEAN pc_mkfs16(int driveno, FMTPARMS *pfmt, BOOLEAN use_raw)
}
if (!devio_write_format(driveno, (dword) 0 + pfmt->numhide, &(b[0]), 1, use_raw) )
if (!devio_write_format(driveno, 0 , &(b[0]), 1, use_raw) )
{
goto errex;
}
@ -246,7 +245,7 @@ BOOLEAN pc_mkfs16(int driveno, FMTPARMS *pfmt, BOOLEAN use_raw)
if (fausize == 4)
b[3] = (byte) 0xff;
blockno = pfmt->numhide + pfmt->secreserved + (i * pfmt->secpfat); //ctr modified
blockno = pfmt->secreserved + (i * pfmt->secpfat);
for ( j = 0; j < pfmt->secpfat; j++)
{
/* WRITE */
@ -260,7 +259,7 @@ BOOLEAN pc_mkfs16(int driveno, FMTPARMS *pfmt, BOOLEAN use_raw)
}
/* Now write the root sectors */
blockno = pfmt->numhide + pfmt->secreserved + pfmt->numfats * pfmt->secpfat; //ctr modified
blockno = pfmt->secreserved + pfmt->numfats * pfmt->secpfat;
rtfs_memset(&b[0], 0, 512);
for ( j = 0; j < (pfmt->numroot/INOPBLOCK) ; j++)
{

View File

@ -72,6 +72,11 @@ BOOLEAN pc_init_drv_fat_info(DDRIVE *pdr, struct pcblk0 *pbl0)
pdr->known_free_clusters = pbl0->free_alloc;
pdr->free_contig_base = pbl0->next_alloc;
/* 2-10-2007 - Added defensive code to check for a valid start hint. If it is out of range set it to
the first cluster in the FAT */
if (pdr->free_contig_base < 2 || pdr->free_contig_base >= pdr->maxfindex)
pdr->free_contig_base = 2;
pdr->free_contig_pointer = pdr->free_contig_base;
pdr->infosec = pbl0->infosec;
pdr->fasize = 8;
@ -161,18 +166,18 @@ BOOLEAN pc_mkfs32(int driveno, FMTPARMS *pfmt, BOOLEAN use_raw)
for (i=0;i<pfmt->secreserved;i++)
{
/* WRITE */
if (!devio_write_format(driveno, pfmt->numhide + (dword) i, &(b[0]), 1, use_raw) ) //ctr modified
if (!devio_write_format(driveno, (dword) i, &(b[0]), 1, use_raw) )
{
goto errex;
}
}
#if (INCLUDE_FAT32_BOOT_CODE)
copybuff(&b[0],&FAT32_BOOT_CODE[512],512);
if (!devio_write_format(driveno, pfmt->numhide + (dword) 8, &(b[0]), 1, use_raw) ) //ctr modified
if (!devio_write_format(driveno, (dword) 8, &(b[0]), 1, use_raw) )
{
goto errex;
}
if (!devio_write_format(driveno, pfmt->numhide + (dword) 2, &(b[0]), 1, use_raw) ) //ctr modified
if (!devio_write_format(driveno, (dword) 2, &(b[0]), 1, use_raw) )
{
goto errex;
}
@ -210,7 +215,7 @@ BOOLEAN pc_mkfs32(int driveno, FMTPARMS *pfmt, BOOLEAN use_raw)
ltotsecs = pfmt->numcyl;
ltotsecs *= pfmt->secptrk;
ltotsecs *= pfmt->numhead;
ltotsecs -= pfmt->numhide;
if (ltotsecs > 0xffffL)
{
@ -304,7 +309,7 @@ BOOLEAN pc_mkfs32(int driveno, FMTPARMS *pfmt, BOOLEAN use_raw)
goto errex;
}
if (!devio_write_format(driveno, (dword) 0 + pfmt->numhide, &(b[0]), 1, use_raw) )
if (!devio_write_format(driveno, 0, &(b[0]), 1, use_raw) )
{
goto errex;
}
@ -316,11 +321,11 @@ BOOLEAN pc_mkfs32(int driveno, FMTPARMS *pfmt, BOOLEAN use_raw)
fr_DWORD( &(b[0x01ec]), (dword)0x00000003);
fr_WORD( &(b[0x01fe]), (word)0xaa55);
if (!devio_write_format(driveno, pfmt->numhide + (dword) 7, &(b[0]), 1, use_raw) ) //ctr modified
if (!devio_write_format(driveno, (dword) 7, &(b[0]), 1, use_raw) )
{
goto errex;
}
if (!devio_write_format(driveno, pfmt->numhide + (dword) 1, &(b[0]), 1, use_raw) ) //ctr modified
if (!devio_write_format(driveno, (dword) 1, &(b[0]), 1, use_raw) )
{
goto errex;
}
@ -342,7 +347,7 @@ BOOLEAN pc_mkfs32(int driveno, FMTPARMS *pfmt, BOOLEAN use_raw)
b[--j] = (byte) 0xff;
}
blockno = pfmt->numhide + pfmt->secreserved + (i * pfmt->secpfat); //ctr modified
blockno = pfmt->secreserved + (i * pfmt->secpfat);
for ( j = 0; j < pfmt->secpfat; j++)
{
/* WRITE */
@ -356,7 +361,7 @@ BOOLEAN pc_mkfs32(int driveno, FMTPARMS *pfmt, BOOLEAN use_raw)
}
/* Now write the root sectors */
blockno = pfmt->numhide + pfmt->secreserved + pfmt->numfats * pfmt->secpfat; //ctr modified
blockno = pfmt->secreserved + pfmt->numfats * pfmt->secpfat;
rtfs_memset(&b[0], 0, 512);
/* Bug fix 11-22-99 use <pfmt->secpalloc instead of 8 */
for(k=0;k<pfmt->secpalloc;k++) /* Is 8 blocks per cluster? */
@ -387,7 +392,6 @@ void pc_pfinode_cluster(DDRIVE *pdr, FINODE *finode, CLUSTERTYPE value) /*__fatf
}
BOOLEAN pc_gblk0_32(word driveno, struct pcblk0 *pbl0, byte *b) /*__fn__*/
{
word i;
if (pbl0->numroot == 0)
{
pbl0->secpfat2 = to_DWORD(b+0x24);
@ -401,7 +405,8 @@ BOOLEAN pc_gblk0_32(word driveno, struct pcblk0 *pbl0, byte *b)
{
return(FALSE);
}
for (i=0; to_DWORD((void *)b) != FSINFOSIG && i<512; b++,i++);
/* 3-07-02 - Remove scan to find INFOSIG. Access at offset 484. */
b += 484;
pbl0->free_alloc = to_DWORD((void *)&((struct fat32_info *)b)->free_alloc);
pbl0->next_alloc = to_DWORD((void *)&((struct fat32_info *)b)->next_alloc);
}
@ -422,7 +427,6 @@ BOOLEAN pc_validate_partition_type(byte p_type)
BOOLEAN fat_flushinfo(DDRIVE *pdr) /*__fn__*/
{
byte *pf;
int j;
BLKBUFF *buf;
if (pdr->fasize == 8)
@ -436,9 +440,14 @@ BOOLEAN fat_flushinfo(DDRIVE *pdr) /*__fn__
}
/* Merge in the new values */
pf = buf->data; /* Now we do not have to use the stack */
for (j=0; to_DWORD(pf)!=FSINFOSIG && j<512; pf++,j++);
/* 3-07-02 - Remove scan to find INFOSIG. Access at offset 484. */
pf += 484;
fr_DWORD((byte *) (&((struct fat32_info *)pf)->free_alloc), pdr->known_free_clusters );
fr_DWORD((byte *) (&((struct fat32_info *)pf)->next_alloc), pdr->free_contig_pointer );
/* fr_DWORD((byte *) (&((struct fat32_info *)pf)->next_alloc), pdr->free_contig_pointer ); */
/* 2-10-2007 - put free_contig_base in allocation hint field. This forces cluster
allocations to initially scan from the base of the FAT for free clusters rather
than from the previous "most likely" location */
fr_DWORD((byte *) (&((struct fat32_info *)pf)->next_alloc), pdr->free_contig_base );
/* Use write_blk, to take advantage of the failsafe cache */
if (!pc_write_blk(buf))
{
@ -499,4 +508,3 @@ BOOLEAN fatxx_pfgdword(DDRIVE *pdr, dword index, dword *value) /*__fatf
#endif

View File

@ -749,20 +749,27 @@ CLUSTERTYPE fatxx_clnext(DDRIVE *pdr, CLUSTERTYPE clno)
{
_Oxffffffful = 0x0ffffffful;
nxt &= _Oxffffffful;
if ( nxt == 0x0ffffffful )
nxt = 0xffffffff; /* end of chain */
/* Bug fix 2-01-2007 - fatxx_clnext() changed to detect terminate
on cluster value > xxfff7. Was expecting xxffff */
if ( (nxt > 0x0ffffff7ul) && (nxt <= 0x0ffffffful) )
nxt = 0xffffffff;
}
else
#endif
{
#if (FAT32)
if ( (nxt >= (CLUSTERTYPE)0xfff7) && (nxt <= (CLUSTERTYPE)0xffff) )
/* Bug fix 2-01-2007 - fatxx_clnext() changed to detect terminate
on cluster value > xxfff7. Was expecting xxffff */
if ( (nxt > (CLUSTERTYPE)0xfff7) && (nxt <= (CLUSTERTYPE)0xffff) )
#else
/* If fat32 is not defined the nxt is always <= 0xffff. picky compilers
notice this and emit a warning */
if (nxt >= (CLUSTERTYPE)0xfff7)
/* Bug fix 2-01-2007 - fatxx_clnext() changed to detect terminate
on cluster value > xxfff7. Was expecting xxffff */
if (nxt > (CLUSTERTYPE)0xfff7)
#endif
nxt = 0xffffffff; /* end of chain */
}
if (nxt != 0xffffffff && (nxt < 2 || nxt > pdr->maxfindex) )
{
@ -1020,8 +1027,6 @@ FAT_DRIVER fatxx_d;
static BOOLEAN init_fat(DDRIVE *pdr)
{
FAT_DRIVER *pfd;
/* int driveno;
driveno = pdr->driveno;*/
pfd = &fatxx_d;
pfd->fatop_alloc_chain = fatxx_alloc_chain;
pfd->fatop_clnext = fatxx_clnext;
@ -1068,4 +1073,3 @@ BOOLEAN init_fat12(DDRIVE *pdr)
}

View File

@ -33,7 +33,7 @@ BOOLEAN rtfs_resource_init(void) /*__fn__*/
PRTFS_SYSTEM_USER rtfs_get_system_user(void)
{
int i;
int i,j;
dword t;
t = rtfs_port_get_taskid();
@ -58,6 +58,17 @@ return_it:
}
/* We are out of user structures so use element 0 */
i = 0;
/* Bug fix 02-01-2007 - If we are using the default user (0), make sure the
current working directory objects are freed and the finode access counts
are reduced */
for(j = 0; j < prtfs_cfg->cfg_NDRIVES; j++)
{
if(prtfs_cfg->rtfs_user_table[i].lcwd[j])
{
pc_freeobj((DROBJ *) prtfs_cfg->rtfs_user_table[i].lcwd[j]);
prtfs_cfg->rtfs_user_table[i].lcwd[j] = 0;
}
}
goto return_it;
}
@ -519,4 +530,3 @@ BLKBUFF *pfile_buffer;
return(preturn);
}

View File

@ -161,7 +161,14 @@ BOOLEAN pc_i_dskopen(int driveno) /*__fn__*/
pdr->secreserved = bl0.secreserved; /* sectors reserved */
pdr->secptrk = bl0.secptrk; /* sectors per track */
pdr->numhead = bl0.numhead; /* number of heads */
{
dword ltemp;
pdr->numhide =bl0.numhide; /* # hidden sectors */
ltemp = bl0.numhide2;
ltemp <<= 16;
pdr->numhide |= ltemp;
}
copybuff(pdr->volume_label, &bl0.vollabel[0], 11);
pdr->volume_label[11] = 0;

View File

@ -145,7 +145,7 @@ void rtfs_print_format_dir(byte *display_buffer, DSTAT *statobj)
sprintf((char *)p,"%-8s.", (char *)&(statobj->fname[0]));
sprintf((char *)gotoeos(p),"%-3s", (char *)&(statobj->fext[0]));
// sprintf((char *)gotoeos(p)," %10lu ", statobj->fsize);
/* sprintf((char *)gotoeos(p)," %10lu ", statobj->fsize); */
sprintf((char *)gotoeos(p)," %10u ", statobj->fsize);
sprintf((char *)gotoeos(p),"%5s", dirstr);
@ -232,4 +232,3 @@ byte * p;
while((*dest++=*p++)!='\0');
return (olddest);
}

View File

@ -54,6 +54,7 @@ Summary
*/
void pc_calculate_chs(dword total, dword *cylinders, int *heads, int *secptrack);
#define DEFAULT_HOST_DISK_SIZE 10240 /* 5M, FAT16 */
@ -61,9 +62,6 @@ Summary
#define WINDOWS_HOSTDISK_SPRINTF sprintf
void calculate_hcn(long n_blocks, PDEV_GEOMETRY pgeometry);
#define MAXSEGMENTS_PER_UNIT 16
#define MAX_UNITS 8
struct file64 {
@ -166,7 +164,6 @@ DWORD size, s;
return((dword)size);
}
BOOLEAN hostdisk_io_64(int unit, dword block, void *buffer, word _count, BOOLEAN reading) /*__fn__*/
{
dword segment_number;
@ -177,12 +174,6 @@ dword nbytes,nblocks;
byte *bbuffer;
bbuffer = (byte *) buffer;
count = (dword) _count;
// if (reading)
// printf("%d,", block);
//else
// printf("%d;", block);
//if (block < 2000)
// printf("\n");
while (count)
{
segment_number = block/BLOCKS_PER_GIG;
@ -315,7 +306,7 @@ DDRIVE *pdr;
gc.dev_geometry_lbas = size_64bit_volume(pdr->logical_unit_number);
if (!gc.dev_geometry_lbas)
return(-1);
calculate_hcn(gc.dev_geometry_lbas, &gc);
pc_calculate_chs(gc.dev_geometry_lbas, &gc.dev_geometry_cylinders, &gc.dev_geometry_heads, &gc.dev_geometry_secptrack);
copybuff(pargs, &gc, sizeof(gc));
return (0);
}
@ -402,8 +393,7 @@ DDRIVE *pdr;
/* Update caller's idea of geometry */
pgc->dev_geometry_lbas = l;
calculate_hcn(pgc->dev_geometry_lbas, pgc);
pc_calculate_chs(pgc->dev_geometry_lbas, &pgc->dev_geometry_cylinders, &pgc->dev_geometry_heads, &pgc->dev_geometry_secptrack);
return(0);
}
break;
@ -448,5 +438,4 @@ DDRIVE *pdr;
}
#endif /* (INCLUDE_HOSTDISK) */

View File

@ -11,7 +11,7 @@
*
* Description:
* This file contains porting layer tuning constants for configuring RTFS.
* It is included by rtfsconf.h.
* It is included by pcconf.h.
*
****************************************************************************/
@ -25,17 +25,14 @@
#define KS_CONSTANT const /* See porting reference guide for explanation */
#define KS_FAR /* See porting reference guide for explanation */
/* Compile time constants to control device inclusion and includion of
porting layer subroutines */
/* Compile time constants to control device inclusion
See the reference guide for an explanation
*/
#define INCLUDE_SD 0
#define INCLUDE_IDE 0 /* - Include the IDE driver */
#define INCLUDE_PCMCIA 0 /* - Include the pcmcia driver */
#define INCLUDE_PCMCIA_SRAM 0 /* - Include the pcmcia static ram card driver */
#define INCLUDE_COMPACT_FLASH 0 /* - Support compact flash (requires IDE and PCMCIA) */
#define INCLUDE_CDROM 0 /* - Support ATAPI CD (requires IDE) */
#define INCLUDE_FLASH_FTL 0 /* - Include the linear flash driver */
#define INCLUDE_ROMDISK 0 /* - Include the rom disk driver */
#define INCLUDE_RAMDISK 0 /* - Include the rom disk driver */
@ -43,8 +40,8 @@
#define INCLUDE_SMARTMEDIA 0 /* - Include the smart media flash card driver */
#define INCLUDE_FLOPPY 0 /* - Include the floppy disk driver */
#define INCLUDE_HOSTDISK 0 /* - Include the host disk disk simulator */
#define INCLUDE_WINDEV 0 /* - Include windows direct device access */
#define INCLUDE_UDMA 0 /* - Include ultra dma support for the ide driver */
#define INCLUDE_82365_PCMCTRL 0 /* - Include the 82365 pcmcia controller driver */
#endif /* __PORTCONF__ */

View File

@ -383,7 +383,6 @@ typedef struct ddrive {
etc are valid */
BOOLEAN mount_abort; /* True if error handler requests abort */
int drive_opencounter; /* Value of global opencounter when we mounted */
dword volume_serialno; /* Volume serial number block 0 */
byte volume_label[14]; /* Volume entry from block 0 */
int bytespcluster; /* */
@ -626,6 +625,7 @@ typedef struct blkbuffcntxt {
struct blkbuff *pfree_blocks; /* uses pnext */
int num_blocks;
int num_free;
int scratch_alloc_count;
int low_water;
int num_alloc_failures;
int hash_size;
@ -795,7 +795,6 @@ typedef struct fmtparms {
#define VOID_CHECK_MEM() if (!prtfs_cfg) {return;}
#define IS_AVOLORDIR(X) ((X->isroot) || (X->finode->fattribute & AVOLUME|ADIRENT))
/* File RTFSINIT.C: */
BOOLEAN pc_ertfs_init(void);
@ -1187,7 +1186,6 @@ typedef struct dev_geometry {
#define DEVCTL_FLUSH 7
/*----------------------------------*/
typedef struct dev_geometry *PDEV_GEOMETRY;
@ -1390,7 +1388,7 @@ extern RTFS_CFG *prtfs_cfg;
#include "prfs.h"
#endif /* INCLUDE_FAILSAFE_CODE */
/* Include RTFS Pro features */
#include "rtfspro.h" //twl modified
#include <rtfspro.h>
#include "attach.h" //ctr modified