Open file description
An open file description is a system-wide open-file object referenced by one or more file descriptors and holding state such as the current file offset and file status flags.
On Linux, each successful open creates a new open file description; dup and descriptors inherited through fork refer to the existing object. In the generic writeback-error path, that object's f_wb_err cursor is shared by its aliases. This source-code relationship explains why two descriptor numbers need not provide independent error observations. A descriptor opened before pathname replacement keeps referring to the file it originally opened; a fresh open() after replacement can reach a different inode. Separate opens of the same inode do not share an open file description merely because the inode matches.
Handoff: SCM_RIGHTS shares an open file description, including its offset; dup does not make a private cursor. Sealing the inode's content and size does not stop another holder from seeking. [7] In the separate 4096-byte Linux handoff experiment, read and dup-read consumed 3072 unchanged suffix bytes after the sender sought to 1024. Positional and separately reopened controls read all 4096 bytes. [9]
Consumption: pread supplies an explicit offset without advancing the shared current position. A complete reader still checks errors, short reads and expected coverage. Stable bytes, valid format and complete consumption are separate properties; none proves producer authenticity or disk persistence. [8]
Retained access: chmod 0600 did not upgrade an O_RDONLY handle or its duplicate in same-owner Linux 6.8 ext4/tmpfs controls; a fresh O_RDWR procfs reopen could write. Duplication and reopening are distinct. [12] [13] This is visibility, not crash durability, NFS or changed-LSM evidence. [14]
Relations
- related
- pread, File offset, fsync, Writeback error, errseq_t, Atomic rename, Inode, Hard link, Unlink, syncfs, O_SYNC, Advisory file lock, Open-file-description lock, O_APPEND, pwrite, File descriptor, close, Linux file sealing, sync_file_range, O_PATH, Close-on-exec, Unix-domain socket, chmod
Limitations
- Sharing an offset or error cursor does not establish persistence or application-level recovery.
Citations
- Linux man-pages: unix(7), SCM_RIGHTS shares the open file description
- Linux man-pages: pread(2), explicit offsets and short reads
- Hesela: sealed bytes and a shared read cursor
- Linux man-pages: F_GETFD(2const), descriptor flags and exec outcome
- Linux man-pages: fork(2), inherited descriptors and shared open file descriptions
- Linux man-pages: F_GETFL / F_SETFL, access modes
- Linux man-pages: proc_pid_fd(5), reopen permission checks
- Hesela: retained local access after permission changes, native evidence and limits
- Hesela: permission-lifetime native observations, source receipts and MIT replay bundle
Further reading
- Linux man-pages 6.19: open(2), open file descriptions
- Linux man-pages 6.19: dup(2), shared open file descriptions
- Linux v6.12: file_check_and_advance_wb_err in mm/filemap.c
- Hesela: Two descriptors are not necessarily two error observers
- Hesela: The name changes; existing readers do not
- Hesela: A lock follows the opened file, not the replacement name
Sources & caveats
- Permission-lifetime evidence: nine scenarios, 108 recorded executions and 108 matching replay records; two compiler configurations, three repetitions per mount and one host, not independent fleet samples. No changed LSM policy, concurrent writer or power-loss experiment. [15]
- Inheritance: close-on-exec belongs to each descriptor, not this shared object. Successful exec can close one reference while an unmarked alias keeps the same description and offset alive. Fork alone does not trigger that closure. [10] [11]