Files
oldlinux-files/Linux-0.98/Yggdrasil-0.98.3/usr/man/man2/read.2
2024-02-19 00:21:16 -05:00

49 lines
1.1 KiB
Groff

.TH READ 2
.UC 4
.SH NAME
read, write \- read / write syscalls
.SH SYNOPSIS
.nf
.B #include <sys/types.h>
.B #include <unistd.h>
.B int read(int fildes, char *buf, off_t count);
.B int write(int fildes, const char *buf, off_t count);
.fi
.SH DESCRIPTION
.B read()
attempts to read
.I count
bytes from open file descriptor
.I filedes
, storing them in the memory location pointed to by
.I buf
.
.B write()
works in the same fashion, only the bytes are written to the file descriptor.
.B read
and
.B write()
return the number of bytes successfully read from or written to the file
descriptor, 0 on EOF, and a negative number on any other error condition.
.SH ERRORS
0 is returned on EOF
.PP
.B -EBADF
is returned when an invalid
.I filedes
was used, the file was opened read only and a write was attempted,
or the file was opened write only and a read was attempted.
.PP
.B -EINVAL
is returned when the
.B i_mode
field of the inode is invalid.
.SH FILES
linux/fs/read_write.c
.br
/usr/include/linux/sys.h
.br
/usr/include/unistd.h
.SH SEE ALSO
fread(3), fwrite(3)