filesystem timestamps and their usage

Oliver Fromme olli at
Thu Sep 13 05:36:18 PDT 2007

deeptech71 at wrote:
 > Let's talk about file system timestamps. What kind of timestamps are
 > there currently, and what are they used for?

This is a late reply, but I haven't seen that question of
yours answered so far, so I try to give it a shot.

First of all, time stamp support depends on two things:
the file system and the operating system.  In order to
be able to use a certain kind of time stamp, both of
them have to support it.  For example, FAT does not
distinguish between mtime and ctime, so FreeBSD treats
them the same on FAT file systems.

The following assumes you use UFS2, which is FreeBSD's
default.  It supports four kinds of file time stamps:

 - mtime (displayed by "ls -l"):  This is updated each
   time the file is written to.

 - atime ("ls -lu"):  Updated each time the file is read.
   Can be disabled (for performance reasons) by mounting
   a file system with the "noatime" option.

 - ctime ("ls -lc"):  Updated each time the file status
   changes.  In other words, when the meta data contained
   in the inode changes, or when a directory entry
   associated with the inode changes.  For example,
   renaming or moving a file will update the ctime,
   also changing ownerships, permissions etc.

 - birthtime ("ls -lU"):  The time when the inode was
   created.  It never changes.

You can read the details in the stat(2) manual page,
including an exact enumeration of syscalls which affect
the various time stamps.

The first three of the time stamps (mtime, atime and
ctime) are specified by standards (POSIX, SUS), so
there's not much room for discussion, I think.  Also
keep in mind that FreeBSD needs to be interoperable
with other systems, so adhering to the standards is
a must.  The birthtime is an extension, but I think
it is a natural and useful one (FAT supports it, too,
by the way).

Best regards

Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:

"Clear perl code is better than unclear awk code; but NOTHING
comes close to unclear perl code"  (taken from comp.lang.awk FAQ)

More information about the freebsd-chat mailing list