Linux system programming Lseek Help documentation

Source: Internet
Author: User

With the Man 2 Lseek you can see the help documentation for the system functions Lseek functions in Linux, and in order to learn better, I translate these important things.

1 NAME2Lseek-reposition read/write file Offset//Resets the offset of a read or write file3 4Synopsis//Summary5#include <sys/types.h>//If you want to use the Lseek function, you need to include these two header files6#include <unistd.h>7 8off_t Lseek (intFD, off_t offset,intwhence);//declaration format for Lseek9 TenDESCRIPTION//Description One The Lseek () function repositions The offset of the open file associated with the file descriptor fd to th EArgument offset according to the directive whence asfollows: - //the function of the Lseek () function is to reset the offset of the open file associated with the file descriptor FD and reset this offset to the parameter offset, which is to be done according to the instruction whence when resetting. The whence can contain the following directives: - Seek_set theThe offset is SetTo offset bytes.//If the whence instruction is seek_set, the file offset is set to the byte of the parameter offset size -  - Seek_cur -The offset is Setto it current location plus offset bytes.//If the whence instruction is seek_cur, the file offset is set to the current position plus the offset size byte +  - Seek_end +The offset is SetTo the size of the file plus offset bytes.//If the whence instruction is seek_end, the file offset is set to the file size plus the offset size byte A  atThe Lseek () function allows the file offset to ISSetBeyond the end of the file (but Thisdoes not the -Size of the file). If data isLater written at ThisPoint, subsequent reads of the datainchThe Gap (a"Hole") -        return NULLBytes (' /') until data isActually written into the gap.//The Lseek () function allows you to set the value of a file's offset beyond the end of the file (although the offset is set to a value that exceeds the end of the file, but does not change the file size). If the data is later written to this offset, and the data is actually written to the space between the end of the file and the offset, then the position of reading from the end of the file to the offset of the set is returned as ' \ S ', - RETURN VALUE -Upon successful completion, Lseek () returns the resulting offset location asMeasuredinchbytes fromThe begin‐ -Ning of the file. On error, the value (off_t)-1  isReturned and errno is Setto indicate the error.//when Lseek completes successfully, the offset returned by Lseek () is the offset from the beginning of the file, measured in its own unit. If error, the return value is-1, and the value of errno is set

Linux system programming Lseek Help documentation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.