File birth time
File birth time (btime) is a filesystem timestamp recording file creation, distinct from modification time and inode change time.
On Linux, stat() does not return btime. statx(), available since Linux 4.11 and glibc 2.28, can return it as stx_btime, with a signed 64-bit seconds field and an unsigned 32-bit nanoseconds field. Request STATX_BTIME and check that the returned stx_mask contains STATX_BTIME before interpreting the value, because a successful call does not guarantee that every requested field was supplied. [2]
When a filesystem cannot supply a field, the kernel clears its bit in stx_mask even if it was requested and may fill in a dummy value, so a nonzero stx_btime is not evidence on its own. STATX_ALL, which bundled STATX_BTIME with the basic fields, is deprecated. [2]
Birth time is set when the file is created and is not changed afterwards. It was not historically present on UNIX systems, and most Linux filesystems do not support it. Availability depends on the kernel and filesystem. Do not substitute ctime for missing birth time. On filesystems without subsecond timestamps the nanosecond field reads as 0. [1]
Relations
Advantages
- Separates recorded file creation from later content and inode-status changes. [1]
Limitations
- Different statx fields may reflect different moments during a single call, so btime and other fields are not one atomic snapshot. [2]
- Setting the request mask to all bits is discouraged because future bits may extend the returned buffer. [2]
Citations
- Linux man-pages 6.19: inode(7), file timestamps
- Linux man-pages 6.19: statx(2), requested and returned fields
Further reading
Sources & caveats
- linux-statx is the Linux man-pages 6.19 statx(2) page, re-read for stx_btime, stx_mask semantics, the timestamp structure and history.
- linux-inode is the Linux man-pages 6.19 inode(7) page, re-read for the btime description and nanosecond timestamp support.
- The rsync-quick-check entry links here because its size and modification-time comparison does not use birth time.