READ(2) READ(2) NAME read, write - read or write file SYNOPSIS int read(fildes, buffer, nbytes) char *buffer; int write(fildes, buffer, nbytes) char *buffer; DESCRIPTION Read reads nbytes bytes of data from the file pointer loca- tion in the file associated with fildes into memory at buffer. The file pointer is advanced by the number of bytes read. It is not guaranteed that all nbytes bytes will be read; for example if the file refers to a terminal at most one line will be returned. In any event the number of char- acters read is returned. A return value of 0 is convention- ally interpreted as end of file. Write writes nbytes bytes of data starting at buffer to the file associated with fildes at the file pointer location. The file pointer is advanced by the number of bytes written. The number of characters actually written is returned. It should be regarded as an error if this is not the same as requested. Reads and writes which are aligned with file system blocks are more efficient than others; see filsys(5). SEE ALSO open(2), dup(2), pipe(2), select(2), dirread(2) DIAGNOSTICS read: EBADF, EFAULT, EINTR, EINVAL, ENXIO write: EBADF, EFAULT, EINTR, EINVAL, EIO, ENXIO, EPIPE, EROFS BUGS A read or a write call may fail because of a prior call to lseek(2).