]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/pread.2
Add feature_test_macros(7) to SEE ALSO
[thirdparty/man-pages.git] / man2 / pread.2
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.
11 .\"
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.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .TH PREAD 2 1999-01-21 "Linux 2.2.0-pre9" "Linux Programmer's Manual"
24 .SH NAME
25 pread, pwrite \- read from or write to a file descriptor at a given offset
26 .SH SYNOPSIS
27 .B #define _XOPEN_SOURCE 500
28 .sp
29 .B #include <unistd.h>
30 .sp
31 .BI "ssize_t pread(int " fd ", void *" buf ", size_t " count ", off_t " offset );
32 .sp
33 .BI "ssize_t pwrite(int " fd ", const void *" buf ", size_t " count ", off_t " offset );
34 .fi
35 .SH DESCRIPTION
36 .BR pread ()
37 reads up to
38 .I count
39 bytes from file descriptor
40 .I fd
41 at offset
42 .I offset
43 (from the start of the file) into the buffer starting at
44 .IR buf .
45 The file offset is not changed.
46 .PP
47 .BR pwrite ()
48 writes up to
49 .I count
50 bytes from the buffer starting at
51 .I buf
52 to the file descriptor
53 .I fd
54 at offset
55 .IR offset .
56 The file offset is not changed.
57 .PP
58 The file referenced by
59 .I fd
60 must be capable of seeking.
61 .SH "RETURN VALUE"
62 On success, the number of bytes read or written is returned (zero
63 indicates that nothing was written, in the case of \fBpwrite\fR(), or
64 end of file, in the case of \fBpread\fR), or \-1 on error, in which
65 case
66 .I errno
67 is set to indicate the error.
68 .SH ERRORS
69 .BR pread ()
70 can fail and set
71 .I errno
72 to any error specified for \fBread\fR(2) or \fBlseek\fR(2).
73 .BR pwrite ()
74 can fail and set
75 .I errno
76 to any error specified for \fBwrite\fR(2) or \fBlseek\fR(2).
77 .SH "CONFORMING TO"
78 POSIX.1-2001.
79 .SH HISTORY
80 The \fBpread\fR() and \fBpwrite\fR() system calls were added to Linux in
81 version 2.1.60; the entries in the i386 system call table were added
82 in 2.1.69. The libc support (including emulation on older kernels
83 without the system calls) was added in glibc 2.1.
84 .SH "SEE ALSO"
85 .BR lseek (2),
86 .BR read (2),
87 .BR write (2),
88 .BR feature_test_macros (7)