]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/pread.2
chdir.2, chmod.2, chown.2, gethostname.2, getsid.2, pread.2, setpgid.2, sigaltstack...
[thirdparty/man-pages.git] / man2 / pread.2
CommitLineData
fea681da
MK
1.\" Copyright (C) 1999 Joseph Samuel Myers.
2.\"
3.\" Permission is granted to make and distribute verbatim copies of this
4.\" manual provided the copyright notice and this permission notice are
5.\" preserved on all copies.
6.\"
7.\" Permission is granted to copy and distribute modified versions of this
8.\" manual under the conditions for verbatim copying, provided that the
9.\" entire resulting derived work is distributed under the terms of a
10.\" permission notice identical to this one.
c13182ef 11.\"
fea681da
MK
12.\" Since the Linux kernel and libraries are constantly changing, this
13.\" manual page may be incorrect or out-of-date. The author(s) assume no
14.\" responsibility for errors or omissions, or for damages resulting from
15.\" the use of the information contained herein. The author(s) may not
16.\" have taken the same level of care in the production of this manual,
17.\" which is licensed free of charge, as they might when working
18.\" professionally.
c13182ef 19.\"
fea681da
MK
20.\" Formatted or processed versions of this manual, if unaccompanied by
21.\" the source, must acknowledge the copyright and authors of this work.
22.\"
50831f9b 23.TH PREAD 2 2010-09-20 "Linux" "Linux Programmer's Manual"
fea681da
MK
24.SH NAME
25pread, pwrite \- read from or write to a file descriptor at a given offset
26.SH SYNOPSIS
fea681da
MK
27.B #include <unistd.h>
28.sp
34e8ac03
MK
29.BI "ssize_t pread(int " fd ", void *" buf ", size_t " count \
30", off_t " offset );
fea681da 31.sp
34e8ac03
MK
32.BI "ssize_t pwrite(int " fd ", const void *" buf ", size_t " count \
33", off_t " offset );
f8342ac3
MK
34.sp
35.in -4n
36Feature Test Macro Requirements for glibc (see
37.BR feature_test_macros (7)):
38.in
39.PD 0
40.ad l
41.sp
42.BR pread (),
43.BR pwrite ():
44.RS 4
98dbe7af 45_XOPEN_SOURCE\ >=\ 500
3ba63d80
MK
46.br
47|| /* Since glibc 2.12: */ _POSIX_C_SOURCE\ >=\ 200809L
f8342ac3
MK
48.RE
49.ad
50.PD
fea681da 51.SH DESCRIPTION
63aa9df0 52.BR pread ()
fea681da
MK
53reads up to
54.I count
55bytes from file descriptor
56.I fd
57at offset
58.I offset
59(from the start of the file) into the buffer starting at
60.IR buf .
61The file offset is not changed.
62.PP
63aa9df0 63.BR pwrite ()
fea681da
MK
64writes up to
65.I count
66bytes from the buffer starting at
67.I buf
68to the file descriptor
69.I fd
70at offset
71.IR offset .
72The file offset is not changed.
73.PP
74The file referenced by
75.I fd
76must be capable of seeking.
77.SH "RETURN VALUE"
78On success, the number of bytes read or written is returned (zero
60a90ecd
MK
79indicates that nothing was written, in the case of
80.BR pwrite (),
81or
375d8847 82end of file, in the case of
687b7c83 83.BR pread ()),
375d8847 84or \-1 on error, in which case
fea681da
MK
85.I errno
86is set to indicate the error.
87.SH ERRORS
e511ffb6 88.BR pread ()
fea681da
MK
89can fail and set
90.I errno
60a90ecd
MK
91to any error specified for
92.BR read (2)
93or
94.BR lseek (2).
e511ffb6 95.BR pwrite ()
fea681da
MK
96can fail and set
97.I errno
60a90ecd
MK
98to any error specified for
99.BR write (2)
100or
101.BR lseek (2).
889829be 102.SH VERSIONS
60a90ecd
MK
103The
104.BR pread ()
105and
106.BR pwrite ()
107system calls were added to Linux in
fea681da 108version 2.1.60; the entries in the i386 system call table were added
1c44bd5b 109in 2.1.69.
5af0d2f5 110C library support (including emulation using
f145728e
MK
111.BR lseek (2)
112on older kernels without the system calls) was added in glibc 2.1.
a1d5f77c
MK
113.SH "CONFORMING TO"
114POSIX.1-2001.
fea681da
MK
115.SH "SEE ALSO"
116.BR lseek (2),
117.BR read (2),
0a90178c
MK
118.BR write (2),
119.BR feature_test_macros (7)