diff --git a/ChangeLog b/ChangeLog index 9a0107c66ed56e672d4c5fb84b56ae18128bdc46..e2081192aff9228a1dd98760c5addc943b787235 100644 --- a/ChangeLog +++ b/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/Documentation/NuttX.html b/Documentation/NuttX.html index 3ad82701fc3698610e57e1131d00729a1980e5c1..1f6993e4d8dcf96189bc3b1be36978fc1838337e 100644 --- a/Documentation/NuttX.html +++ b/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/examples/nsh/nsh.h b/examples/nsh/nsh.h index 71d5d5100899d04ac0d702b49c87cf3224571d7c..d6fdcb2976bcd53552ffeb298cb2ff217cd88cdb 100644 --- a/examples/nsh/nsh.h +++ b/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/examples/nsh/nsh_fscmds.c b/examples/nsh/nsh_fscmds.c index 84c36b8fd4f82510e96d3383e777d7b259db4b8d..a1f8c2ee53922f20a84499b290c195f968fffd75 100644 --- a/examples/nsh/nsh_fscmds.c +++ b/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> @@ -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 ****************************************************************************/ diff --git a/examples/nsh/nsh_main.c b/examples/nsh/nsh_main.c index 204ff34797c3501e3f0ac5f076029ff66ec99aad..242db6872d61c162999fe65cdebd9e5fddb0bb50 100644 --- a/examples/nsh/nsh_main.c +++ b/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 } }; /****************************************************************************