[vox-tech] Stat a file's creation time

Sam Peterson vox-tech@lists.lugod.org
Wed, 6 Nov 2002 20:27:27 -0800


--+HP7ph2BbKc20aGI
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hookay, maybe I'm trippin' but after reading the man pages for
stat(1), ls, and stat(2), I'm beginning to think that Unix filesystems
don't bother to keep track of the original creation date of a file.
Not that this information has ever been terribly important to me, but
I stumbled into it while I was writing a backup script for a small
Linux server I use here at work.

Actually, it's not even important for me to have this information for
my script.  I just thought I'd look up a few of my file's creation
times out of curiosity while I was writing the script, which happens
to be in perl and I was using the File::stat library.  I quickly
noticed that there didn't seem to be a way to do it via perl's stat
functions, so I tried the stat program.

The stat program lists Access, Modification, and Change times akin to
atime, mtime, and ctime of perl's File::stat module, which are just
tie-ins to stat(2) anyway.  Since I figured I was missing something, I
experimented with the stat program and a text file and concluded.

  * Access time represents the last time the file was open to be read.
  * Modification time represents the last time the file was written to
    in any shape or form.
  * Change time represents the last time any of the file's meta data
    was altered, such as permissions, uid, gid, and size.  It often
    coincides with modification time, because if a file's size is changed,
    the meta data which keeps track of the size has to change to
    represent that.

But someone please correct me if I've misunderstood what each one
means.  Nothing above seems to represent the time that a file was
originally created.  Granted that this isn't a very functionally
important piece of information compared to the modification time of a
file (at least for most purposes), but it seems like it'd be useful to
someone, somewhere.

I ssh'ed into the isun servers and ran the same tests and sure enough
same results, hmm, it's not just a linux-ism, it's a unix-ism.

Tripwire and Integrit keep file integrity databases and I imagine such
information is present in those databases.  However, one would have to
then run these systems and this information would have to be retreived
programatically through provided libraries.  It just seems like this
information would be important for someone to have if they needed it,
and it would therefore be in the best interests of the filesystem to
be keeping track of this information, not to rag on those open source
developers; I certainly don't have the coding skills to write a unix
file system, or provide a facility that may stray from the standards.

Maybe I'm on crack; it's been a long day after all.  Anybody know of a
way to stat a file's original creation time on Unix or a standard
external system that can be used to track such information?  Or is
this from the "It's not important, so we don't care," department?  I
have no need of the information currently, but this has dug into the
better side of my curiosity.

--=20
----------------------------------------------------------------------
| sam -- Programmer I                                                |
| University of California, Davis : Hart Interdisciplinary Programs  |
| GPG Fingerprint: 4F08 E33E 92A2 EA88 CE75  75DC D84C 6046 0240 515F|
----------------------------------------------------------------------

--+HP7ph2BbKc20aGI
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9yeuv2ExgRgJAUV8RAjKIAKCEaaCRHI650CEtnGokrC1XwadOVwCgpeBv
UIDrNVNYcICQPN+FK1KWWGQ=
=Yhst
-----END PGP SIGNATURE-----

--+HP7ph2BbKc20aGI--