nshlib: move etc romfs mount from nsh to nuttx
This commit corresponds to apache/nuttx#11498 in nuttx. Move etc romfs mount to sched/init for compatibility with kernel/protected mode. changes: - move etc romfs mount from nsh to Nuttx, but keep the script to parse and execute. - move and rename the related CONFIG, move customized nsh_romfsimg.h to etc_romfs.c in boards, and no need declaration for romfs_img/romfs_img_len. Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
This commit is contained in:
parent
c4e78cd10a
commit
385f707382
@ -60,10 +60,6 @@ if(CONFIG_NSH_LIBRARY)
|
|||||||
list(APPEND CSRCS nsh_vars.c)
|
list(APPEND CSRCS nsh_vars.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_NSH_ROMFSETC)
|
|
||||||
list(APPEND CSRCS nsh_romfsetc.c)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CONFIG_NET)
|
if(CONFIG_NET)
|
||||||
list(APPEND CSRCS nsh_netcmds.c)
|
list(APPEND CSRCS nsh_netcmds.c)
|
||||||
|
|
||||||
|
130
nshlib/Kconfig
130
nshlib/Kconfig
@ -9,9 +9,8 @@ config NSH_LIBRARY
|
|||||||
bool "NSH Library"
|
bool "NSH Library"
|
||||||
default n
|
default n
|
||||||
select NETUTILS_NETLIB if NET
|
select NETUTILS_NETLIB if NET
|
||||||
select BOARDCTL if (!NSH_DISABLE_MKRD && !DISABLE_MOUNTPOINT) || NSH_ARCHINIT || NSH_ROMFSETC
|
select BOARDCTL if (!NSH_DISABLE_MKRD && !DISABLE_MOUNTPOINT) || NSH_ARCHINIT
|
||||||
select BOARDCTL_MKRD if !NSH_DISABLE_MKRD && !DISABLE_MOUNTPOINT
|
select BOARDCTL_MKRD if !NSH_DISABLE_MKRD && !DISABLE_MOUNTPOINT
|
||||||
select BOARDCTL_ROMDISK if NSH_ROMFSETC
|
|
||||||
---help---
|
---help---
|
||||||
Build the NSH support library. This is used, for example, by
|
Build the NSH support library. This is used, for example, by
|
||||||
system/nsh in order to implement the full NuttShell (NSH).
|
system/nsh in order to implement the full NuttShell (NSH).
|
||||||
@ -793,29 +792,6 @@ config NSH_DISABLE_LOOPS
|
|||||||
systems where some minimal scripting is required but looping
|
systems where some minimal scripting is required but looping
|
||||||
is not.
|
is not.
|
||||||
|
|
||||||
endif # !NSH_DISABLESCRIPT
|
|
||||||
|
|
||||||
config NSH_ROMFSETC
|
|
||||||
bool "Support ROMFS start-up script"
|
|
||||||
default n
|
|
||||||
depends on FS_ROMFS
|
|
||||||
---help---
|
|
||||||
Mount a ROMFS filesystem at /etc and provide a system init
|
|
||||||
script at /etc/init.d/rc.sysinit and a startup script
|
|
||||||
at /etc/init.d/rcS. The default system init script will mount
|
|
||||||
a FAT FS RAMDISK at /tmp but the logic is easily extensible.
|
|
||||||
|
|
||||||
if NSH_ROMFSETC
|
|
||||||
|
|
||||||
config NSH_CROMFSETC
|
|
||||||
bool "Support CROMFS (compressed) start-up script"
|
|
||||||
default n
|
|
||||||
depends on FS_CROMFS
|
|
||||||
---help---
|
|
||||||
Mount a CROMFS filesystem at /etc and provide a compressed system
|
|
||||||
init script at /etc/init.d/rc.sysinit and a startup script
|
|
||||||
at /etc/init.d/rcS.
|
|
||||||
|
|
||||||
config NSH_ROMFSRC
|
config NSH_ROMFSRC
|
||||||
bool "Support ROMFS login script"
|
bool "Support ROMFS login script"
|
||||||
default n
|
default n
|
||||||
@ -828,14 +804,6 @@ config NSH_ROMFSRC
|
|||||||
session. Selecting this option enables support for such a login
|
session. Selecting this option enables support for such a login
|
||||||
script
|
script
|
||||||
|
|
||||||
config NSH_ROMFSMOUNTPT
|
|
||||||
string "ROMFS mount point"
|
|
||||||
default "/etc"
|
|
||||||
---help---
|
|
||||||
The default mountpoint for the ROMFS volume is /etc, but that
|
|
||||||
can be changed with this setting. This must be a absolute path
|
|
||||||
beginning with '/'.
|
|
||||||
|
|
||||||
config NSH_SYSINITSCRIPT
|
config NSH_SYSINITSCRIPT
|
||||||
string "Relative path to sysinit script"
|
string "Relative path to sysinit script"
|
||||||
default "init.d/rc.sysinit"
|
default "init.d/rc.sysinit"
|
||||||
@ -861,106 +829,14 @@ config NSH_RCSCRIPT
|
|||||||
The default is .nshrc. This is a relative path and must not
|
The default is .nshrc. This is a relative path and must not
|
||||||
start with '/'.
|
start with '/'.
|
||||||
|
|
||||||
config NSH_ROMFSDEVNO
|
|
||||||
int "ROMFS block device minor number"
|
|
||||||
default 0
|
|
||||||
---help---
|
|
||||||
This is the minor number of the ROMFS block device. The default is
|
|
||||||
'0' corresponding to /dev/ram0.
|
|
||||||
|
|
||||||
config NSH_ROMFSSECTSIZE
|
|
||||||
int "ROMFS sector size"
|
|
||||||
default 64
|
|
||||||
---help---
|
|
||||||
This is the sector size to use with the ROMFS volume. Since the
|
|
||||||
default volume is very small, this defaults to 64 but should be
|
|
||||||
increased if the ROMFS volume were to be become large. Any value
|
|
||||||
selected must be a power of 2.
|
|
||||||
|
|
||||||
choice
|
|
||||||
prompt "ROMFS header location"
|
|
||||||
default NSH_DEFAULTROMFS
|
|
||||||
|
|
||||||
config NSH_DEFAULTROMFS
|
|
||||||
bool "Default ROMFS header path"
|
|
||||||
---help---
|
|
||||||
Selects the default header located in the source directory of the
|
|
||||||
NSH library.
|
|
||||||
|
|
||||||
config NSH_ARCHROMFS
|
|
||||||
bool "Architecture-specific ROMFS path"
|
|
||||||
---help---
|
|
||||||
Enable this option to provide an architecture-specific ROMFS
|
|
||||||
header at arch/<boardname>/nsh_romfsimg.h. Note that this header
|
|
||||||
will be linked (or copied) from nuttx/boards/<arch>/<chip>/<board>/include
|
|
||||||
and should be stored at that location in the nuttx boards/
|
|
||||||
sub-directory.
|
|
||||||
|
|
||||||
config NSH_CUSTOMROMFS
|
|
||||||
bool "Custom ROMFS header path"
|
|
||||||
---help---
|
|
||||||
Enable this option to provide a custom ROMFS header. The path to
|
|
||||||
the header file can be specified in the option "Custom ROMFS header
|
|
||||||
file".
|
|
||||||
|
|
||||||
endchoice
|
|
||||||
|
|
||||||
if NSH_CUSTOMROMFS
|
|
||||||
|
|
||||||
config NSH_CUSTOMROMFS_HEADER
|
|
||||||
string "Custom ROMFS header file path"
|
|
||||||
default ""
|
|
||||||
---help---
|
|
||||||
Specifies the path to the custom ROMFS header file. This must be
|
|
||||||
either a full path or a path relative to one of the include file
|
|
||||||
search paths provided in your CFLAGS.
|
|
||||||
|
|
||||||
endif #NSH_CUSTOMROMFS
|
|
||||||
|
|
||||||
config NSH_FATDEVNO
|
|
||||||
int "FAT block device minor number"
|
|
||||||
default 1
|
|
||||||
depends on FS_FAT
|
|
||||||
---help---
|
|
||||||
When the default rcS file used when NSH_ROMFSETC is selected, it
|
|
||||||
will mount a FAT FS under /tmp. This is the minor number of the FAT
|
|
||||||
FS block device. The default is '1' corresponding to /dev/ram1.
|
|
||||||
|
|
||||||
config NSH_FATSECTSIZE
|
|
||||||
int "FAT sector size"
|
|
||||||
default 512
|
|
||||||
depends on FS_FAT
|
|
||||||
---help---
|
|
||||||
When the default rcS file used when NSH_ROMFSETC is selected, it
|
|
||||||
will mount a FAT FS under /tmp. This is the sector size use with the
|
|
||||||
FAT FS. Default is 512.
|
|
||||||
|
|
||||||
config NSH_FATNSECTORS
|
|
||||||
int "FAT number of sectors"
|
|
||||||
default 1024
|
|
||||||
depends on FS_FAT
|
|
||||||
---help---
|
|
||||||
When the default rcS file used when NSH_ROMFSETC is selected, it
|
|
||||||
will mount a FAT FS under /tmp. This is the number of sectors to use
|
|
||||||
with the FAT FS. Default is 1024. The amount of memory used by the
|
|
||||||
FAT FS will be NSH_FATSECTSIZE * NSH_FATNSECTORS bytes.
|
|
||||||
|
|
||||||
config NSH_FATMOUNTPT
|
|
||||||
string "FAT mount point"
|
|
||||||
default "/tmp"
|
|
||||||
depends on FS_FAT
|
|
||||||
---help---
|
|
||||||
When the default rcS file used when NSH_ROMFSETC is selected, it
|
|
||||||
will mount a FAT FS under /tmp. This is the location where the FAT
|
|
||||||
FS will be mounted. Default is "/tmp".
|
|
||||||
|
|
||||||
config NSH_SCRIPT_REDIRECT_PATH
|
config NSH_SCRIPT_REDIRECT_PATH
|
||||||
string "rcS redirect output"
|
string "rcS redirect output"
|
||||||
default ""
|
default ""
|
||||||
---help---
|
---help---
|
||||||
This option can redirect rcS output.such as /dev/log or other.
|
This option can redirect rcS output.such as /dev/log or other.
|
||||||
|
|
||||||
endif # NSH_ROMFSETC
|
endif # !NSH_DISABLESCRIPT
|
||||||
|
|
||||||
endmenu # Scripting Support
|
endmenu # Scripting Support
|
||||||
|
|
||||||
menu "Console Configuration"
|
menu "Console Configuration"
|
||||||
|
@ -45,10 +45,6 @@ ifeq ($(CONFIG_NSH_VARS),y)
|
|||||||
CSRCS += nsh_vars.c
|
CSRCS += nsh_vars.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_NSH_ROMFSETC),y)
|
|
||||||
CSRCS += nsh_romfsetc.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_NET),y)
|
ifeq ($(CONFIG_NET),y)
|
||||||
CSRCS += nsh_netcmds.c
|
CSRCS += nsh_netcmds.c
|
||||||
|
|
||||||
|
45
nshlib/nsh.h
45
nshlib/nsh.h
@ -287,20 +287,7 @@
|
|||||||
|
|
||||||
/* Verify support for ROMFS /etc directory support options */
|
/* Verify support for ROMFS /etc directory support options */
|
||||||
|
|
||||||
#ifdef CONFIG_NSH_ROMFSETC
|
#ifdef CONFIG_ETC_ROMFS
|
||||||
# ifdef CONFIG_DISABLE_MOUNTPOINT
|
|
||||||
# error "Mountpoint support is disabled"
|
|
||||||
# undef CONFIG_NSH_ROMFSETC
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef CONFIG_FS_ROMFS
|
|
||||||
# error "ROMFS support not enabled"
|
|
||||||
# undef CONFIG_NSH_ROMFSETC
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef CONFIG_NSH_ROMFSMOUNTPT
|
|
||||||
# define CONFIG_NSH_ROMFSMOUNTPT "/etc"
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef CONFIG_NSH_SYSINITSCRIPT
|
# ifndef CONFIG_NSH_SYSINITSCRIPT
|
||||||
# define CONFIG_NSH_SYSINITSCRIPT "init.d/rc.sysinit"
|
# define CONFIG_NSH_SYSINITSCRIPT "init.d/rc.sysinit"
|
||||||
@ -311,10 +298,10 @@
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
# undef NSH_SYSINITPATH
|
# undef NSH_SYSINITPATH
|
||||||
# define NSH_SYSINITPATH CONFIG_NSH_ROMFSMOUNTPT "/" CONFIG_NSH_SYSINITSCRIPT
|
# define NSH_SYSINITPATH CONFIG_ETC_ROMFSMOUNTPT "/" CONFIG_NSH_SYSINITSCRIPT
|
||||||
|
|
||||||
# undef NSH_INITPATH
|
# undef NSH_INITPATH
|
||||||
# define NSH_INITPATH CONFIG_NSH_ROMFSMOUNTPT "/" CONFIG_NSH_INITSCRIPT
|
# define NSH_INITPATH CONFIG_ETC_ROMFSMOUNTPT "/" CONFIG_NSH_INITSCRIPT
|
||||||
|
|
||||||
# ifdef CONFIG_NSH_ROMFSRC
|
# ifdef CONFIG_NSH_ROMFSRC
|
||||||
# ifndef CONFIG_NSH_RCSCRIPT
|
# ifndef CONFIG_NSH_RCSCRIPT
|
||||||
@ -322,30 +309,14 @@
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
# undef NSH_RCPATH
|
# undef NSH_RCPATH
|
||||||
# define NSH_RCPATH CONFIG_NSH_ROMFSMOUNTPT "/" CONFIG_NSH_RCSCRIPT
|
# define NSH_RCPATH CONFIG_ETC_ROMFSMOUNTPT "/" CONFIG_NSH_RCSCRIPT
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifndef CONFIG_NSH_ROMFSDEVNO
|
|
||||||
# define CONFIG_NSH_ROMFSDEVNO 0
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef CONFIG_NSH_ROMFSSECTSIZE
|
|
||||||
# define CONFIG_NSH_ROMFSSECTSIZE 64
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# define NSECTORS(b) (((b)+CONFIG_NSH_ROMFSSECTSIZE-1)/CONFIG_NSH_ROMFSSECTSIZE)
|
|
||||||
# define STR_RAMDEVNO(m) #m
|
|
||||||
# define MKMOUNT_DEVNAME(m) "/dev/ram" STR_RAMDEVNO(m)
|
|
||||||
# define MOUNT_DEVNAME MKMOUNT_DEVNAME(CONFIG_NSH_ROMFSDEVNO)
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
# undef CONFIG_NSH_ROMFSRC
|
# undef CONFIG_NSH_ROMFSRC
|
||||||
# undef CONFIG_NSH_ROMFSMOUNTPT
|
|
||||||
# undef CONFIG_NSH_INITSCRIPT
|
# undef CONFIG_NSH_INITSCRIPT
|
||||||
# undef CONFIG_NSH_RCSCRIPT
|
# undef CONFIG_NSH_RCSCRIPT
|
||||||
# undef CONFIG_NSH_ROMFSDEVNO
|
|
||||||
# undef CONFIG_NSH_ROMFSSECTSIZE
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -804,12 +775,6 @@ extern "C"
|
|||||||
|
|
||||||
/* Initialization */
|
/* Initialization */
|
||||||
|
|
||||||
#ifdef CONFIG_NSH_ROMFSETC
|
|
||||||
int nsh_romfsetc(void);
|
|
||||||
#else
|
|
||||||
# define nsh_romfsetc() (-ENOSYS)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_USB_CONSOLE
|
#ifdef HAVE_USB_CONSOLE
|
||||||
int nsh_usbconsole(void);
|
int nsh_usbconsole(void);
|
||||||
#else
|
#else
|
||||||
@ -826,7 +791,7 @@ void nsh_aliasfree(FAR struct nsh_vtbl_s *vtbl,
|
|||||||
#ifndef CONFIG_NSH_DISABLESCRIPT
|
#ifndef CONFIG_NSH_DISABLESCRIPT
|
||||||
int nsh_script(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
|
int nsh_script(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
|
||||||
FAR const char *path, bool log);
|
FAR const char *path, bool log);
|
||||||
#ifdef CONFIG_NSH_ROMFSETC
|
#ifdef CONFIG_ETC_ROMFS
|
||||||
int nsh_sysinitscript(FAR struct nsh_vtbl_s *vtbl);
|
int nsh_sysinitscript(FAR struct nsh_vtbl_s *vtbl);
|
||||||
int nsh_initscript(FAR struct nsh_vtbl_s *vtbl);
|
int nsh_initscript(FAR struct nsh_vtbl_s *vtbl);
|
||||||
#ifdef CONFIG_NSH_ROMFSRC
|
#ifdef CONFIG_NSH_ROMFSRC
|
||||||
|
@ -106,7 +106,7 @@ void nsh_initialize(void)
|
|||||||
#if defined (CONFIG_NSH_SYMTAB)
|
#if defined (CONFIG_NSH_SYMTAB)
|
||||||
struct boardioc_symtab_s symdesc;
|
struct boardioc_symtab_s symdesc;
|
||||||
#endif
|
#endif
|
||||||
#if defined(CONFIG_NSH_ROMFSETC) && !defined(CONFIG_NSH_DISABLESCRIPT)
|
#if defined(CONFIG_ETC_ROMFS) && !defined(CONFIG_NSH_DISABLESCRIPT)
|
||||||
FAR struct console_stdio_s *pstate;
|
FAR struct console_stdio_s *pstate;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -122,10 +122,6 @@ void nsh_initialize(void)
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Mount the /etc filesystem */
|
|
||||||
|
|
||||||
(void)nsh_romfsetc();
|
|
||||||
|
|
||||||
#ifdef CONFIG_NSH_USBDEV_TRACE
|
#ifdef CONFIG_NSH_USBDEV_TRACE
|
||||||
/* Initialize any USB tracing options that were requested */
|
/* Initialize any USB tracing options that were requested */
|
||||||
|
|
||||||
@ -147,7 +143,7 @@ void nsh_initialize(void)
|
|||||||
boardctl(BOARDIOC_INIT, 0);
|
boardctl(BOARDIOC_INIT, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_NSH_ROMFSETC) && !defined(CONFIG_NSH_DISABLESCRIPT)
|
#if defined(CONFIG_ETC_ROMFS) && !defined(CONFIG_NSH_DISABLESCRIPT)
|
||||||
pstate = nsh_newconsole(false);
|
pstate = nsh_newconsole(false);
|
||||||
|
|
||||||
/* Execute the system init script */
|
/* Execute the system init script */
|
||||||
@ -167,7 +163,7 @@ void nsh_initialize(void)
|
|||||||
boardctl(BOARDIOC_FINALINIT, 0);
|
boardctl(BOARDIOC_FINALINIT, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_NSH_ROMFSETC) && !defined(CONFIG_NSH_DISABLESCRIPT)
|
#if defined(CONFIG_ETC_ROMFS) && !defined(CONFIG_NSH_DISABLESCRIPT)
|
||||||
/* Execute the start-up script */
|
/* Execute the start-up script */
|
||||||
|
|
||||||
nsh_initscript(&pstate->cn_vtbl);
|
nsh_initscript(&pstate->cn_vtbl);
|
||||||
|
@ -1,123 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* apps/nshlib/nsh_romfsetc.c
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership. The
|
|
||||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance with the
|
|
||||||
* License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <sys/mount.h>
|
|
||||||
#include <sys/boardctl.h>
|
|
||||||
#include <debug.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <nuttx/drivers/ramdisk.h>
|
|
||||||
|
|
||||||
#include "nsh.h"
|
|
||||||
|
|
||||||
#ifdef CONFIG_NSH_ROMFSETC
|
|
||||||
|
|
||||||
/* Should we use the default ROMFS image? Or a custom, board-specific
|
|
||||||
* ROMFS image?
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef CONFIG_NSH_ARCHROMFS
|
|
||||||
# include <arch/board/nsh_romfsimg.h>
|
|
||||||
#elif defined(CONFIG_NSH_CUSTOMROMFS)
|
|
||||||
# include CONFIG_NSH_CUSTOMROMFS_HEADER
|
|
||||||
#else /* if defined(CONFIG_NSH_DEFAULTROMFS) */
|
|
||||||
# include "nsh_romfsimg.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_DISABLE_MOUNTPOINT
|
|
||||||
# error You must not disable mountpoints via CONFIG_DISABLE_MOUNTPOINT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_NSH_CROMFSETC)
|
|
||||||
# ifndef CONFIG_FS_CROMFS
|
|
||||||
# error You must select CONFIG_FS_CROMFS in your configuration file
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
# ifndef CONFIG_FS_ROMFS
|
|
||||||
# error You must select CONFIG_FS_ROMFS in your configuration file
|
|
||||||
# endif
|
|
||||||
# ifndef CONFIG_BOARDCTL_ROMDISK
|
|
||||||
# error You must select CONFIG_BOARDCTL_ROMDISK in your configuration file
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: nsh_romfsetc
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int nsh_romfsetc(void)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
#ifndef CONFIG_NSH_CROMFSETC
|
|
||||||
struct boardioc_romdisk_s desc;
|
|
||||||
|
|
||||||
/* Create a ROM disk for the /etc filesystem */
|
|
||||||
|
|
||||||
desc.minor = CONFIG_NSH_ROMFSDEVNO; /* Minor device number of the RAM disk. */
|
|
||||||
desc.nsectors = NSECTORS(romfs_img_len); /* The number of sectors in the RAM disk */
|
|
||||||
desc.sectsize = CONFIG_NSH_ROMFSSECTSIZE; /* The size of one sector in bytes */
|
|
||||||
desc.image = romfs_img; /* File system image */
|
|
||||||
|
|
||||||
ret = boardctl(BOARDIOC_ROMDISK, (uintptr_t)&desc);
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
ferr("ERROR: boardctl(BOARDIOC_ROMDISK) failed: %d\n", -ret);
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Mount the file system */
|
|
||||||
|
|
||||||
finfo("Mounting ROMFS filesystem at target=%s with source=%s\n",
|
|
||||||
CONFIG_NSH_ROMFSMOUNTPT, MOUNT_DEVNAME);
|
|
||||||
|
|
||||||
#if defined(CONFIG_NSH_CROMFSETC)
|
|
||||||
ret = mount(MOUNT_DEVNAME, CONFIG_NSH_ROMFSMOUNTPT, "cromfs", MS_RDONLY,
|
|
||||||
NULL);
|
|
||||||
#else
|
|
||||||
ret = mount(MOUNT_DEVNAME, CONFIG_NSH_ROMFSMOUNTPT, "romfs", MS_RDONLY,
|
|
||||||
NULL);
|
|
||||||
#endif
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
ferr("ERROR: mount(%s,%s,romfs) failed: %d\n",
|
|
||||||
MOUNT_DEVNAME, CONFIG_NSH_ROMFSMOUNTPT, errno);
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* CONFIG_NSH_ROMFSETC */
|
|
@ -1,111 +0,0 @@
|
|||||||
/***************************************************************************
|
|
||||||
* apps/nshlib/nsh_romfsimg.h
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership. The
|
|
||||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance with the
|
|
||||||
* License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
const unsigned char romfs_img[] =
|
|
||||||
{
|
|
||||||
0x2d, 0x72, 0x6f, 0x6d, 0x31, 0x66, 0x73, 0x2d, 0x00, 0x00, 0x01, 0x50,
|
|
||||||
0x9f, 0x13, 0x82, 0x87, 0x4e, 0x53, 0x48, 0x49, 0x6e, 0x69, 0x74, 0x56,
|
|
||||||
0x6f, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49,
|
|
||||||
0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0xd1, 0xff, 0xff, 0x97,
|
|
||||||
0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x20,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0xd1, 0xd1, 0xff, 0x80, 0x2e, 0x2e, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x68, 0x2d, 0x96, 0x03, 0x69, 0x6e, 0x69, 0x74, 0x2e, 0x64, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0,
|
|
||||||
0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0xd1, 0xff, 0xff, 0x00,
|
|
||||||
0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x3a, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x6e, 0x8d, 0x9c, 0xab, 0x58, 0x72, 0x63, 0x53, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x23, 0x20, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x20, 0x61, 0x20, 0x52,
|
|
||||||
0x41, 0x4d, 0x44, 0x49, 0x53, 0x4b, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x6d,
|
|
||||||
0x6f, 0x75, 0x6e, 0x74, 0x20, 0x69, 0x74, 0x20, 0x61, 0x74, 0x20, 0x2f,
|
|
||||||
0x74, 0x6d, 0x70, 0x0a, 0x0a, 0x6d, 0x6b, 0x72, 0x64, 0x20, 0x2d, 0x6d,
|
|
||||||
0x20, 0x32, 0x20, 0x2d, 0x73, 0x20, 0x35, 0x31, 0x32, 0x20, 0x31, 0x30,
|
|
||||||
0x32, 0x34, 0x0a, 0x6d, 0x6b, 0x66, 0x61, 0x74, 0x66, 0x73, 0x20, 0x2f,
|
|
||||||
0x64, 0x65, 0x76, 0x2f, 0x72, 0x61, 0x6d, 0x32, 0x0a, 0x6d, 0x6f, 0x75,
|
|
||||||
0x6e, 0x74, 0x20, 0x2d, 0x74, 0x20, 0x76, 0x66, 0x61, 0x74, 0x20, 0x2f,
|
|
||||||
0x64, 0x65, 0x76, 0x2f, 0x72, 0x61, 0x6d, 0x32, 0x20, 0x2f, 0x74, 0x6d,
|
|
||||||
0x70, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0xd1, 0xd1, 0xff, 0xe0, 0x2e, 0x2e, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00
|
|
||||||
};
|
|
||||||
|
|
||||||
const unsigned int romfs_img_len = 1024;
|
|
@ -39,7 +39,7 @@
|
|||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_NSH_ROMFSETC) || defined(CONFIG_NSH_ROMFSRC)
|
#if defined(CONFIG_ETC_ROMFS) || defined(CONFIG_NSH_ROMFSRC)
|
||||||
static int nsh_script_redirect(FAR struct nsh_vtbl_s *vtbl,
|
static int nsh_script_redirect(FAR struct nsh_vtbl_s *vtbl,
|
||||||
FAR const char *cmd,
|
FAR const char *cmd,
|
||||||
FAR const char *path,
|
FAR const char *path,
|
||||||
@ -202,7 +202,7 @@ int nsh_script(FAR struct nsh_vtbl_s *vtbl, FAR const FAR char *cmd,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NSH_ROMFSETC
|
#ifdef CONFIG_ETC_ROMFS
|
||||||
int nsh_sysinitscript(FAR struct nsh_vtbl_s *vtbl)
|
int nsh_sysinitscript(FAR struct nsh_vtbl_s *vtbl)
|
||||||
{
|
{
|
||||||
/* Since most existing systems only use the NSH_INITPATH script file.
|
/* Since most existing systems only use the NSH_INITPATH script file.
|
||||||
@ -224,7 +224,7 @@ int nsh_sysinitscript(FAR struct nsh_vtbl_s *vtbl)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NSH_ROMFSETC
|
#ifdef CONFIG_ETC_ROMFS
|
||||||
int nsh_initscript(FAR struct nsh_vtbl_s *vtbl)
|
int nsh_initscript(FAR struct nsh_vtbl_s *vtbl)
|
||||||
{
|
{
|
||||||
static bool initialized;
|
static bool initialized;
|
||||||
@ -268,6 +268,6 @@ int nsh_loginscript(FAR struct nsh_vtbl_s *vtbl)
|
|||||||
return nsh_script_redirect(vtbl, "login", NSH_RCPATH, true);
|
return nsh_script_redirect(vtbl, "login", NSH_RCPATH, true);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif /* CONFIG_NSH_ROMFSETC */
|
#endif /* CONFIG_ETC_ROMFS */
|
||||||
|
|
||||||
#endif /* CONFIG_NSH_DISABLESCRIPT */
|
#endif /* CONFIG_NSH_DISABLESCRIPT */
|
||||||
|
Loading…
Reference in New Issue
Block a user