fs/vfs: Add new internal OS interface nx_read(). nx_read() is functionally equivalent to read() except that it does not modify the errno variable and it is not a cancellation point. Changed all references to read() in the OS to nx_read().

This commit is contained in:
Gregory Nutt
2017-10-11 12:13:41 -06:00
parent 957831d2ba
commit 181875f3ba
18 changed files with 222 additions and 141 deletions
+41 -3
View File
@@ -83,11 +83,13 @@
*/
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
# define _NX_READ(f,b,s) nx_read(f,b,s)
# define _NX_WRITE(f,b,s) nx_write(f,b,s)
# define _NX_GETERRNO(r) (-(r))
# define _NX_SETERRNO(r) set_errno(-(r))
# define _NX_GETERRVAL(r) (r)
#else
# define _NX_READ(f,b,s) read(f,b,s)
# define _NX_WRITE(f,b,s) write(f,b,s)
# define _NX_GETERRNO(r) errno
# define _NX_SETERRNO(r)
@@ -913,9 +915,22 @@ int fs_getfilep(int fd, FAR struct file **filep);
* Name: file_read
*
* Description:
* Equivalent to the standard read() function except that is accepts a
* struct file instance instead of a file descriptor. Currently used
* only by net_sendfile() and aio_read();
* file_read() is an interanl OS interface. It is functionally similar to
* the standard read() interface except:
*
* - It does not modify the errno variable,
* - It is not a cancellation point,
* - It does not handle socket descriptors, and
* - It accepts a file structure instance instead of file descriptor.
*
* Input Parameters:
* filep - File structure instance
* buf - User-provided to save the data
* nbytes - The maximum size of the user-provided buffer
*
* Returned Value:
* The positive non-zero number of bytes read on success, 0 on if an
* end-of-file condition, or a negated errno value on any failure.
*
****************************************************************************/
@@ -923,6 +938,29 @@ int fs_getfilep(int fd, FAR struct file **filep);
ssize_t file_read(FAR struct file *filep, FAR void *buf, size_t nbytes);
#endif
/****************************************************************************
* Name: nx_read
*
* Description:
* nx_read() is an interanl OS interface. It is functionally similar to
* the standard read() interface except:
*
* - It does not modify the errno variable, and
* - It is not a cancellation point.
*
* Input Parameters:
* fd - File descriptor to read from
* buf - User-provided to save the data
* nbytes - The maximum size of the user-provided buffer
*
* Returned Value:
* The positive non-zero number of bytes read on success, 0 on if an
* end-of-file condition, or a negated errno value on any failure.
*
****************************************************************************/
ssize_t nx_read(int fd, FAR void *buf, size_t nbytes);
/****************************************************************************
* Name: file_write
*