From c54c3b0a25662661c58e197fab3b841db4e2a57b Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 11 Sep 2008 05:21:36 +0000 Subject: [PATCH] Add a test of ROMFS git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@906 42af7a65-404d-4744-a932-0658087f49c3 --- ChangeLog | 3 ++- Documentation/NuttX.html | 3 ++- arch/sim/src/up_initialize.c | 2 ++ examples/README.txt | 16 ++++++++++++++++ fs/romfs/fs_romfs.c | 6 +----- fs/romfs/fs_romfs.h | 3 ++- fs/romfs/fs_romfsutil.c | 13 ++++++++++--- 7 files changed, 35 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index eb05614ae7..7ed1a3ed64 100644 --- a/ChangeLog +++ b/ChangeLog @@ -463,4 +463,5 @@ random access to large files. 0.3.15 2008-xx-xx Gregory Nutt - * Add support for ROMFS filesystem (initial checkin untested) + * Added support for ROMFS filesystem. + * Added a simple test the ROMFS filesystem (examples/romfs) diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html index 9dc58d9092..62068e2c2e 100644 --- a/Documentation/NuttX.html +++ b/Documentation/NuttX.html @@ -1097,7 +1097,8 @@ buildroot-0.1.0 2007-03-09 <spudmonkey@racsa.co.cr>
    nuttx-0.3.15 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> - * Add support for ROMFS filesystem (initial checkin untested) + * Added support for ROMFS filesystem. + * Added a simple test the ROMFS filesystem (examples/romfs) pascal-0.1.3 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> diff --git a/arch/sim/src/up_initialize.c b/arch/sim/src/up_initialize.c index 7eb49cb1fa..56c43e8b30 100644 --- a/arch/sim/src/up_initialize.c +++ b/arch/sim/src/up_initialize.c @@ -95,7 +95,9 @@ void up_initialize(void) devnull_register(); /* Standard /dev/null */ up_devconsole(); /* Our private /dev/console */ +#if defined(CONFIG_FS_FAT) && !defined(CONFIG_DISABLE_MOUNTPOINT) up_registerblockdevice(); /* Our FAT ramdisk at /dev/ram0 */ +#endif #if defined(CONFIG_NET) && defined(linux) uipdriver_init(); /* Our "real" netwok driver */ #endif diff --git a/examples/README.txt b/examples/README.txt index ba6051e16f..d47e5cdc1e 100644 --- a/examples/README.txt +++ b/examples/README.txt @@ -58,6 +58,22 @@ examples/mount when CONFIG_EXAMPLES_MOUNT_DEVNAME is not defined. The default is zero (meaning that "/dev/ram0" will be used). +examples/romfs +^^^^^^^^^^^^^^ + + This example exercises the romfs filesystem. Configuration options + include: + + * CONFIG_EXAMPLES_ROMFS_RAMDEVNO + The minor device number to use for the ROM disk. The default is + 1 (meaning /dev/ram1) + + * CONFIG_EXAMPLES_ROMFS_SECTORSIZE + The ROM disk sector size to use. Default is 64. + + * CONFIG_EXAMPLES_ROMFS_MOUNTPOINT + The location to mount the ROM disk. Deafault: "/usr/local/share" + examples/null ^^^^^^^^^^^^^ diff --git a/fs/romfs/fs_romfs.c b/fs/romfs/fs_romfs.c index 5400b5d00d..55b86869f3 100644 --- a/fs/romfs/fs_romfs.c +++ b/fs/romfs/fs_romfs.c @@ -654,7 +654,7 @@ static int romfs_readdir(struct inode *mountpt, struct internal_dir_s *dir) dir->fd_dir.d_type = DTYPE_DIRECTORY; break; } - else if (IS_DIRECTORY(next)) + else if (IS_FILE(next)) { dir->fd_dir.d_type = DTYPE_FILE; break; @@ -919,10 +919,6 @@ static int romfs_stat(struct inode *mountpt, const char *relpath, struct stat *b { struct romfs_mountpt_s *rm; struct romfs_dirinfo_s dirinfo; - uint16 date; - uint16 date2; - uint16 time; - ubyte attribute; int ret; /* Sanity checks */ diff --git a/fs/romfs/fs_romfs.h b/fs/romfs/fs_romfs.h index 40e166f84e..8432c9bd01 100644 --- a/fs/romfs/fs_romfs.h +++ b/fs/romfs/fs_romfs.h @@ -77,7 +77,8 @@ * values specified in */ #define RFNEXT_MODEMASK 7 /* Bits 0-2: Mode; bit 3: Executable */ -#define RFNEXT_OFFSETMASK (~7) /* Bits n-3: Offset to next entry */ +#define RFNEXT_ALLMODEMASK 15 /* Bits 0-3: All mode bits */ +#define RFNEXT_OFFSETMASK (~15) /* Bits n-3: Offset to next entry */ #define RFNEXT_HARDLINK 0 /* rf_info = Link destination file header */ #define RFNEXT_DIRECTORY 1 /* rf_info = First file's header */ diff --git a/fs/romfs/fs_romfsutil.c b/fs/romfs/fs_romfsutil.c index cbd10e3bd4..77d03b5652 100644 --- a/fs/romfs/fs_romfsutil.c +++ b/fs/romfs/fs_romfsutil.c @@ -247,7 +247,7 @@ static inline int romfs_searchdir(struct romfs_mountpt_s *rm, /* No match... select the offset to the next entry */ - offset += next; + offset = next; } while (next != 0) @@ -543,9 +543,16 @@ int romfs_finddirentry(struct romfs_mountpt_s *rm, struct romfs_dirinfo_s *dirin dirinfo->rd_dir.fr_diroffset = 0; dirinfo->rd_dir.fr_firstoffset = rm->rm_rootoffset; dirinfo->rd_dir.fr_curroffset = rm->rm_rootoffset; - dirinfo->rd_next = 0; + dirinfo->rd_next = RFNEXT_DIRECTORY; dirinfo->rd_size = 0; + /* The root directory is a special case */ + + if (!path || path[0] == '\0') + { + return OK; + } + /* Then loop for each directory/file component in the full path */ entryname = path; @@ -689,7 +696,7 @@ int romfs_parsedirentry(struct romfs_mountpt_s *rm, uint32 offset, uint32 *poffs */ *poffset = offset; - *pnext = (save & RFNEXT_OFFSETMASK) | (next & RFNEXT_MODEMASK); + *pnext = (save & RFNEXT_OFFSETMASK) | (next & RFNEXT_ALLMODEMASK); *pinfo = info; *psize = size; return OK;