Regular file
A regular file is a file type that presents data as a byte sequence, distinct from directories, symbolic links and device or communication files.
On Linux, S_ISREG(st_mode) tests the type reported by a successful status call. stat() follows a final symbolic link, lstat() reports the link itself, and fstat() reports the object referenced by an open descriptor. A filename extension is not this file-type classification. Fields returned by one status call can reflect different moments during concurrent metadata changes. Checking a pathname and opening it later does not establish that both operations selected the same object. [1] [2] [3]
For ordinary stored files, st_size is the logical length in bytes, while Linux st_blocks reports allocated space in 512-byte units. Sparse holes can make allocation smaller than logical length; st_blksize is a preferred I/O size, not the multiplier for st_blocks. These fields do not directly measure physical consumption in a lower storage pool. [1] [7]
Regular-file type does not establish persistent backing. Tmpfs keeps files in virtual memory, may swap pages, and loses its contents when unmounted. On a persistent filesystem, successful write() completion alone does not establish durability. Synchronization and its errors must be handled separately; fsync() on a file does not necessarily persist its containing directory entry. [4] [5] [6]
The file object, its names and its open descriptions are separate concepts. Replacing a pathname does not redirect an already open descriptor to the replacement file. Separate opens create separate open descriptions; duplicated descriptors share an offset and file-status flags. Neither arrangement alone makes file contents an immutable snapshot. [3]
Relations
- related
- File size, End of file, Inode, File offset, Sparse file, tmpfs, Named pipe (FIFO special file)
Citations
- Linux man-pages: inode(7), file types, logical size and allocated blocks
- Linux man-pages: stat(2), pathname, link and descriptor observations
- Linux man-pages: open(2), descriptors and open file descriptions
- Linux kernel documentation: Tmpfs, virtual memory and unmount lifetime
- Linux man-pages: write(2), successful writes and delayed errors
- Linux man-pages: fsync(2), file and directory synchronization
- Hesela: Sparse files, preallocation and thin-pool capacity
Sources & caveats
- Primary-source terminology synthesis, not a new filesystem experiment or a claim about every synthetic filesystem's readable length or seek behavior.