yamt commented on code in PR #13498:
URL: https://github.com/apache/nuttx/pull/13498#discussion_r1818303398
##########
fs/vfs/fs_write.c:
##########
@@ -32,30 +32,96 @@
#include <assert.h>
#include <nuttx/cancelpt.h>
+#include <nuttx/fs/uio.h>
#include "notify/notify.h"
#include "inode/inode.h"
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: iovec_compat_writev
+ *
+ * Description:
+ * Emulate writev using file_operation::write.
+ *
+ ****************************************************************************/
+
+static ssize_t iovec_compat_writev(FAR struct file *filep,
+ FAR const struct uio *uio)
+{
+ const struct iovec *iov = uio->uio_iov;
+ int iovcnt = uio->uio_iovcnt;
+ FAR struct inode *inode = filep->f_inode;
+ ssize_t ntotal;
+ ssize_t nwritten;
+ size_t remaining;
+ FAR uint8_t *buffer;
+ int i;
+
+ DEBUGASSERT(inode->u.i_ops->write != NULL);
+
+ /* Process each entry in the struct iovec array */
+
+ for (i = 0, ntotal = 0; i < iovcnt; i++)
+ {
+ /* Ignore zero-length writes */
+
+ if (iov[i].iov_len > 0)
+ {
+ buffer = iov[i].iov_base;
+ remaining = iov[i].iov_len;
+
+ /* Write repeatedly as necessary to write the entire buffer */
+
+ do
+ {
+ nwritten = inode->u.i_ops->write(filep, (void *)buffer,
Review Comment:
this cast is necessary to appease a compiler warning. (-Wpointer-sign)
note that our file_operations use "char *" buffers for some reasons.
IMO, it should be changed to "void *". but it isn't in the scope of this PR.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]