yamt commented on code in PR #14898:
URL: https://github.com/apache/nuttx/pull/14898#discussion_r1883387526


##########
fs/vfs/fs_uio.c:
##########
@@ -117,3 +117,97 @@ void uio_init(FAR struct uio *uio)
 {
   memset(uio, 0, sizeof(*uio));
 }
+
+/****************************************************************************
+ * Name: uio_copyfrom
+ *
+ * Description:
+ *   Copy data from the linear buffer to uio.
+ *
+ ****************************************************************************/
+
+void uio_copyfrom(FAR struct uio *uio, size_t offset, FAR const void *buf,
+                  size_t len)
+{
+  FAR const struct iovec *iov = uio->uio_iov;
+
+  DEBUGASSERT(uio_resid(uio) >= 0);
+  DEBUGASSERT(len <= uio_resid(uio));
+  DEBUGASSERT(offset <= uio_resid(uio) - len);
+  DEBUGASSERT(SSIZE_MAX - offset >= uio->uio_offset_in_iov);
+
+  offset += uio->uio_offset_in_iov;
+  while (offset > iov->iov_len)
+    {
+      offset -= iov->iov_len;
+      iov++;
+    }
+
+  while (len > 0)
+    {
+      size_t blen = len;
+      if (blen > iov->iov_len - offset)
+        {
+          blen = iov->iov_len - offset;
+        }
+
+      memcpy((FAR uint8_t *)iov->iov_base + offset, buf, blen);
+
+      len -= blen;
+      if (len == 0)

Review Comment:
   ok



-- 
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