File system
File system lseek
// PROTOTYPE
off_t lseek(int fd, off_t offset, int whence)
Seek to a position in a file. Affects where the next read or write will occur. Seeking past the end of the file does not immediately increase the size of the file, but will do so after the next write.
fd
: The file descriptor for the file, return from theopen
call.offset
: Offset. The usage depends onwhence
. ForSEEK_SET
the offset must be >= 0. ForSEEK_CUR
it can be positive or negative to seek relative to the current position. Negative values used withSEEK_END
move relative to the end-of-file.whence
:SEEK_SET
: Seek tooffset
bytes from the beginning of the file.SEEK_CUR
: Seek relative to the current file position.SEEK_END
: Seek relative to the end of the file.offset
of 0 means seek to the end of the file when usingSEEK_END
.