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
http://www.opengroup.org/bookstore/.
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 SunOS 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.
This notice shall appear on any product containing this material.
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.
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.
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]
Copyright 1989 AT&T.
Portions Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved.
#include <stdio.h> int fseek(FILE *stream, long offset, int whence);
int fseeko(FILE *stream, off_t offset, int whence);
The new position, measured in bytes from the beginning of the file, is obtained by adding offset to the position specified by whence, whose values are defined in <stdio.h> as follows: SEEK_SET
Set position equal to offset bytes.
Set position to current location plus offset.
Set position to EOF plus offset.
If the stream is to be used with wide character input/output functions, offset must either be 0 or a value returned by an earlier call to ftell(3C) on the same stream and whence must be SEEK_SET. This constraint does not hold for streams created by open_wmemstream(3C).
A successful call to fseek() clears the end-of-file indicator for the stream and undoes any effects of ungetc(3C) and ungetwc(3C) on the same stream. After an fseek() call, the next operation on an update stream may be either input or output.
If the most recent operation, other than ftell(3C), on a given stream is fflush(3C), the file offset in the underlying open file description will be adjusted to reflect the location specified by fseek().
The fseek() function allows the file-position indicator to be set beyond the end of existing data in the file. If data is later written at this point, subsequent reads of data in the gap will return bytes with the value 0 until data is actually written into the gap.
The value of the file offset returned by fseek() on devices which are incapable of seeking is undefined.
If the stream is writable and buffered data had not been written to the underlying file, fseek() will cause the unwritten data to be written to the file and mark the st_ctime and st_mtime fields of the file for update.
The O_NONBLOCK flag is set for the file descriptor and the process would be delayed in the write operation.
The file descriptor underlying the stream file is not open for writing or the stream's buffer needed to be flushed and the file is not open.
An attempt was made to write a file that exceeds the maximum file size or the process's file size limit, or the file is a regular file and an attempt was made to write at or beyond the offset maximum associated with the corresponding stream.
The write operation was terminated due to the receipt of a signal, and no data was transferred.
The whence argument is invalid. The resulting file-position indicator would be set to a negative value.
A physical I/O error has occurred; or the process is a member of a background process group attempting to perform a write(2) operation to its controlling terminal, TOSTOP is set, the process is neither ignoring nor blocking SIGTTOU, and the process group of the process is orphaned.
There was no free space remaining on the device containing the file.
A request was made of a non-existent device, or the request was outside the capabilities of the device.
The file descriptor underlying stream is associated with a pipe or FIFO.
An attempt was made to write to a pipe or FIFO that is not open for reading by any process. A SIGPIPE signal will also be sent to the calling thread.
The fseek() function will fail if: EOVERFLOW
The resulting file offset would be a value which cannot be represented correctly in an object of type long.
The fseeko() function will fail if: EOVERFLOW
The resulting file offset would be a value which cannot be represented correctly in an object of type off_t.
The fseeko() function has a transitional interface for 64-bit file offsets. See lf64(7).
ATTRIBUTE TYPE ATTRIBUTE VALUE |
Interface Stability Standard |
MT-Level MT-Safe |