summaryrefslogtreecommitdiff
path: root/apps/nshlib/nsh_fscmds.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-08-03 23:47:32 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-08-03 23:47:32 +0000
commita98c9af060ce31895336fd3170e5efc961f1b298 (patch)
treee591f268857f6ec0f27b064bdb0b438ae8515a29 /apps/nshlib/nsh_fscmds.c
parent16d6e830b07e83e2e791c7d7bc6c712af28541e1 (diff)
downloadnuttx-a98c9af060ce31895336fd3170e5efc961f1b298.tar.gz
nuttx-a98c9af060ce31895336fd3170e5efc961f1b298.tar.bz2
nuttx-a98c9af060ce31895336fd3170e5efc961f1b298.zip
Extend the NSH mount command so that it will enumerate mountpoints if no arguments are provided
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5006 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/nshlib/nsh_fscmds.c')
-rw-r--r--apps/nshlib/nsh_fscmds.c226
1 files changed, 1 insertions, 225 deletions
diff --git a/apps/nshlib/nsh_fscmds.c b/apps/nshlib/nsh_fscmds.c
index f6784d5b6..1a9f2eb57 100644
--- a/apps/nshlib/nsh_fscmds.c
+++ b/apps/nshlib/nsh_fscmds.c
@@ -1032,7 +1032,7 @@ int cmd_mkrd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
int minor = 0;
int ret;
- /* Get the mount options */
+ /* Get the mkrd options */
int option;
while ((option = getopt(argc, argv, ":m:s:")) != ERROR)
@@ -1127,96 +1127,6 @@ errout_with_fmt:
#endif
/****************************************************************************
- * Name: cmd_mount
- ****************************************************************************/
-
-#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_READABLE)
-#ifndef CONFIG_NSH_DISABLE_MOUNT
-int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
-{
- char *source;
- char *target;
- char *filesystem = 0;
- bool badarg = false;
- int ret;
-
- /* Get the mount options */
-
- int option;
- while ((option = getopt(argc, argv, ":t:")) != ERROR)
- {
- switch (option)
- {
- case 't':
- filesystem = optarg;
- break;
-
- case ':':
- nsh_output(vtbl, g_fmtargrequired, argv[0]);
- badarg = true;
- break;
-
- case '?':
- default:
- nsh_output(vtbl, g_fmtarginvalid, argv[0]);
- badarg = true;
- break;
- }
- }
-
- /* If a bad argument was encountered, then return without processing the command */
-
- if (badarg)
- {
- return ERROR;
- }
-
- /* There are two required arguments after the options */
-
- if (optind + 2 < argc)
- {
- nsh_output(vtbl, g_fmttoomanyargs, argv[0]);
- return ERROR;
- }
- else if (optind + 2 > argc)
- {
- nsh_output(vtbl, g_fmtargrequired, argv[0]);
- return ERROR;
- }
-
- /* The source and target paths might be relative to the current
- * working directory.
- */
-
- source = nsh_getfullpath(vtbl, argv[optind]);
- if (!source)
- {
- return ERROR;
- }
-
- target = nsh_getfullpath(vtbl, argv[optind+1]);
- if (!target)
- {
- nsh_freefullpath(source);
- return ERROR;
- }
-
- /* Perform the mount */
-
- ret = mount(source, target, filesystem, 0, NULL);
- if (ret < 0)
- {
- nsh_output(vtbl, g_fmtcmdfailed, argv[0], "mount", NSH_ERRNO);
- }
-
- nsh_freefullpath(source);
- nsh_freefullpath(target);
- return ret;
-}
-#endif
-#endif
-
-/****************************************************************************
* Name: cmd_mv
****************************************************************************/
@@ -1261,113 +1171,6 @@ int cmd_mv(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
#endif
/****************************************************************************
- * Name: cmd_nfsmount
- ****************************************************************************/
-
-#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && \
- defined(CONFIG_NET) && defined(CONFIG_NFS)
-#ifndef CONFIG_NSH_DISABLE_NFSMOUNT
-int cmd_nfsmount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
-{
- struct nfs_args data;
- FAR char *address;
- FAR char *lpath;
- FAR char *rpath;
- bool badarg = false;
-#ifdef CONFIG_NET_IPv6
- FAR struct sockaddr_in6 *sin;
- struct in6_addr inaddr;
-#else
- FAR struct sockaddr_in *sin;
- struct in_addr inaddr;
-#endif
- int ret;
-
- /* If a bad argument was encountered, then return without processing the
- * command.
- */
-
- if (badarg)
- {
- return ERROR;
- }
-
- /* The fist argument on the command line should be the NFS server IP address
- * in standard IPv4 (or IPv6) dot format.
- */
-
- address = argv[1];
- if (!address)
- {
- return ERROR;
- }
-
- /* The local mount point path (lpath) might be relative to the current working
- * directory.
- */
-
- lpath = nsh_getfullpath(vtbl, argv[2]);
- if (!lpath)
- {
- return ERROR;
- }
-
- /* Get the remote mount point path */
-
- rpath = argv[3];
-
- /* Convert the IP address string into its binary form */
-
-#ifdef CONFIG_NET_IPv6
- ret = inet_pton(AF_INET6, address, &inaddr);
-#else
- ret = inet_pton(AF_INET, address, &inaddr);
-#endif
- if (ret != 1)
- {
- nsh_freefullpath(lpath);
- return ERROR;
- }
-
- /* Place all of the NFS arguements into the nfs_args structure */
-
- memset(&data, 0, sizeof(data));
-
-#ifdef CONFIG_NET_IPv6
- sin = (FAR struct sockaddr_in6 *)&data.addr;
- sin->sin_family = AF_INET6;
- sin->sin_port = htons(NFS_PMAPPORT);
- memcpy(&sin->sin6_addr, &inaddr, sizeof(struct in6_addr));
- data.addrlen = sizeof(struct sockaddr_in6);
-#else
- sin = (FAR struct sockaddr_in *)&data.addr;
- sin->sin_family = AF_INET;
- sin->sin_port = htons(NFS_PMAPPORT);
- sin->sin_addr = inaddr;
- data.addrlen = sizeof(struct sockaddr_in);
-#endif
-
- data.sotype = SOCK_DGRAM;
- data.path = rpath;
- data.flags = 0; /* 0=Use all defaults */
-
- /* Perform the mount */
-
- ret = mount(NULL, lpath, "nfs", 0, (FAR void *)&data);
- if (ret < 0)
- {
- nsh_output(vtbl, g_fmtcmdfailed, argv[0], "mount", NSH_ERRNO);
- }
-
- /* We no longer need the allocated mount point path */
-
- nsh_freefullpath(lpath);
- return ret;
-}
-#endif
-#endif
-
-/****************************************************************************
* Name: cmd_rm
****************************************************************************/
@@ -1494,30 +1297,3 @@ int cmd_sh(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
}
#endif
#endif
-
-/****************************************************************************
- * Name: cmd_umount
- ****************************************************************************/
-
-#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_READABLE)
-#ifndef CONFIG_NSH_DISABLE_UMOUNT
-int cmd_umount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
-{
- char *fullpath = nsh_getfullpath(vtbl, argv[1]);
- int ret = ERROR;
-
- if (fullpath)
- {
- /* Perform the umount */
-
- ret = umount(fullpath);
- if (ret < 0)
- {
- nsh_output(vtbl, g_fmtcmdfailed, argv[0], "umount", NSH_ERRNO);
- }
- nsh_freefullpath(fullpath);
- }
- return ret;
-}
-#endif
-#endif