diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-04-30 18:03:04 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-04-30 18:03:04 -0600 |
commit | db3072bd6f1ace9bd459ca802d8cd226e901de72 (patch) | |
tree | a3fd1a146a3a18dfc7e6ea84393fd50994fc463d /apps/nshlib/nsh_fscmds.c | |
parent | 82b5ec73c0007df5cf0a5a04d54ea159e76b2951 (diff) | |
download | nuttx-db3072bd6f1ace9bd459ca802d8cd226e901de72.tar.gz nuttx-db3072bd6f1ace9bd459ca802d8cd226e901de72.tar.bz2 nuttx-db3072bd6f1ace9bd459ca802d8cd226e901de72.zip |
Add -h option to NSH git command; And NSH mksmartfs command. From Ken Petit
Diffstat (limited to 'apps/nshlib/nsh_fscmds.c')
-rw-r--r-- | apps/nshlib/nsh_fscmds.c | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/apps/nshlib/nsh_fscmds.c b/apps/nshlib/nsh_fscmds.c index 35d5c81bd..99d6268a5 100644 --- a/apps/nshlib/nsh_fscmds.c +++ b/apps/nshlib/nsh_fscmds.c @@ -54,6 +54,9 @@ # ifdef CONFIG_FS_FAT # include <nuttx/fs/mkfatfs.h> # endif +# ifdef CONFIG_FS_SMARTFS +# include <nuttx/fs/mksmartfs.h> +# endif # ifdef CONFIG_NFS # include <sys/socket.h> # include <netinet/in.h> @@ -980,7 +983,7 @@ int cmd_mkfatfs(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) int ret = ERROR; if (fullpath) - { + { ret = mkfatfs(fullpath, &fmt); if (ret < 0) { @@ -1129,6 +1132,57 @@ errout_with_fmt: #endif /**************************************************************************** + * Name: cmd_mksmartfs + ****************************************************************************/ + +#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && \ + defined(CONFIG_FS_SMARTFS) +#ifndef CONFIG_NSH_DISABLE_MKSMARTFS +int cmd_mksmartfs(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) +{ + char *fullpath = nsh_getfullpath(vtbl, argv[1]); + int ret = ERROR; +#ifdef CONFIG_SMARTFS_MULTI_ROOT_DIRS + int nrootdirs = 1; +#endif + + if (fullpath) + { + /* Test if number of root directories was supplied */ + +#ifdef CONFIG_SMARTFS_MULTI_ROOT_DIRS + if (argc == 3) + { + nrootdirs = atoi(argv[2]); + } + + if (nrootdirs > 8 || nrootdirs < 1) + { + nsh_output(vtbl, "Invalid number of root directories specified\n"); + } + else +#endif + { +#ifdef CONFIG_SMARTFS_MULTI_ROOT_DIRS + ret = mksmartfs(fullpath, nrootdirs); +#else + ret = mksmartfs(fullpath); +#endif + if (ret < 0) + { + nsh_output(vtbl, g_fmtcmdfailed, argv[0], "mksmartfs", NSH_ERRNO); + } + } + + nsh_freefullpath(fullpath); + } + + return ret; +} +#endif +#endif + +/**************************************************************************** * Name: cmd_mv ****************************************************************************/ |