1951 leaking a vdev when removing an l2cache device
[unleashed.git] / usr / src / man / man3c / fseek.3c
blob7db56303c2f393f1388cb62d1c422bb49f7a9bd6
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 "Nov 1, 2003"
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 .sp
28 .LP
29 The \fBfseek()\fR function sets the file-position indicator for the stream
30 pointed to by \fIstream\fR. The \fBfseeko()\fR function is identical to
31 \fBfseek()\fR except for the type of \fIoffset\fR.
32 .sp
33 .LP
34 The new position, measured in bytes from the beginning of the file, is obtained
35 by adding \fIoffset\fR to the position specified by \fIwhence\fR, whose values
36 are defined in <\fBstdio.h\fR> as follows:
37 .sp
38 .ne 2
39 .na
40 \fB\fBSEEK_SET\fR\fR
41 .ad
42 .RS 12n
43 Set position equal to \fIoffset\fR bytes.
44 .RE
46 .sp
47 .ne 2
48 .na
49 \fB\fBSEEK_CUR\fR\fR
50 .ad
51 .RS 12n
52 Set position to current location plus \fIoffset\fR.
53 .RE
55 .sp
56 .ne 2
57 .na
58 \fB\fBSEEK_END\fR\fR
59 .ad
60 .RS 12n
61 Set position to \fBEOF\fR plus \fIoffset\fR.
62 .RE
64 .sp
65 .LP
66 If the stream is to be used with wide character input/output functions,
67 \fIoffset\fR must either be 0 or a value returned by an earlier call to
68 \fBftell\fR(3C) on the same stream and \fIwhence\fR must be \fBSEEK_SET\fR.
69 .sp
70 .LP
71 A successful call to \fBfseek()\fR clears the end-of-file indicator for the
72 stream and undoes any effects of \fBungetc\fR(3C) and \fBungetwc\fR(3C) on the
73 same stream.  After an \fBfseek()\fR call, the next operation on an update
74 stream may be either input or output.
75 .sp
76 .LP
77 If the most recent operation, other than \fBftell\fR(3C), on a given stream is
78 \fBfflush\fR(3C), the file offset in the underlying open file description will
79 be adjusted to reflect the location specified by \fBfseek()\fR.
80 .sp
81 .LP
82 The \fBfseek()\fR function allows the file-position indicator to be set beyond
83 the end of existing data in the file. If data is later written at this point,
84 subsequent reads of data in the gap will return bytes with the value 0 until
85 data is actually written into the gap.
86 .sp
87 .LP
88 The value of the file offset returned by \fBfseek()\fR on devices which are
89 incapable of seeking is undefined.
90 .sp
91 .LP
92 If the stream is writable and buffered data had not been written to the
93 underlying file, \fBfseek()\fR will cause the unwritten data to be written to
94 the file and mark the \fBst_ctime\fR and \fBst_mtime\fR fields of the file for
95 update.
96 .SH RETURN VALUES
97 .sp
98 .LP
99 The \fBfseek()\fR and \fBfseeko()\fR functions return \fB0\fR on success;
100 otherwise, they returned \fB\(mi1\fR and set \fBerrno\fR to indicate the error.
101 .SH ERRORS
104 The \fBfseek()\fR and \fBfseeko()\fR functions will fail if, either the
105 \fIstream\fR is unbuffered or the \fIstream\fR's buffer needed to be flushed,
106 and the call to \fBfseek()\fR or \fBfseeko()\fR causes an underlying
107 \fBlseek\fR(2) or \fBwrite\fR(2) to be invoked:
109 .ne 2
111 \fB\fBEAGAIN\fR\fR
113 .RS 10n
114 The \fBO_NONBLOCK\fR flag is set for the file descriptor and the process would
115 be delayed in the write operation.
119 .ne 2
121 \fB\fBEBADF\fR\fR
123 .RS 10n
124 The file descriptor underlying the stream file is not open for writing or the
125 stream's buffer needed to be flushed and the file is not open.
129 .ne 2
131 \fB\fBEFBIG\fR\fR
133 .RS 10n
134 An attempt was made to write a file that exceeds the maximum file size or the
135 process's file size limit, or the file is a regular file and an attempt was
136 made to write at or beyond the offset maximum associated with the corresponding
137 stream.
141 .ne 2
143 \fB\fBEINTR\fR\fR
145 .RS 10n
146 The write operation was terminated due to the receipt of a signal, and no data
147 was transferred.
151 .ne 2
153 \fB\fBEINVAL\fR\fR
155 .RS 10n
156 The \fIwhence\fR argument is invalid. The resulting file-position indicator
157 would be set to a negative value.
161 .ne 2
163 \fB\fBEIO\fR\fR
165 .RS 10n
166 A physical I/O error has occurred; or the process is a member of a background
167 process group attempting to perform a \fBwrite\fR(2) operation to its
168 controlling terminal, \fBTOSTOP\fR is set, the process is neither ignoring nor
169 blocking \fBSIGTTOU\fR, and the process group of the process is orphaned.
173 .ne 2
175 \fB\fBENOSPC\fR\fR
177 .RS 10n
178 There was no free space remaining on the device containing the file.
182 .ne 2
184 \fB\fBENXIO\fR\fR
186 .RS 10n
187 A request was made of a non-existent device, or the request was outside the
188 capabilities of the device.
192 .ne 2
194 \fB\fBEPIPE\fR\fR
196 .RS 10n
197 The file descriptor underlying \fIstream\fR is associated with a pipe or FIFO.
201 .ne 2
203 \fB\fBEPIPE\fR\fR
205 .RS 10n
206 An attempt was made to write to a pipe or \fBFIFO\fR that is not open for
207 reading by any process. A \fBSIGPIPE\fR signal will also be sent to the calling
208 thread.
213 The \fBfseek()\fR function will fail if:
215 .ne 2
217 \fB\fBEOVERFLOW\fR\fR
219 .RS 13n
220 The resulting file offset would be a value which cannot be represented
221 correctly in an object of type \fBlong\fR.
226 The \fBfseeko()\fR function will fail if:
228 .ne 2
230 \fB\fBEOVERFLOW\fR\fR
232 .RS 13n
233 The resulting file offset would be a value which cannot be represented
234 correctly in an object of type \fBoff_t\fR.
237 .SH USAGE
240 Although on the UNIX system an offset returned by \fBftell()\fR or
241 \fBftello()\fR (see \fBftell\fR(3C)) is measured in bytes, and it is
242 permissible to seek to positions relative to that offset, portability to
243 non-UNIX systems requires that an offset be used by \fBfseek()\fR directly.
244 Arithmetic may not meaningfully be performed on such an offset, which is not
245 necessarily measured in bytes.
248 The \fBfseeko()\fR function has a transitional interface for 64-bit file
249 offsets.  See \fBlf64\fR(5).
250 .SH ATTRIBUTES
253 See \fBattributes\fR(5) for descriptions of the following attributes:
258 box;
259 c | c
260 l | l .
261 ATTRIBUTE TYPE  ATTRIBUTE VALUE
263 Interface Stability     Standard
265 MT-Level        MT-Safe
268 .SH SEE ALSO
271 \fBgetrlimit\fR(2), \fBulimit\fR(2), \fBfopen\fR(3UCB), \fBftell\fR(3C),
272 \fBrewind\fR(3C), \fBungetc\fR(3C), \fBungetwc\fR(3C), \fBattributes\fR(5),
273 \fBlf64\fR(5), \fBstandards\fR(5)