lseek64()--Set File Read/Write Offset (Large File Enabled)


  Syntax
 #include <unistd.h>

 off64_t lseek64(int file_descriptor,
                    off64_t offset, int whence);  
  Service Program Name: QP0LLIB1

  Default Public Authority: *USE

  Threadsafe: Conditional; see Usage Notes.

The lseek64() function changes the current file offset to a new position in the file. The new position is the given byte offset from the position specified by whence. After you have used lseek64() to seek to a new location, the next I/O operation on the file begins at that location.

lseek64() lets you specify new file offsets past the current end of the file. If data is written at such a point, read operations in the gap between this data and the old end of the file will return bytes containing binary zeros (or bytes containing blanks in the QSYS.LIB or independent ASP QSYS.LIB file systems). In other words, the gap is assumed to be filled with zeros (or with blanks in the QSYS.LIB or independent ASP QSYS.LIB file systems). If you seek past the end of a file, however, the length of the file is not automatically extended. The maximum offset that can be specified is the largest value that can be held in an 8-byte, signed integer. You must do a write operation before the file is actually extended.

In the QSYS.LIB or independent ASP QSYS.LIB file systems, you can seek only to the beginning of a member while in text mode; otherwise error [EINVAL] will be returned.

lseek64() is enabled for large files. It is capable of operating on files larger than 2GB minus 1 byte as long as the file has been opened by either of the following:

For additional information about parameters, authorities required, error conditions and examples, see lseek()--Set File Read/Write Offset.


Usage Notes

  1. When you develop in C-based languages, the prototypes for the 64-bit APIs are normally hidden. To use the lseek64() API and the off64_t data type, you must compile the source with the _LARGE_FILE_API defined.

  2. QFileSvr.400 File System Differences

    When connecting to a system at release V5R4M5 and earlier, QFileSvr.400 does not support a resulting file offset greater than 2 GB minus 2 bytes, [EOVERFLOW] will be returned. Otherwise, the lseek64() operation succeeds. However, subsequent operations to access the file data may fail if the file system being accessed on the remote system does not support the resulting file offset.

  3. All of the usage notes for lseek() apply to lseek64(). See Usage Notes in the lseek() API.


API introduced: V4R4

[ Back to top | UNIX-Type APIs | APIs by category ]