Changeset View
Changeset View
Standalone View
Standalone View
head/lib/libc/sys/read.2
Show All 22 Lines | |||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
.\" SUCH DAMAGE. | .\" SUCH DAMAGE. | ||||
.\" | .\" | ||||
.\" @(#)read.2 8.4 (Berkeley) 2/26/94 | .\" @(#)read.2 8.4 (Berkeley) 2/26/94 | ||||
.\" $FreeBSD$ | .\" $FreeBSD$ | ||||
.\" | .\" | ||||
.Dd December 1, 2017 | .Dd July 6, 2019 | ||||
.Dt READ 2 | .Dt READ 2 | ||||
.Os | .Os | ||||
.Sh NAME | .Sh NAME | ||||
.Nm read , | .Nm read , | ||||
.Nm readv , | .Nm readv , | ||||
.Nm pread , | .Nm pread , | ||||
.Nm preadv | .Nm preadv | ||||
.Nd read input | .Nd read input | ||||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | |||||
.Fn readv , | .Fn readv , | ||||
.Fn pread | .Fn pread | ||||
and | and | ||||
.Fn preadv | .Fn preadv | ||||
return the number of bytes actually read and placed in the buffer. | return the number of bytes actually read and placed in the buffer. | ||||
The system guarantees to read the number of bytes requested if | The system guarantees to read the number of bytes requested if | ||||
the descriptor references a normal file that has that many bytes left | the descriptor references a normal file that has that many bytes left | ||||
before the end-of-file, but in no other case. | before the end-of-file, but in no other case. | ||||
.Pp | |||||
In accordance with | |||||
.St -p1003.1-2004 , | |||||
both | |||||
.Xr read 2 | |||||
and | |||||
.Xr write 2 | |||||
syscalls are atomic with respect to each other in the effects on file | |||||
content, when they operate on regular files. | |||||
If two threads each call one of the | |||||
.Xr read 2 | |||||
or | |||||
.Xr write 2 , | |||||
syscalls, each call will see either all of the changes of the other call, | |||||
or none of them. | |||||
The | |||||
.Fx | |||||
kernel implements this guarantee by locking the file ranges affected by | |||||
the calls. | |||||
.Sh RETURN VALUES | .Sh RETURN VALUES | ||||
If successful, the | If successful, the | ||||
number of bytes actually read is returned. | number of bytes actually read is returned. | ||||
Upon reading end-of-file, | Upon reading end-of-file, | ||||
zero is returned. | zero is returned. | ||||
Otherwise, a -1 is returned and the global variable | Otherwise, a -1 is returned and the global variable | ||||
.Va errno | .Va errno | ||||
is set to indicate the error. | is set to indicate the error. | ||||
▲ Show 20 Lines • Show All 146 Lines • Show Last 20 Lines |