OSDN Git Service

(split) LDP man-pages の original/ を v3.32 に更新。
[linuxjm/LDP_man-pages.git] / original / 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 2010-11-21 "Linux" "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 #include <unistd.h>
28 .sp
29 .BI "ssize_t pread(int " fd ", void *" buf ", size_t " count \
30 ", off_t " offset );
31 .sp
32 .BI "ssize_t pwrite(int " fd ", const void *" buf ", size_t " count \
33 ", off_t " offset );
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
45 _XOPEN_SOURCE\ >=\ 500
46 .br
47 || /* Since glibc 2.12: */ _POSIX_C_SOURCE\ >=\ 200809L
48 .RE
49 .ad
50 .PD
51 .SH DESCRIPTION
52 .BR pread ()
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
63 .BR pwrite ()
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
79 indicates that nothing was written, in the case of
80 .BR pwrite (),
81 or
82 end of file, in the case of
83 .BR pread ()),
84 or \-1 on error, in which case
85 .I errno
86 is set to indicate the error.
87 .SH ERRORS
88 .BR pread ()
89 can fail and set
90 .I errno
91 to any error specified for
92 .BR read (2)
93 or
94 .BR lseek (2).
95 .BR pwrite ()
96 can fail and set
97 .I errno
98 to any error specified for
99 .BR write (2)
100 or
101 .BR lseek (2).
102 .SH VERSIONS
103 The
104 .BR pread ()
105 and
106 .BR pwrite ()
107 system calls were added to Linux in
108 version 2.1.60; the entries in the i386 system call table were added
109 in 2.1.69.
110 C library support (including emulation using
111 .BR lseek (2)
112 on older kernels without the system calls) was added in glibc 2.1.
113 .SH "CONFORMING TO"
114 POSIX.1-2001.
115 .SH NOTES
116 On Linux, the underlying system calls were renamed
117 in kernel 2.6:
118 .BR pread ()
119 became
120 .BR pread64 (),
121 and
122 .BR pwrite ()
123 became
124 .BR pwrite64 ().
125 The system call numbers remained the same.
126 The glibc
127 .BR pread ()
128 and
129 .BR pwrite ()
130 wrapper functions transparently deal with the change.
131 .SH "SEE ALSO"
132 .BR lseek (2),
133 .BR read (2),
134 .BR readv (2),
135 .BR write (2)