diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html index dd73585c12..c9cf2f5d39 100644 --- a/Documentation/NuttX.html +++ b/Documentation/NuttX.html @@ -633,7 +633,7 @@ Other memory: * examples/ostest: Added an environment variable test. * examples/nsh/: Break into several files. * lib/: Added strrchr, basename, dirname - * examples/nsh/: Add cp command + * examples/nsh/: Add cp, rm, and rmdir commands * Started m68322 diff --git a/examples/nsh/nsh.h b/examples/nsh/nsh.h index 521a935fe6..fef113e456 100644 --- a/examples/nsh/nsh.h +++ b/examples/nsh/nsh.h @@ -85,6 +85,8 @@ void cmd_mount(int argc, char **argv); #endif void cmd_ps(int argc, char **argv); #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 +void cmd_rm(int argc, char **argv); +void cmd_rmdir(int argc, char **argv); void cmd_umount(int argc, char **argv); #endif diff --git a/examples/nsh/nsh_fscmds.c b/examples/nsh/nsh_fscmds.c index f8f95d39c9..a40120d8f5 100644 --- a/examples/nsh/nsh_fscmds.c +++ b/examples/nsh/nsh_fscmds.c @@ -683,6 +683,34 @@ void cmd_mount(int argc, char **argv) } #endif +/**************************************************************************** + * Name: cmd_rm + ****************************************************************************/ + +#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 +void cmd_rm(int argc, char **argv) +{ + if (unlink(argv[1]) < 0) + { + printf(g_fmtcmdfailed, argv[0], "unlink", strerror(errno)); + } +} +#endif + +/**************************************************************************** + * Name: cmd_rm + ****************************************************************************/ + +#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 +void cmd_rmdir(int argc, char **argv) +{ + if (rmdir(argv[1]) < 0) + { + printf(g_fmtcmdfailed, argv[0], "rmdir", strerror(errno)); + } +} +#endif + /**************************************************************************** * Name: cmd_umount ****************************************************************************/ diff --git a/examples/nsh/nsh_main.c b/examples/nsh/nsh_main.c index 774a7d3686..e0b7e79049 100644 --- a/examples/nsh/nsh_main.c +++ b/examples/nsh/nsh_main.c @@ -91,15 +91,17 @@ static const struct cmdmap_s g_cmdmap[] = { "exec", cmd_exec, 2, 3, "" }, { "help", cmd_help, 1, 1, NULL }, #if CONFIG_NFILE_DESCRIPTORS > 0 - { "ls", cmd_ls, 2, 5, "[-lRs] " }, + { "ls", cmd_ls, 2, 5, "[-lRs] " }, #endif #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 { "mkdir", cmd_mkdir, 2, 2, "" }, - { "mount", cmd_mount, 4, 5, "-t " }, + { "mount", cmd_mount, 4, 5, "-t " }, #endif { "ps", cmd_ps, 1, 1, NULL }, #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 - { "umount", cmd_umount, 2, 2, "" }, + { "rm", cmd_rm, 2, 2, "" }, + { "rmdir", cmd_rmdir, 2, 2, "" }, + { "umount", cmd_umount, 2, 2, "" }, #endif { NULL, NULL, 1, 1, NULL } };