Atomically positions a file pointer and reads from a specified file.
#include <nks/fsio.h> int NXRead ( NXHandle_t handle, NXOffset_t offset, size_t length, void *address, unsigned long flags, size_t *bytesRead);
(IN) Specifies a file handle (or descriptor), which refers to a system-maintained state description for a file. If a FIFO or other sequential I/O device, all values that might be in offset are ignored.
(IN) Specifies the offset at which the read is to start. NXOffset_t is guaranteed to be 64-bits wide.
(IN) Specifies the number of bytes to be read. If zero, NXRead returns zero and has no other results.
(IN) Points to a memory address (which is meaningful in your virtual machine) where the data read from the file should be placed.
(IN) Pass 0.
(OUT) Points to the number of bytes actually read. This number might be less than length if the number of bytes left in the file is less than length. A value of zero is returned when an end-of-file has been reached. If an error occurs, returns -1.
On a non-blocking FIFO, the number of bytes read may be different than the number requested. In this case, no error is returned, but bytesRead does indicate the number of valid bytes in the buffer.
If successful, returns 0. Otherwise, returns one of the following error codes.
NXRead attempts to read the number of specified bytes from the file associated with handle into the buffer specified by address.
NXRead reads data previously written to a file. If any portion of a file has not been written, NXRead returns data read from that portion as zero bytes. NXRead cannot be used to read data when the offset parameter is positioned beyond the end-of-file.
NXRead updates the time of last access of the file.