.TH READ 2 .CT 2 file_io comm_proc .SH NAME read, write \(mi read or write file .SH SYNOPSIS .nf .B int read(fildes, buffer, nbytes) .B char *buffer; .PP .B int write(fildes, buffer, nbytes) .B char *buffer; .fi .SH DESCRIPTION .I Read reads .I nbytes bytes of data from the file pointer location in the file associated with .I fildes into memory at .IR buffer . The file pointer is advanced by the number of bytes read. It is not guaranteed that all .I 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 characters read is returned. A return value of 0 is conventionally interpreted as end of file. .PP .I Write writes .I nbytes bytes of data starting at .I buffer to the file associated with .I 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. .PP Reads and writes which are aligned with file system blocks are more efficient than others; see .IR filsys (5). .SH "SEE ALSO" .IR open (2), .IR dup (2), .IR pipe (2), .IR select (2), .IR dirread (2) .SH DIAGNOSTICS .IR read : .BR EBADF , .BR EFAULT , .BR EINTR , .BR EINVAL , .BR ENXIO .br .IR write : .BR EBADF , .BR EFAULT , .BR EINTR , .BR EINVAL , .BR EIO , .BR ENXIO , .BR EPIPE , .BR EROFS .SH BUGS A .I read or a .I write call may fail because of a prior call to .IR lseek (2).