You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/02/27 18:58:38 UTC

[incubator-nuttx-apps] 01/01: nshlib: cmd_nfsmount support the mount with TCP protocol

This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit 5f273b2c5c617720c71ce7aea86b87e130f52143
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Fri Feb 28 01:39:16 2020 +0800

    nshlib: cmd_nfsmount support the mount with TCP protocol
    
    And make TCP as the default like Linux
---
 nshlib/nsh_command.c | 12 ++++++------
 nshlib/nsh_mntcmds.c | 11 ++++++++++-
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/nshlib/nsh_command.c b/nshlib/nsh_command.c
index 5e84024..45075a0 100644
--- a/nshlib/nsh_command.c
+++ b/nshlib/nsh_command.c
@@ -1,7 +1,7 @@
 /****************************************************************************
  * apps/nshlib/nsh_command.c
  *
- *   Copyright (C) 2007-2019 Gregory Nutt. All rights reserved.
+ *   Copyright (C) 2007-2019, 2020 Gregory Nutt. All rights reserved.
  *   Author: Gregory Nutt <gn...@nuttx.org>
  *
  * Redistribution and use in source and binary forms, with or without
@@ -361,7 +361,7 @@ static const struct cmdmap_s g_cmdmap[] =
 #if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_NET) && \
     defined(CONFIG_NFS)
 #  ifndef CONFIG_NSH_DISABLE_NFSMOUNT
-  { "nfsmount", cmd_nfsmount, 4, 4, "<server-address> <mount-point> <remote-path>" },
+  { "nfsmount", cmd_nfsmount, 4, 5, "<server-address> <mount-point> <remote-path> [udp]" },
 #  endif
 #endif
 
@@ -693,7 +693,7 @@ static void help_showcmd(FAR struct nsh_vtbl_s *vtbl,
     {
       nsh_output(vtbl, "  %s %s\n", cmdmap->cmd, cmdmap->usage);
     }
-   else
+  else
     {
       nsh_output(vtbl, "  %s\n", cmdmap->cmd);
     }
@@ -883,7 +883,7 @@ static int cmd_help(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
     }
   else
     {
-       /* In verbose mode, show detailed help for all commands */
+      /* In verbose mode, show detailed help for all commands */
 
 #ifndef CONFIG_NSH_HELP_TERSE
       if (verbose)
@@ -1027,8 +1027,8 @@ int nsh_command(FAR struct nsh_vtbl_s *vtbl, int argc, char *argv[])
         }
     }
 
-   ret = handler(vtbl, argc, argv);
-   return ret;
+  ret = handler(vtbl, argc, argv);
+  return ret;
 }
 
 /****************************************************************************
diff --git a/nshlib/nsh_mntcmds.c b/nshlib/nsh_mntcmds.c
index 0e4a1df..085ead4 100644
--- a/nshlib/nsh_mntcmds.c
+++ b/nshlib/nsh_mntcmds.c
@@ -45,6 +45,7 @@
 
 #include <stdint.h>
 #include <stdbool.h>
+#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 #include <errno.h>
@@ -334,7 +335,15 @@ int cmd_nfsmount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
       return ERROR;
     }
 
-  data.sotype             = SOCK_DGRAM;
+  if (argc > 4 && strcmp(argv[4], "udp") == 0)
+    {
+      data.sotype         = SOCK_DGRAM;
+    }
+  else
+    {
+      data.sotype         = SOCK_STREAM;
+    }
+
   data.path               = rpath;
   data.flags              = 0;       /* 0=Use all defaults */