diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-08-10 18:42:55 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-08-10 18:42:55 +0000 |
commit | b519cf020d830ad425ff6c7e3f2f807ed0268600 (patch) | |
tree | 13630c679ff68959563d05a08dd2333119f725eb /nuttx | |
parent | 8c4ab8a0633559af64ea6a7fa966c7b608c48c1d (diff) | |
download | px4-nuttx-b519cf020d830ad425ff6c7e3f2f807ed0268600.tar.gz px4-nuttx-b519cf020d830ad425ff6c7e3f2f807ed0268600.tar.bz2 px4-nuttx-b519cf020d830ad425ff6c7e3f2f807ed0268600.zip |
Added mkfatfs command to NSH
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@811 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx')
-rw-r--r-- | nuttx/ChangeLog | 3 | ||||
-rw-r--r-- | nuttx/Documentation/NuttX.html | 2 | ||||
-rw-r--r-- | nuttx/examples/nsh/nsh.h | 1 | ||||
-rw-r--r-- | nuttx/examples/nsh/nsh_fscmds.c | 25 | ||||
-rw-r--r-- | nuttx/examples/nsh/nsh_main.c | 35 |
5 files changed, 45 insertions, 21 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 9a0107c66..e2081192a 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -393,3 +393,6 @@ basic mkfatfs functionality for FAT12. 0.3.13 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> + + * Added mkfatfs command to NSH + diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html index 3ad82701f..1f6993e4d 100644 --- a/nuttx/Documentation/NuttX.html +++ b/nuttx/Documentation/NuttX.html @@ -1028,6 +1028,8 @@ buildroot-0.1.0 2007-03-09 <spudmonkey@racsa.co.cr> <pre><ul> nuttx-0.3.13 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> + * Added mkfatfs command to NSH + pascal-0.1.3 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> buildroot-0.1.1 2008-xx-xx <spudmonkey@racsa.co.cr> diff --git a/nuttx/examples/nsh/nsh.h b/nuttx/examples/nsh/nsh.h index 71d5d5100..d6fdcb297 100644 --- a/nuttx/examples/nsh/nsh.h +++ b/nuttx/examples/nsh/nsh.h @@ -129,6 +129,7 @@ extern void cmd_ls(FAR void *handle, int argc, char **argv); #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 extern void cmd_mkdir(FAR void *handle, int argc, char **argv); #ifdef CONFIG_FS_FAT /* Need at least one filesytem in configuration */ +extern void cmd_mkfatfs(FAR void *handle, int argc, char **argv); extern void cmd_mount(FAR void *handle, int argc, char **argv); #endif #endif diff --git a/nuttx/examples/nsh/nsh_fscmds.c b/nuttx/examples/nsh/nsh_fscmds.c index 84c36b8fd..a1f8c2ee5 100644 --- a/nuttx/examples/nsh/nsh_fscmds.c +++ b/nuttx/examples/nsh/nsh_fscmds.c @@ -43,11 +43,12 @@ #if CONFIG_NFILE_DESCRIPTORS > 0 # include <sys/stat.h> # include <fcntl.h> +# if !defined(CONFIG_DISABLE_MOUNTPOINT) +# ifdef CONFIG_FS_FAT /* Need at least one filesytem in configuration */ +# include <sys/mount.h> +# include <nuttx/mkfatfs.h> +# endif #endif -#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 -# ifdef CONFIG_FS_FAT /* Need at least one filesytem in configuration */ -# include <sys/mount.h> -# endif #endif #include <stdio.h> @@ -634,6 +635,22 @@ void cmd_mkdir(FAR void *handle, int argc, char **argv) #endif /**************************************************************************** + * Name: cmd_mkfatfs + ****************************************************************************/ + +#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_FAT) +void cmd_mkfatfs(FAR void *handle, int argc, char **argv) +{ + struct fat_format_s fmt = FAT_FORMAT_INITIALIZER; + int result = mkfatfs(argv[1], &fmt); + if ( result < 0) + { + nsh_output(handle, g_fmtcmdfailed, argv[0], "mkfatfs", NSH_ERRNO); + } +} +#endif + +/**************************************************************************** * Name: cmd_mount ****************************************************************************/ diff --git a/nuttx/examples/nsh/nsh_main.c b/nuttx/examples/nsh/nsh_main.c index 204ff3479..242db6872 100644 --- a/nuttx/examples/nsh/nsh_main.c +++ b/nuttx/examples/nsh/nsh_main.c @@ -81,44 +81,45 @@ static const char delim[] = " \t\n"; static const struct cmdmap_s g_cmdmap[] = { #if CONFIG_NFILE_DESCRIPTORS > 0 - { "cat", cmd_cat, 2, 2, "<path>" }, - { "cp", cmd_cp, 3, 3, "<source-path> <dest-path>" }, + { "cat", cmd_cat, 2, 2, "<path>" }, + { "cp", cmd_cp, 3, 3, "<source-path> <dest-path>" }, #endif #ifndef CONFIG_DISABLE_ENVIRON - { "echo", cmd_echo, 0, NSH_MAX_ARGUMENTS, "[<string|$name> [<string|$name>...]]" }, + { "echo", cmd_echo, 0, NSH_MAX_ARGUMENTS, "[<string|$name> [<string|$name>...]]" }, #else - { "echo", cmd_echo, 0, NSH_MAX_ARGUMENTS, "[<string> [<string>...]]" }, + { "echo", cmd_echo, 0, NSH_MAX_ARGUMENTS, "[<string> [<string>...]]" }, #endif - { "exec", cmd_exec, 2, 3, "<hex-address>" }, - { "exit", cmd_exit, 1, 1, NULL }, - { "help", cmd_help, 1, 1, NULL }, + { "exec", cmd_exec, 2, 3, "<hex-address>" }, + { "exit", cmd_exit, 1, 1, NULL }, + { "help", cmd_help, 1, 1, NULL }, #if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0 { "ifconfig", cmd_ifconfig, 1, 1, NULL }, #endif #if CONFIG_NFILE_DESCRIPTORS > 0 - { "ls", cmd_ls, 2, 5, "[-lRs] <dir-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>" }, + { "mkdir", cmd_mkdir, 2, 2, "<path>" }, #ifdef CONFIG_FS_FAT /* Need at least one filesytem in configuration */ - { "mount", cmd_mount, 4, 5, "-t <fstype> <block-device> <dir-path>" }, + { "mkfatfs", cmd_mkfatfs, 2, 2, "<path>" }, + { "mount", cmd_mount, 4, 5, "-t <fstype> <block-device> <dir-path>" }, #endif #endif - { "ps", cmd_ps, 1, 1, NULL }, + { "ps", cmd_ps, 1, 1, NULL }, #ifndef CONFIG_DISABLE_ENVIRON - { "set", cmd_set, 3, 3, "<name> <value>" }, + { "set", cmd_set, 3, 3, "<name> <value>" }, #endif #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 - { "rm", cmd_rm, 2, 2, "<file-path>" }, - { "rmdir", cmd_rmdir, 2, 2, "<dir-path>" }, + { "rm", cmd_rm, 2, 2, "<file-path>" }, + { "rmdir", cmd_rmdir, 2, 2, "<dir-path>" }, # ifdef CONFIG_FS_FAT /* Need at least one filesytem in configuration */ - { "umount", cmd_umount, 2, 2, "<dir-path>" }, + { "umount", cmd_umount, 2, 2, "<dir-path>" }, #endif #endif #ifndef CONFIG_DISABLE_ENVIRON - { "unset", cmd_unset, 2, 2, "<name>" }, + { "unset", cmd_unset, 2, 2, "<name>" }, #endif - { NULL, NULL, 1, 1, NULL } + { NULL, NULL, 1, 1, NULL } }; /**************************************************************************** |