Question: What Is Offset in Linux?
Contents the Offset Is the Current Position in the File, as Maintained by the Kernel for a Given File Description (See the Lseek(2) and Open(2) Manpages for...
Contents
The offset is the current position in the file, as maintained by the kernel for a given file description (see the lseek(2) and open(2) manpages for details).
What is offset of a file?
An offset into a file is simply the character location within that file, usually starting with 0; thus “offset 240” is actually the 241st byte in the file. See relative address. (3) In word processing, the amount of space a document is printed from the left margin.
How do I find the offset of a file?
To get the current offset of an open file, you use lseek() :
- off_t offset;
- offset = lseek (fd, 0, SEEK_CUR);
- if (offset == (offset_t) -1) {
- perror(“lseek”);
- return -1;
- }
- printf(“fd is currently at offset %jdn”, (intmax_t) offset);