{
  "slug": "file-offset",
  "term": "File offset",
  "aliases": [
    "current file offset",
    "file position"
  ],
  "definition": "A file offset is a byte position measured from the beginning of a file, used as a current I/O cursor or an explicit positional-access argument.",
  "note": "The current cursor belongs to the open file description. Duplicating a descriptor shares that cursor; opening the file separately creates a new open file description. A descriptor number and an offset therefore identify different parts of an I/O request. [open-api] [dup-api]\n\nFor regular files, lseek can position the cursor beyond EOF without enlarging the file. SEEK_SET, SEEK_CUR and SEEK_END interpret the supplied displacement relative to the beginning, current position and file size respectively. A byte position does not describe physical allocation or a device-sector address. [lseek-api]\n\npread and pwrite supply an explicit position without advancing the current cursor. A separate lseek then read sequence needs coordination if another holder can move that cursor between calls. [pread-api] [dup-api]",
  "status": "shipping",
  "advantages": [],
  "limitations": [
    "Not a file length or a measure of consumed or allocated bytes.",
    "Independent cursors do not isolate readers from changes to file content."
  ],
  "related": [
    "open-file-description",
    "file-descriptor",
    "pread",
    "pwrite",
    "short-read",
    "sparse-file",
    "file-truncation"
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-02",
  "citations": [
    {
      "id": "open-api",
      "title": "Linux man-pages 6.19: open(2), open file descriptions",
      "url": "https://man7.org/linux/man-pages/man2/open.2.html",
      "accessed": "2026-11-02"
    },
    {
      "id": "dup-api",
      "title": "Linux man-pages 6.19: dup(2), shared cursor state",
      "url": "https://man7.org/linux/man-pages/man2/dup.2.html",
      "accessed": "2026-11-02"
    },
    {
      "id": "lseek-api",
      "title": "Linux man-pages 6.19: lseek(2), origins and seeking beyond EOF",
      "url": "https://man7.org/linux/man-pages/man2/lseek.2.html",
      "accessed": "2026-11-02"
    },
    {
      "id": "pread-api",
      "title": "Linux man-pages 6.19: pread(2), explicit-position I/O",
      "url": "https://man7.org/linux/man-pages/man2/pread.2.html",
      "accessed": "2026-11-02"
    }
  ],
  "provenance": [
    "The byte-position concept is distinct from the open file description that stores a current cursor."
  ]
}
