Apps Issue #246: Replace romdisk_register() with boardctl(BOARDIOC_ROMDISK)

C file changes:
   examples/bastest/bastest_main.c
   examples/elf/elf_main.c
   examples/module/module_main.c
   examples/posix_spawn/spawn_main.c
   examples/romfs/romfs_main.c
   examples/sotest/sotest_main.c
   examples/unionfs/unionfs_main.c

Update examples/elf/elf_main.c

Co-authored-by: Xiang Xiao <xiaoxiang781216@gmail.com>

Update examples/unionfs/unionfs_main.c

Co-authored-by: Xiang Xiao <xiaoxiang781216@gmail.com>

Update examples/unionfs/unionfs_main.c

Co-authored-by: Xiang Xiao <xiaoxiang781216@gmail.com>

Update examples/posix_spawn/spawn_main.c

Co-authored-by: Xiang Xiao <xiaoxiang781216@gmail.com>

Update examples/elf/elf_main.c

Co-authored-by: Xiang Xiao <xiaoxiang781216@gmail.com>

Update examples/elf/elf_main.c

Co-authored-by: Xiang Xiao <xiaoxiang781216@gmail.com>
This commit is contained in:
Tanushree Baindur 2021-05-08 13:33:52 -05:00 committed by Xiang Xiao
parent bb1e93cb67
commit f0c044adb1
7 changed files with 119 additions and 102 deletions

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* examples/bastest/bastest_main.c * apps/examples/bastest/bastest_main.c
* *
* Copyright (C) 2014 Gregory Nutt. All rights reserved. * Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
@ -40,7 +40,9 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <sys/boardctl.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <errno.h> #include <errno.h>
#include <nuttx/drivers/ramdisk.h> #include <nuttx/drivers/ramdisk.h>
@ -92,15 +94,23 @@
int main(int argc, FAR char *argv[]) int main(int argc, FAR char *argv[])
{ {
int ret; int ret;
struct boardioc_romdisk_s desc;
/* Create a ROM disk for the ROMFS filesystem */ /* Create a ROM disk for the ROMFS filesystem */
printf("Registering romdisk at /dev/ram%d\n", CONFIG_EXAMPLES_BASTEST_DEVMINOR); printf("Registering romdisk at /dev/ram%d\n",
ret = romdisk_register(CONFIG_EXAMPLES_BASTEST_DEVMINOR, (FAR uint8_t *)romfs_img, CONFIG_EXAMPLES_BASTEST_DEVMINOR);
NSECTORS(romfs_img_len), SECTORSIZE);
desc.minor = CONFIG_EXAMPLES_BASTEST_DEVMINOR; /* Minor device number of the ROM disk. */
desc.nsectors = NSECTORS(romfs_img_len); /* The number of sectors in the ROM disk */
desc.sectsize = SECTORSIZE; /* The size of one sector in bytes */
desc.image = (FAR uint8_t *)romfs_img; /* File system image */
ret = boardctl(BOARDIOC_ROMDISK, (uintptr_t)&desc);
if (ret < 0) if (ret < 0)
{ {
fprintf(stderr, "ERROR: romdisk_register failed: %d\n", ret); fprintf(stderr, "ERROR: romdisk_register failed: %s\n",
strerror(errno));
return 1; return 1;
} }
@ -109,11 +119,12 @@ int main(int argc, FAR char *argv[])
printf("Mounting ROMFS filesystem at target=%s with source=%s\n", printf("Mounting ROMFS filesystem at target=%s with source=%s\n",
MOUNTPT, CONFIG_EXAMPLES_BASTEST_DEVPATH); MOUNTPT, CONFIG_EXAMPLES_BASTEST_DEVPATH);
ret = mount(CONFIG_EXAMPLES_BASTEST_DEVPATH, MOUNTPT, "romfs", MS_RDONLY, NULL); ret = mount(CONFIG_EXAMPLES_BASTEST_DEVPATH, MOUNTPT, "romfs",
MS_RDONLY, NULL);
if (ret < 0) if (ret < 0)
{ {
fprintf(stderr, "ERROR: mount(%s,%s,romfs) failed: %s\n", fprintf(stderr, "ERROR: mount(%s,%s,romfs) failed: %s\n",
CONFIG_EXAMPLES_BASTEST_DEVPATH, MOUNTPT, errno); CONFIG_EXAMPLES_BASTEST_DEVPATH, MOUNTPT, strerror(errno));
return 1; return 1;
} }

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* examples/elf/elf_main.c * apps/examples/elf/elf_main.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -24,6 +24,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <nuttx/compiler.h> #include <nuttx/compiler.h>
#include <sys/boardctl.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -205,36 +206,32 @@ int main(int argc, FAR char *argv[])
FAR char *args[1]; FAR char *args[1];
int ret; int ret;
int i; int i;
struct boardioc_romdisk_s desc;
/* Initialize the memory monitor */ /* Initialize the memory monitor */
mm_initmonitor(); mm_initmonitor();
#if defined(CONFIG_EXAMPLES_ELF_ROMFS) #if defined(CONFIG_EXAMPLES_ELF_ROMFS)
#if defined(CONFIG_BUILD_FLAT)
/* This example violates the portable POSIX interface by calling the OS
* internal function romdisk_register() (aka ramdisk_register()). We can
* squeak by in with this violation in the FLAT build mode, but not in
* other build modes. In other build modes, the following logic must be
* performed in the OS board initialization logic (where it really belongs
* anyway).
*/
/* Create a ROM disk for the ROMFS filesystem */ /* Create a ROM disk for the ROMFS filesystem */
message("Registering romdisk at /dev/ram%d\n", message("Registering romdisk at /dev/ram%d\n",
CONFIG_EXAMPLES_ELF_DEVMINOR); CONFIG_EXAMPLES_ELF_DEVMINOR);
ret = romdisk_register(CONFIG_EXAMPLES_ELF_DEVMINOR,
(FAR uint8_t *)romfs_img, desc.minor = CONFIG_EXAMPLES_ELF_DEVMINOR; /* Minor device number of the ROM disk. */
NSECTORS(romfs_img_len), SECTORSIZE); desc.nsectors = NSECTORS(romfs_img_len); /* The number of sectors in the ROM disk */
desc.sectsize = SECTORSIZE; /* The size of one sector in bytes */
desc.image = (FAR uint8_t *)romfs_img; /* File system image */
ret = boardctl(BOARDIOC_ROMDISK, (uintptr_t)&desc);
if (ret < 0) if (ret < 0)
{ {
errmsg("ERROR: romdisk_register failed: %d\n", ret); errmsg("ERROR: romdisk_register failed: %s\n", strerror(errno));
exit(1); exit(1);
} }
mm_update(&g_mmstep, "after romdisk_register"); mm_update(&g_mmstep, "after romdisk_register");
#endif
/* Mount the ROMFS file system */ /* Mount the ROMFS file system */
@ -245,8 +242,8 @@ int main(int argc, FAR char *argv[])
MS_RDONLY, NULL); MS_RDONLY, NULL);
if (ret < 0) if (ret < 0)
{ {
errmsg("ERROR: mount(%s,%s,romfs) failed: %d\n", errmsg("ERROR: mount(%s,%s,romfs) failed: %s\n",
CONFIG_EXAMPLES_ELF_DEVPATH, MOUNTPT, errno); CONFIG_EXAMPLES_ELF_DEVPATH, MOUNTPT, strerror(errno));
} }
#elif defined(CONFIG_EXAMPLES_ELF_CROMFS) #elif defined(CONFIG_EXAMPLES_ELF_CROMFS)
@ -257,7 +254,8 @@ int main(int argc, FAR char *argv[])
ret = mount(NULL, MOUNTPT, "cromfs", MS_RDONLY, NULL); ret = mount(NULL, MOUNTPT, "cromfs", MS_RDONLY, NULL);
if (ret < 0) if (ret < 0)
{ {
errmsg("ERROR: mount(%s, cromfs) failed: %d\n", MOUNTPT, errno); errmsg("ERROR: mount(%s, cromfs) failed: %s\n",
MOUNTPT, strerror(errno));
} }
#elif defined(CONFIG_EXAMPLES_ELF_EXTERN) #elif defined(CONFIG_EXAMPLES_ELF_EXTERN)
/* An external file system is being used */ /* An external file system is being used */
@ -280,8 +278,8 @@ int main(int argc, FAR char *argv[])
} }
else else
{ {
printf("ERROR: stat(%s) failed: %d Aborting...\n", printf("ERROR: stat(%s) failed: %s Aborting...\n",
CONFIG_EXAMPLES_ELF_DEVPATH, errcode); CONFIG_EXAMPLES_ELF_DEVPATH, strerror(errcode));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
@ -304,9 +302,9 @@ int main(int argc, FAR char *argv[])
CONFIG_EXAMPLES_ELF_FSTYPE, MS_RDONLY, NULL); CONFIG_EXAMPLES_ELF_FSTYPE, MS_RDONLY, NULL);
if (ret < 0) if (ret < 0)
{ {
errmsg("ERROR: mount(%s, %s, %s) failed: %d\n", errmsg("ERROR: mount(%s, %s, %s) failed: %s\n",
CONFIG_EXAMPLES_ELF_DEVPATH, CONFIG_EXAMPLES_ELF_FSTYPE, CONFIG_EXAMPLES_ELF_DEVPATH, CONFIG_EXAMPLES_ELF_FSTYPE,
MOUNTPT, errno); MOUNTPT, strerror(errno));
} }
#endif #endif
#else #else
@ -364,7 +362,8 @@ int main(int argc, FAR char *argv[])
if (ret < 0) if (ret < 0)
{ {
errmsg("ERROR: exec(%s) failed: %d\n", dirlist[i], errno); errmsg("ERROR: exec(%s) failed: %s\n",
dirlist[i], strerror(errno));
} }
else else
{ {

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* examples/module/module_main.c * apps/examples/module/module_main.c
* *
* Copyright (C) 2015, 2017-2018 Gregory Nutt. All rights reserved. * Copyright (C) 2015, 2017-2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
@ -160,6 +160,7 @@ int main(int argc, FAR char *argv[])
ssize_t nbytes; ssize_t nbytes;
int ret; int ret;
int fd; int fd;
struct boardioc_romdisk_s desc;
#ifdef CONFIG_BUILD_FLAT #ifdef CONFIG_BUILD_FLAT
/* Set the OS symbol table indirectly through the boardctl() */ /* Set the OS symbol table indirectly through the boardctl() */
@ -169,8 +170,8 @@ int main(int argc, FAR char *argv[])
ret = boardctl(BOARDIOC_OS_SYMTAB, (uintptr_t)&symdesc); ret = boardctl(BOARDIOC_OS_SYMTAB, (uintptr_t)&symdesc);
if (ret < 0) if (ret < 0)
{ {
fprintf(stderr, "ERROR: boardctl(BOARDIOC_OS_SYMTAB) failed: %d\n", fprintf(stderr, "ERROR: boardctl(BOARDIOC_OS_SYMTAB) failed: %s\n",
ret); strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
#endif #endif
@ -182,33 +183,18 @@ int main(int argc, FAR char *argv[])
printf("main: Registering romdisk at /dev/ram%d\n", printf("main: Registering romdisk at /dev/ram%d\n",
CONFIG_EXAMPLES_MODULE_DEVMINOR); CONFIG_EXAMPLES_MODULE_DEVMINOR);
#if defined(CONFIG_BUILD_FLAT) desc.minor = CONFIG_EXAMPLES_MODULE_DEVMINOR; /* Minor device number of the ROM disk. */
/* This example violates the portable POSIX interface by calling the OS desc.nsectors = NSECTORS(romfs_img_len); /* The number of sectors in the ROM disk */
* internal function romdisk_register() (aka ramdisk_register()). We can desc.sectsize = SECTORSIZE; /* The size of one sector in bytes */
* squeak by in with this violation in the FLAT build mode, but not in desc.image = (FAR uint8_t *)romfs_img; /* File system image */
* other build modes. In other build modes, the following logic must be
* performed in the OS board initialization logic (where it really belongs
* anyway).
*/
ret = romdisk_register(CONFIG_EXAMPLES_MODULE_DEVMINOR, ret = boardctl(BOARDIOC_ROMDISK, (uintptr_t)&desc);
(FAR uint8_t *)romfs_img,
NSECTORS(romfs_img_len), SECTORSIZE);
if (ret < 0) if (ret < 0)
{ {
/* This will happen naturally if we registered the ROM disk fprintf(stderr, "ERROR: romdisk_register failed: %s\n",
* previously. strerror(errno));
*/ exit(EXIT_FAILURE);
if (ret != -EEXIST)
{
fprintf(stderr, "ERROR: romdisk_register failed: %d\n", ret);
exit(EXIT_FAILURE);
}
printf("main: ROM disk already registered\n");
} }
#endif
/* Mount the file system */ /* Mount the file system */

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* examples/posix_spawn/spawn_main.c * apps/examples/posix_spawn/spawn_main.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -83,12 +83,12 @@
#define NSECTORS(b) (((b)+SECTORSIZE-1)/SECTORSIZE) #define NSECTORS(b) (((b)+SECTORSIZE-1)/SECTORSIZE)
#define MOUNTPT "/mnt/romfs" #define MOUNTPT "/mnt/romfs"
#ifndef CONFIG_EXAMPLES_ELF_DEVMINOR #ifndef CONFIG_EXAMPLES_POSIXSPAWN_DEVMINOR
# define CONFIG_EXAMPLES_ELF_DEVMINOR 0 # define CONFIG_EXAMPLES_POSIXSPAWN_DEVMINOR 0
#endif #endif
#ifndef CONFIG_EXAMPLES_ELF_DEVPATH #ifndef CONFIG_EXAMPLES_POSIXSPAWN_DEVPATH
# define CONFIG_EXAMPLES_ELF_DEVPATH "/dev/ram0" # define CONFIG_EXAMPLES_POSIXSPAWN_DEVPATH "/dev/ram0"
#endif #endif
/* If CONFIG_DEBUG_FEATURES is enabled, use info/err instead of printf so /* If CONFIG_DEBUG_FEATURES is enabled, use info/err instead of printf so
@ -207,6 +207,7 @@ int main(int argc, FAR char *argv[])
FAR const char *filepath; FAR const char *filepath;
pid_t pid; pid_t pid;
int ret; int ret;
struct boardioc_romdisk_s desc;
/* Initialize the memory monitor */ /* Initialize the memory monitor */
@ -214,15 +215,19 @@ int main(int argc, FAR char *argv[])
/* Create a ROM disk for the ROMFS filesystem */ /* Create a ROM disk for the ROMFS filesystem */
message("Registering romdisk at /dev/ram%d\n", desc.minor = CONFIG_EXAMPLES_POSIXSPAWN_DEVMINOR; /* Minor device number of the ROM disk. */
CONFIG_EXAMPLES_ELF_DEVMINOR); desc.nsectors = NSECTORS(romfs_img_len); /* The number of sectors in the ROM disk */
desc.sectsize = SECTORSIZE; /* The size of one sector in bytes */
desc.image = (FAR uint8_t *)romfs_img; /* File system image */
message("Registering romdisk at /dev/ram%d\n",
CONFIG_EXAMPLES_POSIXSPAWN_DEVMINOR);
ret = boardctl(BOARDIOC_ROMDISK, (uintptr_t)&desc);
ret = romdisk_register(CONFIG_EXAMPLES_ELF_DEVMINOR,
(FAR uint8_t *)romfs_img, NSECTORS(romfs_img_len),
SECTORSIZE);
if (ret < 0) if (ret < 0)
{ {
errmsg("ERROR: romdisk_register failed: %d\n", ret); errmsg("ERROR: romdisk_register failed: %s\n", strerror(errno));
exit(1); exit(1);
} }
@ -231,14 +236,14 @@ int main(int argc, FAR char *argv[])
/* Mount the file system */ /* Mount the file system */
message("Mounting ROMFS filesystem at target=%s with source=%s\n", message("Mounting ROMFS filesystem at target=%s with source=%s\n",
MOUNTPT, CONFIG_EXAMPLES_ELF_DEVPATH); MOUNTPT, CONFIG_EXAMPLES_POSIXSPAWN_DEVPATH);
ret = mount(CONFIG_EXAMPLES_ELF_DEVPATH, MOUNTPT, "romfs", ret = mount(CONFIG_EXAMPLES_POSIXSPAWN_DEVPATH, MOUNTPT, "romfs",
MS_RDONLY, NULL); MS_RDONLY, NULL);
if (ret < 0) if (ret < 0)
{ {
errmsg("ERROR: mount(%s,%s,romfs) failed: %d\n", errmsg("ERROR: mount(%s,%s,romfs) failed: %s\n",
CONFIG_EXAMPLES_ELF_DEVPATH, MOUNTPT, errno); CONFIG_EXAMPLES_POSIXSPAWN_DEVPATH, MOUNTPT, strerror(errno));
} }
mm_update(&g_mmstep, "after mount"); mm_update(&g_mmstep, "after mount");

View File

@ -60,6 +60,7 @@
#include <sys/mount.h> #include <sys/mount.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/boardctl.h>
#include <inttypes.h> #include <inttypes.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
@ -474,15 +475,20 @@ static void checkdirectories(struct node_s *entry)
int main(int argc, FAR char *argv[]) int main(int argc, FAR char *argv[])
{ {
int ret; int ret;
struct boardioc_romdisk_s desc;
/* Create a RAM disk for the test */ /* Create a RAM disk for the test */
ret = romdisk_register(CONFIG_EXAMPLES_ROMFS_RAMDEVNO, testdir_img, desc.minor = CONFIG_EXAMPLES_ROMFS_RAMDEVNO; /* Minor device number of the ROM disk. */
NSECTORS(testdir_img_len), desc.nsectors = NSECTORS(testdir_img_len); /* The number of sectors in the ROM disk */
CONFIG_EXAMPLES_ROMFS_SECTORSIZE); desc.sectsize = CONFIG_EXAMPLES_ROMFS_SECTORSIZE; /* The size of one sector in bytes */
desc.image = (FAR uint8_t *)testdir_img; /* File system image */
ret = boardctl(BOARDIOC_ROMDISK, (uintptr_t)&desc);
if (ret < 0) if (ret < 0)
{ {
printf("ERROR: Failed to create RAM disk\n"); printf("ERROR: Failed to create RAM disk: %s\n", strerror(errno));
return 1; return 1;
} }
@ -495,7 +501,7 @@ int main(int argc, FAR char *argv[])
MS_RDONLY, NULL); MS_RDONLY, NULL);
if (ret < 0) if (ret < 0)
{ {
printf("ERROR: Mount failed: %d\n", errno); printf("ERROR: Mount failed: %s\n", strerror(errno));
return 1; return 1;
} }

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* examples/sotest/sotest_main.c * apps/examples/sotest/sotest_main.c
* *
* Copyright (C) 2017 Gregory Nutt. All rights reserved. * Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
@ -41,6 +41,7 @@
#ifdef CONFIG_EXAMPLES_SOTEST_BUILTINFS #ifdef CONFIG_EXAMPLES_SOTEST_BUILTINFS
# include <sys/mount.h> # include <sys/mount.h>
# include <sys/boardctl.h>
#endif #endif
#include <stdio.h> #include <stdio.h>
@ -124,7 +125,9 @@ int main(int argc, FAR char *argv[])
CODE void (*testfunc)(FAR const char *msg); CODE void (*testfunc)(FAR const char *msg);
FAR const char *msg; FAR const char *msg;
int ret; int ret;
#ifdef CONFIG_EXAMPLES_SOTEST_BUILTINFS
struct boardioc_romdisk_s desc;
#endif
/* Set the shared library symbol table */ /* Set the shared library symbol table */
ret = dlsymtab((FAR struct symtab_s *)g_sot_exports, g_sot_nexports); ret = dlsymtab((FAR struct symtab_s *)g_sot_exports, g_sot_nexports);
@ -137,25 +140,21 @@ int main(int argc, FAR char *argv[])
#ifdef CONFIG_EXAMPLES_SOTEST_BUILTINFS #ifdef CONFIG_EXAMPLES_SOTEST_BUILTINFS
/* Create a ROM disk for the ROMFS filesystem */ /* Create a ROM disk for the ROMFS filesystem */
desc.minor = CONFIG_EXAMPLES_SOTEST_DEVMINOR; /* Minor device number of the ROM disk. */
desc.nsectors = NSECTORS(romfs_img_len); /* The number of sectors in the ROM disk */
desc.sectsize = SECTORSIZE; /* The size of one sector in bytes */
desc.image = (FAR uint8_t *)romfs_img; /* File system image */
printf("main: Registering romdisk at /dev/ram%d\n", printf("main: Registering romdisk at /dev/ram%d\n",
CONFIG_EXAMPLES_SOTEST_DEVMINOR); CONFIG_EXAMPLES_SOTEST_DEVMINOR);
ret = romdisk_register(CONFIG_EXAMPLES_SOTEST_DEVMINOR, ret = boardctl(BOARDIOC_ROMDISK, (uintptr_t)&desc);
(FAR uint8_t *)romfs_img,
NSECTORS(romfs_img_len), SECTORSIZE);
if (ret < 0) if (ret < 0)
{ {
/* This will happen naturally if we registered the ROM disk fprintf(stderr, "ERROR: romdisk_register failed: %s\n",
* previously. strerror(errno));
*/ exit(EXIT_FAILURE);
if (ret != -EEXIST)
{
fprintf(stderr, "ERROR: romdisk_register failed: %d\n", ret);
exit(EXIT_FAILURE);
}
printf("main: ROM disk already registered\n");
} }
/* Mount the file system */ /* Mount the file system */

View File

@ -43,6 +43,7 @@
#include <sys/mount.h> #include <sys/mount.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/boardctl.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -128,15 +129,21 @@
int main(int argc, FAR char *argv[]) int main(int argc, FAR char *argv[])
{ {
int ret; int ret;
struct boardioc_romdisk_s desc;
/* Create a RAM disk for file system 1 */ /* Create a RAM disk for file system 1 */
ret = romdisk_register(CONFIG_EXAMPLES_UNIONFS_RAMDEVNO_A, atestdir_img, desc.minor = CONFIG_EXAMPLES_UNIONFS_RAMDEVNO_A; /* Minor device number of the ROM disk. */
NSECTORS(atestdir_img_len), desc.nsectors = NSECTORS(atestdir_img_len); /* The number of sectors in the ROM disk */
CONFIG_EXAMPLES_UNIONFS_SECTORSIZE); desc.sectsize = CONFIG_EXAMPLES_UNIONFS_SECTORSIZE; /* The size of one sector in bytes */
desc.image = (FAR uint8_t *)atestdir_img; /* File system image */
ret = boardctl(BOARDIOC_ROMDISK, (uintptr_t)&desc);
if (ret < 0) if (ret < 0)
{ {
printf("ERROR: Failed to create file system 1 RAM disk\n"); printf("ERROR: Failed to create file system 1 RAM disk: %s\n",
strerror(errno));
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -149,18 +156,22 @@ int main(int argc, FAR char *argv[])
MS_RDONLY, NULL); MS_RDONLY, NULL);
if (ret < 0) if (ret < 0)
{ {
printf("ERROR: File system 1 mount failed: %d\n", errno); printf("ERROR: File system 1 mount failed: %s\n", strerror(errno));
return EXIT_FAILURE; return EXIT_FAILURE;
} }
/* Create a RAM disk for file system 2 */ /* Create a RAM disk for file system 2 */
desc.minor = CONFIG_EXAMPLES_UNIONFS_RAMDEVNO_B; /* Minor device number of the ROM disk. */
desc.nsectors = NSECTORS(btestdir_img_len); /* The number of sectors in the ROM disk */
desc.image = (FAR uint8_t *)btestdir_img; /* File system image */
ret = boardctl(BOARDIOC_ROMDISK, (uintptr_t)&desc);
ret = romdisk_register(CONFIG_EXAMPLES_UNIONFS_RAMDEVNO_B, btestdir_img,
NSECTORS(btestdir_img_len),
CONFIG_EXAMPLES_UNIONFS_SECTORSIZE);
if (ret < 0) if (ret < 0)
{ {
printf("ERROR: Failed to register file system 1: %d\n", ret); printf("ERROR: Failed to create file system 2 RAM disk: %s\n",
strerror(errno));
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -173,7 +184,7 @@ int main(int argc, FAR char *argv[])
MS_RDONLY, NULL); MS_RDONLY, NULL);
if (ret < 0) if (ret < 0)
{ {
printf("ERROR: Failed to register file system 1: %d\n", ret); printf("ERROR: File system 2 mount failed: %s\n", strerror(errno));
return EXIT_FAILURE; return EXIT_FAILURE;
} }