Update of NSH nfsmount command
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4735 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
parent
efa79242c5
commit
84ee950c08
|
@ -1222,9 +1222,10 @@ int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||||
int cmd_nfsmount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
int cmd_nfsmount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct nfs_args data;
|
struct nfs_args data;
|
||||||
FAR char *address;
|
|
||||||
FAR char *target;
|
|
||||||
FAR char *protocol;
|
FAR char *protocol;
|
||||||
|
FAR char *address;
|
||||||
|
FAR char *lpath;
|
||||||
|
FAR char *rpath;
|
||||||
FAR struct sockaddr_in *sin;
|
FAR struct sockaddr_in *sin;
|
||||||
bool badarg = false;
|
bool badarg = false;
|
||||||
#ifdef CONFIG_NET_IPv6
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
@ -1289,16 +1290,16 @@ int cmd_nfsmount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* There are two required arguments after the options: (1) The NFS server IP
|
/* There are three required arguments after the options: (1) The NFS server IP
|
||||||
* address and then (1) the path to the mount point.
|
* address and then (1) the path to the mount point.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (optind + 2 < argc)
|
if (optind + 3 < argc)
|
||||||
{
|
{
|
||||||
nsh_output(vtbl, g_fmttoomanyargs, argv[0]);
|
nsh_output(vtbl, g_fmttoomanyargs, argv[0]);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
else if (optind + 2 > argc)
|
else if (optind + 3 > argc)
|
||||||
{
|
{
|
||||||
nsh_output(vtbl, g_fmtargrequired, argv[0]);
|
nsh_output(vtbl, g_fmtargrequired, argv[0]);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
|
@ -1314,16 +1315,20 @@ int cmd_nfsmount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The target mount point path might be relative to the current working
|
/* The local mount point path (lpath) might be relative to the current working
|
||||||
* directory.
|
* directory.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
target = nsh_getfullpath(vtbl, argv[optind+1]);
|
lpath = nsh_getfullpath(vtbl, argv[optind+1]);
|
||||||
if (!target)
|
if (!lpath)
|
||||||
{
|
{
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Get the remote mount point path */
|
||||||
|
|
||||||
|
rpath = argv[optind+2];
|
||||||
|
|
||||||
/* Convert the IP address string into its binary form */
|
/* Convert the IP address string into its binary form */
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
@ -1333,7 +1338,7 @@ int cmd_nfsmount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||||
#endif
|
#endif
|
||||||
if (ret != 1)
|
if (ret != 1)
|
||||||
{
|
{
|
||||||
nsh_freefullpath(target);
|
nsh_freefullpath(lpath);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1348,10 +1353,11 @@ int cmd_nfsmount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||||
data.addrlen = sizeof(struct sockaddr_in);
|
data.addrlen = sizeof(struct sockaddr_in);
|
||||||
|
|
||||||
data.version = NFS_ARGSVERSION;
|
data.version = NFS_ARGSVERSION;
|
||||||
data.proto = (tcp) ? IPPROTO_TCP : IPPROTO_UDP;
|
|
||||||
data.sotype = (tcp) ? SOCK_STREAM : SOCK_DGRAM;
|
data.sotype = (tcp) ? SOCK_STREAM : SOCK_DGRAM;
|
||||||
|
data.proto = (tcp) ? IPPROTO_TCP : IPPROTO_UDP;
|
||||||
data.flags = NFSMNT_NFSV3;
|
data.flags = NFSMNT_NFSV3;
|
||||||
data.retrans = 3;
|
data.retrans = 3;
|
||||||
|
data.path = rpath;
|
||||||
data.acregmin = 3;
|
data.acregmin = 3;
|
||||||
data.acregmax = 60;
|
data.acregmax = 60;
|
||||||
data.acdirmin = 30;
|
data.acdirmin = 30;
|
||||||
|
@ -1362,7 +1368,7 @@ int cmd_nfsmount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||||
|
|
||||||
/* Perform the mount */
|
/* Perform the mount */
|
||||||
|
|
||||||
ret = mount(NULL, target, "nfs", 0, (FAR void *)&data);
|
ret = mount(NULL, lpath, "nfs", 0, (FAR void *)&data);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "mount", NSH_ERRNO);
|
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "mount", NSH_ERRNO);
|
||||||
|
@ -1370,7 +1376,7 @@ int cmd_nfsmount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||||
|
|
||||||
/* We no longer need the allocated mount point path */
|
/* We no longer need the allocated mount point path */
|
||||||
|
|
||||||
nsh_freefullpath(target);
|
nsh_freefullpath(lpath);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -270,7 +270,7 @@ static const struct cmdmap_s g_cmdmap[] =
|
||||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && \
|
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && \
|
||||||
defined(CONFIG_FS_READABLE) && defined(CONFIG_NET) && defined(CONFIG_NFS)
|
defined(CONFIG_FS_READABLE) && defined(CONFIG_NET) && defined(CONFIG_NFS)
|
||||||
# ifndef CONFIG_NSH_DISABLE_NFSMOUNT
|
# ifndef CONFIG_NSH_DISABLE_NFSMOUNT
|
||||||
{ "nfsmount", cmd_nfsmount, 3, 5, "[-p <protocol>] <server-address> <mount-point>" },
|
{ "nfsmount", cmd_nfsmount, 4, 6, "[-p <protocol>] <server-address> <mount-point> <remote-path>" },
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue