summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-01-16 19:08:23 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-01-16 19:08:23 +0000
commit357d086cf3b85cded5221dab092c917a3fa3c285 (patch)
treef5ccbefcedc52e86e0b48f906c6b2167ec2128d2
parent880aa24ce3cb2bae6decbbdb2650f91a2547ba53 (diff)
downloadnuttx-357d086cf3b85cded5221dab092c917a3fa3c285.tar.gz
nuttx-357d086cf3b85cded5221dab092c917a3fa3c285.tar.bz2
nuttx-357d086cf3b85cded5221dab092c917a3fa3c285.zip
Add a binary 'loader' so that builtin applications can be executed from the BINFS file system
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5525 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--apps/ChangeLog.txt8
-rw-r--r--apps/nshlib/Kconfig2
-rw-r--r--apps/nshlib/nsh_mntcmds.c72
-rw-r--r--apps/nshlib/nsh_parse.c2
-rw-r--r--nuttx/ChangeLog5
-rw-r--r--nuttx/binfmt/builtin.c195
-rw-r--r--nuttx/binfmt/elf.c2
-rw-r--r--nuttx/binfmt/libbuiltin/Make.defs9
-rw-r--r--nuttx/configs/cloudctrl/nsh/defconfig2
-rw-r--r--nuttx/configs/compal_e88/nsh_highram/defconfig2
-rw-r--r--nuttx/configs/compal_e99/nsh_compalram/defconfig2
-rw-r--r--nuttx/configs/compal_e99/nsh_highram/defconfig2
-rw-r--r--nuttx/configs/fire-stm32v2/nsh/defconfig10
-rw-r--r--nuttx/configs/hymini-stm32v/nsh2/defconfig1
-rw-r--r--nuttx/configs/mirtoo/ostest/defconfig2
-rwxr-xr-xnuttx/configs/olimex-lpc1766stk/ftpc/defconfig3
-rwxr-xr-xnuttx/configs/olimex-lpc1766stk/nsh/defconfig1
-rw-r--r--nuttx/configs/olimex-stm32-p107/nsh/defconfig1
-rw-r--r--nuttx/configs/pcblogic-pic32mx/nsh/defconfig1
-rw-r--r--nuttx/configs/pic32-starterkit/nsh/defconfig1
-rw-r--r--nuttx/configs/pic32-starterkit/nsh2/defconfig1
-rw-r--r--nuttx/configs/pic32mx7mmb/nsh/defconfig1
-rwxr-xr-xnuttx/configs/sam3u-ek/touchscreen/defconfig1
-rw-r--r--nuttx/configs/shenzhou/nsh/defconfig2
-rw-r--r--nuttx/configs/shenzhou/nxwm/defconfig2
-rw-r--r--nuttx/configs/shenzhou/thttpd/defconfig2
-rw-r--r--nuttx/configs/sim/nsh/defconfig1
-rw-r--r--nuttx/configs/sim/nsh2/defconfig1
-rw-r--r--nuttx/configs/stm3210e-eval/nsh2/defconfig1
-rw-r--r--nuttx/configs/stm3210e-eval/nxconsole/defconfig1
-rw-r--r--nuttx/configs/stm3210e-eval/pm/defconfig1
-rw-r--r--nuttx/configs/stm3220g-eval/nsh/defconfig1
-rw-r--r--nuttx/configs/stm3220g-eval/nsh2/defconfig1
-rw-r--r--nuttx/configs/stm3220g-eval/ostest/defconfig2
-rw-r--r--nuttx/configs/stm3240g-eval/nsh/defconfig1
-rw-r--r--nuttx/configs/stm3240g-eval/nsh2/defconfig1
-rw-r--r--nuttx/configs/stm3240g-eval/nxconsole/defconfig1
-rw-r--r--nuttx/configs/stm3240g-eval/ostest/defconfig2
-rw-r--r--nuttx/configs/stm3240g-eval/webserver/defconfig2
-rw-r--r--nuttx/configs/stm32f100rc_generic/nsh/defconfig2
-rw-r--r--nuttx/configs/stm32f4discovery/nsh/defconfig1
-rw-r--r--nuttx/configs/stm32f4discovery/pm/defconfig1
-rw-r--r--nuttx/configs/sure-pic32mx/nsh/defconfig1
-rw-r--r--nuttx/configs/sure-pic32mx/usbnsh/defconfig1
-rw-r--r--nuttx/configs/ubw32/nsh/defconfig1
-rwxr-xr-xnuttx/configs/vsn/nsh/defconfig1
-rw-r--r--nuttx/fs/fs_mount.c2
47 files changed, 316 insertions, 42 deletions
diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt
index 6faac9e4b..14eb78950 100644
--- a/apps/ChangeLog.txt
+++ b/apps/ChangeLog.txt
@@ -478,6 +478,10 @@
* apps/include/builtin.h: Some of the content of
apps/include/apps.h moved to include/nuttx/binfmt/builtin.h.
apps/include/apps.h renamed builtin.h
- * pps/builtin/exec_builtins.c: Move utility builtin
+ * apps/builtin/exec_builtins.c: Move utility builtin
utility functions from apps/builtin/exec_builtins.c to
- binfmt/libbuiltin/libbuiltin_utils.c \ No newline at end of file
+ binfmt/libbuiltin/libbuiltin_utils.c
+ * apps/nshlib/nsh_mountcmds.c: The block driver/source
+ argument is now optional. Many files systems do not need
+ a source and it is really stupid to have to enter a bogus
+ source parameter.
diff --git a/apps/nshlib/Kconfig b/apps/nshlib/Kconfig
index 9cfc020a5..e60e9c480 100644
--- a/apps/nshlib/Kconfig
+++ b/apps/nshlib/Kconfig
@@ -15,7 +15,7 @@ if NSH_LIBRARY
config NSH_BUILTIN_APPS
bool "Enable built-in applications"
default y
- select BUILTIN
+ depends on BUILTIN
---help---
Support external registered, "built-in" applications that can be
executed from the NSH command line (see apps/README.txt for
diff --git a/apps/nshlib/nsh_mntcmds.c b/apps/nshlib/nsh_mntcmds.c
index b16ba8465..f8e3a142a 100644
--- a/apps/nshlib/nsh_mntcmds.c
+++ b/apps/nshlib/nsh_mntcmds.c
@@ -133,7 +133,7 @@ static int mount_handler(FAR const char *mountpoint,
#ifdef CONFIG_FS_BINFS
case BINFS_MAGIC:
- fstype = "bindir";
+ fstype = "binfs";
break;
#endif
@@ -198,9 +198,11 @@ int cmd_df(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
defined(CONFIG_FS_READABLE) && !defined(CONFIG_NSH_DISABLE_MOUNT)
int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{
- FAR char *source;
- FAR char *target;
- FAR char *filesystem = NULL;
+ FAR const char *source;
+ FAR char *fullsource;
+ FAR const char *target;
+ FAR char *fulltarget;
+ FAR const char *filesystem = NULL;
bool badarg = false;
int option;
int ret;
@@ -248,19 +250,32 @@ int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
return ERROR;
}
- /* There are two required arguments after the options: the source and target
- * paths.
+ /* There may be one or two required arguments after the options: the source
+ * and target paths. Some file systems do not require the source parameter
+ * so if there is only one parameter left, it must be the target.
*/
- if (optind + 2 < argc)
+ if (optind >= argc)
{
- nsh_output(vtbl, g_fmttoomanyargs, argv[0]);
+ nsh_output(vtbl, g_fmtargrequired, argv[0]);
return ERROR;
}
- else if (optind + 2 > argc)
+
+ source = NULL;
+ target = argv[optind];
+ optind++;
+
+ if (optind < argc)
{
- nsh_output(vtbl, g_fmtargrequired, argv[0]);
- return ERROR;
+ source = target;
+ target = argv[optind];
+ optind++;
+
+ if (optind < argc)
+ {
+ nsh_output(vtbl, g_fmttoomanyargs, argv[0]);
+ return ERROR;
+ }
}
/* While the above parsing for the -t argument looks nice, the -t argument
@@ -277,29 +292,44 @@ int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
* working directory.
*/
- source = nsh_getfullpath(vtbl, argv[optind]);
- if (!source)
+ fullsource = NULL;
+ fulltarget = NULL;
+
+ if (source)
{
- return ERROR;
+ fullsource = nsh_getfullpath(vtbl, source);
+ if (!fullsource)
+ {
+ return ERROR;
+ }
}
- target = nsh_getfullpath(vtbl, argv[optind+1]);
- if (!target)
+ fulltarget = nsh_getfullpath(vtbl, target);
+ if (!fulltarget)
{
- nsh_freefullpath(source);
- return ERROR;
+ ret = ERROR;
+ goto errout;
}
/* Perform the mount */
- ret = mount(source, target, filesystem, 0, NULL);
+ ret = mount(fullsource, fulltarget, filesystem, 0, NULL);
if (ret < 0)
{
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "mount", NSH_ERRNO);
}
- nsh_freefullpath(source);
- nsh_freefullpath(target);
+errout:
+ if (fullsource)
+ {
+ nsh_freefullpath(fullsource);
+ }
+
+ if (fulltarget)
+ {
+ nsh_freefullpath(fulltarget);
+ }
+
return ret;
}
#endif
diff --git a/apps/nshlib/nsh_parse.c b/apps/nshlib/nsh_parse.c
index c36724372..ef4125a63 100644
--- a/apps/nshlib/nsh_parse.c
+++ b/apps/nshlib/nsh_parse.c
@@ -301,7 +301,7 @@ static const struct cmdmap_s g_cmdmap[] =
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_READABLE)
# ifndef CONFIG_NSH_DISABLE_MOUNT
- { "mount", cmd_mount, 1, 5, "[-t <fstype> <block-device> <mount-point>]" },
+ { "mount", cmd_mount, 1, 5, "[-t <fstype> [<block-device>] <mount-point>]" },
# endif
#endif
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 57925a8b3..8d6d81363 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -3961,4 +3961,7 @@
apps/include/apps.h moved to include/nuttx/binfmt/builtin.h
* binfmt/libbuiltin/libbuiltin_utils.c: Move utility builtin
utility functions from apps/builtin/exec_builtins.c to
- binfmt/libbuiltin/libbuiltin_utils.c \ No newline at end of file
+ binfmt/libbuiltin/libbuiltin_utils.c
+ * binfmt/builtin.c and binfmt/libbuiltin: Add a binary "loader"
+ that can be used to execute builtin programs from the BINFS
+ file system.
diff --git a/nuttx/binfmt/builtin.c b/nuttx/binfmt/builtin.c
new file mode 100644
index 000000000..e591ebea8
--- /dev/null
+++ b/nuttx/binfmt/builtin.c
@@ -0,0 +1,195 @@
+/****************************************************************************
+ * binfmt/builtin.c
+ *
+ * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+
+#include <stdint.h>
+#include <string.h>
+#include <fcntl.h>
+#include <debug.h>
+#include <errno.h>
+
+#include <nuttx/fs/ioctl.h>
+#include <nuttx/binfmt/binfmt.h>
+#include <nuttx/binfmt/builtin.h>
+
+#ifdef CONFIG_BUILTIN
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static int builtin_loadbinary(FAR struct binary_s *binp);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct binfmt_s g_builtin_binfmt =
+{
+ NULL, /* next */
+ builtin_loadbinary, /* load */
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: builtin_loadbinary
+ *
+ * Description:
+ * Verify that the file is an builtin binary.
+ *
+ ****************************************************************************/
+
+static int builtin_loadbinary(struct binary_s *binp)
+{
+ FAR const char *filename;
+ int fd;
+ int index;
+ int ret;
+
+ bvdbg("Loading file: %s\n", binp->filename);
+
+ /* Open the binary file for reading (only) */
+
+ fd = open(filename, O_RDONLY);
+ if (fd < 0)
+ {
+ int errval = errno;
+ bdbg("ERROR: Failed to open binary %s: %d\n", filename, errval);
+ return -errval;
+ }
+
+ /* If this file is a BINFS file system, then we can recover the name of
+ * the file using the FIOC_FILENAME ioctl() call.
+ */
+
+ ret = ioctl(fd, FIOC_FILENAME, (unsigned long)((uintptr_t)&filename));
+ if (ret < 0)
+ {
+ int errval = errno;
+ bdbg("ERROR: FIOC_FILENAME ioctl failed: %d\n", errval);
+ return -errval;
+ }
+
+ /* Other file systems may also support FIOC_FILENAME, so the real proof
+ * is that we can look up the index to this name in g_builtins[].
+ */
+
+ index = builtin_isavail(filename);
+ if (index < 0)
+ {
+ int errval = errno;
+ bdbg("ERROR: %s is not a builtin application\n", filename);
+ return -errval;
+
+ }
+
+ /* Return the load information. NOTE: that there is no way to configure
+ * the priority. That is a bug and needs to be fixed.
+ */
+
+ binp->entrypt = g_builtins[index].main;
+ binp->stacksize = g_builtins[index].stacksize;
+ return OK;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: builtin_initialize
+ *
+ * Description:
+ * Builtin support is built unconditionally. However, it order to
+ * use this binary format, this function must be called during system
+ * format in order to register the builtin binary format.
+ *
+ * Returned Value:
+ * This is a NuttX internal function so it follows the convention that
+ * 0 (OK) is returned on success and a negated errno is returned on
+ * failure.
+ *
+ ****************************************************************************/
+
+int builtin_initialize(void)
+{
+ int ret;
+
+ /* Register ourselves as a binfmt loader */
+
+ bvdbg("Registering Builtin Loader\n");
+
+ ret = register_binfmt(&g_builtin_binfmt);
+ if (ret != 0)
+ {
+ bdbg("Failed to register binfmt: %d\n", ret);
+ }
+
+ return ret;
+}
+
+/****************************************************************************
+ * Name: builtin_uninitialize
+ *
+ * Description:
+ * Unregister the builtin binary loader
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void builtin_uninitialize(void)
+{
+ unregister_binfmt(&g_builtin_binfmt);
+}
+
+#endif /* CONFIG_BUILTIN */
+
diff --git a/nuttx/binfmt/elf.c b/nuttx/binfmt/elf.c
index bcebf13ca..9dc59fbdd 100644
--- a/nuttx/binfmt/elf.c
+++ b/nuttx/binfmt/elf.c
@@ -183,7 +183,7 @@ static int elf_loadbinary(struct binary_s *binp)
bvdbg("Loading file: %s\n", binp->filename);
- /* Initialize the xflat library to load the program binary. */
+ /* Initialize the ELF library to load the program binary. */
ret = elf_init(binp->filename, &loadinfo);
elf_dumploadinfo(&loadinfo);
diff --git a/nuttx/binfmt/libbuiltin/Make.defs b/nuttx/binfmt/libbuiltin/Make.defs
index 1d129294c..96e8b6c37 100644
--- a/nuttx/binfmt/libbuiltin/Make.defs
+++ b/nuttx/binfmt/libbuiltin/Make.defs
@@ -33,11 +33,14 @@
#
############################################################################
-# Legacy configurations don't set CONFIG_BUILTIN
-# ifeq ($(CONFIG_BUILTIN),y)
+ifeq ($(CONFIG_BUILTIN),y)
# Builtin application interfaces
+BINFMT_CSRCS += builtin.c
+
+# Builtin library interfaces
+
BINFMT_CSRCS += libbuiltin_utils.c
# Hook the libelf subdirectory into the build
@@ -46,4 +49,4 @@ VPATH += libbuiltin
SUBDIRS += libbuiltin
DEPPATH += --dep-path libbuiltin
-# endif
+endif
diff --git a/nuttx/configs/cloudctrl/nsh/defconfig b/nuttx/configs/cloudctrl/nsh/defconfig
index 8f145d3ab..009d9bdfa 100644
--- a/nuttx/configs/cloudctrl/nsh/defconfig
+++ b/nuttx/configs/cloudctrl/nsh/defconfig
@@ -463,6 +463,7 @@ CONFIG_MM_REGIONS=1
# CONFIG_BINFMT_DISABLE is not set
# CONFIG_NXFLAT is not set
# CONFIG_ELF is not set
+CONFIG_BUILTIN=y
# CONFIG_SYMTAB_ORDEREDBYNAME is not set
#
@@ -505,7 +506,6 @@ CONFIG_HAVE_CXX=y
#
# Named Applications
#
-CONFIG_BUILTIN=y
#
# Examples
diff --git a/nuttx/configs/compal_e88/nsh_highram/defconfig b/nuttx/configs/compal_e88/nsh_highram/defconfig
index a6868e869..7715317b7 100644
--- a/nuttx/configs/compal_e88/nsh_highram/defconfig
+++ b/nuttx/configs/compal_e88/nsh_highram/defconfig
@@ -250,6 +250,8 @@ CONFIG_NSH_NOMAC=y
CONFIG_NSH_IPADDR=0x0a000002
CONFIG_NSH_DRIPADDR=0x0a000001
CONFIG_NSH_NETMASK=0xffffff00
+
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
#
diff --git a/nuttx/configs/compal_e99/nsh_compalram/defconfig b/nuttx/configs/compal_e99/nsh_compalram/defconfig
index 058dc2aa2..8739c6b91 100644
--- a/nuttx/configs/compal_e99/nsh_compalram/defconfig
+++ b/nuttx/configs/compal_e99/nsh_compalram/defconfig
@@ -256,6 +256,8 @@ CONFIG_NSH_NOMAC=y
CONFIG_NSH_IPADDR=0x0a000002
CONFIG_NSH_DRIPADDR=0x0a000001
CONFIG_NSH_NETMASK=0xffffff00
+
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
#
diff --git a/nuttx/configs/compal_e99/nsh_highram/defconfig b/nuttx/configs/compal_e99/nsh_highram/defconfig
index ee1405ca5..9efcd9a81 100644
--- a/nuttx/configs/compal_e99/nsh_highram/defconfig
+++ b/nuttx/configs/compal_e99/nsh_highram/defconfig
@@ -254,6 +254,8 @@ CONFIG_NSH_NOMAC=y
CONFIG_NSH_IPADDR=0x0a000002
CONFIG_NSH_DRIPADDR=0x0a000001
CONFIG_NSH_NETMASK=0xffffff00
+
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
#
diff --git a/nuttx/configs/fire-stm32v2/nsh/defconfig b/nuttx/configs/fire-stm32v2/nsh/defconfig
index 266098496..7a4bc1bed 100644
--- a/nuttx/configs/fire-stm32v2/nsh/defconfig
+++ b/nuttx/configs/fire-stm32v2/nsh/defconfig
@@ -502,6 +502,15 @@ CONFIG_MM_REGIONS=1
# CONFIG_GRAN is not set
#
+# Binary Formats
+#
+# CONFIG_BINFMT_DISABLE is not set
+# CONFIG_NXFLAT is not set
+# CONFIG_ELF is not set
+CONFIG_BUILTIN=y
+# CONFIG_SYMTAB_ORDEREDBYNAME is not set
+
+#
# Library Routines
#
CONFIG_STDIO_BUFFER_SIZE=256
@@ -531,7 +540,6 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512
#
# Named Applications
#
-CONFIG_BUILTIN=y
#
# Examples
diff --git a/nuttx/configs/hymini-stm32v/nsh2/defconfig b/nuttx/configs/hymini-stm32v/nsh2/defconfig
index 7183a8632..61c7fcd69 100644
--- a/nuttx/configs/hymini-stm32v/nsh2/defconfig
+++ b/nuttx/configs/hymini-stm32v/nsh2/defconfig
@@ -447,6 +447,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/configs/mirtoo/ostest/defconfig b/nuttx/configs/mirtoo/ostest/defconfig
index 7c8596dbf..46612d993 100644
--- a/nuttx/configs/mirtoo/ostest/defconfig
+++ b/nuttx/configs/mirtoo/ostest/defconfig
@@ -401,7 +401,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
-CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_BUILTIN_APPS=n
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
CONFIG_NSH_LINELEN=64
diff --git a/nuttx/configs/olimex-lpc1766stk/ftpc/defconfig b/nuttx/configs/olimex-lpc1766stk/ftpc/defconfig
index 15b26899b..a25be53de 100755
--- a/nuttx/configs/olimex-lpc1766stk/ftpc/defconfig
+++ b/nuttx/configs/olimex-lpc1766stk/ftpc/defconfig
@@ -163,7 +163,7 @@ CONFIG_RAW_BINARY=n
#
# General OS setup
#
-CONFIG_USER_ENTRYPOINT="ftpc_main"
+CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_DEBUG=n
CONFIG_DEBUG_VERBOSE=n
CONFIG_DEBUG_SYMBOLS=n
@@ -489,6 +489,7 @@ CONFIG_EXAMPLES_BUTTONS_NAME7="RIGHT"
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/configs/olimex-lpc1766stk/nsh/defconfig b/nuttx/configs/olimex-lpc1766stk/nsh/defconfig
index 8ed82a3ed..c096cdb0e 100755
--- a/nuttx/configs/olimex-lpc1766stk/nsh/defconfig
+++ b/nuttx/configs/olimex-lpc1766stk/nsh/defconfig
@@ -470,6 +470,7 @@ CONFIG_EXAMPLES_BUTTONS_NAME7="RIGHT"
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/configs/olimex-stm32-p107/nsh/defconfig b/nuttx/configs/olimex-stm32-p107/nsh/defconfig
index 09d447e14..1dcb5123a 100644
--- a/nuttx/configs/olimex-stm32-p107/nsh/defconfig
+++ b/nuttx/configs/olimex-stm32-p107/nsh/defconfig
@@ -476,6 +476,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/configs/pcblogic-pic32mx/nsh/defconfig b/nuttx/configs/pcblogic-pic32mx/nsh/defconfig
index fe24cb886..d59e2b7d2 100644
--- a/nuttx/configs/pcblogic-pic32mx/nsh/defconfig
+++ b/nuttx/configs/pcblogic-pic32mx/nsh/defconfig
@@ -398,6 +398,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/configs/pic32-starterkit/nsh/defconfig b/nuttx/configs/pic32-starterkit/nsh/defconfig
index 8bf0432e2..b50dd77fb 100644
--- a/nuttx/configs/pic32-starterkit/nsh/defconfig
+++ b/nuttx/configs/pic32-starterkit/nsh/defconfig
@@ -562,6 +562,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/configs/pic32-starterkit/nsh2/defconfig b/nuttx/configs/pic32-starterkit/nsh2/defconfig
index fb54a2949..2a1be755d 100644
--- a/nuttx/configs/pic32-starterkit/nsh2/defconfig
+++ b/nuttx/configs/pic32-starterkit/nsh2/defconfig
@@ -561,6 +561,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/configs/pic32mx7mmb/nsh/defconfig b/nuttx/configs/pic32mx7mmb/nsh/defconfig
index 62f524ee2..eb4b64e72 100644
--- a/nuttx/configs/pic32mx7mmb/nsh/defconfig
+++ b/nuttx/configs/pic32mx7mmb/nsh/defconfig
@@ -608,6 +608,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/configs/sam3u-ek/touchscreen/defconfig b/nuttx/configs/sam3u-ek/touchscreen/defconfig
index 278c55478..25f808635 100755
--- a/nuttx/configs/sam3u-ek/touchscreen/defconfig
+++ b/nuttx/configs/sam3u-ek/touchscreen/defconfig
@@ -443,6 +443,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/configs/shenzhou/nsh/defconfig b/nuttx/configs/shenzhou/nsh/defconfig
index 383522b6f..d23290e86 100644
--- a/nuttx/configs/shenzhou/nsh/defconfig
+++ b/nuttx/configs/shenzhou/nsh/defconfig
@@ -463,6 +463,7 @@ CONFIG_MM_REGIONS=1
# CONFIG_BINFMT_DISABLE is not set
# CONFIG_NXFLAT is not set
# CONFIG_ELF is not set
+CONFIG_BUILTIN=y
# CONFIG_SYMTAB_ORDEREDBYNAME is not set
#
@@ -505,7 +506,6 @@ CONFIG_HAVE_CXX=y
#
# Named Applications
#
-CONFIG_BUILTIN=y
#
# Examples
diff --git a/nuttx/configs/shenzhou/nxwm/defconfig b/nuttx/configs/shenzhou/nxwm/defconfig
index b9bf72aeb..e13fb72dc 100644
--- a/nuttx/configs/shenzhou/nxwm/defconfig
+++ b/nuttx/configs/shenzhou/nxwm/defconfig
@@ -586,6 +586,7 @@ CONFIG_MM_REGIONS=1
# CONFIG_BINFMT_EXEPATH is not set
# CONFIG_NXFLAT is not set
# CONFIG_ELF is not set
+# CONFIG_BUILTIN is not set
# CONFIG_PIC is not set
# CONFIG_SYMTAB_ORDEREDBYNAME is not set
@@ -630,7 +631,6 @@ CONFIG_HAVE_CXXINITIALIZE=y
#
# Named Applications
#
-CONFIG_BUILTIN=y
#
# Examples
diff --git a/nuttx/configs/shenzhou/thttpd/defconfig b/nuttx/configs/shenzhou/thttpd/defconfig
index d7af34821..05d5fa337 100644
--- a/nuttx/configs/shenzhou/thttpd/defconfig
+++ b/nuttx/configs/shenzhou/thttpd/defconfig
@@ -474,7 +474,6 @@ CONFIG_HAVE_CXX=y
#
# Named Applications
#
-CONFIG_BUILTIN=y
#
# Examples
@@ -835,6 +834,7 @@ CONFIG_NETUTILS_WEBCLIENT=y
# NSH Library
#
CONFIG_NSH_LIBRARY=y
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
#
diff --git a/nuttx/configs/sim/nsh/defconfig b/nuttx/configs/sim/nsh/defconfig
index 146519aa6..3f52dfe69 100644
--- a/nuttx/configs/sim/nsh/defconfig
+++ b/nuttx/configs/sim/nsh/defconfig
@@ -230,6 +230,7 @@ CONFIG_EXAMPLES_OSTEST_STACKSIZE=8192
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=1024
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/configs/sim/nsh2/defconfig b/nuttx/configs/sim/nsh2/defconfig
index b7e31b9e3..bcbe806cc 100644
--- a/nuttx/configs/sim/nsh2/defconfig
+++ b/nuttx/configs/sim/nsh2/defconfig
@@ -274,6 +274,7 @@ CONFIG_EXAMPLES_OSTEST_STACKSIZE=8192
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=1024
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/configs/stm3210e-eval/nsh2/defconfig b/nuttx/configs/stm3210e-eval/nsh2/defconfig
index 063307143..2be2dcefd 100644
--- a/nuttx/configs/stm3210e-eval/nsh2/defconfig
+++ b/nuttx/configs/stm3210e-eval/nsh2/defconfig
@@ -571,6 +571,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/configs/stm3210e-eval/nxconsole/defconfig b/nuttx/configs/stm3210e-eval/nxconsole/defconfig
index 94dbf500f..9e7ed363f 100644
--- a/nuttx/configs/stm3210e-eval/nxconsole/defconfig
+++ b/nuttx/configs/stm3210e-eval/nxconsole/defconfig
@@ -496,6 +496,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/configs/stm3210e-eval/pm/defconfig b/nuttx/configs/stm3210e-eval/pm/defconfig
index c113ddf60..e4a976727 100644
--- a/nuttx/configs/stm3210e-eval/pm/defconfig
+++ b/nuttx/configs/stm3210e-eval/pm/defconfig
@@ -616,6 +616,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/configs/stm3220g-eval/nsh/defconfig b/nuttx/configs/stm3220g-eval/nsh/defconfig
index 8486c4fd6..71a03d212 100644
--- a/nuttx/configs/stm3220g-eval/nsh/defconfig
+++ b/nuttx/configs/stm3220g-eval/nsh/defconfig
@@ -672,6 +672,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/configs/stm3220g-eval/nsh2/defconfig b/nuttx/configs/stm3220g-eval/nsh2/defconfig
index bc641b8be..84950645b 100644
--- a/nuttx/configs/stm3220g-eval/nsh2/defconfig
+++ b/nuttx/configs/stm3220g-eval/nsh2/defconfig
@@ -659,6 +659,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/configs/stm3220g-eval/ostest/defconfig b/nuttx/configs/stm3220g-eval/ostest/defconfig
index 3ec417516..f03f67cbd 100644
--- a/nuttx/configs/stm3220g-eval/ostest/defconfig
+++ b/nuttx/configs/stm3220g-eval/ostest/defconfig
@@ -562,7 +562,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
-CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_BUILTIN_APPS=n
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
CONFIG_NSH_LINELEN=64
diff --git a/nuttx/configs/stm3240g-eval/nsh/defconfig b/nuttx/configs/stm3240g-eval/nsh/defconfig
index 82caf1622..efc60cd2f 100644
--- a/nuttx/configs/stm3240g-eval/nsh/defconfig
+++ b/nuttx/configs/stm3240g-eval/nsh/defconfig
@@ -672,6 +672,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/configs/stm3240g-eval/nsh2/defconfig b/nuttx/configs/stm3240g-eval/nsh2/defconfig
index 9e7d57ade..122910e4e 100644
--- a/nuttx/configs/stm3240g-eval/nsh2/defconfig
+++ b/nuttx/configs/stm3240g-eval/nsh2/defconfig
@@ -619,6 +619,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/configs/stm3240g-eval/nxconsole/defconfig b/nuttx/configs/stm3240g-eval/nxconsole/defconfig
index 92c3ceb75..bd8be9f5d 100644
--- a/nuttx/configs/stm3240g-eval/nxconsole/defconfig
+++ b/nuttx/configs/stm3240g-eval/nxconsole/defconfig
@@ -642,6 +642,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/configs/stm3240g-eval/ostest/defconfig b/nuttx/configs/stm3240g-eval/ostest/defconfig
index f9e690a10..f7eb4ef95 100644
--- a/nuttx/configs/stm3240g-eval/ostest/defconfig
+++ b/nuttx/configs/stm3240g-eval/ostest/defconfig
@@ -574,7 +574,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
-CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_BUILTIN_APPS=n
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
CONFIG_NSH_LINELEN=64
diff --git a/nuttx/configs/stm3240g-eval/webserver/defconfig b/nuttx/configs/stm3240g-eval/webserver/defconfig
index 792eafa0a..6b4d47e53 100644
--- a/nuttx/configs/stm3240g-eval/webserver/defconfig
+++ b/nuttx/configs/stm3240g-eval/webserver/defconfig
@@ -673,7 +673,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
-CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_BUILTIN_APPS=n
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
CONFIG_NSH_LINELEN=64
diff --git a/nuttx/configs/stm32f100rc_generic/nsh/defconfig b/nuttx/configs/stm32f100rc_generic/nsh/defconfig
index 12193e7ed..aea79ff3f 100644
--- a/nuttx/configs/stm32f100rc_generic/nsh/defconfig
+++ b/nuttx/configs/stm32f100rc_generic/nsh/defconfig
@@ -393,6 +393,7 @@ CONFIG_MM_REGIONS=1
# CONFIG_BINFMT_DISABLE is not set
# CONFIG_NXFLAT is not set
# CONFIG_ELF is not set
+CONFIG_BUILTIN=y
CONFIG_SYMTAB_ORDEREDBYNAME=y
#
@@ -428,7 +429,6 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512
#
# Named Applications
#
-CONFIG_BUILTIN=y
#
# Examples
diff --git a/nuttx/configs/stm32f4discovery/nsh/defconfig b/nuttx/configs/stm32f4discovery/nsh/defconfig
index d9917b3a8..3ec117055 100644
--- a/nuttx/configs/stm32f4discovery/nsh/defconfig
+++ b/nuttx/configs/stm32f4discovery/nsh/defconfig
@@ -603,6 +603,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/configs/stm32f4discovery/pm/defconfig b/nuttx/configs/stm32f4discovery/pm/defconfig
index 1636f6ecb..332235050 100644
--- a/nuttx/configs/stm32f4discovery/pm/defconfig
+++ b/nuttx/configs/stm32f4discovery/pm/defconfig
@@ -622,6 +622,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/configs/sure-pic32mx/nsh/defconfig b/nuttx/configs/sure-pic32mx/nsh/defconfig
index d15bac1f4..a5977733c 100644
--- a/nuttx/configs/sure-pic32mx/nsh/defconfig
+++ b/nuttx/configs/sure-pic32mx/nsh/defconfig
@@ -434,6 +434,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/configs/sure-pic32mx/usbnsh/defconfig b/nuttx/configs/sure-pic32mx/usbnsh/defconfig
index 3ebfde834..3ab4563e9 100644
--- a/nuttx/configs/sure-pic32mx/usbnsh/defconfig
+++ b/nuttx/configs/sure-pic32mx/usbnsh/defconfig
@@ -431,6 +431,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/configs/ubw32/nsh/defconfig b/nuttx/configs/ubw32/nsh/defconfig
index 8769fa677..c9718ca8d 100644
--- a/nuttx/configs/ubw32/nsh/defconfig
+++ b/nuttx/configs/ubw32/nsh/defconfig
@@ -421,6 +421,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/configs/vsn/nsh/defconfig b/nuttx/configs/vsn/nsh/defconfig
index 5ec7e06eb..88d14aba6 100755
--- a/nuttx/configs/vsn/nsh/defconfig
+++ b/nuttx/configs/vsn/nsh/defconfig
@@ -459,6 +459,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
#
# Settings for apps/nshlib
#
+CONFIG_BUILTIN=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_STRERROR=n
diff --git a/nuttx/fs/fs_mount.c b/nuttx/fs/fs_mount.c
index 1b3da8dc3..a91e7d366 100644
--- a/nuttx/fs/fs_mount.c
+++ b/nuttx/fs/fs_mount.c
@@ -221,7 +221,7 @@ int mount(FAR const char *source, FAR const char *target,
/* Find the specified filesystem. Try the block driver file systems first */
#ifdef BDFS_SUPPORT
- if ((mops = mount_findfs(g_bdfsmap, filesystemtype)) != NULL)
+ if (source && (mops = mount_findfs(g_bdfsmap, filesystemtype)) != NULL)
{
/* Make sure that a block driver argument was provided */