]>
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 | .\" | |
f145728e | 23 | .TH PREAD 2 2008-120-3 "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 | |
27 | .B #define _XOPEN_SOURCE 500 | |
28 | .sp | |
29 | .B #include <unistd.h> | |
30 | .sp | |
34e8ac03 MK |
31 | .BI "ssize_t pread(int " fd ", void *" buf ", size_t " count \ |
32 | ", off_t " offset ); | |
fea681da | 33 | .sp |
34e8ac03 MK |
34 | .BI "ssize_t pwrite(int " fd ", const void *" buf ", size_t " count \ |
35 | ", off_t " offset ); | |
fea681da | 36 | .SH DESCRIPTION |
63aa9df0 | 37 | .BR pread () |
fea681da MK |
38 | reads up to |
39 | .I count | |
40 | bytes from file descriptor | |
41 | .I fd | |
42 | at offset | |
43 | .I offset | |
44 | (from the start of the file) into the buffer starting at | |
45 | .IR buf . | |
46 | The file offset is not changed. | |
47 | .PP | |
63aa9df0 | 48 | .BR pwrite () |
fea681da MK |
49 | writes up to |
50 | .I count | |
51 | bytes from the buffer starting at | |
52 | .I buf | |
53 | to the file descriptor | |
54 | .I fd | |
55 | at offset | |
56 | .IR offset . | |
57 | The file offset is not changed. | |
58 | .PP | |
59 | The file referenced by | |
60 | .I fd | |
61 | must be capable of seeking. | |
62 | .SH "RETURN VALUE" | |
63 | On success, the number of bytes read or written is returned (zero | |
60a90ecd MK |
64 | indicates that nothing was written, in the case of |
65 | .BR pwrite (), | |
66 | or | |
375d8847 MK |
67 | end of file, in the case of |
68 | .BR pread (), | |
69 | or \-1 on error, in which case | |
fea681da MK |
70 | .I errno |
71 | is set to indicate the error. | |
72 | .SH ERRORS | |
e511ffb6 | 73 | .BR pread () |
fea681da MK |
74 | can fail and set |
75 | .I errno | |
60a90ecd MK |
76 | to any error specified for |
77 | .BR read (2) | |
78 | or | |
79 | .BR lseek (2). | |
e511ffb6 | 80 | .BR pwrite () |
fea681da MK |
81 | can fail and set |
82 | .I errno | |
60a90ecd MK |
83 | to any error specified for |
84 | .BR write (2) | |
85 | or | |
86 | .BR lseek (2). | |
889829be | 87 | .SH VERSIONS |
60a90ecd MK |
88 | The |
89 | .BR pread () | |
90 | and | |
91 | .BR pwrite () | |
92 | system calls were added to Linux in | |
fea681da | 93 | version 2.1.60; the entries in the i386 system call table were added |
1c44bd5b | 94 | in 2.1.69. |
f145728e MK |
95 | The libc support (including emulation using |
96 | .BR lseek (2) | |
97 | on older kernels without the system calls) was added in glibc 2.1. | |
a1d5f77c MK |
98 | .SH "CONFORMING TO" |
99 | POSIX.1-2001. | |
fea681da MK |
100 | .SH "SEE ALSO" |
101 | .BR lseek (2), | |
102 | .BR read (2), | |
0a90178c MK |
103 | .BR write (2), |
104 | .BR feature_test_macros (7) |