]>
Commit | Line | Data |
---|---|---|
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 |
25 | pread, 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 | |
36 | Feature 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 |
53 | reads up to |
54 | .I count | |
55 | bytes from file descriptor | |
56 | .I fd | |
57 | at offset | |
58 | .I offset | |
59 | (from the start of the file) into the buffer starting at | |
60 | .IR buf . | |
61 | The file offset is not changed. | |
62 | .PP | |
63aa9df0 | 63 | .BR pwrite () |
fea681da MK |
64 | writes up to |
65 | .I count | |
66 | bytes from the buffer starting at | |
67 | .I buf | |
68 | to the file descriptor | |
69 | .I fd | |
70 | at offset | |
71 | .IR offset . | |
72 | The file offset is not changed. | |
73 | .PP | |
74 | The file referenced by | |
75 | .I fd | |
76 | must be capable of seeking. | |
77 | .SH "RETURN VALUE" | |
78 | On success, the number of bytes read or written is returned (zero | |
60a90ecd MK |
79 | indicates that nothing was written, in the case of |
80 | .BR pwrite (), | |
81 | or | |
375d8847 | 82 | end of file, in the case of |
687b7c83 | 83 | .BR pread ()), |
375d8847 | 84 | or \-1 on error, in which case |
fea681da MK |
85 | .I errno |
86 | is set to indicate the error. | |
87 | .SH ERRORS | |
e511ffb6 | 88 | .BR pread () |
fea681da MK |
89 | can fail and set |
90 | .I errno | |
60a90ecd MK |
91 | to any error specified for |
92 | .BR read (2) | |
93 | or | |
94 | .BR lseek (2). | |
e511ffb6 | 95 | .BR pwrite () |
fea681da MK |
96 | can fail and set |
97 | .I errno | |
60a90ecd MK |
98 | to any error specified for |
99 | .BR write (2) | |
100 | or | |
101 | .BR lseek (2). | |
889829be | 102 | .SH VERSIONS |
60a90ecd MK |
103 | The |
104 | .BR pread () | |
105 | and | |
106 | .BR pwrite () | |
107 | system calls were added to Linux in | |
fea681da | 108 | version 2.1.60; the entries in the i386 system call table were added |
1c44bd5b | 109 | in 2.1.69. |
5af0d2f5 | 110 | C library support (including emulation using |
f145728e MK |
111 | .BR lseek (2) |
112 | on older kernels without the system calls) was added in glibc 2.1. | |
a1d5f77c MK |
113 | .SH "CONFORMING TO" |
114 | POSIX.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) |