anchao commented on code in PR #15597:
URL: https://github.com/apache/nuttx/pull/15597#discussion_r1921065346


##########
fs/v9fs/socket_9p.c:
##########
@@ -0,0 +1,228 @@
+/****************************************************************************
+ * fs/v9fs/socket_9p.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <sys/param.h>
+#include <nuttx/kmalloc.h>
+#include <arpa/inet.h>
+#include <nuttx/net/net.h>
+#include <nuttx/fs/fs.h>
+
+#include "client.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define V9FS_HEADER_OFFSET 7
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct socket_9p_priv_s
+{
+  struct v9fs_transport_s transport;
+  struct socket psock;
+  mutex_t lock;
+};
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static int socket_9p_create(FAR struct v9fs_transport_s **transport,
+                            FAR const char *args);
+static int socket_9p_request(FAR struct v9fs_transport_s *transport,
+                             FAR struct v9fs_payload_s *payload);
+static void socket_9p_destroy(FAR struct v9fs_transport_s *transport);
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+const struct v9fs_transport_ops_s g_socket_9p_transport_ops =
+{
+  socket_9p_create,  /* create */
+  socket_9p_request, /* request */
+  socket_9p_destroy, /* close */
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: socket_9p_create
+ ****************************************************************************/
+
+static int socket_9p_create(FAR struct v9fs_transport_s **transport,
+                            FAR const char *args)
+{
+  FAR struct socket_9p_priv_s *priv;
+  struct sockaddr_in sin;
+  FAR const char *port;
+  FAR const char *addr;
+  int ret;
+
+  /* Parse IP and port */
+
+  addr = strstr(args, "tag=");
+  if (addr == NULL)
+    {
+      return -EINVAL;
+    }
+
+  addr += 4;
+  port = strchr(addr, ':');
+  if (port == NULL)
+    {
+      /* set default port */
+
+      port = ":563";

Review Comment:
   define this port to macro



##########
fs/v9fs/Kconfig:
##########
@@ -21,4 +21,9 @@ config V9FS_VIRTIO_9P
        depends on DRIVERS_VIRTIO
        default n
 
+config V9FS_SOCKET_9P

Review Comment:
   ```suggestion
   config V9FS_SOCKET
   ```



##########
net/tcp/tcp_recvfrom.c:
##########
@@ -843,10 +843,71 @@ ssize_t psock_tcp_recvfrom(FAR struct socket *psock, FAR 
struct msghdr *msg,
     }
 
   tcp_notify_recvcpu(conn);
+  tcp_recvfrom_uninitialize(&state);
+  return ret;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: psock_tcp_recvfrom
+ *
+ * Description:
+ *   Perform the recvfrom operation for a TCP/IP SOCK_STREAM
+ *
+ * Input Parameters:
+ *   psock    Pointer to the socket structure for the SOCK_DRAM socket
+ *   msg      Receive info and buffer for receive data
+ *   flags    Receive flags
+ *
+ * Returned Value:
+ *   On success, returns the number of characters received.  On  error,
+ *   -errno is returned (see recvfrom for list of errnos).
+ *
+ * Assumptions:
+ *
+ ****************************************************************************/
+
+ssize_t psock_tcp_recvfrom(FAR struct socket *psock, FAR struct msghdr *msg,
+                           int flags)
+{
+  FAR struct sockaddr   *from    = msg->msg_name;
+  FAR socklen_t         *fromlen = &msg->msg_namelen;
+  FAR struct tcp_conn_s *conn;
+  ssize_t                nrecv   = 0;
+  ssize_t                ret     = 0;
+  int                    i;
+
+  net_lock();
+
+  conn = psock->s_conn;
+  for (i = 0; i < msg->msg_iovlen; i++)
+    {
+      FAR void *buf = msg->msg_iov[i].iov_base;
+      size_t len = msg->msg_iov[i].iov_len;
+
+      ret = tcp_recvfrom_one(conn, buf, len, from, fromlen, flags);
+
+      /* User has not set MSG_WAITALL: If the first buffer is full
+       * when received for the first time, then check the next buffer,
+       * otherwise return the received data.
+       * User sets MSG_WAITALL: Ensure that each iov is filled before
+       * returning
+       */
+
+      if (ret < 0 ||
+          (!(flags & MSG_WAITALL) && ret < msg->msg_iov[i].iov_len))

Review Comment:
   update the nrecv if ret < iov_len



##########
net/socket/recvmsg.c:
##########
@@ -88,11 +88,6 @@ ssize_t psock_recvmsg(FAR struct socket *psock, FAR struct 
msghdr *msg,
       return -EINVAL;
     }
 
-  if (msg->msg_iovlen != 1)

Review Comment:
   why not implement multi message recv in this function?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to