Skip to content

Commit

Permalink
file_readv_compat: add a comment to explain limitations
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt authored and anchao committed Jan 22, 2025
1 parent 0ffb0b7 commit ab9522f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions fs/vfs/fs_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,26 @@
* Description:
* Emulate readv using file_operation::read.
*
* Unless iovcnt <= 1, this implementation is NOT appropriate for files
* with non-trivial semantics, including:
*
* - Files which might return partial success. (except the EOF)
* (Eg. certain character devices, including tty.)
*
* - Files which need to preserve data boundaries.
* (Eg. datagram sockets)
*
* - Files which need to provide read/write atomicity.
* (Eg. regular files, pipes, fifos. Note that, although NuttX
* doesn't implement the atomicity for regular files as of writing
* this, POSIX requires it.)
*
* - Files with flow-control mechanisms might be confused a bit by
* this implementation. (Eg. TCP socket)
*
* For those kind of files, please consider to implement
* file_operations::readv natively instead of using this function.
*
****************************************************************************/

static ssize_t file_readv_compat(FAR struct file *filep, FAR struct uio *uio)
Expand Down
2 changes: 2 additions & 0 deletions fs/vfs/fs_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
* Description:
* Emulate writev using file_operation::write.
*
* Please read the comment on file_readv_compat as well.
*
****************************************************************************/

static ssize_t file_writev_compat(FAR struct file *filep,
Expand Down

0 comments on commit ab9522f

Please sign in to comment.