READ(2)
NAME
read − read from file
SYNOPSIS
read(fildes, buffer, nbytes)
char *buffer;
unsigned nbytes;
DESCRIPTION
A file descriptor is a word returned from a successful open, creat, dup, or pipe call. Buffer is the location of nbytes contiguous bytes into which the input will be placed. It is not guaranteed that all nbytes bytes will be read; for example if the file refers to a typewriter at most one line will be returned. In any event the number of characters read is returned.
If the returned value is 0, then end-of-file has been reached.
DIAGNOSTICS
Read will fail if one or more of the following is true:
[EBADF] Fildes is not a valid file descriptor open for reading.
[EFAULT] Buf points outside the process’s allocated address space.
[EFAULT] The specified address is either odd or out of range when dealing with character special files.
[EINTR] A read from a slow device was interrupted (before any data arrived) by the delivery of a signal.
[ENXIO] The /dev/mem address specified is illegal.
[ETPL] The magtape tape position was lost or the tape unit went offline during a read.
[EWOULDBLOCK]
The process would hang waiting for input (when mode is set to interrupt on each character input).
SEE ALSO
open(2), creat(2), dup(2), pipe(2)
ASSEMBLER
(read = 3.)
(file descriptor in r0)
sys read; buffer; nbytes
(byte count in r0)