diff --git a/examples/mount/ramdisk.c b/examples/mount/ramdisk.c index 5604e06c1..6e026f070 100644 --- a/examples/mount/ramdisk.c +++ b/examples/mount/ramdisk.c @@ -1,7 +1,7 @@ /**************************************************************************** * examples/mount/ramdisk.c * - * Copyright (C) 2008-2009, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2015, 2019 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -39,6 +39,7 @@ #include +#include #include #include #include @@ -56,15 +57,8 @@ * Private Definitions ****************************************************************************/ -#define BUFFER_SIZE (CONFIG_EXAMPLES_MOUNT_NSECTORS*CONFIG_EXAMPLES_MOUNT_SECTORSIZE) - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ +#define BUFFER_SIZE \ + (CONFIG_EXAMPLES_MOUNT_NSECTORS * CONFIG_EXAMPLES_MOUNT_SECTORSIZE) /**************************************************************************** * Private Data @@ -72,10 +66,6 @@ static struct fat_format_s g_fmt = FAT_FORMAT_INITIALIZER; -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -97,31 +87,21 @@ static struct fat_format_s g_fmt = FAT_FORMAT_INITIALIZER; int create_ramdisk(void) { - FAR char *pbuffer; + struct boardioc_mkrd_s desc; int ret; - /* Allocate a buffer to hold the file system image. */ + /* Create a RAMDISK device to manage */ - pbuffer = (char*)malloc(BUFFER_SIZE); - if (!pbuffer) - { - printf("create_ramdisk: Failed to allocate ramdisk of size %d\n", - BUFFER_SIZE); - return -ENOMEM; - } + desc.minor = CONFIG_EXAMPLES_MOUNT_RAMDEVNO; /* Minor device number of the RAM disk. */ + desc.nsectors = CONFIG_EXAMPLES_MOUNT_NSECTORS; /* The number of sectors in the RAM disk. */ + desc.sectsize = CONFIG_EXAMPLES_MOUNT_SECTORSIZE; /* The size of one sector in bytes. */ + desc.rdflags = RDFLAG_WRENABLED | RDFLAG_FUNLINK; /* See ramdisk.h. */ - /* Register a RAMDISK device to manage this RAM image */ - - ret = ramdisk_register(CONFIG_EXAMPLES_MOUNT_RAMDEVNO, - (FAR uint8_t *)pbuffer, - CONFIG_EXAMPLES_MOUNT_NSECTORS, - CONFIG_EXAMPLES_MOUNT_SECTORSIZE, - RDFLAG_WRENABLED | RDFLAG_FUNLINK); + ret = boardctl(BOARDIOC_MKRD, (uintptr_t)&desc); if (ret < 0) { - printf("create_ramdisk: Failed to register ramdisk at %s: %d\n", + printf("create_ramdisk: Failed to create ramdisk at %s: %d\n", g_source, -ret); - free(pbuffer); return ret; } @@ -132,7 +112,6 @@ int create_ramdisk(void) { printf("create_ramdisk: Failed to create FAT filesystem on ramdisk at %s\n", g_source); - /* free(pbuffer); -- RAM disk is registered */ return ret; } diff --git a/examples/sotest/Kconfig b/examples/sotest/Kconfig index a3298927e..3920c76e3 100644 --- a/examples/sotest/Kconfig +++ b/examples/sotest/Kconfig @@ -31,7 +31,7 @@ config EXAMPLES_SOTEST_BUILTINFS card, for testing on the target. NOTE: This option can only be used in the FLAT build mode because - it makes an illegal OS call to ramdisk_register(). + it makes an illegal OS call to romdisk_register(). if EXAMPLES_SOTEST_BUILTINFS diff --git a/nshlib/nsh_fscmds.c b/nshlib/nsh_fscmds.c index c56ca31b1..190ecdbd5 100644 --- a/nshlib/nsh_fscmds.c +++ b/nshlib/nsh_fscmds.c @@ -1430,7 +1430,8 @@ int cmd_mkrd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) ret = boardctl(BOARDIOC_MKRD, (uintptr_t)&desc); if (ret < 0) { - nsh_error(vtbl, g_fmtcmdfailed, argv[0], "ramdisk_register", NSH_ERRNO_OF(-ret)); + nsh_error(vtbl, g_fmtcmdfailed, argv[0], "boarctl(BOARDIOC_MKRD)", + NSH_ERRNO_OF(-ret)); return ERROR; }