Added mkfatfs command to NSH

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@811 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2008-08-10 18:42:55 +00:00
parent 2cee73f956
commit 75ec13c73e
5 changed files with 45 additions and 21 deletions

View File

@ -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

View File

@ -1028,6 +1028,8 @@ buildroot-0.1.0 2007-03-09 &lt;spudmonkey@racsa.co.cr&gt
<pre><ul>
nuttx-0.3.13 2008-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
* Added mkfatfs command to NSH
pascal-0.1.3 2008-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
buildroot-0.1.1 2008-xx-xx &lt;spudmonkey@racsa.co.cr&gt

View File

@ -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

View File

@ -43,12 +43,13 @@
#if CONFIG_NFILE_DESCRIPTORS > 0
# include <sys/stat.h>
# include <fcntl.h>
#endif
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0
# 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
#endif
#include <stdio.h>
#include <stdlib.h>
@ -633,6 +634,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
****************************************************************************/

View File

@ -101,6 +101,7 @@ static const struct cmdmap_s g_cmdmap[] =
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0
{ "mkdir", cmd_mkdir, 2, 2, "<path>" },
#ifdef CONFIG_FS_FAT /* Need at least one filesytem in configuration */
{ "mkfatfs", cmd_mkfatfs, 2, 2, "<path>" },
{ "mount", cmd_mount, 4, 5, "-t <fstype> <block-device> <dir-path>" },
#endif
#endif