51 lines
1.4 KiB
C
51 lines
1.4 KiB
C
#include <stdio.h>
|
|
#include <nuttx/config.h>
|
|
|
|
#include "js-root.h"
|
|
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
#include <sys/types.h>
|
|
#include <sys/mount.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/mman.h>
|
|
#include <sys/boardctl.h>
|
|
#include <inttypes.h>
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
#include <fcntl.h>
|
|
#include <dirent.h>
|
|
#include <errno.h>
|
|
|
|
#include <nuttx/drivers/ramdisk.h>
|
|
|
|
#define CONFIG_JS_RAMFS 1
|
|
#define STR_RAMDEVNO(m) #m
|
|
#define MKMOUNT_DEVNAME(m) "/dev/ram" STR_RAMDEVNO(m)
|
|
#define MOUNT_DEVNAME MKMOUNT_DEVNAME(CONFIG_JS_RAMFS)
|
|
#ifndef CONFIG_EXAMPLES_ROMFS_SECTORSIZE
|
|
# define CONFIG_EXAMPLES_ROMFS_SECTORSIZE 64
|
|
#endif
|
|
#define NSECTORS(b) (((b)+CONFIG_EXAMPLES_ROMFS_SECTORSIZE-1)/CONFIG_EXAMPLES_ROMFS_SECTORSIZE)
|
|
|
|
int main(int argc, char *argv[]) {
|
|
struct boardioc_romdisk_s desc;
|
|
|
|
/* Create a RAM disk for the test */
|
|
|
|
desc.minor = CONFIG_JS_RAMFS; /* Minor device number of the ROM disk. */
|
|
desc.nsectors = NSECTORS(js_img_len); /* The number of sectors in the ROM disk */
|
|
desc.sectsize = CONFIG_EXAMPLES_ROMFS_SECTORSIZE; /* The size of one sector in bytes */
|
|
desc.image = (FAR uint8_t *)js_img; /* File system image */
|
|
|
|
boardctl(BOARDIOC_ROMDISK, (uintptr_t)&desc);
|
|
mkdir("/js", 0755);
|
|
printf("%d\n", mount(MOUNT_DEVNAME, "/js", "romfs",
|
|
MS_RDONLY, NULL));
|
|
return 0;
|
|
}
|