Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)

read(2) OSS System Calls Reference Manual
NAME
read - Reads from a file
LIBRARY
G-series native OSS processes: system library
H-series and J-series OSS processes: implicit libraries
32-bit H-series and J-series OSS processes that use the POSIX User Thread Model library:
/G/system/zdllnnn/zputdll
64-bit H-series and J-series OSS processes that use the POSIX User Thread Model library:
/G/system/zdllnnn/yputdll
SYNOPSIS
#include <sys/types.h> /* optional except for POSIX.1 */
#include <unistd.h>
ssize_t read(
int filedes,
void *buffer,
size_t nbytes);
PARAMETERS
filedes Specifies an open file descriptor obtained from a successful call to the accept(),
creat(), creat64(), dup(), dup2( ), fcntl(), open(), open64(), pipe(), socket(),
or socketpair() function.
When the function is thread-aware, specifies an open file descriptor obtained
from a successful call to the creat(), creat64(), dup(), open(), open64(),
pipe( ), socket(),orsocketpair() function, or the thread-aware accept(),
dup2( ),orfcntl( ) function.
buffer Points to the buffer to receive data read.
nbytes Specifies the number of bytes to read from the file associated with the filedes
parameter.
If the value of nbytes is 0 (zero), the read() function returns 0 (zero). There are
no other results.
If the value of nbytes is greater than SSIZE_MAX, the read() function returns
-1 and sets errno to [EINVAL].
DESCRIPTION
The read() function attempts to read nbytes bytes of data from the file associated with the filedes
parameter into the buffer pointed to by the buffer parameter.
To pass a 32-bit pointer from a 32-bit Guardian or OSS client, read() or read64_() may be
called.
To pass a 64-bit pointer from a 32-bit Guardian or OSS client, read64_() must be called.
32-bit Guardian and 64-bit OSS clients can pass 32-bit pointers and 64-bit pointers to read64_().
On regular files and devices capable of seeking, the read() function starts at a position in the file
given by the file pointer associated with the filedes parameter. Upon return from the read() func-
tion, the file pointer is incremented by the number of bytes actually read.
Devices that are incapable of seeking always read from the current position. For such devices,
the value of the file pointer after a call to the read() function is always 0 (zero).
Upon successful completion, the read() function returns the number of bytes actually read and
placed in the buffer. This number is never greater than the value of the nbytes parameter.
62 Hewlett-Packard Company 527186-023