Guardian Native C Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)
Guardian Native C Library Calls (f) fseek(3)
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 (zero) until data is actually written into the gap. The fseek() function does not,
by itself, extend the size of a file.
Information About Guardian EDIT Files
If called from a native process, the fseek() function can operate on Guardian EDIT files (type
101 files). The behavior of this function differs according to whether the file is opened with a
Guardian connection or with an OSS connection.
To operate on a Guardian EDIT file using a Guardian connection to that file, a stream must be
opened by calling:
• fopen_guardian(), freopen_guardian(), or a similar function from any process.
• fopen( ), freopen(), or a similar function from a process executing in the Guardian
environment.
When the stream references a Guardian EDIT file using a Guardian connection, a call to the
fseek() function implements a position operation as if an equivalent call were being made to the
edfseek() function.
To operate on a Guardian EDIT file using an OSS connection, a stream must be opened by cal-
ling:
• fopen_oss( ), freopen_oss(), or a similar function from any process.
• fopen( ), freopen(), or a similar function from a process executing in the OSS environ-
ment.
When the stream references a Guardian EDIT file using an OSS connection, calls to the fseek()
function are implemented using the lseek() function. Refer to the lseek(2) reference page for
information about the lseek() function.
RETURN VALUES
Upon successful completion, the fseek() function returns a value of 0 (zero). If the fseek() func-
tion fails, a value of -1 is returned, and errno is set to indicate the error.
ERRORS
The fseek() function fails if either the stream is unbuffered, or the stream’s buffer needed to be
flushed and the call to fseek() caused an underlying lseek() or write() function to be invoked. If
the fseek() function attempts to move the file pointer to an odd-byte position in an even-
unstructured file, the run unit terminates abnormally and run-time error 199, "START positioning
failed with error 0," is returned.
In addition, if any of the following conditions occurs, the fseek() function sets errno to the value
that corresponds to the condition.
[EAGAIN] The O_NONBLOCK flag is set for the file descriptor underlying the stream
parameter and the process would be delayed in the write operation.
[EBADF] The file descriptor underlying the stream parameter is not a valid file descriptor
open for writing.
[EFBIG] The buffers of the stream need to be flushed, and the starting point is greater than
or equal to an offset of 2 gigabytes. The file offset maximum for this function,
for both OSS files and Guardian files, is 2 gigabytes.
527192-018 Hewlett-Packard Company 2−137