| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 2: System Calls Oracle Solaris 11 Information Library |
- move extended read/write file pointer
#include <sys/types.h>#include <unistd.h>offset_tllseek(intfildes,offset_toffset,intwhence);
Thellseek() function sets the 64-bit extended file pointer associated with theopen file descriptor specified byfildes as follows:
Ifwhence isSEEK_SET, the pointer is set tooffset bytes.
Ifwhence isSEEK_CUR, the pointer is set to its current location plusoffset.
Ifwhence isSEEK_END, the pointer is set to the size of the file plusoffset.
Ifwhence isSEEK_HOLE, the offset of the start of the next hole greater than or equal to the supplied offset is returned. The definition of a hole immediately follows this list.
Ifwhence isSEEK_DATA, the file pointer is set to the start of the next non-hole file region greater than or equal to the supplied offset.
A “hole” is defined as a contiguous range of bytes in afile, all having the value of zero, but not all zeros ina file are guaranteed to be represented as holes returned withSEEK_HOLE.Filesystems are allowed to expose ranges of zeros withSEEK_HOLE, but not requiredto. Applications can useSEEK_HOLE to optimise their behavior for ranges ofzeros, but must not depend on it to find all such rangesin a file. The existence of a hole at the end ofevery data region allows for easy programming and implies that a virtualhole exists at the end of the file.
For filesystems that do not supply information about holes, the file willbe represented as one entire data region.
Although each file has a 64-bit file pointer associated with it, someexisting file system types (such astmpfs) do not support the fullrange of 64-bit offsets. In particular, on such file systems, non-devicefiles remain limited to offsets of less than two gigabytes. Device driversmay support offsets of up to 1024 gigabytes for device special files.
Some devices are incapable of seeking. The value of the file pointerassociated with such a device is undefined.
Upon successful completion,llseek() returns the resulting pointer location as measured inbytes from the beginning of the file. Remote file descriptors are theonly ones that allow negative file pointers. Otherwise,-1 is returned, thefile pointer remains unchanged, anderrno is set to indicate the error.
Thellseek() function will fail if:
Thefildes argument is not an open file descriptor.
Thewhence argument is notSEEK_SET,SEEK_CUR, orSEEK_END; theoffset argument is not a valid offset for this file system type; or thefildes argument is not a remote file descriptor and the resulting file pointer would be negative.
ForSEEK_DATA, there are no more data regions past the supplied offset. ForSEEK_HOLE, there are no more holes past the supplied offset.
Thefildes argument is associated with a pipe or FIFO.
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |