unlink/rm can now be used on nodes in the pseudo-filesystem. There is new configuration option to suppress these costly and mostly useless operations on the pseudo-filesystem

This commit is contained in:
Gregory Nutt 2014-02-20 18:14:02 -06:00
parent da0235e8e6
commit 2bc6d67866
7 changed files with 68 additions and 36 deletions

View File

@ -798,7 +798,7 @@
(2014-1-17). (2014-1-17).
* apps/nshlib/Kconfig, README.txt, nsh.h, nsh_command.c, and * apps/nshlib/Kconfig, README.txt, nsh.h, nsh_command.c, and
nsh_script.c: Add an option to conditionally compile out support for nsh_script.c: Add an option to conditionally compile out support for
loop and for if-then-else-fi sequence (2014-1-17). loop and for if-then-else-fi sequence (2014-1-17).
* apps/nshlib/nsh.h, nsh_command.c, and nsh_parse.c: Add a break * apps/nshlib/nsh.h, nsh_command.c, and nsh_parse.c: Add a break
command that can be executed with a loop to terminate the loop command that can be executed with a loop to terminate the loop
immediately (2014-1-17). immediately (2014-1-17).
@ -831,6 +831,12 @@
* apps/nshlib: 'mkdir' can now be used in the pseudo-filesystem. Hence, * apps/nshlib: 'mkdir' can now be used in the pseudo-filesystem. Hence,
the command needs to be available even if there are no write-able the command needs to be available even if there are no write-able
filesystem enabled (2014-2-19). filesystem enabled (2014-2-19).
* apps/nshlib: 'rename' can now be used in the pseudo-filesystem. Hence, * apps/nshlib: 'mv' can now be used in the pseudo-filesystem. Hence,
the 'mv' command needs to be available even if there are no write-able the 'mv' command needs to be available even if there are no write-able
filesystem enabled (2014-2-19). filesystem enabled (2014-2-19).
* apps/nshlib: 'rm' can now be used to remove nodes frm the pseudo-
filesystem. Hence, the 'rm' command needs to be available even if there
are no write-able filesystem enabled (2014-2-20).
* CONFIG_DISABLE_PSEUDOFS_OPERATIONS: This new configuration setting
basically backs out the recent changes to mv, rm, mkdir, and rmdir
(2014-2-20).

View File

@ -304,6 +304,7 @@ config NSH_DISABLE_SEMICOLON
config NSH_CMDPARMS config NSH_CMDPARMS
bool "Enable commands as parameters" bool "Enable commands as parameters"
default n default n
depends on !DISABLE_MOUNTPOINT
---help--- ---help---
If selected, then the output from commands, from file applications, and If selected, then the output from commands, from file applications, and
from NSH built-in commands can be used as arguments to other from NSH built-in commands can be used as arguments to other
@ -316,7 +317,7 @@ config NSH_CMDPARMS
environment variable BAR. The value of the environment variable FOO environment variable BAR. The value of the environment variable FOO
is then set output of myprogram on stdout. is then set output of myprogram on stdout.
Because this feature commits significant resourse, it is disabled by Because this feature commits significant resources, it is disabled by
default. default.
config NSH_TMPDIR config NSH_TMPDIR
@ -464,7 +465,7 @@ config NSH_ROMFSDEVNO
int "ROMFS block device minor number" int "ROMFS block device minor number"
default 0 default 0
---help--- ---help---
This is the minor number of the ROMFS block device. The default is This is the minor number of the ROMFS block device. The default is
'0' corresponding to /dev/ram0. '0' corresponding to /dev/ram0.
config NSH_ROMFSSECTSIZE config NSH_ROMFSSECTSIZE

View File

@ -307,7 +307,7 @@ o break
until loop, between the do and done tokens. Outside of a loop, break until loop, between the do and done tokens. Outside of a loop, break
command does nothing. If the break command is executed within the body command does nothing. If the break command is executed within the body
of a loop, the loop will immediately terminate and execution will of a loop, the loop will immediately terminate and execution will
continue with the next command immediately following the done token. continue with the next command immediately following the done token.
o cat <path> [<path> [<path> ...]] o cat <path> [<path> [<path> ...]]
@ -955,7 +955,7 @@ Command Dependencies on Configuration Settings
cd !CONFIG_DISABLE_ENVIRON && CONFIG_NFILE_DESCRIPTORS > 0 cd !CONFIG_DISABLE_ENVIRON && CONFIG_NFILE_DESCRIPTORS > 0
cp CONFIG_NFILE_DESCRIPTORS > 0 cp CONFIG_NFILE_DESCRIPTORS > 0
dd CONFIG_NFILE_DESCRIPTORS > 0 dd CONFIG_NFILE_DESCRIPTORS > 0
delrout CONFIG_NET && CONFIG_NET_ROUTE delrout CONFIG_NET && CONFIG_NET_ROUTE
df !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_READABLE (see note 3) df !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_READABLE (see note 3)
echo -- echo --
exec -- exec --
@ -972,19 +972,19 @@ Command Dependencies on Configuration Settings
ls CONFIG_NFILE_DESCRIPTORS > 0 ls CONFIG_NFILE_DESCRIPTORS > 0
md5 CONFIG_NETUTILS_CODECS && CONFIG_CODECS_HASH_MD5 md5 CONFIG_NETUTILS_CODECS && CONFIG_CODECS_HASH_MD5
mb,mh,mw --- mb,mh,mw ---
mkdir CONFIG_NFILE_DESCRIPTORS > 0 mkdir (((!CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_WRITABLE) || !CONFIG_DISABLE_PSEUDOFS_OPERATIONS) && CONFIG_NFILE_DESCRIPTORS > 0)
mkfatfs !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_FAT mkfatfs !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_FAT
mkfifo CONFIG_NFILE_DESCRIPTORS > 0 mkfifo CONFIG_NFILE_DESCRIPTORS > 0
mkrd !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_WRITABLE (see note 4) mkrd !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_WRITABLE (see note 4)
mount !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_READABLE (see note 3) mount !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_READABLE (see note 3)
mv !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_WRITABLE (see note 4) mv (((!CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_WRITABLE) || !CONFIG_DISABLE_PSEUDOFS_OPERATIONS) && CONFIG_NFILE_DESCRIPTORS > 0) (see note 4)
nfsmount !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NET && CONFIG_NFS nfsmount !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NET && CONFIG_NFS
ping CONFIG_NET && CONFIG_NET_ICMP && CONFIG_NET_ICMP_PING && !CONFIG_DISABLE_CLOCK && !CONFIG_DISABLE_SIGNALS ping CONFIG_NET && CONFIG_NET_ICMP && CONFIG_NET_ICMP_PING && !CONFIG_DISABLE_CLOCK && !CONFIG_DISABLE_SIGNALS
ps -- ps --
put CONFIG_NET && CONFIG_NET_UDP && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NET_BUFSIZE >= 558 (see note 1,2) put CONFIG_NET && CONFIG_NET_UDP && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NET_BUFSIZE >= 558 (see note 1,2)
pwd !CONFIG_DISABLE_ENVIRON && CONFIG_NFILE_DESCRIPTORS > 0 pwd !CONFIG_DISABLE_ENVIRON && CONFIG_NFILE_DESCRIPTORS > 0
rm !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_WRITABLE (see note 4) rm (((!CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_WRITABLE) || !CONFIG_DISABLE_PSEUDOFS_OPERATIONS) && CONFIG_NFILE_DESCRIPTORS > 0)
rmdir CONFIG_NFILE_DESCRIPTORS > 0 rmdir (((!CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_WRITABLE) || !CONFIG_DISABLE_PSEUDOFS_OPERATIONS) && CONFIG_NFILE_DESCRIPTORS > 0)
set !CONFIG_DISABLE_ENVIRON set !CONFIG_DISABLE_ENVIRON
sh CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0 && !CONFIG_NSH_DISABLESCRIPT sh CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0 && !CONFIG_NSH_DISABLESCRIPT
sleep !CONFIG_DISABLE_SIGNALS sleep !CONFIG_DISABLE_SIGNALS

View File

@ -75,6 +75,27 @@
# undef CONFIG_NSH_CMDPARMS # undef CONFIG_NSH_CMDPARMS
#endif #endif
/* rmdir, mkdir, rm, and mv are only available if mountpoints are enabled
* AND there is a writeable file system OR if these operations on the
* pseudo-filesystem are not disabled.
*/
#undef NSH_HAVE_WRITABLE_MOUNTPOINT
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_WRITABLE) && \
CONFIG_NFILE_STREAMS > 0
# define NSH_HAVE_WRITABLE_MOUNTPOINT 1
#endif
#undef NSH_HAVE_PSEUDOFS_OPERATIONS
#if !defined(CONFIG_DISABLE_PSEUDOFS_OPERATIONS) && CONFIG_NFILE_STREAMS > 0
# define NSH_HAVE_PSEUDOFS_OPERATIONS 1
#endif
#undef NSH_HAVE_DIROPTS
#if defined(NSH_HAVE_WRITABLE_MOUNTPOINT) || defined(NSH_HAVE_PSEUDOFS_OPERATIONS)
# define NSH_HAVE_DIROPTS 1
#endif
/* If CONFIG_NSH_CMDPARMS is selected, then the path to a directory to /* If CONFIG_NSH_CMDPARMS is selected, then the path to a directory to
* hold temporary files must be provided. * hold temporary files must be provided.
*/ */
@ -661,7 +682,7 @@ void nsh_usbtrace(void);
#if !defined(CONFIG_NSH_DISABLESCRIPT) && !defined(CONFIG_NSH_DISABLE_LOOPS) #if !defined(CONFIG_NSH_DISABLESCRIPT) && !defined(CONFIG_NSH_DISABLE_LOOPS)
int cmd_break(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); int cmd_break(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
#endif #endif
#ifndef CONFIG_NSH_DISABLE_ECHO #ifndef CONFIG_NSH_DISABLE_ECHO
int cmd_echo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); int cmd_echo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
#endif #endif
@ -717,15 +738,6 @@ void nsh_usbtrace(void);
# ifndef CONFIG_NSH_DISABLE_LS # ifndef CONFIG_NSH_DISABLE_LS
int cmd_ls(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); int cmd_ls(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
# endif # endif
# ifndef CONFIG_NSH_DISABLE_MKDIR
int cmd_mkdir(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
# endif
# ifndef CONFIG_NSH_DISABLE_MV
int cmd_mv(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
# endif
# ifndef CONFIG_NSH_DISABLE_RMDIR
int cmd_rmdir(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
# endif
# if defined(CONFIG_SYSLOG) && defined(CONFIG_RAMLOG_SYSLOG) && !defined(CONFIG_NSH_DISABLE_DMESG) # if defined(CONFIG_SYSLOG) && defined(CONFIG_RAMLOG_SYSLOG) && !defined(CONFIG_NSH_DISABLE_DMESG)
int cmd_dmesg(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); int cmd_dmesg(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
# endif # endif
@ -734,6 +746,22 @@ void nsh_usbtrace(void);
int cmd_sh(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); int cmd_sh(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
# endif # endif
# endif /* CONFIG_NFILE_STREAMS && !CONFIG_NSH_DISABLESCRIPT */ # endif /* CONFIG_NFILE_STREAMS && !CONFIG_NSH_DISABLESCRIPT */
# ifdef NSH_HAVE_DIROPTS
# ifndef CONFIG_NSH_DISABLE_MKDIR
int cmd_mkdir(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
# endif
# ifndef CONFIG_NSH_DISABLE_MV
int cmd_mv(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
# endif
# ifndef CONFIG_NSH_DISABLE_RM
int cmd_rm(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
# endif
# ifndef CONFIG_NSH_DISABLE_RMDIR
int cmd_rmdir(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
# endif
# endif /* CONFIG_NFILE_STREAMS && NSH_HAVE_DIROPTS */
# ifndef CONFIG_DISABLE_MOUNTPOINT # ifndef CONFIG_DISABLE_MOUNTPOINT
# ifndef CONFIG_NSH_DISABLE_LOSETUP # ifndef CONFIG_NSH_DISABLE_LOSETUP
int cmd_losetup(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); int cmd_losetup(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
@ -755,9 +783,6 @@ void nsh_usbtrace(void);
# ifndef CONFIG_NSH_DISABLE_MKRD # ifndef CONFIG_NSH_DISABLE_MKRD
int cmd_mkrd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); int cmd_mkrd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
# endif # endif
# ifndef CONFIG_NSH_DISABLE_RM
int cmd_rm(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
# endif
# endif /* CONFIG_FS_WRITABLE */ # endif /* CONFIG_FS_WRITABLE */
# endif /* CONFIG_FS_READABLE */ # endif /* CONFIG_FS_READABLE */
# ifdef CONFIG_FS_FAT # ifdef CONFIG_FS_FAT

View File

@ -121,7 +121,7 @@ static const struct cmdmap_s g_cmdmap[] =
#if !defined(CONFIG_NSH_DISABLESCRIPT) && !defined(CONFIG_NSH_DISABLE_LOOPS) #if !defined(CONFIG_NSH_DISABLESCRIPT) && !defined(CONFIG_NSH_DISABLE_LOOPS)
{ "break", cmd_break, 1, 1, NULL }, { "break", cmd_break, 1, 1, NULL },
#endif #endif
#if CONFIG_NFILE_DESCRIPTORS > 0 #if CONFIG_NFILE_DESCRIPTORS > 0
# ifndef CONFIG_NSH_DISABLE_CAT # ifndef CONFIG_NSH_DISABLE_CAT
@ -252,7 +252,7 @@ static const struct cmdmap_s g_cmdmap[] =
# endif # endif
#endif #endif
#if CONFIG_NFILE_DESCRIPTORS > 0 #ifdef NSH_HAVE_DIROPTS
# ifndef CONFIG_NSH_DISABLE_MKDIR # ifndef CONFIG_NSH_DISABLE_MKDIR
{ "mkdir", cmd_mkdir, 2, 2, "<path>" }, { "mkdir", cmd_mkdir, 2, 2, "<path>" },
# endif # endif
@ -270,7 +270,7 @@ static const struct cmdmap_s g_cmdmap[] =
# endif # endif
#endif #endif
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_WRITABLE) #ifdef NSH_HAVE_WRITABLE_MOUNTPOINT
# ifndef CONFIG_NSH_DISABLE_MKRD # ifndef CONFIG_NSH_DISABLE_MKRD
{ "mkrd", cmd_mkrd, 2, 6, "[-m <minor>] [-s <sector-size>] <nsectors>" }, { "mkrd", cmd_mkrd, 2, 6, "[-m <minor>] [-s <sector-size>] <nsectors>" },
# endif # endif
@ -300,7 +300,7 @@ static const struct cmdmap_s g_cmdmap[] =
# endif # endif
#endif #endif
#if CONFIG_NFILE_DESCRIPTORS > 0 #ifdef NSH_HAVE_DIROPTS
# ifndef CONFIG_NSH_DISABLE_MV # ifndef CONFIG_NSH_DISABLE_MV
{ "mv", cmd_mv, 3, 3, "<old-path> <new-path>" }, { "mv", cmd_mv, 3, 3, "<old-path> <new-path>" },
# endif # endif
@ -340,13 +340,13 @@ static const struct cmdmap_s g_cmdmap[] =
# endif # endif
#endif #endif
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_WRITABLE) #ifdef NSH_HAVE_DIROPTS
# ifndef CONFIG_NSH_DISABLE_RM # ifndef CONFIG_NSH_DISABLE_RM
{ "rm", cmd_rm, 2, 2, "<file-path>" }, { "rm", cmd_rm, 2, 2, "<file-path>" },
# endif # endif
# endif #endif
#if CONFIG_NFILE_DESCRIPTORS > 0 #ifdef NSH_HAVE_DIROPTS
# ifndef CONFIG_NSH_DISABLE_RMDIR # ifndef CONFIG_NSH_DISABLE_RMDIR
{ "rmdir", cmd_rmdir, 2, 2, "<dir-path>" }, { "rmdir", cmd_rmdir, 2, 2, "<dir-path>" },
# endif # endif

View File

@ -995,7 +995,7 @@ int cmd_ls(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
* Name: cmd_mkdir * Name: cmd_mkdir
****************************************************************************/ ****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0 #ifdef NSH_HAVE_DIROPTS
#ifndef CONFIG_NSH_DISABLE_MKDIR #ifndef CONFIG_NSH_DISABLE_MKDIR
int cmd_mkdir(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) int cmd_mkdir(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{ {
@ -1136,7 +1136,7 @@ int cmd_mkfifo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
* Name: cmd_mkrd * Name: cmd_mkrd
****************************************************************************/ ****************************************************************************/
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_WRITABLE) #ifdef NSH_HAVE_WRITABLE_MOUNTPOINT
#ifndef CONFIG_NSH_DISABLE_MKRD #ifndef CONFIG_NSH_DISABLE_MKRD
int cmd_mkrd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) int cmd_mkrd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{ {
@ -1298,7 +1298,7 @@ int cmd_mksmartfs(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
* Name: cmd_mv * Name: cmd_mv
****************************************************************************/ ****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0 #ifdef NSH_HAVE_DIROPTS
#ifndef CONFIG_NSH_DISABLE_MV #ifndef CONFIG_NSH_DISABLE_MV
int cmd_mv(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) int cmd_mv(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{ {
@ -1342,7 +1342,7 @@ int cmd_mv(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
* Name: cmd_rm * Name: cmd_rm
****************************************************************************/ ****************************************************************************/
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_WRITABLE) #ifdef NSH_HAVE_DIROPTS
#ifndef CONFIG_NSH_DISABLE_RM #ifndef CONFIG_NSH_DISABLE_RM
int cmd_rm(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) int cmd_rm(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{ {
@ -1369,7 +1369,7 @@ int cmd_rm(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
* Name: cmd_rmdir * Name: cmd_rmdir
****************************************************************************/ ****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0 #ifdef NSH_HAVE_DIROPTS
#ifndef CONFIG_NSH_DISABLE_RMDIR #ifndef CONFIG_NSH_DISABLE_RMDIR
int cmd_rmdir(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) int cmd_rmdir(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{ {

View File

@ -2298,4 +2298,4 @@ int cmd_break(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
return OK; return OK;
} }
#endif #endif