diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-06-21 18:55:19 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-06-21 18:55:19 +0000 |
commit | d3236bb10124ede44104a9e83ec282b8b762acba (patch) | |
tree | f19556e9214092d91c38f706bf63994d6acd5c48 /nuttx/examples/nxflat/nxflat_main.c | |
parent | 622ea63d734f5a3e86eaffac117d6fb66507ec7f (diff) | |
download | px4-nuttx-d3236bb10124ede44104a9e83ec282b8b762acba.tar.gz px4-nuttx-d3236bb10124ede44104a9e83ec282b8b762acba.tar.bz2 px4-nuttx-d3236bb10124ede44104a9e83ec282b8b762acba.zip |
Add logic to mount ROMFS filesystem
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1923 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples/nxflat/nxflat_main.c')
-rw-r--r-- | nuttx/examples/nxflat/nxflat_main.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/nuttx/examples/nxflat/nxflat_main.c b/nuttx/examples/nxflat/nxflat_main.c index e792fa1b7..4c4de4313 100644 --- a/nuttx/examples/nxflat/nxflat_main.c +++ b/nuttx/examples/nxflat/nxflat_main.c @@ -39,6 +39,7 @@ #include <nuttx/config.h> #include <sys/types.h> +#include <sys/mount.h> #include <stdio.h> #include <stdlib.h> @@ -48,7 +49,9 @@ #include <debug.h> #include <errno.h> +#include <nuttx/ramdisk.h> #include <nuttx/binfmt.h> + #include "tests/romfs.h" #include "tests/dirlist.h" #include "tests/symtab.h" @@ -57,6 +60,11 @@ * Definitions ****************************************************************************/ +#define SECTORSIZE 512 +#define NSECTORS(b) (((b)+SECTORSIZE-1)/SECTORSIZE) +#define ROMFSDEV "/dev/ram0" +#define MOUNTPT "/mnt/romfs" + /**************************************************************************** * Private Types ****************************************************************************/ @@ -68,6 +76,8 @@ static const char delimiter[] = "****************************************************************************"; +static char path[128]; + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -103,12 +113,38 @@ int user_start(int argc, char *argv[]) int ret; int i; + /* Create a ROM disk for the ROMFS filesystem */ + + printf("Registering romdisk\n"); + ret = romdisk_register(0, romfs_img, NSECTORS(romfs_img_len), SECTORSIZE); + if (ret < 0) + { + fprintf(stderr, "ERROR: romdisk_register failed: %d\n", ret); + exit(1); + } + + /* Mount the file system */ + + printf("Mounting ROMFS filesystem at target=%s with source=%s\n", + MOUNTPT, ROMFSDEV); + + ret = mount(ROMFSDEV, MOUNTPT, "romfs", MS_RDONLY, NULL); + if (ret < 0) + { + fprintf(stderr, "ERROR: mount(%s,%s,romfs) failed: %s\n", + ROMFSDEV, MOUNTPT, errno); + } + + /* Now excercise every progrm in the ROMFS file system */ + for (i = 0; dirlist[i]; i++) { testheader(dirlist[i]); memset(&bin, 0, sizeof(struct binary_s)); - bin.filename = dirlist[i]; + snprintf(path, 128, "%s/%s", MOUNTPT, dirlist[i]); + + bin.filename = path; bin.exports = exports; bin.nexports = NEXPORTS; |