summaryrefslogtreecommitdiff
path: root/apps/examples/romfs
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-03-20 18:18:19 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-03-20 18:18:19 +0000
commiteafaeb9398216dacb92de69683ccdda6007efb1d (patch)
treee513e4fd791670d9b74d33821682d4059ed73098 /apps/examples/romfs
parentf68c474e8ae9cfa5c9124a6eb92ec06fe2bf40a1 (diff)
downloadnuttx-eafaeb9398216dacb92de69683ccdda6007efb1d.tar.gz
nuttx-eafaeb9398216dacb92de69683ccdda6007efb1d.tar.bz2
nuttx-eafaeb9398216dacb92de69683ccdda6007efb1d.zip
Move nuttx/examples to apps/examples
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3405 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/examples/romfs')
-rw-r--r--apps/examples/romfs/Makefile107
-rw-r--r--apps/examples/romfs/romfs_main.c506
-rw-r--r--apps/examples/romfs/romfs_testdir.h89
-rw-r--r--apps/examples/romfs/testdir.tar.gzbin0 -> 387 bytes
-rw-r--r--apps/examples/romfs/testdir.txt105
5 files changed, 807 insertions, 0 deletions
diff --git a/apps/examples/romfs/Makefile b/apps/examples/romfs/Makefile
new file mode 100644
index 000000000..70b5e869c
--- /dev/null
+++ b/apps/examples/romfs/Makefile
@@ -0,0 +1,107 @@
+############################################################################
+# apps/examples/romfs/Makefile
+#
+# Copyright (C) 2008, 2010-2011 Gregory Nutt. All rights reserved.
+# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# 3. Neither the name NuttX nor the names of its contributors may be
+# used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+############################################################################
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+include $(APPDIR)/Make.defs
+
+# ROMFS File System Example
+
+ASRCS =
+CSRCS = romfs_main.c
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+
+SRCS = $(ASRCS) $(CSRCS)
+OBJS = $(AOBJS) $(COBJS)
+
+BIN = ../../libapps$(LIBEXT)
+
+ROOTDEPPATH = --dep-path .
+
+# Common build
+
+VPATH =
+
+all: .built
+.PHONY: checkgenromfs .built clean depend disclean
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+checkgenromfs:
+ @genromfs -h 1>/dev/null 2>&1 || { \
+ echo "Host executable genromfs not available in PATH"; \
+ echo "You may need to download in from http://romfs.sourceforge.net/"; \
+ exit 1; \
+ }
+
+testdir : testdir.tar.gz
+ @tar zxf $< || { echo "tar zxf $< failed" ; exit 1 ; }
+
+testdir.img : checkgenromfs testdir
+ @genromfs -f $@ -d testdir -V "ROMFS_Test" || { echo "genromfs failed" ; exit 1 ; }
+
+romfs_testdir.h : testdir.img
+ @xxd -i $< >$@ || { echo "xxd of $< failed" ; exit 1 ; }
+
+$(BIN): romfs_testdir.h $(OBJS)
+ @( for obj in $(OBJS) ; do \
+ $(call ARCHIVE, $@, $${obj}); \
+ done ; )
+ @touch .built
+
+.built: $(BIN)
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+# Register application
+depend: .depend
+
+clean:
+ @rm -f $(BIN) *.o *~ .*.swp .built
+ $(call CLEAN)
+
+distclean: clean
+ @rm -f Make.dep .depend testdir.img
+
+-include Make.dep
+
diff --git a/apps/examples/romfs/romfs_main.c b/apps/examples/romfs/romfs_main.c
new file mode 100644
index 000000000..2e231a31c
--- /dev/null
+++ b/apps/examples/romfs/romfs_main.c
@@ -0,0 +1,506 @@
+/****************************************************************************
+ * examples/romfs/romfs_main.c
+ *
+ * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/* Mount the ROMFS image, Verifty that it contains the
+ * following:
+ *
+ * testdir
+ * |---------- [drwxr-xr-x 4096] adir
+ * | |------ [-rw-r--r-- 21] anotherfile.txt
+ * | |------ [drwxr-xr-x 4096] subdir
+ * | | `-- [-rw-r--r-- 21] subdirfile.txt
+ * | `------ [-rw-r--r-- 25] yafile.txt
+ * |---------- [-rw-r--r-- 15] afile.txt
+ * |---------- [-rw-r--r-- 21] hfile
+ * `---------- [lrwxrwxrwx 11] ldir -> adir/subdir
+ *
+ * testdir/ldir is a soft-link and should not be detectable.
+ * hfile is a hardlink to subdirfile and should be identical
+ */
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <errno.h>
+
+#include <nuttx/ramdisk.h>
+
+#include "romfs_testdir.h"
+
+/****************************************************************************
+ * Definitions
+ ****************************************************************************/
+
+/* Configuration settings */
+
+#ifndef CONFIG_EXAMPLES_ROMFS_RAMDEVNO
+# define CONFIG_EXAMPLES_ROMFS_RAMDEVNO 1
+#endif
+
+#ifndef CONFIG_EXAMPLES_ROMFS_SECTORSIZE
+# define CONFIG_EXAMPLES_ROMFS_SECTORSIZE 64
+#endif
+
+#ifndef CONFIG_EXAMPLES_ROMFS_MOUNTPOINT
+# define CONFIG_EXAMPLES_ROMFS_MOUNTPOINT "/usr/local/share"
+#endif
+
+#ifdef CONFIG_DISABLE_MOUNTPOINT
+# error "Mountpoint support is disabled"
+#endif
+
+#if CONFIG_NFILE_DESCRIPTORS < 4
+# error "Not enough file descriptors"
+#endif
+
+#ifndef CONFIG_FS_ROMFS
+# error "ROMFS support not enabled"
+#endif
+
+#define NSECTORS(b) (((b)+CONFIG_EXAMPLES_ROMFS_SECTORSIZE-1)/CONFIG_EXAMPLES_ROMFS_SECTORSIZE)
+#define STR_RAMDEVNO(m) #m
+#define MKMOUNT_DEVNAME(m) "/dev/ram" STR_RAMDEVNO(m)
+#define MOUNT_DEVNAME MKMOUNT_DEVNAME(CONFIG_EXAMPLES_ROMFS_RAMDEVNO)
+
+#define SCRATCHBUFFER_SIZE 1024
+
+/* Test directory stuff */
+
+#define WRITABLE_MODE (S_IWOTH|S_IWGRP|S_IWUSR)
+#define READABLE_MODE (S_IROTH|S_IRGRP|S_IRUSR)
+#define EXECUTABLE_MODE (S_IXOTH|S_IXGRP|S_IXUSR)
+
+#define DIRECTORY_MODE (S_IFDIR|READABLE_MODE|EXECUTABLE_MODE)
+#define FILE_MODE (S_IFREG|READABLE_MODE)
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct node_s
+{
+ struct node_s *peer; /* Next node in this directory */
+ bool directory; /* True: directory */
+ bool found; /* True: found and verified */
+ const char *name; /* Node name */
+ mode_t mode; /* Expected permissions */
+ size_t size; /* Expected size */
+ union
+ {
+ const char *filecontent; /* Context of text file */
+ struct node_s *child; /* Subdirectory start */
+ } u;
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static const char g_afilecontent[] = "This is a file\n";
+static const char g_anotherfilecontent[] = "This is another file\n";
+static const char g_yafilecontent[] = "This is yet another file\n";
+static const char g_subdirfilecontent[] = "File in subdirectory\n";
+
+#define g_hfilecontent g_subdirfilecontent
+
+static struct node_s g_adir;
+static struct node_s g_afile;
+static struct node_s g_hfile;
+
+static struct node_s g_anotherfile;
+static struct node_s g_subdir;
+static struct node_s g_yafile;
+
+static struct node_s g_subdirfile;
+
+static int g_nerrors = 0;
+
+static char g_scratchbuffer[SCRATCHBUFFER_SIZE];
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name:
+ ****************************************************************************/
+
+static void connectem(void)
+{
+ g_adir.peer = &g_afile;
+ g_adir.directory = true;
+ g_adir.found = false;
+ g_adir.name = "adir";
+ g_adir.mode = DIRECTORY_MODE;
+ g_adir.size = 0;
+ g_adir.u.child = &g_anotherfile;
+
+ g_afile.peer = &g_hfile;
+ g_afile.directory = false;
+ g_afile.found = false;
+ g_afile.name = "afile.txt";
+ g_afile.mode = FILE_MODE;
+ g_afile.size = strlen(g_afilecontent);
+ g_afile.u.filecontent = g_afilecontent;
+
+ g_hfile.peer = NULL;
+ g_hfile.directory = false; /* Actually a hard link */
+ g_hfile.found = false;
+ g_hfile.name = "hfile";
+ g_hfile.mode = FILE_MODE;
+ g_hfile.size = strlen(g_hfilecontent);
+ g_hfile.u.filecontent = g_hfilecontent;
+
+ g_anotherfile.peer = &g_yafile;
+ g_anotherfile.directory = false;
+ g_anotherfile.found = false;
+ g_anotherfile.name = "anotherfile.txt";
+ g_anotherfile.mode = FILE_MODE;
+ g_anotherfile.size = strlen(g_anotherfilecontent);
+ g_anotherfile.u.filecontent = g_anotherfilecontent;
+
+ g_yafile.peer = &g_subdir;
+ g_yafile.directory = false;
+ g_yafile.found = false;
+ g_yafile.name = "yafile.txt";
+ g_yafile.mode = FILE_MODE;
+ g_yafile.size = strlen(g_yafilecontent);
+ g_yafile.u.filecontent = g_yafilecontent;
+
+ g_subdir.peer = NULL;
+ g_subdir.directory = true;
+ g_subdir.found = false;
+ g_subdir.name = "subdir";
+ g_subdir.mode = DIRECTORY_MODE;
+ g_subdir.size = 0;
+ g_subdir.u.child = &g_subdirfile;
+
+ g_subdirfile.peer = NULL;
+ g_subdirfile.directory = false;
+ g_subdirfile.found = false;
+ g_subdirfile.name = "subdirfile.txt";
+ g_subdirfile.mode = FILE_MODE;
+ g_subdirfile.size = strlen(g_subdirfilecontent);
+ g_subdirfile.u.filecontent = g_subdirfilecontent;
+}
+
+/****************************************************************************
+ * Name: findindirectory
+ ****************************************************************************/
+
+static struct node_s *findindirectory(struct node_s *entry, const char *name)
+{
+ for (; entry; entry = entry->peer)
+ {
+ if (!entry->found && strcmp(entry->name, name) == 0)
+ {
+ entry->found = true;
+ return entry;
+ }
+ }
+ return NULL;
+}
+
+/****************************************************************************
+ * Name: checkattributes
+ ****************************************************************************/
+
+static void checkattributes(const char *path, mode_t mode, size_t size)
+{
+ struct stat buf;
+ int ret;
+
+ ret = stat(path, &buf);
+ if (ret != 0)
+ {
+ printf(" -- ERROR: Failed to stat %s: %d\n", path, errno);
+ g_nerrors++;
+ return;
+ }
+
+ if (mode != buf.st_mode)
+ {
+ printf(" -- ERROR: Expected mode %08x, got %08x\n", mode, buf.st_mode);
+ g_nerrors++;
+ }
+
+ if (size != buf.st_size)
+ {
+ printf(" -- ERROR: Expected size %d, got %d\n", mode, buf.st_size);
+ g_nerrors++;
+ }
+}
+
+/****************************************************************************
+ * Name: checkfile
+ ****************************************************************************/
+
+static void checkfile(const char *path, struct node_s *node)
+{
+ ssize_t nbytesread;
+ char *filedata;
+ int fd;
+
+ /* Open the file */
+
+ fd = open(path, O_RDONLY);
+ if (fd < 0)
+ {
+ printf(" -- ERROR: Failed to open %s: %d\n", path, errno);
+ g_nerrors++;
+ return;
+ }
+
+ /* Read and verify the file contents */
+
+ nbytesread = read(fd, g_scratchbuffer, SCRATCHBUFFER_SIZE);
+ if (nbytesread < 0)
+ {
+ printf(" -- ERROR: Failed to read from %s: %d\n", path, errno);
+ g_nerrors++;
+ }
+ else if (nbytesread != node->size)
+ {
+ printf(" -- ERROR: Read %d bytes, expected %d\n", nbytesread, node->size);
+ g_nerrors++;
+ }
+ else if (memcmp(g_scratchbuffer, node->u.filecontent, node->size) != 0)
+ {
+ g_scratchbuffer[nbytesread] = '\0';
+ printf(" -- ERROR: File content read does not match expectation:\n");
+ printf(" -- Read: [%s]\n", g_scratchbuffer);
+ printf(" -- Expected: [%s]\n", node->u.filecontent);
+ g_nerrors++;
+ }
+
+ /* Memory map and verify the file contents */
+
+ filedata = (char*)mmap(NULL, node->size, PROT_READ, MAP_SHARED|MAP_FILE, fd, 0);
+ if (!filedata || filedata == (char*)MAP_FAILED)
+ {
+ printf(" -- ERROR: mmap of %s failed: %d\n", path, errno);
+ g_nerrors++;
+ }
+ else
+ {
+ if (memcmp(filedata, node->u.filecontent, node->size) != 0)
+ {
+ memcpy(g_scratchbuffer, filedata, node->size);
+ g_scratchbuffer[node->size] = '\0';
+ printf(" -- ERROR: Mapped file content read does not match expectation:\n");
+ printf(" -- Memory: [%s]\n", filedata);
+ printf(" -- Expected: [%s]\n", node->u.filecontent);
+ g_nerrors++;
+ }
+ munmap(filedata, node->size);
+ }
+
+ /* Close the file */
+
+ if (close(fd) != OK)
+ {
+ printf(" -- ERROR: Failed to close %s: %d\n", path, errno);
+ g_nerrors++;
+ }
+}
+
+/****************************************************************************
+ * Name: readdirectories
+ ****************************************************************************/
+
+static void readdirectories(const char *path, struct node_s *entry)
+{
+ DIR *dirp;
+ struct node_s *node;
+ struct dirent *direntry;
+ char *fullpath;
+
+ printf("Traversing directory: %s\n", path);
+ dirp = opendir(path);
+ if (!dirp)
+ {
+ printf(" ERROR opendir(\"%s\") failed: %d\n", path, errno);
+ g_nerrors++;
+ return;
+ }
+
+ for (direntry = readdir(dirp); direntry; direntry = readdir(dirp))
+ {
+ if (strcmp(direntry->d_name, ".") == 0 || strcmp(direntry->d_name, "..") == 0)
+ {
+ printf(" Skipping %s\n", direntry->d_name);
+ continue;
+ }
+
+ node = findindirectory(entry, direntry->d_name);
+ if (!node)
+ {
+ printf(" ERROR: No node found for %s\n", direntry->d_name);
+ g_nerrors++;
+ continue;
+ }
+
+ /* Get the full path to the entry */
+
+ sprintf(g_scratchbuffer, "%s/%s", path, direntry->d_name);
+ fullpath = strdup(g_scratchbuffer);
+
+ if (DIRENT_ISDIRECTORY(direntry->d_type))
+ {
+ printf(" DIRECTORY: %s/\n", fullpath);
+ if (!node->directory)
+ {
+ printf(" -- ERROR: Expected type directory\n");
+ g_nerrors++;
+ }
+ else
+ {
+ checkattributes(fullpath, node->mode, 0);
+ readdirectories(fullpath, node->u.child);
+ printf("Continuing directory: %s\n", path);
+ }
+ }
+ else
+ {
+ printf(" FILE: %s/\n", fullpath);
+ if (node->directory)
+ {
+ printf(" -- ERROR: Expected type file\n");
+ g_nerrors++;
+ }
+ else
+ {
+ checkattributes(fullpath, node->mode, node->size);
+ checkfile(fullpath, node);
+ }
+ }
+ free(fullpath);
+ }
+
+ closedir(dirp);
+}
+
+/****************************************************************************
+ * Name: checkdirectories
+ ****************************************************************************/
+
+static void checkdirectories(struct node_s *entry)
+{
+ for (; entry; entry = entry->peer)
+ {
+ if (!entry->found )
+ {
+ printf("ERROR: %s never found\n", entry->name);
+ g_nerrors++;
+ }
+
+ if (entry->directory)
+ {
+ checkdirectories(entry->u.child);
+ }
+ }
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: user_initialize
+ ****************************************************************************/
+
+void user_initialize(void)
+{
+}
+
+/****************************************************************************
+ * Name: user_start
+ ****************************************************************************/
+
+int user_start(int argc, char *argv[])
+{
+ int ret;
+
+ /* Create a RAM disk for the test */
+
+ ret = romdisk_register(CONFIG_EXAMPLES_ROMFS_RAMDEVNO, testdir_img,
+ NSECTORS(testdir_img_len), CONFIG_EXAMPLES_ROMFS_SECTORSIZE);
+ if (ret < 0)
+ {
+ printf("ERROR: Failed to create RAM disk\n");
+ return 1;
+ }
+
+ /* Mount the test file system */
+
+ printf("Mounting ROMFS filesystem at target=%s with source=%s\n",
+ CONFIG_EXAMPLES_ROMFS_MOUNTPOINT, MOUNT_DEVNAME);
+
+ ret = mount(MOUNT_DEVNAME, CONFIG_EXAMPLES_ROMFS_MOUNTPOINT, "romfs", MS_RDONLY, NULL);
+ if (ret < 0)
+ {
+ printf("ERROR: Mount failed: %d\n", errno);
+ return 1;
+ }
+
+ /* Perform the test */
+
+ connectem();
+ readdirectories(CONFIG_EXAMPLES_ROMFS_MOUNTPOINT, &g_adir);
+ checkdirectories(&g_adir);
+
+ if (g_nerrors)
+ {
+ printf("Finished with %d errors\n", g_nerrors);
+ return g_nerrors;
+ }
+
+ printf("PASSED\n");
+ return 0;
+}
diff --git a/apps/examples/romfs/romfs_testdir.h b/apps/examples/romfs/romfs_testdir.h
new file mode 100644
index 000000000..53f93105c
--- /dev/null
+++ b/apps/examples/romfs/romfs_testdir.h
@@ -0,0 +1,89 @@
+unsigned char testdir_img[] = {
+ 0x2d, 0x72, 0x6f, 0x6d, 0x31, 0x66, 0x73, 0x2d, 0x00, 0x00, 0x02, 0x60,
+ 0x27, 0x43, 0x4a, 0x8a, 0x52, 0x4f, 0x4d, 0x46, 0x53, 0x5f, 0x54, 0x65,
+ 0x73, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49,
+ 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0xd1, 0xff, 0xff, 0x97,
+ 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x20,
+ 0x00, 0x00, 0x00, 0x00, 0xd1, 0xd1, 0xff, 0x80, 0x2e, 0x2e, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b,
+ 0x93, 0x9b, 0x95, 0xf0, 0x6c, 0x64, 0x69, 0x72, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x61, 0x64, 0x69, 0x72,
+ 0x2f, 0x73, 0x75, 0x62, 0x64, 0x69, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x02, 0x19, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, 0x00,
+ 0x9e, 0x9b, 0x93, 0xc5, 0x61, 0x64, 0x69, 0x72, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x58, 0x47, 0x43, 0xf1,
+ 0x61, 0x6e, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x66, 0x69, 0x6c, 0x65, 0x2e,
+ 0x74, 0x78, 0x74, 0x00, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
+ 0x61, 0x6e, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x20, 0x66, 0x69, 0x6c, 0x65,
+ 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19,
+ 0xa1, 0xc5, 0x69, 0xd8, 0x79, 0x61, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x74,
+ 0x78, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x68, 0x69, 0x73,
+ 0x20, 0x69, 0x73, 0x20, 0x79, 0x65, 0x74, 0x20, 0x61, 0x6e, 0x6f, 0x74,
+ 0x68, 0x65, 0x72, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x0a, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x50, 0x00, 0x00, 0x00, 0x90,
+ 0x00, 0x00, 0x00, 0x00, 0xd1, 0xff, 0xfe, 0x20, 0x2e, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0x70, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
+ 0xd1, 0xd1, 0xfe, 0x70, 0x2e, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,
+ 0x00, 0x00, 0x01, 0x90, 0x00, 0x00, 0x00, 0x00, 0x23, 0x18, 0x9c, 0x03,
+ 0x73, 0x75, 0x62, 0x64, 0x69, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xd2, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x15, 0x3e, 0x3f, 0x06, 0xd8, 0x73, 0x75, 0x62, 0x64,
+ 0x69, 0x72, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x74, 0x78, 0x74, 0x00, 0x00,
+ 0x46, 0x69, 0x6c, 0x65, 0x20, 0x69, 0x6e, 0x20, 0x73, 0x75, 0x62, 0x64,
+ 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x0a, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf0,
+ 0x00, 0x00, 0x01, 0x70, 0x00, 0x00, 0x00, 0x00, 0xd1, 0xff, 0xfc, 0xa0,
+ 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90,
+ 0x00, 0x00, 0x00, 0x00, 0xd1, 0xd1, 0xff, 0x70, 0x2e, 0x2e, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x02, 0x30, 0x00, 0x00, 0x01, 0x90, 0x00, 0x00, 0x00, 0x00,
+ 0x32, 0x99, 0x92, 0xd4, 0x68, 0x66, 0x69, 0x6c, 0x65, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc5, 0x6b, 0x22, 0x0b,
+ 0x61, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x74, 0x78, 0x74, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
+ 0x61, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
+};
+unsigned int testdir_img_len = 1024;
diff --git a/apps/examples/romfs/testdir.tar.gz b/apps/examples/romfs/testdir.tar.gz
new file mode 100644
index 000000000..cd0e9c518
--- /dev/null
+++ b/apps/examples/romfs/testdir.tar.gz
Binary files differ
diff --git a/apps/examples/romfs/testdir.txt b/apps/examples/romfs/testdir.txt
new file mode 100644
index 000000000..e321d6ded
--- /dev/null
+++ b/apps/examples/romfs/testdir.txt
@@ -0,0 +1,105 @@
+VOLUME HEADER: Name=ROMFS_Test
+0000000: 2d72 6f6d 3166 732d 0000 0260 2743 4a8a -rom1fs-...`'CJ.
+0000010: 524f 4d46 535f 5465 7374 0000 0000 0000 ROMFS_Test......
+
+FILE HEADER 1: Name=.
+0000020: 0000 0049 0000 0020 0000 0000 d1ff ff97 ...I... ........
+0000030: 2e00 0000 0000 0000 0000 0000 0000 0000 ................
+
+FILE HEADER 2: Name=..
+0000040: 0000 0060 0000 0020 0000 0000 d1d1 ff80 ...`... ........
+0000050: 2e2e 0000 0000 0000 0000 0000 0000 0000 ................
+
+FILE HEADER 3: Name=ldir
+0000060: 0000 0093 0000 0000 0000 000b 939b 95f0 ................
+0000070: 6c64 6972 0000 0000 0000 0000 0000 0000 ldir............
+
+ FILE CONTENT:
+ 0000080: 6164 6972 2f73 7562 6469 7200 0000 0000 adir/subdir.....
+
+FILE HEADER 4: Name=adir
+0000090: 0000 0219 0000 00b0 0000 0000 9e9b 93c5 ................
+00000a0: 6164 6972 0000 0000 0000 0000 0000 0000 adir............
+
+ FILE HEADER 4.1: Name=anotherfile.txt
+ 00000b0: 0000 00f2 0000 0000 0000 0015 5847 43f1 ............XGC.
+ 00000c0: 616e 6f74 6865 7266 696c 652e 7478 7400 anotherfile.txt.
+
+ FILE CONTENT:
+ 00000d0: 5468 6973 2069 7320 616e 6f74 6865 7220 This is another
+ 00000e0: 6669 6c65 0a00 0000 0000 0000 0000 0000 file............
+
+ FILE HEADER 4.2: Name=yafile.txt
+ 00000f0: 0000 0132 0000 0000 0000 0019 a1c5 69d8 ...2..........i.
+ 0000100: 7961 6669 6c65 2e74 7874 0000 0000 0000 yafile.txt......
+
+ FILE CONTENT:
+ 0000110: 5468 6973 2069 7320 7965 7420 616e 6f74 This is yet anot
+ 0000120: 6865 7220 6669 6c65 0a00 0000 0000 0000 her file........
+
+ FILE HEADER 4.3: Name=.
+ 0000130: 0000 0150 0000 0090 0000 0000 d1ff fe20 ...P...........
+ 0000140: 2e00 0000 0000 0000 0000 0000 0000 0000 ................
+
+ FILE HEADER 4.4: Name=..
+ 0000150: 0000 0170 0000 0020 0000 0000 d1d1 fe70 ...p... .......p
+ 0000160: 2e2e 0000 0000 0000 0000 0000 0000 0000 ................
+
+ FILE HEADER 4.5: Name=subdir
+ 0000170: 0000 0009 0000 0190 0000 0000 2318 9c03 ............#...
+ 0000180: 7375 6264 6972 0000 0000 0000 0000 0000 subdir..........
+
+ FILE HEADER 4.5.1: Name=subdirfile.txt
+ 0000190: 0000 01d2 0000 0000 0000 0015 3e3f 06d8 ............>?..
+ 00001a0: 7375 6264 6972 6669 6c65 2e74 7874 0000 subdirfile.txt..
+
+ FILE CONTENT:
+ 00001b0: 4669 6c65 2069 6e20 7375 6264 6972 6563 File in subdirec
+ 00001c0: 746f 7279 0a00 0000 0000 0000 0000 0000 tory............
+
+ FILE HEADER 4.5.2: Name=.
+ 00001d0: 0000 01f0 0000 0170 0000 0000 d1ff fca0 .......p........
+ 00001e0: 2e00 0000 0000 0000 0000 0000 0000 0000 ................
+
+ FILE HEADER 4.5.3: Name=..
+ 00001f0: 0000 0000 0000 0090 0000 0000 d1d1 ff70 ...............p
+ 0000200: 2e2e 0000 0000 0000 0000 0000 0000 0000 ................
+
+FILE HEADER 5: Name=hfile
+0000210: 0000 0230 0000 0190 0000 0000 3299 92d4 ...0........2...
+0000220: 6866 696c 6500 0000 0000 0000 0000 0000 hfile...........
+
+FILE HEADER 6: Name=afile.txt
+0000230: 0000 0002 0000 0000 0000 000f c56b 220b .............k".
+0000240: 6166 696c 652e 7478 7400 0000 0000 0000 afile.txt.......
+
+ FILE CONTENT:
+ 0000250: 5468 6973 2069 7320 6120 6669 6c65 0a00 This is a file..
+
+PADDING
+0000260: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000270: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000280: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000290: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+00002a0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+00002b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+00002c0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+00002d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+00002e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+00002f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000300: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000310: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000320: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000330: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000340: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000350: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000360: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000370: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000380: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000390: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+00003a0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+00003b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+00003c0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+00003d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+00003e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+00003f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................