From 01a8dcd9a5272e4e0486bd8712f1393a5dcfb572 Mon Sep 17 00:00:00 2001 From: Bogdan Marinescu Date: Tue, 19 Jun 2012 16:21:14 +0300 Subject: [PATCH] Changed the ROMFS terminator char The ROMFS termination char is now 0xFF instead of 0x00 (in preparation of WOFS). --- mkfs.py | 4 ++-- src/romfs.c | 11 ++++------- utils/mkfs.lua | 4 ++-- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/mkfs.py b/mkfs.py index 67b8bfdf..324fb622 100644 --- a/mkfs.py +++ b/mkfs.py @@ -133,8 +133,8 @@ def mkfs( dirname, outname, flist, mode, compcmd ): # Report print "Encoded file %s (%d bytes real size, %d bytes after rounding, %d bytes total)" % ( fname, len( filedata ), actual, _fcnt ) - # All done, write the final "0" (terminator) - _add_data( 0, outfile, False ) + # All done, write the final "0xFF" (terminator) + _add_data( 0xFF, outfile, False ) outfile.write( "};\n\n#endif\n" ); outfile.close() print "Done, total size is %d bytes" % _bytecnt diff --git a/src/romfs.c b/src/romfs.c index fcb2df9b..fbe9edd3 100644 --- a/src/romfs.c +++ b/src/romfs.c @@ -48,17 +48,14 @@ static u8 romfs_open_file( const char* fname, u8 *pbase, FD* pfd ) i = 0; while( 1 ) { + if( pbase[ i ] == 0xFF ) + return FS_FILE_NOT_FOUND; // Read file name for( j = 0; j < DM_MAX_FNAME_LENGTH; j ++ ) { fsname[ j ] = pbase[ i + j ]; if( fsname[ j ] == 0 ) - { - if( j == 0 ) - return FS_FILE_NOT_FOUND; - else - break; - } + break; } // ' i + j' now points at the '0' byte j = i + j + 1; @@ -182,7 +179,7 @@ static struct dm_dirent* romfs_readdir_r( struct _reent *r, void *d, void *pdata FSDATA *pfsdata = ( FSDATA* )pdata; u8 *pbase = pfsdata->pbase; - if( pbase[ off ] == 0 ) + if( pbase[ off ] == 0xFF ) return NULL; while( ( dm_shared_fname[ j ++ ] = pbase[ off ++ ] ) != '\0' ); pent->fname = dm_shared_fname; diff --git a/utils/mkfs.lua b/utils/mkfs.lua index 32ab6261..4bbda537 100644 --- a/utils/mkfs.lua +++ b/utils/mkfs.lua @@ -143,8 +143,8 @@ function mkfs( dirname, outname, flist, mode, compcmd ) end end - -- All done, write the final "0" (terminator) - _add_data( 0, outfile, false ) + -- All done, write the final "0xFF" (terminator) + _add_data( 0xFF, outfile, false ) outfile:write( "};\n\n#endif\n" ); outfile:close() print( sf( "Done, total size is %d bytes", _bytecnt ) )