8212 manpages contain obsolete references
[unleashed.git] / usr / src / man / man3c / fseek.3c
blob50e23871d08cfcb229fbac7385dd941c21a67ab1
1 '\" te
2 .\" Copyright 1989 AT&T.  Copyright (c) 20023, Sun Microsystems, Inc.  All Rights Reserved.  Portions Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
3 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
4 .\" http://www.opengroup.org/bookstore/.
5 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
6 .\"  This notice shall appear on any product containing this material.
7 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
9 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
10 .TH FSEEK 3C "May 13, 2017"
11 .SH NAME
12 fseek, fseeko \- reposition a file-position indicator in a stream
13 .SH SYNOPSIS
14 .LP
15 .nf
16 #include <stdio.h>
18 \fBint\fR \fBfseek\fR(\fBFILE *\fR\fIstream\fR, \fBlong\fR \fIoffset\fR, \fBint\fR \fIwhence\fR);
19 .fi
21 .LP
22 .nf
23 \fBint\fR \fBfseeko\fR(\fBFILE *\fR\fIstream\fR, \fBoff_t\fR \fIoffset\fR, \fBint\fR \fIwhence\fR);
24 .fi
26 .SH DESCRIPTION
27 .LP
28 The \fBfseek()\fR function sets the file-position indicator for the stream
29 pointed to by \fIstream\fR. The \fBfseeko()\fR function is identical to
30 \fBfseek()\fR except for the type of \fIoffset\fR.
31 .sp
32 .LP
33 The new position, measured in bytes from the beginning of the file, is obtained
34 by adding \fIoffset\fR to the position specified by \fIwhence\fR, whose values
35 are defined in <\fBstdio.h\fR> as follows:
36 .sp
37 .ne 2
38 .na
39 \fB\fBSEEK_SET\fR\fR
40 .ad
41 .RS 12n
42 Set position equal to \fIoffset\fR bytes.
43 .RE
45 .sp
46 .ne 2
47 .na
48 \fB\fBSEEK_CUR\fR\fR
49 .ad
50 .RS 12n
51 Set position to current location plus \fIoffset\fR.
52 .RE
54 .sp
55 .ne 2
56 .na
57 \fB\fBSEEK_END\fR\fR
58 .ad
59 .RS 12n
60 Set position to \fBEOF\fR plus \fIoffset\fR.
61 .RE
63 .sp
64 .LP
65 If the stream is to be used with wide character input/output functions,
66 \fIoffset\fR must either be 0 or a value returned by an earlier call to
67 \fBftell\fR(3C) on the same stream and \fIwhence\fR must be \fBSEEK_SET\fR.
68 .sp
69 .LP
70 A successful call to \fBfseek()\fR clears the end-of-file indicator for the
71 stream and undoes any effects of \fBungetc\fR(3C) and \fBungetwc\fR(3C) on the
72 same stream.  After an \fBfseek()\fR call, the next operation on an update
73 stream may be either input or output.
74 .sp
75 .LP
76 If the most recent operation, other than \fBftell\fR(3C), on a given stream is
77 \fBfflush\fR(3C), the file offset in the underlying open file description will
78 be adjusted to reflect the location specified by \fBfseek()\fR.
79 .sp
80 .LP
81 The \fBfseek()\fR function allows the file-position indicator to be set beyond
82 the end of existing data in the file. If data is later written at this point,
83 subsequent reads of data in the gap will return bytes with the value 0 until
84 data is actually written into the gap.
85 .sp
86 .LP
87 The value of the file offset returned by \fBfseek()\fR on devices which are
88 incapable of seeking is undefined.
89 .sp
90 .LP
91 If the stream is writable and buffered data had not been written to the
92 underlying file, \fBfseek()\fR will cause the unwritten data to be written to
93 the file and mark the \fBst_ctime\fR and \fBst_mtime\fR fields of the file for
94 update.
95 .SH RETURN VALUES
96 .LP
97 The \fBfseek()\fR and \fBfseeko()\fR functions return \fB0\fR on success;
98 otherwise, they returned \fB\(mi1\fR and set \fBerrno\fR to indicate the error.
99 .SH ERRORS
101 The \fBfseek()\fR and \fBfseeko()\fR functions will fail if, either the
102 \fIstream\fR is unbuffered or the \fIstream\fR's buffer needed to be flushed,
103 and the call to \fBfseek()\fR or \fBfseeko()\fR causes an underlying
104 \fBlseek\fR(2) or \fBwrite\fR(2) to be invoked:
106 .ne 2
108 \fB\fBEAGAIN\fR\fR
110 .RS 10n
111 The \fBO_NONBLOCK\fR flag is set for the file descriptor and the process would
112 be delayed in the write operation.
116 .ne 2
118 \fB\fBEBADF\fR\fR
120 .RS 10n
121 The file descriptor underlying the stream file is not open for writing or the
122 stream's buffer needed to be flushed and the file is not open.
126 .ne 2
128 \fB\fBEFBIG\fR\fR
130 .RS 10n
131 An attempt was made to write a file that exceeds the maximum file size or the
132 process's file size limit, or the file is a regular file and an attempt was
133 made to write at or beyond the offset maximum associated with the corresponding
134 stream.
138 .ne 2
140 \fB\fBEINTR\fR\fR
142 .RS 10n
143 The write operation was terminated due to the receipt of a signal, and no data
144 was transferred.
148 .ne 2
150 \fB\fBEINVAL\fR\fR
152 .RS 10n
153 The \fIwhence\fR argument is invalid. The resulting file-position indicator
154 would be set to a negative value.
158 .ne 2
160 \fB\fBEIO\fR\fR
162 .RS 10n
163 A physical I/O error has occurred; or the process is a member of a background
164 process group attempting to perform a \fBwrite\fR(2) operation to its
165 controlling terminal, \fBTOSTOP\fR is set, the process is neither ignoring nor
166 blocking \fBSIGTTOU\fR, and the process group of the process is orphaned.
170 .ne 2
172 \fB\fBENOSPC\fR\fR
174 .RS 10n
175 There was no free space remaining on the device containing the file.
179 .ne 2
181 \fB\fBENXIO\fR\fR
183 .RS 10n
184 A request was made of a non-existent device, or the request was outside the
185 capabilities of the device.
189 .ne 2
191 \fB\fBEPIPE\fR\fR
193 .RS 10n
194 The file descriptor underlying \fIstream\fR is associated with a pipe or FIFO.
198 .ne 2
200 \fB\fBEPIPE\fR\fR
202 .RS 10n
203 An attempt was made to write to a pipe or \fBFIFO\fR that is not open for
204 reading by any process. A \fBSIGPIPE\fR signal will also be sent to the calling
205 thread.
210 The \fBfseek()\fR function will fail if:
212 .ne 2
214 \fB\fBEOVERFLOW\fR\fR
216 .RS 13n
217 The resulting file offset would be a value which cannot be represented
218 correctly in an object of type \fBlong\fR.
223 The \fBfseeko()\fR function will fail if:
225 .ne 2
227 \fB\fBEOVERFLOW\fR\fR
229 .RS 13n
230 The resulting file offset would be a value which cannot be represented
231 correctly in an object of type \fBoff_t\fR.
234 .SH USAGE
236 Although on the UNIX system an offset returned by \fBftell()\fR or
237 \fBftello()\fR (see \fBftell\fR(3C)) is measured in bytes, and it is
238 permissible to seek to positions relative to that offset, portability to
239 non-UNIX systems requires that an offset be used by \fBfseek()\fR directly.
240 Arithmetic may not meaningfully be performed on such an offset, which is not
241 necessarily measured in bytes.
244 The \fBfseeko()\fR function has a transitional interface for 64-bit file
245 offsets.  See \fBlf64\fR(5).
246 .SH ATTRIBUTES
248 See \fBattributes\fR(5) for descriptions of the following attributes:
253 box;
254 c | c
255 l | l .
256 ATTRIBUTE TYPE  ATTRIBUTE VALUE
258 Interface Stability     Standard
260 MT-Level        MT-Safe
263 .SH SEE ALSO
265 \fBgetrlimit\fR(2), \fBulimit\fR(2), \fBftell\fR(3C),
266 \fBrewind\fR(3C), \fBungetc\fR(3C), \fBungetwc\fR(3C), \fBattributes\fR(5),
267 \fBlf64\fR(5), \fBstandards\fR(5)