diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-07-01 19:22:54 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-07-01 19:22:54 +0000 |
commit | 83fb5545a1eb49bcd1bfcf36140e676d772ceef9 (patch) | |
tree | 23b526c1237944f7c1b4b736fbe8fe6d44b45a06 /nuttx/examples | |
parent | 5f2d898113f8991a6894c4db2133115cfbbe3c05 (diff) | |
download | px4-nuttx-83fb5545a1eb49bcd1bfcf36140e676d772ceef9.tar.gz px4-nuttx-83fb5545a1eb49bcd1bfcf36140e676d772ceef9.tar.bz2 px4-nuttx-83fb5545a1eb49bcd1bfcf36140e676d772ceef9.zip |
Add rm and rmdir commandsChangeLog
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@304 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples')
-rw-r--r-- | nuttx/examples/nsh/nsh.h | 2 | ||||
-rw-r--r-- | nuttx/examples/nsh/nsh_fscmds.c | 28 | ||||
-rw-r--r-- | nuttx/examples/nsh/nsh_main.c | 8 |
3 files changed, 35 insertions, 3 deletions
diff --git a/nuttx/examples/nsh/nsh.h b/nuttx/examples/nsh/nsh.h index 521a935fe..fef113e45 100644 --- a/nuttx/examples/nsh/nsh.h +++ b/nuttx/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/nuttx/examples/nsh/nsh_fscmds.c b/nuttx/examples/nsh/nsh_fscmds.c index f8f95d39c..a40120d8f 100644 --- a/nuttx/examples/nsh/nsh_fscmds.c +++ b/nuttx/examples/nsh/nsh_fscmds.c @@ -684,6 +684,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/nuttx/examples/nsh/nsh_main.c b/nuttx/examples/nsh/nsh_main.c index 774a7d368..e0b7e7904 100644 --- a/nuttx/examples/nsh/nsh_main.c +++ b/nuttx/examples/nsh/nsh_main.c @@ -91,15 +91,17 @@ static const struct cmdmap_s g_cmdmap[] = { "exec", cmd_exec, 2, 3, "<hex-address>" }, { "help", cmd_help, 1, 1, NULL }, #if CONFIG_NFILE_DESCRIPTORS > 0 - { "ls", cmd_ls, 2, 5, "[-lRs] <path>" }, + { "ls", cmd_ls, 2, 5, "[-lRs] <dir-path>" }, #endif #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 { "mkdir", cmd_mkdir, 2, 2, "<path>" }, - { "mount", cmd_mount, 4, 5, "-t <fstype> <device> <dir>" }, + { "mount", cmd_mount, 4, 5, "-t <fstype> <block-device> <dir-path>" }, #endif { "ps", cmd_ps, 1, 1, NULL }, #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 - { "umount", cmd_umount, 2, 2, "<mountpoint-dir>" }, + { "rm", cmd_rm, 2, 2, "<file-path>" }, + { "rmdir", cmd_rmdir, 2, 2, "<dir-path>" }, + { "umount", cmd_umount, 2, 2, "<dir-path>" }, #endif { NULL, NULL, 1, 1, NULL } }; |