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/sotest/sotest_main.c
* apps/examples/sotest/sotest_main.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@@ -41,6 +41,7 @@
#ifdef CONFIG_EXAMPLES_SOTEST_BUILTINFS
# include <sys/mount.h>
# include <sys/boardctl.h>
#endif
#include <stdio.h>
@@ -124,7 +125,9 @@ int main(int argc, FAR char *argv[])
CODE void (*testfunc)(FAR const char *msg);
FAR const char *msg;
int ret;
#ifdef CONFIG_EXAMPLES_SOTEST_BUILTINFS
struct boardioc_romdisk_s desc;
#endif
/* Set the shared library symbol table */
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
/* 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",
CONFIG_EXAMPLES_SOTEST_DEVMINOR);
ret = romdisk_register(CONFIG_EXAMPLES_SOTEST_DEVMINOR,
(FAR uint8_t *)romfs_img,
NSECTORS(romfs_img_len), SECTORSIZE);
ret = boardctl(BOARDIOC_ROMDISK, (uintptr_t)&desc);
if (ret < 0)
{
/* This will happen naturally if we registered the ROM disk
* previously.
*/
if (ret != -EEXIST)
{
fprintf(stderr, "ERROR: romdisk_register failed: %d\n", ret);
exit(EXIT_FAILURE);
}
printf("main: ROM disk already registered\n");
fprintf(stderr, "ERROR: romdisk_register failed: %s\n",
strerror(errno));
exit(EXIT_FAILURE);
}
/* Mount the file system */