Add logic to mount ROMFS filesystem
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1923 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
d66772529b
commit
d9c7b592fc
|
@ -295,7 +295,7 @@ CONFIG_DISABLE_POSIX_TIMERS=n
|
|||
CONFIG_DISABLE_PTHREAD=n
|
||||
CONFIG_DISABLE_SIGNALS=n
|
||||
CONFIG_DISABLE_MQUEUE=n
|
||||
CONFIG_DISABLE_MOUNTPOINT=y
|
||||
CONFIG_DISABLE_MOUNTPOINT=n
|
||||
CONFIG_DISABLE_ENVIRON=y
|
||||
CONFIG_DISABLE_POLL=y
|
||||
|
||||
|
@ -382,7 +382,7 @@ CONFIG_PREALLOC_TIMERS=4
|
|||
# CONFIG_FAT_SECTORSIZE - Max supported sector size
|
||||
# CONFIG_FS_ROMFS - Enable ROMFS filesystem support
|
||||
CONFIG_FS_FAT=n
|
||||
CONFIG_FS_ROMFS=n
|
||||
CONFIG_FS_ROMFS=y
|
||||
|
||||
#
|
||||
# SPI-based MMC/SD driver
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ $(ROMFS_IMG): populate
|
|||
# Create the romfs.h header file from the romfs.img file
|
||||
|
||||
$(ROMFS_HDR) : $(ROMFS_IMG)
|
||||
@xxd -i $^ >$@
|
||||
@(cd $(TESTS_DIR); xxd -i romfs.img >$@)
|
||||
|
||||
# Create the dirlist.h header file from the romfs directory
|
||||
|
||||
|
|
Loading…
Reference in New Issue